Pieces Protocol

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

Destructive Order Management in Sell/Buy Mechanism

Description: The buyOrder function completely removes the seller's order from the s_userToSellOrders array after a purchase, preventing partial order fulfillment and causing potential loss of market flexibility. This is a design flaw that could be considered a medium-severity issue, as it directly reduces the seller's market flexibility and control over their sell orders.

Impact:

  • Sellers cannot partially sell their listed tokens

  • Entire sell order is deleted after any purchase

  • Reduced control over token selling process

  • Potential economic loss for sellers

Proof of Concept:

function buyOrder(uint256 orderIndex, address seller) external payable {
// Completely removes order, regardless of purchase amount
s_userToSellOrders[seller][orderIndex] = s_userToSellOrders[seller][s_userToSellOrders[seller].length - 1];
s_userToSellOrders[seller].pop();
}

Recommended Mitigation:

  • Implement partial order fulfillment

  • Reduce order amount instead of deleting entire order

  • Add logic to track and update remaining token amounts in sell orders

Updates

Lead Judging Commences

fishy Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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