Rounding down of fees are caused in swapping of low decimal tokens in the onAfterSwap callback function of UpliftOnlyExample contract .
To explain the bug, let's take an example token - GUSD (or Gemini Dollar which has decimal of 2 https://etherscan.io/token/0x056fd409e1d7a124bd7017459dfea2f387b6d5cd#readContract#F3 -> It is supported by Balancer Pool , so I believe it is an in scope asset - https://balancer.fi/pools/ethereum/v2/0x81e998523f02adf4679ff57fff8ca2b9d23a574700020000000000000000060a ) .
In UpliftOnlyExample contract , when onAfterSwap function is called after a swap where the tokenout == GUSD , hookfee is to be calculated in the tokenOut amount as can be seen here -
https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-hooks/contracts/hooks-quantamm/UpliftOnlyExample.sol#L292-L350
Here let's take an example scenario of params.amountCalculatedRaw to be 50 dollars of GUSD i.e., 50e2 .
Let's hookSwapFeePercentage be 1% == 0.01e18 , quantAMMFeeTake also be 1% == 0.01e18 .
Here , hookFee will round up to 50 .
Now looking at the calculation of adminFee we see that it becomes => adminFee = (50)/(1e18/1e16)
= 50/100 = 0
Here as we can , for 50 USD worth of GUSD as output token , the admin fee turns out to be 0 . And so the whole amount hooFee would be transferred to UpliftOnlyExample which itself is not withdrawable as I have explained in another report of myself .
Quant AMM Admin doesn't receive the fees for swap, as it is round down to 0 & this 0 amount is tried to be transferred to quantAMMAdmin causing problems .
Manual review
Use a different mechanism to calculate Quant Amm Admin fees for low decimal tokens .
Likelyihood: Very Low, tokens with 2 or less decimals and few fees. Impact: Low, bypass fees but for very few amounts, gas usage will be equivalent. (No reason to break a big swap in multiple)
Likelyihood: Very Low, tokens with 2 or less decimals and few fees. Impact: Low, bypass fees but for very few amounts, gas usage will be equivalent. (No reason to break a big swap in multiple)
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.