Skip to content

LemnLabs/solana-jupiter-arbitrage-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solana Jupiter Arbitrage Bot On-Chain & Off-Chain

Solana Jupiter Arbitrage Bot that identifies and executes profitable price differences across multiple DEXs using gRPC, Jito bundles, and advanced MEV strategies.

Call Me

Telegram

DeFi Activity

image

WSOL/WSOL, USDC/USDC, WETH/WETH It can be anything pair

Latest Updates

Big Updates

  • Updated to Protocol Buffers: Latest protobuf specification for better forward compatibility
  • Dependency Updates: All dependencies upgraded to latest stable versions
    • Tokio 1.49 for enhanced async performance
    • Tonic 0.14.2 and Prost 0.14.3 for improved gRPC support
    • Anchor Lang 0.32.1 for latest Solana features
    • Reqwest 0.13.1, Hyper 1.8.1, Tower-HTTP 0.6.8 for better networking
    • SQLx 0.8.6 with improved PostgreSQL support
    • Enhanced error handling with Thiserror 2.0.17 and Anyhow 1.0.100
  • Improvements:
    • Extensible adapter architecture
    • Parallel quote fetching from all DEXes
    • Cached liquidity data (30 seconds expiry)
    • Optimized WebSocket connections with tokio-tungstenite 0.23.0

onchain vs off chain

  • offchain: easy to maintain, dynamic route by using jupiter
  • onchain: a bit hared to maintain, customized route

Features

  • Multi-DEX Arbitrage: Supports Raydium, Orca, Serum, Aldrin, Saber, and Mercurial
  • Jupiter Aggregator Integration: Optimal routing and price discovery across 20+ DEXs
  • Real-time Price Monitoring: gRPC streaming for instant price updates
  • Jito Bundle Integration: Atomic execution with priority fees
  • Flash Loan Support: Capital-efficient arbitrage opportunities
  • Risk Management: Built-in stop-loss, take-profit, and position sizing
  • Performance Monitoring: Prometheus metrics and real-time analytics
  • Configurable Strategies: Customizable arbitrage parameters
  • Hybrid Execution: Choose between Jupiter routing or direct DEX execution

Supported DEXs & Program IDs

This bot supports integration with major Solana DEXs. Here are the program IDs and addresses for each supported exchange:

Primary DEXs

DEX Program ID Description Status
Raydium AMM V4 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 Automated Market Maker ✅ Active
Raydium AMM V3 5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h Legacy AMM ✅ Active
Orca Whirlpool whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc Concentrated Liquidity ✅ Active
Orca AMM V1 9W959DqEETiGZocYWCQPaJ6sBmUzgfxXfqGeTEdp3aQP Legacy AMM ✅ Active
Serum DEX V3 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin Order Book DEX ✅ Active

Secondary DEXs

DEX Program ID Description Status
Aldrin AMM55ShdkoGRB5jVYPjWJkkeY4QwKDoBQfN9GpU8pY5 AMM with concentrated liquidity ✅ Active
Saber SSwpkEEqUyuG4Qb3n5B39u2KrY3mzd9qat9noGn5E88 Stable swap AMM ✅ Active
Mercurial MERLuDFBMmsHnsBPZw2sDQZHvXFMwp8EdjudcU2HKky Stable swap AMM ✅ Active
Atrix ATR1xDEX1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1 AMM with concentrated liquidity ✅ Active
Crema Finance 6MLxLqiXaaSUpkgMnWDTuejNZEz3kE7k2woyHGVFw319 Concentrated liquidity AMM ✅ Active
Lifinity LiFiD1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1 Concentrated liquidity AMM ✅ Active
Meteora Eo7WjKq67rjJQS5xS6p3BywB4Y9EhmDbRcTnY6T6fP Dynamic AMM ✅ Active
OpenBook srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX Order book DEX (Serum fork) ✅ Active

Jupiter Aggregator

Service Program ID Description
Jupiter V6 JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33WcGuJB Main aggregator program
Jupiter V4 JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33WcGuJB Legacy aggregator

Additional Program IDs

Program Address Description
Token Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA SPL Token program
Associated Token Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL Associated token accounts
System Program 11111111111111111111111111111111 Solana system program
Rent Program SysvarRent111111111111111111111111111111111 Rent sysvar
Clock Program SysvarC1ock11111111111111111111111111111111 Clock sysvar

Pool Addresses (Examples)

Token Pair Raydium Pool Orca Pool Serum Market
SOL/USDC 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2 HJPjoWUrhoZzkNfRpHuieeFk9WcZWjwy6PBjZ81ngndJ 9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT
SOL/USDT 7qbRF6YsyGuLUVs6Y1q64bdVrfe4ZcUUz1JRdoVNUJnm Dqk7mHQBx2ZWExmyrR2S8X6UG75CrbbpK2FSBZsNVswF HWHvQhFmJBShNUZZxXb7LbQ3h6uH5bVf7Wq3o9y8Y6nK
USDC/USDT 77quYg4MGneUdjgXCunt9GgM1utm2ZJtkx7n7nrkpuNA 2QdhepnKRTLjjSqPL1PtKNwqrUkoLee5Gqs8bvZhRdMv 77quYg4MGneUdjgXCunt9GgM1utm2ZJtkx7n7nrkpuNA

RPC Endpoints

Provider Mainnet RPC Description
Solana Labs https://api.mainnet-beta.solana.com Official Solana RPC
Project Serum https://solana-api.projectserum.com Serum RPC endpoint
Ankr https://rpc.ankr.com/solana Ankr RPC service
QuickNode https://solana-mainnet.quiknode.pro/ QuickNode RPC
Alchemy https://solana-mainnet.g.alchemy.com/v2/ Alchemy RPC

API Endpoints

DEX API Endpoint Documentation
Raydium https://api.raydium.io/v2/sdk/liquidity/mainnet.json Raydium Docs
Orca https://api.mainnet.orca.so/v1/whirlpool/list Orca Docs
Serum https://serum-api.bonfida.com/pools Serum Docs
Jupiter https://quote-api.jup.ag/v6 Jupiter Docs
Aldrin https://api.aldrin.com/pools Aldrin Docs
Saber https://api.saber.so/pools Saber Docs
Mercurial https://api.mercurial.finance/pools Mercurial Docs

Note: Program IDs and addresses are subject to change. Always verify the latest addresses from official sources before using in production.

Installation

Prerequisites

  • Rust 1.70+ (Rust 2021 edition)
  • Solana CLI tools (SDK 2.0+)
  • Protocol Buffers compiler (protoc) for edition 2024 support
  • Jito bundle access for MEV-resistant execution
  • RPC endpoints for multiple DEXs (Helius, QuickNode, or Alchemy recommended)
  • Jupiter API access (optional, can use public API)

Key Dependencies

This bot leverages the latest versions of industry-standard libraries:

Category Dependencies Version
Async Runtime Tokio, Tokio-stream 1.49, 0.1.18
gRPC/Protobuf Tonic, Prost 0.14.2, 0.14.3
Solana Solana-SDK, Anchor 2.0, 0.32.1
HTTP/Networking Reqwest, Hyper, Tower 0.13.1, 1.8.1, 0.5.2
Database SQLx (PostgreSQL) 0.8.6
Monitoring Prometheus, Metrics 0.13, 0.24
Serialization Serde, Serde-JSON 1.0.193, 1.0

Build

# Clone the repository
git clone https://github.com/roswelly/solana-jupiter-bot
cd solana-jupiter-arbitrage-bot

# Build the project (will compile protobuf files automatically)
cargo build --release

# The build process will:
# 1. Compile proto/arbitrage.proto using Protocol Buffers Edition 2024
# 2. Generate Rust code for gRPC services
# 3. Build all dependencies with optimizations

Installation Verification

# Check the version
./target/release/solana-jupiter-arbitrage-bot --version

# Run tests
cargo test

# Check for updates
cargo update --dry-run

Configuration

Create a config.toml file:

[rpc_endpoints]
primary = "https://api.mainnet-beta.solana.com"
secondary = ["https://solana-api.projectserum.com", "https://rpc.ankr.com/solana"]
timeout_ms = 5000
retry_attempts = 3

[wallet]
private_key = ""  # Your wallet private key (Base58 format)
public_key = ""   # Your wallet public key
max_sol_balance = 10.0
min_sol_balance = 0.1

[jito]
enabled = true
tip_account = ""
bundle_endpoint = "https://mainnet.block-engine.jito.wtf"
max_tip_lamports = 1000000  # 0.001 SOL
min_tip_lamports = 100000   # 0.0001 SOL

[jupiter]
enabled = true
api_url = "https://quote-api.jup.ag/v6"
api_key = ""  # Optional: Your Jupiter API key
timeout_ms = 10000
retry_attempts = 3
default_slippage_bps = 50  # 0.5%
max_price_impact_pct = 5.0
preferred_dexes = ["Raydium", "Orca", "Serum"]
excluded_dexes = ["Aldrin", "Saber", "Mercurial"]
use_shared_accounts = true
dynamic_compute_unit_limit = true
prioritization_fee_lamports = 100000  # 0.0001 SOL

[risk_settings]
max_position_size = 1000.0
max_daily_loss = 100.0
max_slippage = 1.0
min_profit_threshold = 0.5
max_trades_per_hour = 10
enable_stop_loss = true
stop_loss_percentage = 5.0
max_gas_price = 1000000
min_liquidity = 10000.0
use_jupiter_for_execution = true
jupiter_slippage_bps = 50
max_price_impact_pct = 5.0

[monitoring]
prometheus_port = 9090
log_level = "info"
enable_metrics = true
metrics_interval_ms = 1000

[trading]
scan_interval_ms = 1000
execution_timeout_ms = 30000
max_concurrent_trades = 3
enable_auto_trading = false
min_opportunity_duration_ms = 500
price_update_threshold = 0.1

Usage

Basic Usage

./target/release/solana-jupiter-arbitrage-bot --config config.toml

Advanced Usage

# Start with Jupiter integration
./target/release/solana-jupiter-arbitrage-bot start --config config.toml --jito --grpc

# Test Jupiter integration
./target/release/solana-jupiter-arbitrage-bot test-jupiter \
  --input-mint So11111111111111111111111111111111111111112 \
  --output-mint  \
  --amount 1000000

# Scan for opportunities with enhanced Jupiter support
./target/release/solana-arbitrage-bot scan --min-profit 0.5 --max-amount 1000.0

Monitoring

The bot provides comprehensive monitoring through:

  • Prometheus Metrics: Real-time performance data
  • Structured Logging: Detailed execution logs
  • Performance Analytics: Profit/loss tracking
  • Health Checks: System status monitoring

Access metrics at: http://localhost:9000/metrics

Jupiter Integration Benefits

Enhanced Price Discovery

  • 20+ DEXs: Access to Raydium, Orca, Serum, Aldrin, Saber, Mercurial, and more
  • Optimal Routing: Automatic pathfinding across multiple DEXs for best prices
  • Real-time Quotes: Instant price updates with minimal latency
  • Liquidity Aggregation: Combined liquidity from all supported DEXs

Improved Execution

  • Atomic Swaps: Single transaction execution across multiple DEXs
  • Slippage Protection: Built-in slippage controls and price impact monitoring
  • Gas Optimization: Efficient transaction routing to minimize costs
  • MEV Protection: Integration with Jito bundles for MEV-resistant execution

Configuration Options

  • DEX Selection: Choose preferred and excluded DEXs
  • Slippage Control: Configurable slippage tolerance (default 0.5%)
  • Price Impact Limits: Maximum price impact thresholds
  • Execution Methods: Choose between Jupiter routing or direct DEX execution

API Reference

Core Functions

// Initialize arbitrage engine with Jupiter
let engine = ArbitrageEngine::new(
    config,
    dex_monitor,
    risk_manager,
    portfolio_manager,
    jito_client,
    jupiter_client,  // New Jupiter client
    monitoring,
).await?;

// Scan for enhanced opportunities
let opportunities = engine.scan_enhanced_opportunities(0.5, 1000.0).await?;

// Execute Jupiter swap
let result = engine.execute_jupiter_swap(&opportunity, amount).await?;

Configuration Options

  • min_profit_threshold: Minimum profit percentage to execute
  • max_slippage: Maximum acceptable slippage
  • enabled_dexs: List of DEXs to monitor
  • risk_management: Risk control parameters

Security

  • Private Key Protection: Secure key handling and storage
  • Transaction Validation: Comprehensive transaction verification
  • Rate Limiting: Protection against API abuse
  • Error Handling: Robust error recovery mechanisms

Performance

  • Sub-second Execution: Optimized for speed with Tokio 1.49 async runtime
  • Low Latency: Direct RPC connections with connection pooling
  • High Throughput: Concurrent opportunity processing with parallel DEX queries
  • Resource Efficient: Minimal CPU and memory usage
  • Enhanced Networking: Hyper 1.8.1 and Tower-HTTP 0.6.8 for improved request handling
  • Efficient Protobuf: Edition 2024 with optimized serialization/deserialization

Technical Specifications

Metric Value
Average Execution Time < 500ms
Max Concurrent Trades 3 (configurable)
Scan Interval 1000ms (configurable)
WebSocket Latency < 50ms
Memory Usage ~100-200MB
CPU Usage 10-30% (single core)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Development Requirements

  • Follow Rust 2021 edition standards
  • Use Protocol Buffers Edition 2024 for any new proto definitions
  • Ensure all tests pass: cargo test
  • Run clippy: cargo clippy -- -D warnings
  • Format code: cargo fmt

Changelog

v1.0.0 (January 2026)

  • Initial stable release
  • Protocol Buffers Edition 2024 support
  • Updated all dependencies to latest stable versions
  • Enhanced performance and stability
  • Comprehensive documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.


Version: 1.0.0 | Last Updated: January 2026 | Rust Edition: 2021 | Protobuf Edition: 2024

About

Solana Arbitrage Bot with Jupiter v6 Integration A high-performance, real-time solana arbitrage bot that identifies and executes profitable price differences across multiple DEXs using Jupiter Aggregator v6, gRPC streaming, Jito bundles, and advanced MEV strategies. Built in rust solana arbitrage bot, solana arbitrage bot that is using Jupiter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages