The function PreMarkets::abortBidTaker
contains a critical error in calculating the depositAmount
. The current calculation is incorrect, which could lead to significant discrepancies in token transfers.
The depositAmount
is intended to represent the amount of tokens deposited by the bid taker to purchase points from the offer maker. It should be calculated using the formula:
stockInfo.points * preOfferInfo.amount / preOfferInfo.points
However, the code incorrectly calculates it as:
stockInfo.points * preOfferInfo.points / preOfferInfo.amount
This incorrect calculation can lead to the wrong amount of tokens being transferred.
copy and paste the code below to file PreMartkets.t.sol
and run it.
• Likelihood: High
This issue will consistently result in incorrect depositAmount
values whenever the function is invoked.
• Impact: High
This could lead to an incorrect number of tokens being transferred to the bid taker, which might never be recovered. Depending on the preOfferInfo.points
and preOfferInfo.amount
values, the bid taker might receive either more or fewer tokens than intended. If the calculated result is higher than expected, the protocol could suffer a loss of tokens, leading to potential shortages for other users. If the calculated result is lower, a portion of the tokens could become trapped within the protocol.
Manual Review
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.