Skip to content

A Solana zero-block sniping bot using gRPC with support for Pump.fun, PumpSwap, Raydium CPMM/AMM/CLMM, and LaunchLab.

Notifications You must be signed in to change notification settings

keidev-sol/Solana-Sniper-Rust-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Solana Sniper Bot (Rust) - High-Performance Multi-DEX Trading Bot

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.

๐Ÿš€ Overview

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

โœจ Key Features

Speed & Performance

  • 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

Multi-DEX Coverage

  • 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

Advanced Auto-Sell System

  • 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

Transaction Services

  • 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

Safety & Reliability

  • 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

๐Ÿ“‹ Test Results

Pumpfun Sniper (0-Block Execution)

Pumpswap Sniper (1-Block Execution)

Raydium CLMM Sniper (1-Block Execution)

๐Ÿ—๏ธ Architecture

System Components

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    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)      โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Processing Flow

  1. Detection: Yellowstone gRPC stream receives transaction data in real-time
  2. Decoding: Carbon decoders parse DEX-specific instructions (Create, Buy, Sell, Swap)
  3. Filtering: Processors filter for new pool creations or target events
  4. Account Arrangement: Automatic PDA derivation and account wiring
  5. Instruction Building: Construct optimized buy instructions with compute budgets
  6. Signing: Transaction signing with recent blockhash
  7. Submission: Route through Jito/Nozomi/ZeroSlot or direct RPC
  8. Monitoring: Auto-sell system tracks positions and executes exit strategies

๐Ÿ“ Directory Structure

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

โš™๏ธ Configuration

Environment Variables

Create a .env file in the project root with the following variables:

Required Configuration

# 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 Configuration

# 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

Filtering Configuration

# Pool Filtering
MIN_LIQUIDITY_SOL=0.0                     # Minimum initial liquidity (SOL)
ONLY_MINTABLE_TOKENS=false                # Only snipe mintable tokens (Pumpfun)

Service-Specific Configuration

# 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

Configuration Notes

  • CU & Priority Fees: Set to 0 to 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

๐Ÿš€ Setup & Installation

Prerequisites

  • 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)

Installation Steps

  1. Clone the repository

    git clone <repository-url>
    cd Sniper-Rust-Validator-Private
  2. Install dependencies

    cargo fetch
  3. Configure environment

    cp .env.example .env  # If example exists, or create manually
    # Edit .env with your configuration
  4. Build the project

    cargo build --release
  5. Run the sniper bot

    cargo run --release

Running in Development Mode

For development with debug logging:

RUST_LOG=debug cargo run

๐Ÿ”ง Advanced Features

1. Multi-DEX Pool Detection

The bot automatically detects new pool creations across all supported DEXs:

  • Pumpfun: Detects Create instructions and immediately executes buy
  • Pumpswap: Detects CreatePool instructions and executes buy
  • Raydium: Detects pool initialization across AMM/CPMM/CLMM variants
  • LaunchLab: Detects primary sale events

2. Zero-Block Copy Transactions

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

3. Intelligent Auto-Sell System

The auto-sell system provides multiple exit strategies:

Take Profit (TP)

  • Sells when profit reaches configured threshold
  • Can trigger Trailing Take Profit (TTP) instead of immediate sell

Stop Loss (SL)

  • Hard stop loss protection
  • Always active if configured

Trailing Stop Loss (TSL)

  • Activates after reaching TRAILING_ACTIVATION_PERCENT profit
  • Follows highest price and sells on drawdown

Trailing Take Profit (TTP)

  • Activates after TP is hit
  • Allows profits to run while protecting against drawdown
  • Sells if price drops by TTP_DRAWDOWN_PERCENT from peak

Lifetime-Based Selling

  • Automatic exit after AUTO_SELL_LIFETIME_SECONDS
  • Useful for time-based strategies

4. Signature Deduplication

Prevents double-spending and transaction replay:

  • Maintains rolling cache of processed signatures
  • Automatic cleanup after 3 seconds
  • Configurable cooldown periods

5. Account Auto-Wiring

Automatic derivation of Program Derived Addresses (PDAs):

  • Fee config accounts
  • Global volume accumulators
  • User volume accumulators
  • Event authority accounts
  • Associated Token Accounts (ATAs)

6. CSV Logging

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)

๐Ÿ“Š Performance Metrics

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

๐Ÿ›ก๏ธ Security Considerations

  • Private Key Management: Never commit .env files 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

๐Ÿ› Troubleshooting

Common Issues

  1. gRPC Connection Failed

    • Verify LOCAL_GRPC_URL is correct
    • Check GRPC_TOKEN if authentication is required
    • Ensure network connectivity to gRPC endpoint
  2. Transaction Failures

    • Check RPC endpoint health
    • Verify sufficient SOL balance for fees
    • Review compute unit limits and priority fees
    • Check slippage tolerance settings
  3. Auto-Sell Not Working

    • Verify AUTO_SELL_ENABLED=true
    • Check BIRDEYE_API_KEY if using price-based triggers
    • Review auto-sell configuration values
  4. No Pools Detected

    • Verify gRPC stream is receiving transactions
    • Check processor registration in main.rs
    • Review transaction filters

๐Ÿ“ Operational Notes

  • 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

๐Ÿ”ฎ Roadmap

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

๐Ÿ“„ License

[Specify your license here]

๐Ÿ‘ฅ Contact

โš ๏ธ Disclaimer

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.

About

A Solana zero-block sniping bot using gRPC with support for Pump.fun, PumpSwap, Raydium CPMM/AMM/CLMM, and LaunchLab.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages