Solana CLMM Auto Rebalance Bot

The AI rebalancing engine that detects out-of-range Orca Whirlpool CLMM positions in 30 seconds and reopens them at optimal tick ranges — automatically, 24/7.

30s
Detection speed
64
Rebalances (live)
7
Risk checks per trade
99.8%
Uptime

What is CLMM Auto-Rebalancing?

On Concentrated Liquidity Market Makers (CLMM) like Orca Whirlpool, 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. Continuous Tick Monitoring

    Every 30 seconds, the bot reads the current tick_current_index from the Orca Whirlpool pool account 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 10% of range boundary) and logs early warnings.

  3. AI Market Filter (7 Checks)

    Before reopening, the AI engine runs 7 risk checks: RSI (not overbought/oversold), MACD signal, EMA200 trend direction, Bollinger Band squeeze, momentum 2h/4h, market regime (trending/ranging/volatile), and flash crash detection. All 7 must pass.

  4. Optimal Tick Range Calculation

    New tick range is calculated based on current volatility. Wide positions use ±15% price range; narrow positions use ±8%. Range width adapts to the market regime — wider during high volatility, narrower during ranging markets.

  5. Position Close + Fee Collection

    The old position is closed via Orca Whirlpool program instruction. All accumulated fees (in SOL and USDC) are automatically 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 accurate SOL/USDC split at the current tick.

🧮 Tick Range Formula

For the SOL/USDC pool (tick spacing = 64), ticks are calculated as:

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

# Align to tick spacing
tick = (tick // tick_spacing) * tick_spacing

# Wide position: ±15% price range
tick_lower_wide = tick - 2496   # ~15% below
tick_upper_wide = tick + 2496   # ~15% above

# Narrow position: ±8% price range
tick_lower_narrow = tick - 1344  # ~8% below
tick_upper_narrow = tick + 1344  # ~8% above

Rebalancing Strategy: Wide + Narrow Positions

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

Wide Position (~±15%)

Stays in range during normal market swings. Provides a stable fee floor. Rebalances less frequently — only on large price moves.

Narrow Position (~±8%)

Concentrated around current price — earns 3–5x more fees per dollar. Rebalances more frequently but generates higher fee APR.

Both positions run simultaneously. If the narrow position goes out of range, the wide position continues earning fees while the bot repositions the narrow one. This ensures continuous fee generation even during volatility.

Risk Management During Rebalancing

The bot does not blindly rebalance on every trigger. Graduated risk management prevents re-entering LP during adverse conditions:

Live Rebalancing Statistics (69 Days)

Total Rebalances

141

Positions closed and reopened over 69 days

Risk-Off Events

64

Knockouts: 33 Tier1, 19 out-of-range, 11 flash crash, 1 Tier2

Fees Collected

$38.99

Across 46 fee collection events (~$0.85/event avg)

Gas Cost

$0.43

206 transactions — Solana fees are negligible (~$0.002/tx)

Frequently Asked Questions

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

The bot checks the current tick every 30 seconds. On average, detection latency is 15 seconds from the moment the position exits range. Repositioning (close + open) takes 2–4 Solana transactions (~8–12 seconds on mainnet).

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.

What tick spacing does the bot use?

The SOL/USDC pool on Orca Whirlpool uses tick_spacing = 64. All tick calculations are aligned to this spacing. This corresponds to a minimum price step of approximately 0.64% per tick spacing unit.

Can I set my own tick ranges?

Currently the bot uses AI-optimized ranges (Wide: ±15%, Narrow: ±8%). Custom range settings are on the roadmap. You can adjust the risk mode (Conservative/Balanced/Aggressive) which affects range widths.

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 · Passive Income · Blog