QuantAMM

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

Fee Bypass Through Precision Loss in Low-Decimal Tokens

Summary

The UpliftOnlyExample contract's fee calculation mechanism can be bypassed for significant amounts when using low-decimal tokens like GUSD (2 decimals). This allows users to execute large trades without paying any fees, leading to potential revenue loss for the protocol and the pool creator.

Vulnerability Details

NOTE: As per the protocol readme: all balancer tokens are in scope and GUSD is a valid balancer token.

The fee calculation in UpliftOnlyExample::afterSwap hook uses the following formula:
UpliftOnlyExample.sol#L298

uint256 hookFee = params.amountCalculatedRaw.mulUp(hookSwapFeePercentage);

With 0.1% fee setting:

hookFee = amountCalculatedRaw * 1e15 / 1e18
= amountCalculatedRaw / 1000

For zero fee (rounding down in integer arithmetic):

amountCalculatedRaw / 1000 < 1
amountCalculatedRaw < 1000

For GUSD (2 decimals):

1000 base units = 10.00 GUSD
Therefore, any amount up to 9.99 GUSD will result in zero fees.

Concrete Example:

  1. Trade amount: 9.99 GUSD = 999 base units

  2. Fee calculation with 0.1% fee:

999 * 1e15 / 1e18 = 0.999 (rounds down to 0)

Impact

Swap fee can be bypassed for low-decimal tokens

Tools Used

Manual Review

Recommendations

Use decimal normalization for fee calculations

Updates

Lead Judging Commences

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

finding_tokens_with_few_decimals_can_bypass_fees

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)

Support

FAQs

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