In the PreMarkets contract, when a taker aborts their position, they should receive their initial deposit back. However, the abortBidTaker() function contains an incorrect calculation for the deposit amount, which results in the taker receiving nothing upon aborting.
The deposit amount is incorrectly calculated as follows in the abortBidTaker() function:
This results in a deposit amount calculated as:
This calculation is inconsistent with the correct formula used in the createTaker() function, which properly calculates the deposit amount:
Correct calculation:
Loss of funds for the users.
Alice creates an offer with CreateOfferParams.points = 1000 and CreateOfferParams.amount = 0.01 * 1e18 (10_000_000_000_000_000).
Bob calls createTaker() with _points = 500 and has to deposit 0.005 USDC:
depositAmount = 500 * 10_000_000_000_000_000 / 1_000 = 5_000_000_000_000_000 / 1e18 = 0.005
Alice aborts the offer with abortAskOffer() to get back her deposit.
Bob aborts their position with abortBidTaker() to get back his deposit, but the calculation is incorrect:
depositAmount = 500 * 1_000 / 10_000_000_000_000_000 = 0.00000000005 / 1e18 = 0.00000000000000000000000000005 = 0 (rounded down by Solidity)
Replace the incorrect calculation in PreMarkets::abortBidTaker() with the correct formula:
Valid high severity, due to incorrect computation of `depositAmount` within `abortBidTaker`, when aborting bid offers created by takers, the collateral refund will be completely wrong for the taker, and depending on the difference between the value of `points` and `amount`, it can possibly even round down to zero, causing definite loss of funds. If not, if points were worth less than the collateral, this could instead be used to drain the CapitalPool contract instead.
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.