When a Maker fails to settle an ASK Offer, the expectation is that the Admin will settle on their behalf, ensuring that the BID Taker receives a portion of the collateral, with the remaining portion allocated to the protocol team. This process relies on accurately accounting for the tokens held by different addresses. However, in the current implementation, when the Admin settles instead of the Maker, the collateral fee is not correctly attributed to the Admin. This results in the funds becoming stuck, as there would be no mechanism for the Admin to withdraw these funds.
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L257
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L276
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L301
Admin is expected to call settleAskMaker()
in DeliveryPlace.sol
instead of Maker.
On line #257
is checked if input parameter _settledPoints
is exactly 0 (this is the only value which satisfies the _settledPoints <= 0
condition, because _settledPoints
is of unsigned type).
Later, on line #276
there is another check _settledPoints == offerInfo.usedPoints
which will be true only if offerInfo.usedPoints
is 0, which is not the case when there are BID Takers to the ASK Offer.
This leads to skipping the code from line #301
-#306
which account for the allowance of token withdrawal for the current msg.sender (in this scenario - Admin).
Because of this inconsistency, Admin wont be able to call withdraw()
in TokenManager.sol
later as his accounted allowance would be 0, instead of the remaining collateral.
The following test case shows the described scenario.
NOTE: need to add deal(user2, 100000000 * 10 ** 18);
in setUp()
.
Collateral of Maker who do not settle remains stuck in the protocol due to wrong accounting.
Manual review, Foundry.
Consider accounting for the collateral fee, when settling ASK Offers as Admin instead of the Maker who created the Offer.
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.