Pieces Protocol

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

`TokenDivider::buyOrder` function updated sellers order list incorrectly

Summary

When a buyer buy tokens or any order from seller which is present in the list of seller order list, `TokenDivider::buyOrder` function updated that list as shown below.
```javascript
s_userToSellOrders[seller][orderIndex] = s_userToSellOrders[seller][s_userToSellOrders[seller].length - 1];
s_userToSellOrders[seller].pop();
```
As this updation happens it will update the list incorrectly so that the orders in the list will become in diffrent order from starting.

Impact

the orders in the list will become in diffrent order from starting will lead to buy wrong order by buyer.
Explaination:
1. Seller's order list -> `[[price = 100],[price = 150],[price = 200],[price = 160]]`
2. Buyer buy `1st` index order.
3. Updated list of sellers order -> `[[price = 100],[price = 160],[price = 200]]`
If only price taken from the order list of seller, then the updated list will be shown above. Due to this incorrect updation user or buyer will pay for wrong order.
Updates

Lead Judging Commences

fishy Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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