The settleAskTaker
function incorrectly enforces the bid-offer maker, instead of the taker, to settle points sold in bid offers. This misimplementation prevents proper settlement by the takers.
Takers of bid-offers are required to settle the points they sold to bid-offer makers following the token generation event (TGE). They use the settleAskTaker function to complete this settlement. However, the current implementation incorrectly enforces the offer makers to settle the points themselves, which is erroneous:
As shown above, the original offer is retrieved from stockInfo.preOffer
, which references the bidder maker's offer. The function then incorrectly enforces the caller to be the offer maker. This is incorrect because the offer maker has purchased points from the taker, and it is the taker who should be responsible for settling the points.
Consider the following scenario, demonstrated by the test case below:
As the Original Offer Maker, Alice posts a buy offer for 1,000 points
with a unit price of 1,000` in advance.
Bob accepts Alice's buy offer and sells 1,000 points
to Alice. This transaction results in Bob having a stock of type Ask
to be settled later after TGE.
During the settlement phase, Bob should settle the 1,000 points
for Alice after TGE. But, the current implementation incorrectly requires Alice to settle the points she bought.
Copy and paste the following test in test/PreMarkets.sol
:
Bid offers takers can not settle their points, which results in:
Losing collateral even if the taker wanted to settle their points
Bidder offers do not receive their token points
Manual review
Consider removing the mentioned offer authority check and replace it with stock authority check. Below is a suggested update to the settleAskTaker
function:
Valid high severity, when taker offers are created pointing to a `offer`, the relevant `stockInfoMap` offers are created with the owner of the offer aka `authority`, set as the creater of the offer, as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L245). Because of the wrong check within settleAskTaker, it will permanently DoS the final settlement functionality for taker offers for the maker that listed the original offer, essentially bricking the whole functionality of the market i.e. maker will always get refunded the original collateral, and takers will never be able to transact the original points put up by the maker. This occurs regardless of market mode.
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.