QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: high
Valid

Precision Loss Causes ownerFee to Become Zero When quantAMMFeeTake > 0.5e18

Summary

In the onAfterSwap function, when quantAMMFeeTake exceeds 0.5e18 (50%), the ownerFee will be incorrectly calculated as zero due to precision loss in arithmetic operations, resulting in the owner not receiving their share of fees

Vulnerability Details

In the onAfterSwap function, the quantAMMFeeTake value is used to calculate the adminFee as a percentage of the total hookFee.

The ownerFee is then derived by subtracting the adminFee from the total hookFee.

However, when quantAMMFeeTake > 0.5e18 (50%), the integer division logic can cause the ownerFee to round down to 0:

uint256 adminFee = hookFee / (1e18 / quantAMMFeeTake);
ownerFee = hookFee - adminFee;

For example:

If hookFee = 100 and quantAMMFeeTake = 0.6e18, the calculation becomes:

Solidity
adminFee = 100 / (1e18 / 0.6e18) = 100 / 1 = 100
ownerFee = 100 - 100 = 0
## Impact
Owner receives no fees when quantAMMFeeTake is above 50%
Admin receives entire fee amount instead of their designated share
## Recommendations
Recommendations
Use Multiplication Before Division to Avoid Precision Loss
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding_onAfterSwap_adminFee_overestimated_solidity_rounding_down

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%.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.