Buyer is never refounded if the seller aborts the offer
Suppose we have the following scenario:
user sells 1000 points for 10 USDC in proteced mode
user transfers 10 USDC as collateral since he's a seller
user1 buys all the points from user
user is credited with the eachTradeTax
as TaxIncome
user is credited with 10 USDC as SalesRevenue
, which are the 10 USDC spent by user1 to buy the points
user aborts his offer by calling abortAskOffer
user1 aborts his offer by calling abortBidTaker
In abortBidTaker
the deposit amount of the buyer is computed as follows:
Especially with USDC (since it has 6 decimals) it can easily round down to 0, for example:
The buyer, user1 in this case, is never refounded of the amount he originally spent to buy the tokens.
The seller, user in this case, is never refounded of his collateral but he gets the USDC spent by the buyer even if the trade never settled.
Add the following test to PreMarkets.t.sol
:
In this scenario, when all the points are bought, nor the seller nor the buyer receive back their collateral.
Manual review
Foundry
The SalesRevenue should be accredited to the seller only after settlement.
The calculation of the depositAmount
should account for the correct decimals of the token being used by the offer.
Valid medium, given the free nature of the markets, it may be possible that such an offer type where both low amount of points correspond to lower decimal and lower amount of collateral value, so I believe medium severity is appropriate.
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.