Advanced automated trading bot for Solana tokens using Helius WebSocket feeds with PumpFun and Raydium support
Features β’ Installation β’ Configuration β’ Usage β’ API β’ Contributing
- Real-time Token Detection: Monitors Helius WebSocket for new token launches and trading opportunities
- Multi-DEX Support: Supports both PumpFun and Raydium DEX for maximum trading flexibility
- Automated Trading: Executes buy/sell orders based on market conditions and strategies
- Risk Management: Built-in stop-loss and take-profit mechanisms
- Position Tracking: Monitors active positions and PnL in real-time
- Multi-token Support: Handles multiple concurrent token positions
- Nozomi Integration: MEV protection and transaction prioritization through Nozomi
- Zero Slot Support: Ultra-fast transaction execution with Zero Slot integration
- Telegram Notifications: Real-time alerts for trades, errors, and status updates
- Jito Integration: MEV protection and transaction bundling support
- Slippage Protection: Configurable slippage tolerance for trades
- Liquidity Checks: Validates minimum liquidity before trading
- Error Handling: Comprehensive error handling and recovery
- Rate Limiting: Built-in rate limiting to prevent API abuse
- Transaction Retry Logic: Automatic retry with exponential backoff
- Real-time Logging: Detailed logging with configurable levels using tracing
- Portfolio Tracking: Track total PnL and trade statistics
- Performance Metrics: Monitor success rates and profitability
- Transaction Monitoring: Real-time transaction status and confirmation tracking
- Rust Performance: High-performance, memory-safe implementation
- Modular Architecture: Clean, maintainable code structure
- WebSocket Reconnection: Automatic reconnection with exponential backoff
- Transaction Optimization: Optimized for Solana's transaction model
- Async/Await: Full async support for concurrent operations
- Rust (latest stable version)
- Cargo (comes with Rust)
- Solana Wallet with SOL for trading
- Helius API Key (for WebSocket feeds)
- Telegram Bot (optional, for notifications)
- 
Clone the repository git clone https://github.com/radioman/Auto-solana-trading-bot.git cd Auto-solana-trading-bot
- 
Install Rust (if not already installed) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env 
- 
Set up environment variables Create a .envfile in the project root:touch .env 
- 
Configure your environment Edit .envfile with your settings:# Required SOL_PUBKEY=your_solana_public_key_here RPC_ENDPOINT=your_helius_rpc_endpoint RPC_WEBSOCKET_ENDPOINT=your_helius_websocket_endpoint TARGET_PUBKEY=target_wallet_to_monitor JUP_PUBKEY=jupiter_aggregator_pubkey # Optional NOZOMI_URL=your_nozomi_endpoint NOZOMI_TIP_VALUE=0.001 ZERO_SLOT_URL=your_zeroslot_endpoint ZERO_SLOT_TIP_VALUE=0.001 TELEGRAM_BOT_TOKEN=your_telegram_bot_token TELEGRAM_CHAT_ID=your_telegram_chat_id 
- 
Build and run # Development cargo run # Release build cargo build --release ./target/release/trading-bot 
| Variable | Description | Default | Required | 
|---|---|---|---|
| SOL_PUBKEY | Your Solana public key | - | β | 
| RPC_ENDPOINT | Helius RPC endpoint | - | β | 
| RPC_WEBSOCKET_ENDPOINT | Helius WebSocket endpoint | - | β | 
| TARGET_PUBKEY | Target wallet to monitor | - | β | 
| JUP_PUBKEY | Jupiter aggregator public key | - | β | 
| NOZOMI_URL | Nozomi MEV protection endpoint | - | β | 
| NOZOMI_TIP_VALUE | Nozomi tip amount in SOL | 0.001 | β | 
| ZERO_SLOT_URL | Zero Slot endpoint | - | β | 
| ZERO_SLOT_TIP_VALUE | Zero Slot tip amount in SOL | 0.001 | β | 
| TELEGRAM_BOT_TOKEN | Telegram bot token | - | β | 
| TELEGRAM_CHAT_ID | Telegram chat ID | - | β | 
You can modify trading parameters in src/common/constants.rs:
pub const BUY_AMOUNT_SOL: f64 = 0.01;           // SOL per trade
pub const MAX_CONCURRENT_TRADES: usize = 5;     // Max positions
pub const STOP_LOSS_PERCENTAGE: f64 = 20.0;     // Stop loss %
pub const TAKE_PROFIT_PERCENTAGE: f64 = 50.0;   // Take profit %The bot supports both PumpFun and Raydium DEX:
- PumpFun: For new token launches and meme coins
- Raydium: For established tokens with liquidity pools
- Automatic Detection: Bot automatically detects which DEX to use based on token characteristics
# Start the bot in development mode
cargo run
# Build and run in release mode
cargo build --release
./target/release/trading-botThe bot runs as a single executable that:
- Connects to Helius WebSocket for real-time transaction monitoring
- Monitors target wallet for trading opportunities
- Executes trades on PumpFun or Raydium based on detected patterns
- Sends notifications via Telegram (if configured)
# Run with specific configuration
cargo run -- --config custom_config.toml
# Run with debug logging
RUST_LOG=debug cargo run
# Run with specific log level
RUST_LOG=info cargo runThe bot provides real-time monitoring through:
- Console Logs: Detailed logging with timestamps using the tracingcrate
- Telegram Notifications: Real-time alerts for trades, errors, and status updates
- Transaction Tracking: Real-time transaction status and confirmation monitoring
- Performance Metrics: Built-in performance monitoring and statistics
- Helius WebSocket: Monitors real-time transaction feeds for trading opportunities
- PumpFun Integration: Automatically trades new token launches on PumpFun
- Raydium Integration: Executes trades on Raydium for established tokens
- Nozomi Protection: Uses Nozomi for MEV protection when available
- Zero Slot Speed: Leverages Zero Slot for ultra-fast transaction execution
- Telegram Alerts: Sends notifications for successful trades, errors, and important events
- strategy.rs: Contains trading strategies and swap logic
- sniper.rs: Implements sniper trading functionality
- swap.rs: Handles swap execution for both PumpFun and Raydium
- pumpfun.rs: PumpFun DEX integration and trading logic
- raydium.rs: Raydium DEX integration and AMM operations
- nozomi.rs: Nozomi MEV protection service
- zeroslot.rs: Zero Slot ultra-fast transaction service
- telegram.rs: Telegram notification service
- jito.rs: Jito MEV protection and bundling
- rpc_client.rs: RPC client utilities and connection management
// Raydium swap execution
pub async fn raydium_swap(
    state: AppState,
    amount_in: f64,
    swap_direction: &str,
    in_type: &str,
    slippage: u64,
    use_jito: bool,
    amm_pool_id: Pubkey,
    pool_state: AmmInfo,
) -> Result<Vec<String>>
// PumpFun swap execution
pub async fn pump_swap(
    state: AppState,
    amount_in: f64,
    // ... parameters
) -> Result<Vec<String>>// Nozomi tip account selection
pub fn get_tip_account() -> Result<Pubkey>
// Zero Slot transaction sending
pub async fn send_transaction(
    &self,
    transaction: &Transaction,
) -> Result<Signature, ClientError>src/
βββ common/             # Common utilities and configuration
β   βββ cache.rs       # Caching utilities
β   βββ constants.rs   # Configuration constants
β   βββ logger.rs      # Logging utilities
β   βββ mod.rs         # Module declarations
β   βββ utils.rs       # Helper functions
βββ core/               # Core trading logic
β   βββ mod.rs         # Module declarations
β   βββ token.rs       # Token handling
β   βββ tx.rs          # Transaction utilities
βββ dex/                # DEX integrations
β   βββ mod.rs         # Module declarations
β   βββ pumpfun.rs     # PumpFun DEX integration
β   βββ raydium.rs     # Raydium DEX integration
βββ engine/             # Trading engine
β   βββ mod.rs         # Module declarations
β   βββ sniper.rs      # Sniper trading logic
β   βββ strategy.rs    # Trading strategies
β   βββ swap.rs        # Swap execution logic
βββ services/           # External service integrations
β   βββ bloxroute.rs   # BloxRoute integration
β   βββ jito.rs        # Jito MEV protection
β   βββ mod.rs         # Module declarations
β   βββ nozomi.rs      # Nozomi MEV protection
β   βββ rpc_client.rs  # RPC client utilities
β   βββ telegram.rs    # Telegram notifications
β   βββ zeroslot.rs    # Zero Slot integration
βββ lib.rs              # Library entry point
βββ main.rs             # Main executable entry point
# Build in debug mode
cargo build
# Build in release mode
cargo build --release
# Clean build artifacts
cargo clean
# Check code without building
cargo check# Run all tests
cargo test
# Run tests with output
cargo test -- --nocapture
# Run specific test
cargo test test_name- Never commit private keys to version control
- Use environment variables for sensitive data
- Consider using a hardware wallet for large amounts
- Regularly rotate keys and monitor transactions
- Start with small amounts to test the bot
- Monitor performance regularly
- Set appropriate stop-losses to limit downside
- Understand the risks of automated trading
- Test on devnet before mainnet
- Monitor logs for errors and anomalies
- Keep the bot updated with latest changes
- Backup your configuration regularly
- Use a fast RPC endpoint for better performance
- Monitor memory usage for long-running instances
- Adjust trade frequency based on market conditions
- Use appropriate slippage settings for your strategy
- Set up alerts for critical errors
- Monitor PnL regularly
- Check transaction success rates
- Review trade logs for patterns
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests (if applicable)
- Submit a pull request
# Fork and clone
git clone https://github.com/radioman/Auto-solana-trading-bot.git
cd Auto-solana-trading-bot
# Install dependencies
npm install
# Create feature branch
git checkout -b feature/your-feature-name
# Make changes and test
npm run dev
# Submit PR
git push origin feature/your-feature-nameThis project is licensed under the MIT License - see the LICENSE file for details.
This software is for educational purposes only. Trading cryptocurrencies involves substantial risk of loss and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade cryptocurrencies, you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with cryptocurrency trading and seek advice from an independent financial advisor if you have any doubts.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
- Connection Issues: Check your RPC endpoint and internet connection
- Transaction Failures: Verify wallet balance and gas settings
- WebSocket Disconnections: Check network stability and reconnection settings
Made with β€οΈ for the Solana community
β Star this repo β’ π Report Bug β’ π‘ Request Feature
