The onAfterSwap
function contains a vulnerability that causes overcharging of QuantAMM Admin fees due to precision loss in the calculation:
This issue arises from integer truncation during division, which results in inflated fee amounts when quantAMMFeeTake
is a fractional value, such as 0.6e18
. As a result, the protocol charges higher fees than intended..
Problematic Formula:
The division 1e18 / quantAMMFeeTake
results in integer truncation, discarding fractional parts.
For example, when quantAMMFeeTake = 0.6e18
, the result of 1e18 / quantAMMFeeTake
is truncated to 1
instead of the correct 1.666...
.
Incorrect Fee Calculation:
Using the truncated value as the denominator causes the adminFee
to be overcharged.
In this example, the adminFee
is calculated as 1e18
wei instead of the intended 0.6e18
wei.
Code Example:
hookFee = 1e18
.
quantAMMFeeTake = 0.6e18
.
Calculate 1e18 / quantAMMFeeTake
:
1e18 / 0.6e18 = 1.666... -> truncated to 1.
Compute adminFee
:
adminFee = 1e18 / 1 = 1e18.
Calculate hookFee * quantAMMFeeTake
:
1e18 * 0.6e18 = 0.6e36.
Divide by 1e18
:
adminFee = 0.6e36 / 1e18 = 0.6e18
Overcharging of Fees
Replace the problematic formula with a precision-preserving calculation:
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.