Skip to content
Business logic Audit finding Intermediate

changeRanges silently fails when price is out of tick range, sending all liquidity to treasury instead of creating new position

The changeRanges function in LiquidityManagerCore silently skips creating a new Uniswap V3 position when the pool price is outside the old tick range, because one collected token amount is zero. Instead of reverting, it sends all collected tokens to the treasury and leaves the position mapping pointing to an empty old position.

anchabadze Follow with hirusha, JohnLaw and 3 others

Originally disclosed on Code4rena

Submitted by anchabadze, also found by hirusha, JohnLaw, Nyx, santipu_, and yonko

autonolas-tokenomics/../contracts/pol/LiquidityManagerCore.sol#L770

The changeRanges function in LiquidityManagerCore.sol is designed to reposition an existing Uniswap V3 liquidity position to a new tick range. The function removes liquidity from the old position, collects all tokens, and creates a new position with the collected amounts.

However, when the current pool price is outside the position’s tick range, Uniswap V3’s collect() returns one of the token amounts as zero (all liquidity is concentrated in one token). The function checks if (amounts[0] > 0 && amounts[1] > 0) before creating a new position, but when this condition fails, the function:

  1. Does NOT revert
  2. Does NOT create a new position
  3. Sends ALL collected tokens to treasury via _manageUtilityAmounts
  4. Leaves mapPoolAddressPositionIds[pool] pointing to the old (now empty) position

This is a silent failure - the owner expects a new position but instead sending all protocol-owned liquidity to treasury.

// LiquidityManagerCore.sol
// Check that we have liquidity for both tokens
if (amounts[0] > 0 && amounts[1] > 0) {
    // ... create new position ...
    mapPoolAddressPositionIds[pool] = positionId;
}
// No else clause - silent failure!

// Manage token leftovers - transfer both to treasury
_manageUtilityAmounts(tokens, MAX_BPS, false);  // ALL tokens go here

Scenario

  1. Protocol has an active LP position in OLAS/WETH pool earning fees with tick range [-10000, +10000].
  2. Market conditions change significantly - OLAS price drops and current tick moves to -15000, outside the position’s range.
  3. Owner calls changeRanges() to reposition liquidity to a new range that includes current price.
  4. decreaseLiquidity() removes all liquidity from old position.
  5. collect() returns all tokens, but since price is out of range, one amount is 0 (e.g., amounts = [1000000 OLAS, 0 WETH]).
  6. The condition amounts[0] > 0 && amounts[1] > 0 evaluates to false, skipping new position creation.
  7. _manageUtilityAmounts() transfers all 1000000 OLAS to treasury.
  8. Function completes successfully without revert - owner has no indication of failure.
  9. mapPoolAddressPositionIds[pool] still points to old position ID which now has zero liquidity.
  10. Protocol loses active LP position and stops earning trading fees indefinitely.
  11. mapPoolAddressPositionIds mapping points to an old (empty) position

Impact

  1. All tokens from the LP position are sent to treasury instead of being redeployed to a new position.
  2. Protocol stops earning trading fees from the affected pool.
  3. No revert or error indication - owner believes operation succeeded.
  4. mapPoolAddressPositionIds mapping points to an empty position. If owner subsequently calls convertToV3 or increaseLiquidity() intending to add tokens to the “new” position, the tokens are instead added to the old position with the old tick range that is still out of current price range. This means newly deposited tokens also earn zero trading fees. The owner believes they are operating on a correctly positioned LP, but in reality all subsequent liquidity additions compound the loss by depositing into an out-of-range position. Additionally, collectFees() and decreaseLiquidity() will revert with ZeroValue error, potentially causing confusion and blocking normal protocol operations until the issue is manually diagnosed and resolved.
  5. Owner must identify the problem, understand the cause, then manually recover: call transferPositionId() to clear the mapping, withdraw tokens from treasury back to the LiquidityManager, and redeploy liquidity via convertToV3, incurring additional gas costs and potential slippage, which affects the protocol

Recommended Mitigation

Handle the out-of-range case inside changeRanges() so the owner does not have to recover manually. When amounts[0] == 0 || amounts[1] == 0 after _collectFees(), do not revert and do not send everything to treasury; instead, open a new position using the single token (single-sided liquidity): compute tick bounds so that the current pool price lies outside the new range, then mint the new position with that one token and update mapPoolAddressPositionIds[pool]. Use the existing two-token flow when both amounts are non-zero.

Optionally, if the protocol prefers to disallow single-sided behaviour here, revert with a clear error (e.g. LiquidityOutOfRange) so the transaction rolls back and the owner can retry when price is in range or exit via decreaseLiquidity() and then recover via transferPositionId(), treasury withdrawal, and convertToV3().

Proof of Concept

View detailed Proof of Concept


The original report as published on Code4rena, by anchabadze. 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

Root cause

Likely the function only creates a new position when both collected token amounts are greater than zero, and has no else branch to handle the single-token case or revert.

Impact

All tokens from the LP position are sent to the treasury instead of being redeployed, the protocol stops earning trading fees, and the stale mapping can cause later deposits to go into an out-of-range position, with some functions reverting until the owner manually recovers.

What the attacker needed

Owner role on LiquidityManager; existing LP position out of tick range

The fix

The function should handle the out-of-range case by opening a single-sided position with the one available token and updating the mapping, or revert with a clear error so the owner can retry.

How it was found

  1. The protocol has an active LP position in the OLAS/WETH pool with a tick range that no longer contains the current price.
  2. The owner calls changeRanges to reposition the liquidity to a new range.
  3. The function removes all liquidity from the old position and collects the tokens.
  4. Because the price is out of range, collect returns one token amount as zero.
  5. The condition requiring both amounts to be positive is false, so no new position is created.
  6. The function transfers all collected tokens to the treasury and completes without reverting.

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.

A liquidity provider puts two tokens into a trading pool to earn fees. When the market price moves far away, the pool gives back only one of the two tokens. The function that is supposed to move the liquidity to a new range checks for both tokens, and when only one comes back it quietly sends everything to the treasury instead of making a new position, without telling the owner anything went wrong.

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 anchabadze

View all

1 more disclosed report, best first.

More from Olas

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.