When an ASK offer maker settles their offer with a partial amount, they permanently lose the entire collateral instead of getting a partial refund.
Alice creates an ASK offer for 1000 points and 2000 collateral
Bob creates a BID order to buy 400 points, sending 800 as payment
Charlie creates a BID order to buy 200 points, sending 400 as payment
Alice settles 599 points on her offer (instead of 600)
Bob gets 399.33333333... points (instead of 400)
Charlie gets 199.6666666... points (instead of 200)
Alice loses the entire collateral because the settlement was partial, even if the bidders got their partial points
Alice now has: (1000 - 598.93) points and 0 collateral, and 1200 payment
Alice should have (2000 - 2.14) collateral left instead of 0. She lost 99.9% of her collateral.
Poc, run forge test --via-ir --match-test test_h10_ask_offer_maker_lose_collateral_partial_settlement -vv
Impact: High (High loss of funds for the ask makers)
Likelihood: Medium (Ask makers must settle a partial order)
Risk: High
Manual review
In DeliveryPlace
change settleAskMaker
so that the refund logic is always executed:
When calculating the maker refund amount, instead of offerInfo.amount
, you should refund a percentage based on how many points were settled.
The refund logic should look like this, but remember to apply a scaling factor to not lose precision: offerInfo.amount * _settledPoints / offerInfo.usedPoints
Valid high, in settleAskTaker/settleAskMaker, if the original offer maker performs a partial final settlement, the existing checks [here](https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/DeliveryPlace.sol#L356-L358) and [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L230-L232) will cause an revert when attempting to complete a full settlement, resulting in their collateral being locked and requiring a rescue from the admin. To note, although examples in the documentation implies settlement in a single click, it is not stated that partial settlements are not allowed, so I believe it is a valid user flow.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.