A mathematical error in the PreMarkets::abortBidTaker function results in the incorrect calculation of the amount returned to bid takers when an offer is aborted. This miscalculation can either lead to excess funds being returned to the bid taker—causing a shortage of tokens for other users—or to an insufficient amount being returned, effectively reducing the bid taker's collateral.
This function allows bid takers to reclaim their deposited amount when the associated offer is aborted. The returned amount is intended to be proportional to the bid taker's share of points relative to the total points in the offer. However, the current formula used to calculate this amount is flawed:
This formula is implemented in the following code snippet:
The incorrect formula results in disproportionate returns based on the offer's point-to-amount ratio. For offers with a high ratio (cheap offers), the function may return excess funds to the bid taker, leading to a deficit in the remaining tokens available for other users. Conversely, for offers with a low ratio (expensive offers), the bid taker may receive less than they are entitled to, effectively losing part of their collateral.
See example for a cheap offer:
Manual review.
Use 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.