Beginner's guide to write your own Solana arbitrage bot
What is this?
This tutorial walks you from zero to a production-ready bot in four progressive stages:
Understanding atomic arbitrage on Solana β the mental model youβll need before touching code.
Bootstrapping a simple bot with Jupiter V6 β minimal effort.
Level-up: writing your own router β for searchers who want more control than Jupiter provides.
Going on-chain β pushing the arbitrage logic into a smart contract for the lowest possible latency.
How Atomic Arbitrage Works on Solana π₯·
What βatomicβ really means
On Solana you can bundle several swap instructions (e.g., buy on Orca, sell on Raydium) into a single transaction. If any leg fails the whole transaction is rolled back, so the trader takes no inventory risk β only the fee for a failed signature. This is possible because Solana validates all instructions before committing the block.
The life-cycle of an atomic arb
State read: a searcher maintains a live copy of DEX account data locally.
Route discovery: path-finding code spots two prices that diverge beyond a profit threshold.
Tx crafting: the bot builds a transaction with both swap instructions.
Submission strategy:
RPC β pay gas fee to the leader.
Jito bundle β pay a tip only when the bundle lands.
Settlement: either the whole trade lands (profit) or reverts (only fee lost).
Building Your First Bot with Jupiter V6
Why Jupiter?
Aggregates >30 DEXs, saving you the trouble of tracking every pool yourself.
Ships a self-hosted binary (jupiter-swap-api) that you can query locally at millisecond latency.
Reference implementation
https://github.com/ChainBuff/sol-arb-bot
Alternative ready-made bots
SolanaMEVBot Jupiter bot β supports blind-quote and back-run strategies out of the box. Just edit config.toml.
Advanced β Roll Your Own Router
Why leave Jupiter?
Need
Jupiter
Custom router
Full control over path search algorithm
Closed-source graph; you only get the REST API.
Write your own heuristics (e.g., favor depth over price).
Adding exotic pools
Wait for Jupiter to integrate.
Plug your adapter immediately.
Latency budget
5-20 ms typical self-hosted.
Can embed in the same process as your strategy for sub-5 ms.
Reference implementation
https://github.com/blockworks-foundation/autobahn
Advanced β On-Chain Arbitrage Bots
Why push logic on-chain?
Latency β state is read during execution, not before submission, eliminating the off-chain read phase.
Speed β Instead of sending the tx after seeing an opportunity, you just keep sending and when there's profit your tx will take it.
Hardware-light β no need for Yellowstone gRPC or a beefy validator; a $5 VPS works.
Reference implementation
Onchain program: https://github.com/buffalojoec/arb-program
Offchain bot: https://github.com/Cetipoo/solana-onchain-arbitrage-bot
Alternative ready-made bots
SolanaMEVBot Onchain bot β supports a large range of dexes. Just edit config.toml to run the bot.
Last updated