Missing width scaling in FeeWalker.up (non-visited) undercredits compounding maker fees
In the FeeWalker.up function, when a node is not visited, the code calculates compounding maker fees without multiplying by the node's width, while the rate denominator includes width scaling. This causes compounding makers to be undercredited on non-visited nodes, reducing their yield and compounding growth.
0xnija Follow with SOPROBRO, anonymousjoe and 9 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-09-ammplify-judging/issues/465
Found by
0xnija, SOPROBRO, anonymousjoe, blockace, globalace, hjo, holtzzx, maigadoh, neeloy, panprog, thimthor, x15
Summary
In FeeWalker.up when visit == false, the code credits compounding maker fees using compoundingLiq = mLiq - ncLiq without multiplying by key.width(), while the per-column rate denominator (totalMLiq) includes width scaling. This undercredits compounding makers on non-visited nodes compared to the visited path which correctly uses width * (mLiq - ncLiq).
Root Cause
Inconsistent units—column rates are per column-liquidity (width-scaled), but the applied compounding quantity in the non-visited path is not width-scaled.
Link (non-visited path): https://github.com/sherlock-audit/2025-09-ammplify/blob/main/Ammplify/src/walkers/Fee.sol#L249-L267
// We charge/pay our own fees.
node.fees.takerXFeesPerLiqX128 += colTakerXRateX128;
node.fees.takerYFeesPerLiqX128 += colTakerYRateX128;
node.fees.makerXFeesPerLiqX128 += colMakerXRateX128;
node.fees.makerYFeesPerLiqX128 += colMakerYRateX128;
// We round down to avoid overpaying dust.
uint256 compoundingLiq = node.liq.mLiq - node.liq.ncLiq; // vulnerable: missing * key.width()
node.fees.xCFees = add128Fees(
node.fees.xCFees,
FullMath.mulX128(colMakerXRateX128, compoundingLiq, false),
data,
true
);
node.fees.yCFees = add128Fees(
node.fees.yCFees,
FullMath.mulX128(colMakerYRateX128, compoundingLiq, false),
data,
false
);
Contrast (visited path correct): https://github.com/sherlock-audit/2025-09-ammplify/blob/main/Ammplify/src/walkers/Fee.sol#L418-L424
uint256 compoundingLiq = width * (node.liq.mLiq - node.liq.ncLiq);
node.fees.xCFees = add128Fees(
node.fees.xCFees,
FullMath.mulX128(colMakerXRateX128, compoundingLiq, false),
data,
true
);
Attack Path
Undercredited compounding makers at non-visited nodes
- Provide compounding maker liquidity such that the node is charged in the propagation (non-visited) path (common during walks up ancestors where
visit == false). - Trigger walks frequently; accrued compounding fees into
xCFees/yCFeesare undercounted due to missingwidthmultiplier. - No downstream normalization exists;
xCFees/yCFeesare later used directly for earnings and compounding.
Impact
- Makers are underpaid on non-visited nodes; compounding growth is reduced. The shortfall scales with node width (e.g., width=8 → ~87.5% undercredit for that node’s compounding portion), causing material loss of user yield and future principal via compounding.
Mitigation
- Multiply by width in the non-visited path to match visited-path logic:
uint256 compoundingLiq = uint256(key.width()) * (node.liq.mLiq - node.liq.ncLiq);
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely inconsistent units: the per-column rate denominator is width-scaled, but the compounding quantity in the non-visited path is not width-scaled.
Impact
Makers are underpaid on non-visited nodes, reducing compounding growth; the shortfall scales with node width, causing material loss of user yield and future principal.
What the attacker needed
Provide compounding maker liquidity; Node charged in non-visited path; Trigger walks frequently
The fix
Multiply by width in the non-visited path to match visited-path logic.
How it was found
- Provide compounding maker liquidity such that the node is charged in the propagation (non-visited) path.
- Trigger walks frequently; accrued compounding fees into xCFees/yCFees are undercounted due to missing width multiplier.
- No downstream normalization exists; xCFees/yCFees are later used directly for earnings and compounding.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a liquidity pool, fees are shared among liquidity providers. The code that calculates these fees sometimes forgets to multiply by a scaling factor (the node's width), so some providers get less than they should. This means they earn less over time.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.