Skip to content
Business logic Audit finding Intermediate

ConcentratedLiquidityPool: incorrect feeGrowthGlobal accounting when crossing ticks

The ConcentratedLiquidityPool contract incorrectly updates fee growth outside values when crossing ticks, swapping the token indices for fee accounting. This leads to wrong fee distribution among liquidity providers.

hickuphh3 Follow

Originally disclosed on Code4rena

Submitted by hickuphh3

Impact

Swap fees are taken from the output. Hence, if swapping token0 for token1 (zeroForOne is true), then fees are taken in token1. We see this to be the case in the initialization of feeGrowthGlobal in the swap cache

feeGrowthGlobal = zeroForOne ? feeGrowthGlobal1 : feeGrowthGlobal0;

and in _updateFees().

However, looking at Ticks.cross(), the logic is the reverse, which causes wrong fee accounting.

if (zeroForOne) {
	...
	ticks[nextTickToCross].feeGrowthOutside0 = feeGrowthGlobal - ticks[nextTickToCross].feeGrowthOutside0;
} else {
	...
	ticks[nextTickToCross].feeGrowthOutside1 = feeGrowthGlobal - ticks[nextTickToCross].feeGrowthOutside1;
}

Recommended Mitigation Steps

Switch the 0 and 1 in Ticks.cross().

if (zeroForOne) {
	...
	// `feeGrowthGlobal` = feeGrowthGlobal1
	ticks[nextTickToCross].feeGrowthOutside1 = feeGrowthGlobal - ticks[nextTickToCross].feeGrowthOutside1;
} else {
	...
	// feeGrowthGlobal = feeGrowthGlobal0
	ticks[nextTickToCross].feeGrowthOutside0 = feeGrowthGlobal - ticks[nextTickToCross].feeGrowthOutside0;
}

sarangparikh22 (Sushi) confirmed

The original report as published on Code4rena, by hickuphh3. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

Impact

Incorrect fee accounting could lead to liquidity providers receiving incorrect fee amounts, potentially causing loss of funds or unfair distribution.

What the attacker needed

None

The fix

The fix is to switch the `0` and `1` indices in `Ticks.cross()` so that the correct fee growth variable is updated for each swap direction.

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, traders pay fees that are shared among liquidity providers. The contract tracks these fees using variables for each token. When a trade crosses a price tick, the contract updates these variables, but it mistakenly updates the wrong token's variable, so fees are not recorded correctly.

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.

More by hickuphh3

View all

43 more disclosed reports, best first.

More from Sushi Trident contest phase 2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.