Skip to content
Smart contracts Audit finding Advanced

`RangePool::adjustToTick()` desyncs when `nextTick == tick` leading to stolen fees

The RangePool::adjustToTick function fails to cross a tick when the next initialized tick equals the current tick, causing the pool's internal tick tracking to desynchronise from the Uniswap pool. An attacker can exploit this by swapping to that tick and adding liquidity to an out-of-range position, thereby stealing fees from honest users.

0x73696d616f Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-09-bmx-deli-swap-judging/issues/178

Found by

0x73696d616f

Summary

RangePool::adjustToTick() breaks when the nextTick equals the current tick:

Solidity
function adjustToTick(State storage self, int24 tickSpacing, int24 tick, address[] memory tokens) internal {
    int24 currentTick = self.tick;
    int128 liquidityChange = 0;
    bool lte = tick <= currentTick;

    if (lte) {
        while (tick < currentTick) {
            (int24 nextTick, bool initialized) =
                self.tickBitmap.nextInitializedTickWithinOneWord(currentTick, tickSpacing, true);

            if (nextTick <= tick) { //@audit here
                break;
            }
    ...

However, this will desync with the Uniswap pool whenever the sqrtPrice reaches the next tick.

For example, consider that a swap moved the price to tick 60, tick spacing is 60, and there is an initialized tick at 60. Looking at the Uniswap pool code, it will cross the tick, and positions from ticks 0 to 60 will now accrue fees, not 60 to 120.

But, this won't happen in the DailyEpochGauge nor IncentiveGauge. These pools will be poked after the swap, so the tick at 60 has been crossed in the Uniswap pool, but in the RangePool::adjustToTick() logic, it won't cross the tick, as the nextTick is 60, and so is the tick, which breaks and doesn't flip the tick nor update liquidity.

As a result, the following happens:

  1. Positions with tick lower at 60 should be out of range (real Uniswap pool tick becomes 59 when the sqrtPrice reaches 60), but in the DailyEpochGauge and IncentiveGauge they will in reality be in range.
  2. Thus, an attacker may exploit this to add liquidity to the Uniswap pool at ticks 60 to 120, out of range, where regular users and bots won't add liquidity because it is out of range. The attacker will get away with most of the fees.
  3. An attacker can force this to happen by specifying the sqrtLimit in the swap to be exactly the next initialized tick, and add liquidity to the out of range position to steal fees.

Root Cause

In RangePool.sol:174, the break condition is incorrect and makes the pool desync.

Internal Pre-conditions

None.

External Pre-conditions

None.

Attack Path

  1. Attacker swaps in PoolManager.swap(), setting the sqrtPrice to the next initialized tick. The Uniswap pool will cross the tick, but the DailyEpochGauge/IncentiveGauge won't.
  2. Attacker adds liquidity to the position out of range in the Uniswap pool, stealing the fees from honest users that placed liquidity in the in range position.

Impact

100% of the fees are stolen by the out of range positions.

PoC

See above.

Mitigation

No response

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/morphex-labs/deli-swap-contracts/pull/19

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

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

An attacker could steal all fees from honest liquidity providers by exploiting the desynchronised tick tracking.

What the attacker needed

None

The fix

The break condition in RangePool::adjustToTick should be corrected to properly cross ticks when nextTick equals tick; the protocol team fixed this issue in a pull request.

How it was found

  1. Attacker swaps in PoolManager.swap(), setting the sqrtPrice to the next initialized tick.
  2. The Uniswap pool crosses the tick, but the DailyEpochGauge/IncentiveGauge do not.
  3. Attacker adds liquidity to the out-of-range position in the Uniswap pool.
  4. Attacker collects fees that should have gone to in-range liquidity providers.

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 automated market makers like Uniswap, liquidity is placed in price ranges called ticks. When the price moves past a tick, the pool must update which positions are active. This report shows that a function responsible for that update skips the update when the price lands exactly on a tick, leaving the pool's records out of sync. An attacker can then add liquidity in a range that should be inactive and collect fees meant for others.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by 0x73696d616f

View all

172 more disclosed reports, best first.

More from BMX Deli Swap

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.