If the offer creator refuses to execute DeliveryPlace::settleAskMaker(), the Taker will lose the tokens they paid.
When a user calls PreMarkets::createOffer() to create an offer, they only need to deposit more than 100% of the tokens as collateral.
The user who calls PreMarkets::createTaker() to execute the transaction triggers the following process:
The internal function PreMarkets::_depositTokenWhenCreateTaker() transfers the required tokens from the caller to the capitalPool.
The internal function PreMarkets::_updateTokenBalanceWhenCreateTaker() updates the balance in the userTokenBalanceMap of the offer creator.
At this stage, the offer creator can withdraw the corresponding balance from the userTokenBalanceMap.
However, the complete process should involve the following steps:
User A creates an offer by calling PreMarkets::createOffer().
User B initiates the transaction by calling PreMarkets::createTaker().
The administrator updates the market by calling SystemConfig::updateMarket().
User A must execute DeliveryPlace::settleAskMaker() to transfer the purchased token to the capitalPool and retrieve the corresponding collateral.
User B calls DeliveryPlace::closeBidTaker() to update the obtained tokens in the userTokenBalanceMap.
If User A fails to execute DeliveryPlace::settleAskMaker(), User B loses all paid tokens and receives nothing. Meanwhile, User A only forfeits the collateral exceeding 100%.
This situation creates an incentive for User A to avoid fulfilling their obligations under DeliveryPlace::settleAskMaker() if the value of their deposited token increases beyond the collateral lost.
Add the following test code to test/PreMarkets.t.sol and execute it:
In this PoC, the collateralRate is set to 10001, a system-allowed value that results in negligible collateral loss. The collateral amount is insufficient to cover User2's expenditure.
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L39-L157
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L159-L284
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L813-L837
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L906-L949
If the offer creator refuses to execute DeliveryPlace::settleAskMaker(), the Taker will lose the tokens they paid.
Manual Review
Potential solutions:
Increase the Minimum Collateral Ratio: Raising the minimum collateral ratio would increase the potential loss for the offer creator, making it less likely for them to abandon their obligations.
Modify the Execution Logic of PreMarkets::createTaker() and DeliveryPlace::settleAskMaker(): Update the token amount handled in PreMarkets::createTaker() -> PreMarkets::_updateTokenBalanceWhenCreateTaker() to be transferred to an intermediate address. Once the offer creator successfully calls DeliveryPlace::settleAskMaker() and transfers the corresponding token, the amount associated with the intermediate address should then be credited to the offer creator’s address. If the offer creator fails to fulfill their obligations, they would forfeit their entire collateral.
Invalid, the makers are incentivized to settle offers to earn maker bonuses when subsequent takers and makers make trade using the original collateral put up for points as well as get back their initial collateral. Additionally, if they do not settle on time, they will lose all their initial collateral, forcing the `owner` to come in and perform the settlement and retrieving that collateral. This is noted as a design decision [here](https://tadle.gitbook.io/tadle/how-tadle-works/features-and-terminologies/settlement-and-collateral-rate) If all else fails, the `owner` can come in to settle as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L254-L256) and [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L365-L367) offers to allow closing offers and subsequently allowing refunds. I acknowledge that perhaps a more decentralized
Valid high severity, given orginal offer makers are not a trusted entity to enforce a settlement. The trade tax set by the maker should be returned back to the takers to avoid abuse of abortion of ask offers to steal trade tax from takers. Note for appeals period: See issue #528 for additional details
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.