The optimizer aggregates data across all bots and adjusts their behavior in real time. Bots are the sensors and actuators — the optimizer is the brain. Below are strategy patterns that illustrate how this relationship can be used.
PnL-Based Spend Control
Each bot reports trade outcomes back to the optimizer via a custom outbound message. The optimizer tracks rolling PnL per bot. When a bot’s performance drops below a threshold, the optimizer pushes a new configuration via AdjustConfiguration — reducing max_spend_lamports or setting position_weight to zero to pause it. When performance recovers, it opens the bot back up.
This creates a closed feedback loop: the bot earns the right to spend by performing.
Message flow:
- Bot → Optimizer:
TradeResult { pnl: f64, slot: u64 } - Optimizer → Bot:
AdjustConfiguration { max_spend_lamports, position_weight }
Validator Leaderboard Gating
On Solana, the slot leader schedule is known in advance. The optimizer tracks which validator is coming up as the next leader and gates transaction submission across the fleet accordingly.
Bots on all validators run continuously and monitor markets. The optimizer pushes position_weight: 0.0 to every bot except the one on the upcoming leader validator. Only that bot is authorized to submit — it has the lowest latency to the next block and the highest chance of inclusion. When the leader slot passes, the optimizer updates the configuration and the next bot takes over.
This eliminates wasted fees from bots submitting transactions they have no realistic chance of landing.
Message flow:
- Optimizer → Bot:
AdjustConfiguration { position_weight }(0.0 to disable, 1.0 to enable)
Arbitrage
The bot subscribes to pool reserve accounts on load. As token account updates arrive, it tracks prices across pools and detects profitable cycles. When a cycle exceeds the configured minimum profit threshold, it builds and submits a swap transaction.
The optimizer controls which pools the bot watches and the minimum profit threshold — allowing the strategy to be tuned without redeploying the bot.
Message flow:
- Bot → Optimizer:
PriceSignal { pool, price, slot } - Optimizer → Bot:
AdjustConfiguration { min_profit_bps, position_weight }
Market Making
The bot monitors order book state and maintains positions on both sides of the spread. It reports fill rate and current spread back to the optimizer. The optimizer adjusts the target spread and maximum position size based on market conditions and overall portfolio exposure.
Message flow:
- Bot → Optimizer:
FillReport { side, size, price, slot } - Optimizer → Bot:
AdjustConfiguration { target_spread_bps, max_position }
Liquidation
The bot subscribes to collateral accounts and monitors health ratios. When a position becomes undercollateralized, it submits a liquidation transaction. The optimizer sets the minimum health ratio threshold and can pause liquidation activity during periods of high network congestion.
Message flow:
- Bot → Optimizer:
HealthUpdate { account, ratio, slot } - Optimizer → Bot:
AdjustConfiguration { min_health_ratio, position_weight }