When the Admin settles on behalf of an ASK Taker, who is responsible for providing tokens after placing a BID Offer, the collateral provided by the Taker becomes stuck in the protocol. This happens because the current implementation lacks a mechanism for the Admin to withdraw the collateral, leaving the funds trapped.
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L335
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L368
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L376
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L400
Admin needs to call settleAskTaker()
in DeliveryPlace.sol
so the BID Maker is able to call closeBidOffer()
in the same contract. Logic in the settleAskTaker()
does not account the collateral provided by the ASK Taker.
On line #368
, the condition if (_settledPoints > 0)
will always evaluate to false because the only possible value for _settledPoints
is 0. This causes the subsequent conditions on line #376
(if (settledPointTokenAmount > 0)
) and line #400
(if (_settledPoints == stockInfo.points)
) to also fail. As a result, the protocol fails to account for the collateral that the Admin should receive from the ASK Taker, leading to unaccounted and stuck funds.
The following test case shows the described scenario:
Funds stuck in the contract due to wrong accounting.
Manual review, Foundry.
Consider adding logic to ensure that when the Admin settles, the Admin is properly accounted for and can withdraw the funds provided by the party that failed to settle (in this case, the ASK Taker).
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.