A highly-optimized, completely stateless on-chain MEV (Maximal Extractable Value) program built on Solana using the Anchor framework. This program executes two-hop atomic arbitrage strategies between the two largest DEXes on Solana: Raydium (CLMM) and Orca (Whirlpools).
- Features
- Architecture
- Prerequisites
- Getting Started
- Testing
- Program Instructions
- Error Codes
- Security Considerations
- License
- Stateless Execution: The program holds absolute zero funds in Program Derived Addresses (PDAs), drastically reducing smart contract risk.
- Atomic Reversions: Transactions mathematically guarantee no loss of principal by reverting entirely if a strict, configurable minimum profit threshold is not met.
- Dynamic CPI Construction: Efficiently handles complex state routing for Concentrated Liquidity Market Makers (CLMMs) across multiple protocols.
- Live Tick-Array Derivation: Derives Tick Array PDAs dynamically via live RPC state to bypass common SDK caching bugs and stale-state errors.
Because Arbiger is stateless, it relies on strict account validation rather than persistent state accounts.
-
Operator Accounts
- Temporarily borrows funds directly from the operator's Associated Token Accounts (ATAs).
- Tracks
starting_token_accountandintermediate_token_accountto route the swap logic.
-
Raydium CPI Accounts
- Expects validated Raydium CLMM state accounts (
amm_config,pool_state,vaults,observation_state). - Dynamically accepts variable-length Tick Array accounts via Anchor's
remaining_accountspattern.
- Expects validated Raydium CLMM state accounts (
-
Orca CPI Accounts
- Expects validated Whirlpool state accounts (
whirlpool,token_vaults,oracle). - Requires deterministic Tick Array accounts based on the swap direction and tick spacing.
- Expects validated Whirlpool state accounts (
Ensure you have the following installed before getting started:
- Rust (latest stable)
- Solana CLI (v1.16+ recommended)
- Anchor CLI (v0.29+)
- Node.js & Bun (or pnpm/yarn)
-
Clone the repository
git clone https://github.com/Enmilo-dev/arbiger cd arbiger -
Install dependencies
pnpm install
-
Build the Anchor program
anchor build
-
Sync program ID Update the program ID in
Anchor.tomlandprograms/arbiger/src/lib.rswith the newly generated key fromtarget/deploy/arbiger-keypair.json.anchor keys sync
Standard local validators are insufficient for testing MEV bots because they lack live liquidity state. This project utilizes Local Mainnet Forking to test against live AMM state.
To test the program, start a local mainnet fork (e.g., using surfpool) that has cloned the Raydium and Orca SOL/USDC pools.
Deploy the program to the fork:
solana program deploy target/deploy/arbiger.so -u http://127.0.0.1:8899Run the end-to-end integration tests:
bunx ts-node test/test.tsExecutes a two-hop atomic arbitrage trade.
- Parameters:
raydium_swap_data: Struct containing amount, threshold, and price limits for Raydium.orca_swap_data: Struct containing amount, threshold, and price limits for Orca.min_profit_bps(u64): The minimum acceptable profit in basis points (e.g., 100 = 1%).
- Behavior: Takes a snapshot of the starting ATA balance, executes the Raydium swap (USDC -> WSOL), immediately executes the Orca swap (WSOL -> USDC), and compares the final balance against the starting balance plus the required profit threshold.
| Code | Name | Description |
|---|---|---|
6000 |
InsufficientProfit |
The final balance after both swaps did not meet the min_profit_bps threshold. |
- Principal Protection: The
min_profit_bpsguard ensures that even if slippage is high or price oracles are manipulated, the transaction will revert rather than execute at a loss. - Stateless Custody: The operator retains full custody of all funds at all times. The program is completely incapable of holding or trapping user funds.
- Strict CPI Validation: All external accounts passed to the Raydium and Orca programs are validated by their respective target programs.
This project is licensed under the MIT License - see the LICENSE file for details.