The abortAskOffer
function is designed to handle the financial settlement when an ask offer is aborted, including calculating and processing refunds. It performs several checks to ensure the caller has the authority to abort the offer and that the offer is in a valid state for abortion. It then calculates the amounts to be refunded based on the current state of the offer.
The problem in this function lies in the calculation of the remainingAmount
and its subsequent use in determining the transferAmount
and makerRefundAmount
.
When the offer status is not Virgin
, the remainingAmount
is calculated using usedPoints
. However, this calculation actually represents the amount that has been used, not the amount remaining. This is a logical error that inverts the intended meaning of remainingAmount
.
This incorrectly calculated remainingAmount
is then used to determine the transferAmount
:
The transferAmount
is critical as it's used to calculate the makerRefundAmount
.
Users may receive incorrect refunds, leading to potential losses or unintended gains.
The correct calculation for remainingAmount
when the offer is not in Virgin
status should be:
This calculates the truly remaining amount by subtracting the used points from the total points.
Valid high, for cancelled offers, the unused collateral should be returned back to the maker. The `remainingAmount` is calculated wrongly with regards to usedPoints instead of unused points. Note: See comments under 826 and 907 for invalidation reasons
Valid high, for cancelled offers, the unused collateral should be returned back to the maker. The `remainingAmount` is calculated wrongly with regards to usedPoints instead of unused points. Note: See comments under 826 and 907 for invalidation reasons
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.