Solana MEV Bot-A production-ready MEV (Maximal Extractable Value) trading bot for the Solana blockchain, designed with clean architecture, modular code, and comprehensive risk controls.
β IMPLEMENTATION COMPLETE: This codebase includes a fully functional MEV bot with arbitrage, sandwich, and liquidation strategies, real-time mempool monitoring, transaction simulation, and optimized execution through Jito bundles.
Preferred method for quick chat:
Also available on:
- Telegram: https://t.me/solanabull0
- WhatsApp:
+1 (838) 273-9959 - Email: tradingsolana8@gmail.com
- Discord:
solanabull0
This software carries significant financial risk. MEV trading can result in substantial losses. Use at your own risk and only with funds you can afford to lose.
- Real-time Mempool Monitoring: WebSocket subscriptions to detect MEV opportunities
- Multi-DEX Arbitrage: Cross-DEX arbitrage between Raydium, Orca, and OpenBook
- Transaction Simulation: Pre-execution validation and profit analysis
- Optimized Execution: Jito bundle support and direct TPU submission
- Risk Management: Comprehensive safety controls and loss limits
- Structured Logging: JSON-formatted logs with performance metrics
- Modular Architecture: Easily extensible strategy system
mev-bot/
βββ config/
β βββ config.toml # Configuration file
βββ src/
β βββ main.rs # Application entry point
β βββ engine/ # Core bot engine
β β βββ mempool_listener.rs # Real-time mempool monitoring
β β βββ strategy_router.rs # Opportunity routing
β β βββ simulation.rs # Transaction simulation
β β βββ executor.rs # Transaction execution
β βββ strategies/ # MEV strategies
β β βββ arbitrage.rs # DEX arbitrage
β β βββ sandwich.rs # Sandwich attacks
β β βββ liquidation.rs # Liquidation monitoring
β βββ dex/ # DEX integrations
β β βββ raydium.rs # Raydium AMM
β β βββ orca.rs # Orca Whirlpool
β β βββ openbook.rs # OpenBook orderbook
β βββ utils/ # Shared utilities
β βββ config.rs # Configuration management
β βββ logger.rs # Logging system
β βββ math.rs # Mathematical operations
β βββ fees.rs # Fee calculations
β βββ priority.rs # Priority fee management
βββ tests/ # Test suites
βββ README.md
- Rust 1.70+
- Solana CLI tools
- Linux/Windows/macOS
git clone <repository-url>
cd solana-mev-bot
cargo build --releaseEdit config/config.toml:
[bot]
enabled = true
name = "solana-mev-bot"
[solana]
rpc_url = "https://api.mainnet-beta.solana.com"
ws_url = "wss://api.mainnet-beta.solana.com"
[strategies]
arbitrage = true
sandwich = false # High risk, enable with caution
liquidation = false
[risk_management]
max_sol_per_trade = 1.0
daily_loss_limit_usd = 100.0
max_consecutive_failures = 5Set your wallet private key (never commit to version control):
export PRIVATE_KEY="your_private_key_here"cargo run --release| Setting | Description | Default |
|---|---|---|
solana.rpc_url |
Solana RPC endpoint | https://api.mainnet-beta.solana.com |
solana.ws_url |
WebSocket endpoint | wss://api.mainnet-beta.solana.com |
risk_management.max_sol_per_trade |
Max SOL per trade | 1.0 |
arbitrage.min_profit_usd |
Minimum arbitrage profit | 0.1 |
[arbitrage]
enabled = true
min_profit_usd = 0.1
max_slippage_bps = 50 # 0.5%
supported_dexes = ["raydium", "orca", "openbook"][sandwich]
enabled = false # Only enable if you understand the risks
min_target_size_usd = 100.0
max_front_run_bps = 20[jito]
enabled = true
block_engine_url = "https://mainnet.block-engine.jito.wtf"
tip_account = "96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU"
max_tip_lamports = 1000000How it works:
- Monitors price differences across DEXes
- Executes atomic swaps when profitable
- Supports multi-hop routes (A β B β C)
Supported DEXes:
- Raydium AMM
- Orca Whirlpool
- OpenBook (Phoenix)
Example Opportunity:
SOL/USD on Raydium: $150.00
SOL/USD on Orca: $150.05
β Buy on Raydium, sell on Orca for $0.05 profit per SOL
How it works:
- Detects large pending swaps in mempool
- Front-runs with buy, back-runs with sell
- Uses slippage protection
How it works:
- Monitors lending protocols (Marginfi, Solend)
- Detects undercollateralized positions
- Liquidates when profitable
-
Position Limits
- Maximum SOL per trade
- Daily loss limits
- Auto-disable on consecutive failures
-
Transaction Validation
- Pre-execution simulation
- Slippage protection
- Compute unit limits
-
Kill Switch
[risk_management] kill_switch = false # Set to true to disable trading
# View logs
tail -f logs/mev-bot.log
# Health check (if monitoring enabled)
curl http://localhost:9090/health- WebSocket Subscriptions: Real-time mempool monitoring
- Jito Bundles: Optimized transaction ordering
- Direct TPU: Minimal network latency
- Pre-computed Routes: Cached DEX pool data
- Connection pooling for RPC calls
- Efficient data structures for price caching
- Garbage collection for stale opportunities
- Automatic retry with exponential backoff
- Circuit breakers for failing components
- Graceful degradation on network issues
# Debug build
cargo build
# Release build (optimized)
cargo build --release
# Run tests
cargo test- Zero unsafe code unless justified
- Strong typing everywhere
- Comprehensive error handling
- Performance-first mindset
- Create strategy in
src/strategies/ - Implement required traits
- Add to
StrategyRouter - Update configuration
Example:
#[async_trait]
impl ExecutableOpportunity for MyStrategy {
async fn get_simulation_data(&self) -> Result<SimulationData, Error> {
// Implementation
}
fn get_expected_profit(&self) -> f64 {
// Implementation
}
}Structured JSON logs include:
- Opportunity detection
- Transaction execution results
- Performance metrics
- Error conditions
[monitoring]
enabled = true
metrics_port = 9090
alert_webhook_url = "https://hooks.slack.com/..."Available metrics:
- Opportunities detected/executed
- Success rates
- Latency measurements
- Error counts
-
Connection Failures
Error: WebSocket connection failed- Check network connectivity
- Verify RPC/WebSocket URLs
- Consider using a different RPC provider
-
Transaction Failures
Error: Simulation failed- Check account balances
- Verify program IDs
- Review slippage settings
-
Low Profit Detection
Warning: No profitable opportunities found- Adjust minimum profit thresholds
- Check DEX liquidity
- Verify price feeds
Enable debug logging:
[logging]
level = "DEBUG"- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
- Use
rustfmtfor formatting - Add documentation for public APIs
- Include unit tests for critical functions
- Follow the existing modular structure
MIT License - see LICENSE file for details.
- Solana Foundation for the excellent documentation
- Jito Labs for MEV infrastructure
- DEX communities for protocol transparency
Remember: MEV trading is highly competitive and risky. This bot provides the infrastructure, but success depends on market conditions, timing, and risk management.