ConcentratedLiquidityPoolHelper : getTickState() might run out of gas
The getTickState() function iterates over all ticks in a concentrated liquidity pool, which can cause it to run out of gas depending on tick spacing. An attacker could call this function to cause a denial of service by exhausting gas.
Submitted by hickuphh3, also found by cmichel
Impact
getTickState() attempts to fetch the state of all inserted ticks (including MIN_TICK and MAX_TICK) of a pool. Depending on the tick spacing, this function may run out of gas.
Recommended Mitigation Steps
Have a starting index parameter to start the iteration from. Also, tickCount can be made use of more meaningfully to limit the number of iterations performed.
function getTickState(
IConcentratedLiquidityPool pool,
int24 startIndex,
uint24 tickCount
) external view returns (SimpleTick[] memory) {
SimpleTick[] memory ticks = new SimpleTick[](tickCount);
IConcentratedLiquidityPool.Tick memory tick;
int24 current = startIndex;
for (uint24 i; i < tickCount; i++) {
tick = pool.ticks(current);
ticks[i] = SimpleTick({index: current, liquidity: tick.liquidity});
// reached end of linked list, exit loop
if (current == TickMath.MAX_TICK) break;
// else, continue with next iteration
current = tick.nextTick;
}
return ticks;
}
sarangparikh22 (Sushi) acknowledged
Functionality is affected, severity 2.
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
The function loops over all ticks without a limit, so the gas cost grows with the number of ticks and can exceed the block gas limit.
Impact
The function may run out of gas, preventing users from retrieving tick state and potentially causing a denial of service.
What the attacker needed
None
The fix
The function should be modified to accept a starting index and a tick count to limit the number of iterations, as suggested in the report.
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.
This is a smart contract function that tries to read data for every tick in a pool. If there are too many ticks, the function uses too much gas and fails, so users cannot get the information they need.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.