The buyOrder function calculates fees using integer division, which can lead to rounding errors and loss of precision. For example, if order.price is small, the calculated fees may be zero. This can result in the protocol not collecting the intended fees, leading to financial discrepancies
The fee calculations in the buyOrder function use integer division, which truncates any fractional part of the result. This can lead to significant rounding errors, especially for small values of order.price. As a result, the calculated fees may be zero or significantly lower than intended, causing financial discrepancies in the protocol.
Medium Impact: Small amounts of funds may be lost due to rounding errors, especially for small order.price values.
Financial Discrepancies: The protocol may not collect the intended fees, leading to financial losses or inconsistencies.
User Dissatisfaction: Users may perceive the protocol as unfair or unreliable if fees are not calculated accurately.
Slither, Foundry
Use fixed-point arithmetic or scaled values to avoid rounding errors and ensure precise fee calculations. For example:
Additional Considerations:
Use libraries like OpenZeppelin's SafeMath or PRBMath for precise arithmetic operations.
Emit events to log fee calculations and ensure transparency for users and auditors.
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.