Solana trading bot guide: on-chain vs CEX execution and code
Solana is the chain where automated trading goes fully on-chain. Cheap, fast blocks make it viable to run a bot directly against a DEX aggregator like Jupiter rather than a centralized exchange — but on-chain execution introduces priority fees, failed transactions and MEV that a CEX bot never faces. This deeper guide compares the two execution paths in detail, shows the code for each, covers the priority-fee math that decides whether your swap even lands, and lays out the strategies that suit SOL’s violent volatility.
Two ways to run a Solana bot
A SOL bot can execute on a centralized exchange via SOL/USDT, or on-chain through a Jupiter swap. The CEX path is simple and cheap; the on-chain path is non-custodial and DeFi-native but exposes you to priority fees, dropped transactions and MEV. This guide goes deeper than the original Solana trading bot overview on the on-chain mechanics specifically.
The CEX path (SOL/USDT)
python · sol_cex.pyimport ccxt
ex = ccxt.bybit({'apiKey': KEY, 'secret': SECRET})
ohlcv = ex.fetch_ohlcv('SOL/USDT', '15m', limit=100)
# compute signal, then:
ex.create_market_buy_order('SOL/USDT', 0.5)
Identical to every other ccxt bot — restricted key, fetch, signal, order. For most traders this is the right path: low fees, deterministic fills, no gas.
The on-chain path (Jupiter)
javascript · jupiter_swap.js// Jupiter v6 quote → swap (simplified)
const quote = await fetch(
`https://quote-api.jup.ag/v6/quote?inputMint=${USDC}` +
`&outputMint=${SOL}&amount=${amount}&slippageBps=50`
).then(r => r.json());
const { swapTransaction } = await fetch(
'https://quote-api.jup.ag/v6/swap',
{ method: 'POST', body: JSON.stringify({ quoteResponse: quote,
userPublicKey: wallet.publicKey, prioritizationFeeLamports: 200000 }) }
).then(r => r.json());
// sign + send swapTransaction with your Solana connection
The key parameters are slippageBps (your tolerance) and prioritizationFeeLamports (your bribe to land the transaction). Set both too low and the swap fails or fills badly.
Priority fees and failed transactions
During congestion, an under-priced transaction is silently dropped — your bot thinks it traded but didn’t. A robust on-chain bot confirms the transaction landed before updating its position, and bumps the priority fee when the network is busy.
Strategies for SOL
SOL’s whipsaw volatility suits grid bots in ranges and breakout bots on the daily. The extra on-chain costs mean your edge must be large enough to clear priority fees and slippage — scalping on-chain is usually a fee-loser. Size from a stop with the position calculator.
Getting started
Start on the CEX path with SOL/USDT, paper trade the signal, and only move on-chain once the strategy is proven and the edge clearly exceeds gas-and-MEV drag. Backtest on the backtester first.
Frequently asked questions
Should a Solana bot run on a CEX or on-chain?
For most traders the CEX path with SOL/USDT is the right choice — it is cheaper, has deterministic fills and no gas or MEV risk. On-chain Jupiter swaps only make sense for DeFi-native strategies where the edge is large enough to clear priority fees and slippage.
What is a priority fee on a Solana bot?
A priority fee (prioritizationFeeLamports) is an extra payment that pushes your transaction to the front during congestion. Set it too low and the network silently drops your swap, so your bot believes it traded when it did not — a robust bot confirms the transaction landed before updating its position.
Can on-chain Solana swaps fail?
Yes. A swap fails if your slippage tolerance is too tight to fill, or it gets dropped if your priority fee is too low during congestion. Always confirm the transaction landed on-chain before assuming the trade executed, and bump the priority fee when the network is busy.
What strategy suits SOL trading bots?
SOL’s violent volatility suits grid bots inside ranges and breakout bots on the daily timeframe. On-chain scalping usually loses to priority fees and slippage, so any high-frequency edge must be large enough to clear those costs before it is worth running.