When an ASK offer maker settles their offer with a partial amount, bid takers receive an excessive amount of collateral refund in addition to their bought points.
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)
Bob gets a full refund of 800 even if his points were 99.9% settled (he now has: 399 points AND 800 collateral)
Charlie gets a full refund of 400 even if his points were 99.9% settled (he now has: 399 points AND 400 collateral)
Bob should have received a refund of 1.222222 instead
Charlie should have received a refund of 0.888888 instead
Poc, run forge test --via-ir --match-test test_h11_ask_offer_taker_gets_too_much_refund -vv
Impact: High (Users receive an excessive refund, so they extract value from the protocol)
Likelihood: Medium (Ask makers must settle a partial order)
Risk: High
Manual review
In DeliveryPlace
change closeBidTaker
so that the refund logic should match a % of the received points instead of the theoretical full amount:
Valid High, afaik, partial settlements are a valid flow and so when closing bid offers by takers and/or when settling offers by makers, we should return a proportionate amount of funds based on points settled. This issues could be related to issue #1008, but seems to be describing a different issue.
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.