The fee calculation logic uses multiplication followed by division with fixed-point arithmetic. Although supported by libraries like PRB Math, the order of operations can lead to rounding issues, particularly for very small amounts.
The fee math is implemented as follows:
Rounding Errors: In transactions with small amounts, rounding differences could lead to slight overcharging or undercharging.
Accumulated Inaccuracies: While minor per transaction, repeated errors could have a cumulative impact over many swaps.
Static analysis
Mathematical verification and simulation
Fuzz testing
Rounding Optimization: Review the order of arithmetic operations to minimize precision loss.
Edge Case Testing: Perform detailed tests on small volume swaps to understand and adjust for rounding.
Library Enhancements: Consider using higher precision arithmetic or specialized libraries if necessary.
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.