The createOffer function is a critical component of the PreMarktes contract, responsible for creating offers within the marketplace. This function accepts several parameters that define the offer's characteristics, such as the amount, points, trade tax, and collateral rate. However, there are some diferences between comments and actual implementation of the function, leading to potential logical errors that could result in improper validation of user inputs.
The comment clearly states that eachTradeTax should be less than EACH_TRADE_TAX_DECIMAL_SCALER. However, the comparison in the code only checks if eachTradeTax is greater than EACH_TRADE_TAX_DECIMAL_SCALER, allowing for the scenario where eachTradeTax is exactly equal to EACH_TRADE_TAX_DECIMAL_SCALER, which violates the stated requirement.
Similary, comment indicates that collateralRate should be greater than COLLATERAL_RATE_DECIMAL_SCALER. The current code only checks if collateralRate is less than COLLATERAL_RATE_DECIMAL_SCALER, thereby allowing the value to be exactly equal to COLLATERAL_RATE_DECIMAL_SCALER, which contradicts the intended validation logic.
See the following code:
First logics difference can lead to situations where the eachTradeTax is set to an unacceptable value, potentially disrupting the intended financial logic of the platform, such as overcharging fees or miscalculating trade tax.
Similary allowing a collateralRate that is equal to COLLATERAL_RATE_DECIMAL_SCALER could potentially result in insufficient collateralization of offers, exposing the system to increased risk if the collateral provided is not adequate to cover potential losses.
Manual Review
The comparison should be modified to use the >= operator instead of >, ensuring that any value equal to or greater than EACH_TRADE_TAX_DECIMAL_SCALER is rejected.
Also the second comparison should be changed to use the <= operator instead of <, ensuring that any value less than or equal to COLLATERAL_RATE_DECIMAL_SCALER is rejected
Similar to issue #1323, Despite this off-by-one error of the intended check, the difference between 99% and 100% is minimal, so I believe whether or not 100% is allowed has minimal impact. Ultimately, takers should not be realistically creating offer with such tradeTax
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.