Pieces Protocol

First Flight #32
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: medium
Invalid

Potential Logical Issues in Fee Calculation

Description
Within buyOrder, the code:

uint256 fee = order.price / 100; // 1% fee
uint256 sellerFee = fee / 2; // 0.5% ?
if (msg.value < order.price + sellerFee) {
revert TokenDivider__InsuficientEtherForFees();
}
...
(bool success, ) = payable(order.seller).call{value: (order.price - sellerFee)}("");
(bool taxSuccess, ) = payable(owner()).call{value: fee}("");

Hence:

  • The buyer pays at least order.price + sellerFee.

  • The seller receives (order.price - sellerFee) — effectively 0.5% less than order.price.

  • The owner receives fee (which is 1% of order.price).

The buyer is actually spending order.price + 0.5%, but the total outflow is order.price - 0.5% (to the seller) + 1% (to the owner) = order.price + 0.5%.

While this may be intended logic, it is somewhat unintuitive that the buyer pays an extra 0.5% beyond the listed price and that the seller receives 0.5% below the listed price. This effectively means:

  1. Seller loses 0.5% from order.price.

  2. Buyer pays 0.5% more than order.price.

  3. Owner gains 1% of order.price.

Impact

  • Possible confusion or user dissatisfaction if they do not fully understand that the cost to buy is price + 0.5% and the seller sees 0.5% subtracted.

Root Cause
Fee distribution logic divides the 1% fee into “half from seller’s proceeds” and “half from buyer's extra payment.”

Recommendation

  • Make fee logic more explicit in code, documentation, or naming (e.g., rename variables to clarify that half is paid by the seller and half by the buyer).

  • If the goal is to have the seller pay 1% and the buyer pay exactly order.price, the math needs to be adjusted accordingly. Decide on a simpler approach if needed:

    • Entire 1% fee from the seller’s proceeds, or

    • Entire 1% from the buyer (price + 1%),

    • Or keep the 50/50 logic but document it clearly.

Updates

Lead Judging Commences

juan_pedro_ventu Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.