leonyx007/Solana-Arbitrage-Bot
High-performance Solana arbitrage engine that detects and executes cross-DEX price opportunities across Pump.fun, Meteora DLMM, and dAMM v2. Powered by a gRPC-based market data and control layer for low-latency execution
Solana Arbitrage Bot
High-performance arbitrage engine for Solana that captures price discrepancies across multiple DEX venues — Pump.fun, Meteora DLMM, and dAMM v2 — with a gRPC-driven market data and control plane.
Test transaction (demo run):
https://solscan.io/tx/3oUmy9CMdc2diGxhrkHcVUuWUBZnr7m862J8QxNELMy943T325wspgZmzHhbZsXRqPhEU68UZ3qpCuNSrHoSMTGC
Overview
This project is an on-chain arbitrage bot that:
- Monitors multiple Solana venues for mispricings in near real-time
- Computes optimal cross-venue routes (2-leg and 3-leg) including fees, slippage, and gas
- Submits atomic transactions to capture spread with strict risk controls
- Uses a gRPC interface for fast data ingestion, control, and observability
The system is designed for low-latency discovery and execution while remaining configurable and safe for continuous operation.
Key Features
- Cross-venue arbitrage: Pump.fun, Meteora DLMM, dAMM v2
- gRPC control plane: start/stop strategies, parameter updates, health checks
- Deterministic pricing with venue-specific fee and slippage modeling
- Atomic swaps with route validation and pre-flight simulation (when enabled)
- Configurable risk limits (max notional, per-venue caps, daily loss limits)
- Rate limiting and backoff to avoid RPC bans
- Structured logging and run-time metrics
Architecture
- gRPC Server: Accepts commands, streams metrics, and publishes market snapshots.
- Strategy Engine: Detects spreads, sizes trades, and enforces risk.
- Router: Selects the best executable path across venue adapters.
- Venue Adapters: Normalized interfaces for Pump.fun, Meteora DLMM, and dAMM v2.
- TX Builder: Crafts atomic transactions with compute budget tuning and prioritization fees.
How It Works
- Subscribe to quotes/orderbooks via gRPC data channels and/or venue polling.
- Normalize quotes to a common representation (price, size, fees, slippage curve).
- Identify profitable cycles (2-leg or 3-leg) that exceed configured thresholds.
- Simulate (optional) and validate all legs with current slots and account states.
- Construct and send an atomic transaction; confirm with desired commitment.
- Record results, update risk metrics, and continue scanning.
Requirements
- Node.js or Rust toolchain (depending on your implementation)
- Solana CLI and access to mainnet RPC + WS endpoints
- A funded keypair with enough SOL for compute/prioritization fees
- Optional: Prometheus/Grafana for metrics, Loki for logs
Configuration
Environment variables (example):
RPC_ENDPOINT=https://mainnet.helius-rpc.com/?api-key=
RPC_WEBSOCKET_ENDPOINT=wss://mainnet.helius-rpc.com/?api-key=
SLIPPAGE=10 # percent
PROFIT_LEVEL=10 # percent
COMMITMENT=processed
JITO_FEE=0.0003
GEYSER_RPC=wss://grpcPer-venue settings can be provided via config files or environment variables (e.g., pool allowlists/denylists, token decimals, slippage curves).
Setup
# 1) Install dependencies
npm install
# 2) Create a .env file
cp .env.example .env
edit .env
# 3) Verify Solana CLI
solana --version
solana config get
# 4) Fund your keypair
solana balanceRunning
# Start the gRPC server and strategy engine
npm run start
# Or run with explicit env overrides
GRPC_PORT=50052 ENABLE_PUMPFUN=false npm run startgRPC interface (examples):
- Start/stop strategy
- Update thresholds (min spread, max notional)
- Stream metrics (PnL, win rate, latency)
- Subscribe to market snapshots
Strategy Controls
- Min spread threshold: Reject routes below net-profit threshold after all fees
- Slippage guard: Size trades to worst-case slippage per venue curve
- Health checks: Halt on repeated failed confirms, RPC errors, or staleness
- Cooldowns: Adaptive backoff after errors or consecutive reverts
Observability
- Structured logs with per-trade breakdown (route, expected vs realized PnL)
- Exported metrics: trades, fills, PnL, error rates, compute, confirmation latency
- Optional tracing for hot paths (routing, account fetching, simulation)
Test Results
- Example mainnet transaction:
https://solscan.io/tx/3oUmy9CMdc2diGxhrkHcVUuWUBZnr7m862J8QxNELMy943T325wspgZmzHhbZsXRqPhEU68UZ3qpCuNSrHoSMTGC
arb_scanner.mp4
Safety Notes
- Mainnet trading is risky; spreads can vanish before confirmation
- Always start with small size; validate configs and simulate
- Maintain sufficient SOL for compute/priority fees and rent
- Understand each venue's constraints and failure modes
Roadmap
- Add more venues and RFQ endpoints
- Improve path search (multi-hop, multi-venue) and sizing
- Portfolio-aware risk (inventory targeting, token caps)
- Enhanced strategy tuning via gRPC