A lightning-fast, production-grade Solana sniper bot built in Rust that monitors and executes trades across multiple decentralized exchanges (DEXs) in near real-time. This bot leverages gRPC data streams and optimized transaction construction to achieve 0-1 block confirmations, enabling you to snipe new token launches before they appear on DEX UIs.
This sniper bot is designed for high-frequency trading on Solana, providing sub-second execution times through:
- Real-time gRPC Data Streaming: Yellowstone gRPC integration for instant transaction detection
- Multi-DEX Support: Simultaneous monitoring of Pumpfun, Pumpswap, Raydium (AMM/CPMM/CLMM), and LaunchLab
- Zero-Block Execution: Optimized transaction routing through Jito, Nozomi, and ZeroSlot services
- Advanced Auto-Sell System: Intelligent position management with multiple exit strategies
- Rust Performance: Memory-safe, low-latency execution leveraging Rust's zero-cost abstractions
- Sub-Second Detection: Detects new pool creations within milliseconds via gRPC streams
- 0-1 Block Confirmations: Achieves same-block or next-block execution through optimized transaction routing
- Low-Latency Architecture: Async/await patterns with Tokio runtime for concurrent processing
- Compute Budget Optimization: Pre-calculated compute units and priority fees for faster inclusion
- Pumpfun: Spot trading with bonding curve mechanics
- Pumpswap: Custom swap protocol with inverted pool support
- Raydium AMM: Automated Market Maker pools
- Raydium CPMM: Constant Product Market Maker pools
- Raydium CLMM: Concentrated Liquidity Market Maker pools
- Raydium LaunchLab: Primary sales and launchpad events
- Take Profit (TP): Automatic selling when profit threshold is reached
- Stop Loss (SL): Hard stop loss protection against downside risk
- Trailing Stop Loss (TSL): Dynamic stop loss that follows price peaks
- Trailing Take Profit (TTP): Let profits run with drawdown protection after TP activation
- Lifetime-Based Selling: Automatic exit after configured time period
- Price Monitoring: Continuous price tracking with configurable intervals
- Jito Integration: Ultra-fast transaction confirmation via Jito Block Engine
- Nozomi Support: Alternative MEV protection and fast confirmation service
- ZeroSlot: Zero-slot transaction inclusion for maximum speed
- Multi-Region Support: Automatic region selection for optimal latency
- Signature Deduplication: Prevents double-spending and transaction replay
- Account Auto-Wiring: Automatic PDA derivation for fee configs, volume accumulators, and event authorities
- Error Handling: Comprehensive error recovery and logging
- CSV Logging: Detailed trade logging for analysis and auditing
- Pool Creation: View Transaction
- Sniper Buy: View Transaction
- Result: โ Same block execution - Purchased immediately upon pool creation
- Pool Creation: View Transaction
- Sniper Buy: View Transaction
- Result: โ 1-block execution - Purchased in the next block after pool creation
- Pool Creation: View Transaction
- Sniper Buy: View Transaction
- Result: โ 1-block execution - Successfully sniped CLMM pool creation
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Yellowstone gRPC Stream โ
โ (Real-time Transaction Monitoring) โ
โโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Carbon Pipeline โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ Pumpfun โ โ Pumpswap โ โ Raydium โ โ
โ โ Decoder โ โ Decoder โ โ Decoders โ โ
โ โโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ โ
โ โ โ โ โ
โ โผ โผ โผ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ Pumpfun โ โ Pumpswap โ โ Raydium โ โ
โ โ Processor โ โ Processor โ โ Processors โ โ
โ โโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ โโโโโโโโฌโโโโโโโโ โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Instruction Builder & Signer โ
โ (Compute Budget, Priority Fees, ATAs)โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Transaction Services (Optional) โ
โ โโโโโโโโ โโโโโโโโ โโโโโโโโโโโโ โ
โ โ Jito โ โNozomiโ โZeroSlot โ โ
โ โโโโโโโโ โโโโโโโโ โโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Solana RPC Network โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Auto-Sell Manager (Optional) โ
โ (TP, SL, TSL, TTP, Lifetime) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Detection: Yellowstone gRPC stream receives transaction data in real-time
- Decoding: Carbon decoders parse DEX-specific instructions (Create, Buy, Sell, Swap)
- Filtering: Processors filter for new pool creations or target events
- Account Arrangement: Automatic PDA derivation and account wiring
- Instruction Building: Construct optimized buy instructions with compute budgets
- Signing: Transaction signing with recent blockhash
- Submission: Route through Jito/Nozomi/ZeroSlot or direct RPC
- Monitoring: Auto-sell system tracks positions and executes exit strategies
src/
โโโ config/ # Configuration management
โ โโโ clients.rs # RPC client initialization
โ โโโ credentials.rs # Wallet key management
โ โโโ trade_setting.rs # Trading parameters (CU, fees, slippage, auto-sell)
โ โโโ mod.rs
โ
โโโ processors/ # DEX-specific processors
โ โโโ pumpfun.rs # Pumpfun pool detection and buy execution
โ โโโ pumpswap.rs # Pumpswap pool detection and buy execution
โ โโโ raydium_amm.rs # Raydium AMM swap detection and execution
โ โโโ raydium_cpmm.rs # Raydium CPMM swap detection and execution
โ โโโ raydium_clmm.rs # Raydium CLMM swap detection and execution
โ โโโ raydium_launchpad.rs # LaunchLab primary sales detection
โ โโโ common.rs # Shared utilities and signature deduplication
โ โโโ mod.rs
โ
โโโ instructions/ # Instruction builders
โ โโโ pumpfun_buy_ix.rs # Pumpfun buy instruction construction
โ โโโ pumpfun_sell_ix.rs # Pumpfun sell instruction construction
โ โโโ pumpswap_buy_ix.rs # Pumpswap buy instruction construction
โ โโโ pumpswap_sell_ix.rs # Pumpswap sell instruction construction
โ โโโ raydium_amm_swap_base_in.rs # AMM swap instruction builder
โ โโโ raydium_cpmm_swap_base_in.rs # CPMM swap instruction builder
โ โโโ raydium_clmm_swap.rs # CLMM swap instruction builder
โ โโโ raydium_launchpad_buy_ix.rs # LaunchLab buy instruction builder
โ โโโ raydium_launchpad_sell_ix.rs # LaunchLab sell instruction builder
โ โโโ types.rs # Shared types and utilities
โ โโโ mod.rs
โ
โโโ service/ # Transaction confirmation services
โ โโโ jito/ # Jito Block Engine integration
โ โ โโโ jito_confirm.rs # Jito transaction confirmation
โ โ โโโ jito_regions.rs # Multi-region Jito endpoint management
โ โ โโโ jito_tip_ix.rs # Jito tip instruction builder
โ โ โโโ mod.rs
โ โโโ nozomi/ # Nozomi service integration
โ โ โโโ nozomi_confirm.rs
โ โ โโโ nozomi_regions.rs
โ โ โโโ nozomi_tip_ix.rs
โ โ โโโ mod.rs
โ โโโ zero_slot/ # ZeroSlot service integration
โ โ โโโ zero_slot_confirm.rs
โ โ โโโ zero_slot_regions.rs
โ โ โโโ zero_slot_tip_ix.rs
โ โ โโโ mod.rs
โ โโโ utils/ # Service utilities
โ โ โโโ ping.rs # Latency testing
โ โ โโโ services.rs # Service discovery
โ โ โโโ tip.rs # Tip calculation
โ โ โโโ mod.rs
โ โโโ mod.rs
โ
โโโ utils/ # Utility functions
โ โโโ auto_sell.rs # Auto-sell manager with TP/SL/TSL/TTP
โ โโโ blockhash.rs # Recent blockhash management
โ โโโ build_and_sign.rs # Transaction building and signing
โ โโโ csv_logger.rs # CSV logging for trades
โ โโโ parse.rs # Transaction parsing utilities
โ โโโ swap_quote.rs # Swap quote calculations
โ โโโ token_price.rs # Token price fetching (Birdeye API)
โ โโโ utils.rs # General utilities
โ โโโ mod.rs
โ
โโโ error/ # Error handling
โ โโโ mod.rs
โ
โโโ lib.rs # Library root
โโโ main.rs # Application entry point
Create a .env file in the project root with the following variables:
# Wallet Configuration
PRIVATE_KEY=your_base58_private_key_or_array
PUBKEY=your_wallet_public_key
# RPC Configuration
RPC_ENDPOINT=https://api.mainnet-beta.solana.com
LOCAL_GRPC_URL=your_yellowstone_grpc_endpoint
GRPC_TOKEN=your_grpc_auth_token # Optional, if required by provider
# Trading Parameters
BUY_SOL_AMOUNT=0.01 # Amount of SOL to spend per buy
SLIPPAGE=1.0 # Slippage tolerance (percentage)
CU=400000 # Compute units limit (0 to disable)
PRIORITY_FEE_MICRO_LAMPORT=5000 # Priority fee in micro-lamports (0 to disable)
THIRD_PARTY_FEE=0.0005 # Third-party service fee (e.g., Jito tip)
# Transaction Confirmation Service
CONFIRM_SERVICE=JITO # Options: JITO, NOZOMI, ZERO_SLOT, or empty for direct RPC# Auto-Sell System
AUTO_SELL_ENABLED=true # Enable/disable auto-sell system
TAKE_PROFIT_PERCENT=10.0 # Take profit threshold (percentage)
STOP_LOSS_PERCENT=5.0 # Stop loss threshold (percentage)
TRAILING_STOP_LOSS_PERCENT=3.0 # Trailing stop loss (percentage)
TRAILING_ACTIVATION_PERCENT=0.0 # Profit % required to activate trailing SL (0 = always active)
TTP_DRAWDOWN_PERCENT=2.0 # Trailing Take Profit drawdown (percentage)
AUTO_SELL_LIFETIME_SECONDS=3600 # Maximum position lifetime (seconds)
PRICE_CHECK_INTERVAL_SECONDS=5 # Price check frequency (seconds)
# Price API (for auto-sell)
BIRDEYE_API_KEY=your_birdeye_api_key # Optional, for price fetching# Pool Filtering
MIN_LIQUIDITY_SOL=0.0 # Minimum initial liquidity (SOL)
ONLY_MINTABLE_TOKENS=false # Only snipe mintable tokens (Pumpfun)# Jito Configuration (if CONFIRM_SERVICE=JITO)
JITO_BLOCK_ENGINE_URL=https://ny.mainnet.block-engine.jito.wtf
JITO_TIP_VALUE=0.00927
# Nozomi Configuration (if CONFIRM_SERVICE=NOZOMI)
NOZOMI_API_URL=your_nozomi_endpoint
# ZeroSlot Configuration (if CONFIRM_SERVICE=ZERO_SLOT)
ZERO_SLOT_API_URL=your_zeroslot_endpoint- CU & Priority Fees: Set to
0to disable compute budget instructions (not recommended for fast execution) - CONFIRM_SERVICE: Leave empty to use direct RPC submission (slower but no service fees)
- Auto-Sell: All auto-sell features are optional and can be disabled by setting
AUTO_SELL_ENABLED=false - Trailing Take Profit (TTP): Activates after TP is hit, allowing profits to run with drawdown protection
-
Rust: Install Rust toolchain (stable or nightly)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Yellowstone gRPC Access: You need access to a Yellowstone gRPC endpoint (e.g., Triton, Helius, or self-hosted)
-
Clone the repository
git clone <repository-url> cd Sniper-Rust-Validator-Private
-
Install dependencies
cargo fetch
-
Configure environment
cp .env.example .env # If example exists, or create manually # Edit .env with your configuration
-
Build the project
cargo build --release
-
Run the sniper bot
cargo run --release
For development with debug logging:
RUST_LOG=debug cargo runThe bot automatically detects new pool creations across all supported DEXs:
- Pumpfun: Detects
Createinstructions and immediately executes buy - Pumpswap: Detects
CreatePoolinstructions and executes buy - Raydium: Detects pool initialization across AMM/CPMM/CLMM variants
- LaunchLab: Detects primary sale events
For maximum speed, the bot can mirror transactions in the same block:
- Pumpswap 0-Block: Mirrors buy transactions immediately
- CPMM 0-Block: Optimized CPMM swap routing
- AMM 0-Block: Fast AMM swap execution
The auto-sell system provides multiple exit strategies:
- Sells when profit reaches configured threshold
- Can trigger Trailing Take Profit (TTP) instead of immediate sell
- Hard stop loss protection
- Always active if configured
- Activates after reaching
TRAILING_ACTIVATION_PERCENTprofit - Follows highest price and sells on drawdown
- Activates after TP is hit
- Allows profits to run while protecting against drawdown
- Sells if price drops by
TTP_DRAWDOWN_PERCENTfrom peak
- Automatic exit after
AUTO_SELL_LIFETIME_SECONDS - Useful for time-based strategies
Prevents double-spending and transaction replay:
- Maintains rolling cache of processed signatures
- Automatic cleanup after 3 seconds
- Configurable cooldown periods
Automatic derivation of Program Derived Addresses (PDAs):
- Fee config accounts
- Global volume accumulators
- User volume accumulators
- Event authority accounts
- Associated Token Accounts (ATAs)
Comprehensive trade logging to auto_sell_logs.csv:
- Buy/sell timestamps
- Entry/exit prices
- Profit/loss percentages
- Transaction signatures
- Trigger reasons (TP, SL, TSL, TTP, Lifetime)
The bot tracks and logs various performance metrics:
- Detection Latency: Time from pool creation to detection
- Execution Latency: Time from detection to transaction submission
- Confirmation Time: Time to transaction confirmation
- Success Rate: Percentage of successful snipes
- Profit Tracking: Per-trade and aggregate profit/loss
- Private Key Management: Never commit
.envfiles or private keys to version control - RPC Rate Limits: Be aware of RPC provider rate limits
- Slippage Protection: Always configure appropriate slippage tolerance
- Compute Budget: Set appropriate CU limits to prevent transaction failures
- Service Fees: Understand fees for Jito/Nozomi/ZeroSlot services
-
gRPC Connection Failed
- Verify
LOCAL_GRPC_URLis correct - Check
GRPC_TOKENif authentication is required - Ensure network connectivity to gRPC endpoint
- Verify
-
Transaction Failures
- Check RPC endpoint health
- Verify sufficient SOL balance for fees
- Review compute unit limits and priority fees
- Check slippage tolerance settings
-
Auto-Sell Not Working
- Verify
AUTO_SELL_ENABLED=true - Check
BIRDEYE_API_KEYif using price-based triggers - Review auto-sell configuration values
- Verify
-
No Pools Detected
- Verify gRPC stream is receiving transactions
- Check processor registration in
main.rs - Review transaction filters
- Blockhash Management: Background task keeps recent blockhash fresh for signing
- Signature Cache: Automatically purges after 3 seconds to prevent memory leaks
- Price Monitoring: Uses Birdeye API for real-time price data (fallback to on-chain quotes)
- Service Selection: Automatically selects optimal region for Jito/Nozomi/ZeroSlot
- Error Recovery: Comprehensive error handling with detailed logging
Potential future enhancements:
- Wallet management UI for dynamic target switching
- Jupiter aggregator integration for optimal routing
- Persistent metrics sink (InfluxDB/Prometheus)
- Historical performance analytics dashboard
- Automated slippage tuning based on fill rates
- Multi-wallet support for position diversification
- Telegram/Discord notifications for trades
- Backtesting framework for strategy validation
[Specify your license here]
This software is provided for educational and research purposes only. Trading cryptocurrencies involves substantial risk of loss. Use at your own risk. The authors and contributors are not responsible for any financial losses incurred while using this software.
Happy Sniping! ๐ฏ
For troubleshooting, feature requests, or contributions, please open an issue or reach out directly via the contact channels above.