In the UpliftOnlyExample::onAfterSwap function, an incorrect calculation of the admin fee (adminFee) leads to scenarios where the entire fee is allocated to the admin, leaving no rewards for the owner. This issue arises due to the division-based calculation method that fails in certain cases because of Solidity's integer math.
The issue lies in this calculation:
Since Solidity does not support floating-point arithmetic, the calculation can result in a rounding error, causing adminFee to be calculated more than expected or as equal to hookFee under specific values.
Unit test:
The owner loses their rightful share of the rewards, resulting in an unfair distribution of fees.
Manual Review
Fuzz Testing
Replace the current calculation of adminFee with a multiplication-based approach to avoid precision loss.
By rewriting the formula, we eliminate the intermediate division, preventing rounding issues and ensuring a fair split between adminFee and ownerFee.
In math, we can change the calculation like this:
(a/b) / (c/d) = (a*d) / (b*c)
so:
(hookFee) / (1e18/quantAMMFeeTake) = (hookFee/1) / (1e18/quantAMMFeeTake) = (hookFee*quantAMMFeeTake) / (1e18)
Likelyhood: High, quantAMMFeeTake is a percentage on calculated fees. Being between 30-70% is very likely. Impact: High, fees for LP providers will be lower than expected and 0 if the admin fees is above 50%.
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.