Lazy Rebalancer
DLMM liquidity provision bot on Solana with market regime detection, EV-based rebalance decisions, delta-based hedging via Drift, and adaptive position parameters. Runs profitably on a $6/month VPS.
The Lazy Rebalancer is a DLMM liquidity provision bot for Meteora's SOL/USDC pools on Solana. It uses market regime detection (ATR, ADX, EMA20, Bollinger Band width) and expected value calculations to decide when rebalancing is actually worth the cost -- and when sitting still is the better trade. I wrote a deep dive into the regime detection, EV logic, and delta-based hedging covering the full indicator pipeline, classification system, and the math behind each decision.
The name stuck even as the bot grew smarter. It is "lazy" in the best sense: it acts infrequently and deliberately. After deploying the regime-aware version, rebalance frequency dropped by about 70% while net yield improved meaningfully.
How It Works
The bot classifies the market into four regimes -- RANGING, TRENDING_UP, TRENDING_DOWN, and HIGH_VOL -- each mapping to a complete set of position parameters: bin step, range width, liquidity distribution shape (including trend-biased BidAsk placement for trending markets), and fee claim schedule.
When the position drifts out of range, instead of rebalancing immediately, the bot starts a wait timer (2 hours baseline, 1 hour in RANGING) and evaluates the expected value of rebalancing versus holding. A rebalance only proceeds when the EV is positive, confidence exceeds 0.6, and the rate limiter allows it (max 2 per day, min 4 hours apart). In practice, roughly 40% of out-of-range events revert within the wait window, saving the full cost of a wasted round trip.
Delta-Based Hedging
The hedging strategy is decoupled from regime classification. Instead of toggling hedges based on market regime, the bot monitors the LP position's actual delta -- the percentage of value exposed to SOL price movements -- and manages Drift perpetual shorts based on thresholds. When LP delta exceeds 60%, a short opens to bring net exposure toward 50%. When delta drops below 40%, the hedge closes. This approach responds to actual market position rather than classification uncertainty, naturally scales with position drift, and eliminates the thrashing problem that plagued the earlier regime-based approach.
Risk Management
Before any action, the bot runs risk checks that can override all other logic. A portfolio drawdown beyond 15% triggers emergency exit. Daily losses above 5% pause all new positions and rebalances. Drift margin ratio below 1.2 forces hedge closure. These guardrails prevent compounding losses during adverse conditions.
Operations
The entire system runs on a $6/month VPS as a single Docker container. A SQLite database stores every P&L event -- fee claims, impermanent loss crystallization, gas costs, hedge realized PnL, funding payments -- creating a full audit trail. A two-way Telegram integration provides monitoring alerts and remote control: I can check status, view P&L breakdowns, or trigger emergency exits from my phone. The bot also includes a backtest engine that replays the strategy against historical candle data, which proved invaluable for tuning regime detection thresholds before deploying real capital.