Solana CLMM Auto Rebalance Bot

The AI rebalancing engine that checks Orca Whirlpool and Raydium CLMM positions about every 2 minutes and reopens out-of-range ones at a width chosen for current volatility — automatically, 24/7.

~2 min
Check interval
24/7
Monitoring
2
DEXes: Orca + Raydium
Wide + Narrow
Position pair

What is CLMM Auto-Rebalancing?

On Concentrated Liquidity Market Makers (CLMM) like Orca Whirlpool and Raydium CLMM, liquidity providers set a price range — defined by tick_lower and tick_upper. The position earns trading fees only while the current tick is within this range.

When the price moves outside the range (out-of-range condition), the position becomes 100% one asset and earns zero fees. Manual LP management means this situation can persist for hours — or days — without repositioning.

Auto-rebalancing is the process of detecting the out-of-range condition and automatically closing the old position, collecting fees, and opening a new one centered on the current market price.

How the Rebalancing Algorithm Works

  1. Regular Tick Monitoring

    On every strategy cycle — about every 2 minutes — the bot reads the pool's current tick (tick_current_index on Orca Whirlpool, tickCurrent on Raydium CLMM) via Solana RPC. This is compared against the stored tick_lower and tick_upper of each active position.

  2. Out-of-Range Detection

    If tick_current < tick_lower or tick_current > tick_upper, the position is flagged for rebalancing. The bot also checks for positions approaching the edge (within 15% of the range width from either boundary) and logs early warnings.

  3. AI Market Filter

    Before reopening, the market filter has to pass. It blocks a new open when SOL has fallen 3% or more within the last hour, when 1-hour volatility is above 4%, on an extreme RSI reading (above 80), or when its trend vote reads a clear downtrend. The vote weighs the 4-hour price trend, EMA50 against EMA200, 2-hour momentum, RSI with divergence, and MACD. A separate flash-crash guard watches for sudden drops (see below).

  4. Optimal Tick Range Calculation

    New tick range is calculated from current volatility. The base widths are ±15% (wide) and ±8% (narrow); realised volatility scales them and hard bounds clamp the result to 12–30% and 7–15%. Wider in volatile regimes, tighter in ranging ones — so a live position rarely sits exactly at its base.

  5. Position Close + Fee Collection

    The old position is closed through the DEX's own program (Orca Whirlpools or Raydium CLMM). The fees it accumulated, in both tokens of the pair, are collected to the wallet.

  6. New Position Open

    A new CLMM position is opened at the calculated tick range. Liquidity is calculated via amounts_from_liquidity() to ensure an accurate token split (SOL/USDC or whichever pair the pool holds) at the current tick.

🧮 Tick Range Formula

For SOL/USDC (the main pool, Orca's 0.04% tier, has tick spacing 4; Raydium's SOL/USDC 0.04% pool has 1), ticks are calculated as:

# Convert price to tick (same math on Orca and Raydium)
# price = (1.0001 ** tick) * 1000  (for SOL/USDC scaled by 10^3)
tick = int(math.log(price / 1000) / math.log(1.0001))

# The width w is applied to PRICE, then converted to ticks
tick_lower = price_to_tick(price * (1 - w))
tick_upper = price_to_tick(price * (1 + w))

# Align outward to the pool's tick spacing (read live for each pool)
tick_lower = (tick_lower // tick_spacing) * tick_spacing
tick_upper = (tick_upper // tick_spacing + 1) * tick_spacing

# Wide base ±15%:   ln(0.85)/ln(1.0001) = -1625.3   ln(1.15)/ln(1.0001) = +1397.7 ticks
# Narrow base ±8%:  ln(0.92)/ln(1.0001) =  -833.9   ln(1.08)/ln(1.0001) =  +769.6 ticks

Percentages are symmetric but ticks are not: −15% sits about 1,625 ticks below the current tick while +15% sits about 1,398 above, because a tick is a constant ratio, not a constant amount. Earlier versions of this page showed ±1408 ticks (22 × 64): that was the tick spacing of the legacy Orca SOL/USDC 0.30% pool, which the bot retired on 26 September 2026.

Rebalancing Strategy: Wide + Narrow Positions

Smart LP Bot uses a dual-position strategy for maximum fee capture with controlled risk:

Wide Position (base ±15%)

Stays in range during normal market swings and provides a stable fee floor. The width is a base, not a constant: it scales with realised volatility and is clamped to 12–30%. In a downtrend or a high-volatility regime it is the only position the bot keeps.

Narrow Position (base ±8%)

Concentrated around current price. Against a full-range position the concentration factor is 25.4× at ±8% versus 13.7× at ±15% — so the narrow position earns roughly 1.9× the fees per dollar of the wide one, not the 3–5× often quoted. It also leaves range far more often. Both numbers come from 2√P / (2√P − P/√Pb − √Pa); you can vary the width yourself in the range optimizer.

In a ranging or rising market both positions run simultaneously (in an uptrend the bases widen to ±20% / ±12%). If the narrow position goes out of range, the wide position continues earning fees while the bot repositions the narrow one — this keeps fees coming in while the narrow one is rebuilt. In a downtrend or high-volatility regime the narrow position is switched off and the wide one runs alone at a base of ±25%.

Raydium as Well as Orca

The tick arithmetic above is the same on Raydium — the bot's Raydium client reuses the Orca math — and the same detection loop drives Raydium CLMM positions. Only the tick spacing differs from pool to pool (1 on Raydium's SOL/USDC 0.04% pool, 4 on Orca's), and the bot reads it live for each pool; everything else — the check about every 2 minutes, the out‑of‑range test, the risk filter — is shared. Positions on both DEXes run side by side and are sized against one wallet balance. Which pools are worth the capital in the first place is a separate question, measured on best Solana LP pools.

Risk Management During Rebalancing

The bot does not blindly rebalance on every trigger. Graduated risk rules, keyed to how far SOL has fallen, prevent re-entering LP during adverse conditions:

Frequently Asked Questions

How quickly does the bot detect an out-of-range position?

The strategy cycle runs about every 2 minutes, and each cycle reads the pool's current tick, so a position that has left its range is caught on the next cycle — within about 2 minutes. Closing and reopening are separate on-chain transactions, and the reopen has to pass the market filter first, so in a sharply falling market it waits.

Does rebalancing cause impermanent loss?

Rebalancing itself doesn't create IL — it just realizes the current state of the position. IL accumulates when price moves away from entry. Frequent rebalancing in a trending market can crystallize IL repeatedly, which is why the AI market filter prevents rebalancing during strong downtrends. You can put numbers on the loss for a given range and price move in the impermanent loss calculator.

What tick spacing does the bot use?

Whatever the pool defines — the bot reads it live for each pool. The main pool, Orca SOL/USDC 0.04%, uses tick_spacing = 4, so one spacing step is about 0.04% of price; Raydium's SOL/USDC 0.04% pool uses 1. The legacy Orca SOL/USDC 0.30% pool used 64 (about 0.64% per step); the bot retired it on 26 September 2026.

Can I set my own tick ranges?

No — the widths are chosen for you from a base of ±15% (wide) and ±8% (narrow), scaled by realised volatility and clamped to 12–30% and 7–15% respectively. What you choose is which pools the bot works in, how much capital each one gets, and whether a pool runs the wide + narrow pair or a single position.

Automate Your CLMM Positions

Stop missing fees from out-of-range positions. Let the AI rebalancer handle it 24/7.

🤖 Start on Telegram See Earnings Potential

Home · Orca Whirlpool Bot · Raydium CLMM Bot · Passive Income · Blog

Figures are illustrative calculations, not investment advice; liquidity positions can lose value.