The createTaker
function within the PreMarkets
contract is susceptible to precision loss when computing the transferAmount
. This risk arises when there is a significant disparity between offerInfo.points
and _points
, leading to potential rounding inaccuracies.
The loss of precision in these calculations can result in incorrect token transfer amounts. This could lead to users receiving fewer tokens than expected or the contract transferring more tokens than intended, causing potential financial discrepancies that could affect both users and the platform.
Here’s an illustration of the issue in the createTaker
function:
In the above scenario, precision loss leads to the assertion failing, which demonstrates how the contract could transfer an incorrect amount.
Increase Precision: Use a larger scale factor in intermediate calculations to mitigate precision loss and ensure accuracy in token transfers.
Implement Range Checks: Introduce checks to verify that the computed transferAmount
is within an acceptable range to prevent significant discrepancies.
Safeguards for Disparities: Add mechanisms to handle situations where there is a substantial difference between _points
and offerInfo.points
, reducing the likelihood of precision-related errors.
Duplicate of #456, however, for issues noting rounding directions, will be low severity given the impact is not proven sufficiently with a PoC/numerical example and most rounding will not result in significant losses e.g. most examples only proved at most a 1 wei difference when computing `depositAmount/platFormFees` and involves lower amount offers
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.