A high-performance Rust-based copy trading bot for Solana blockchain that automatically replicates trades from target wallets across multiple DEX platforms including Pump.fun and Raydium.
- Real-time Monitoring: Monitors target wallets via WebSocket connections
- Automatic Execution: Instantly replicates buy/sell transactions
- Multi-DEX Support: Works with Pump.fun and Raydium DEX
- Slippage Protection: Configurable slippage tolerance
- Jito Integration: Uses Jito bundles for MEV protection and faster execution
- Priority Fees: Configurable compute unit pricing for transaction prioritization
- Async Architecture: Built with Tokio for high-performance async operations
- Private Key Management: Secure wallet key handling
- Transaction Simulation: Pre-flight transaction validation
- Error Handling: Comprehensive error handling and logging
- Bundle Confirmation: Waits for bundle confirmation with timeout
- Buy/Sell Operations: Support for both buy and sell transactions
- Token Management: Automatic ATA (Associated Token Account) creation
- Pool Detection: Automatic pool discovery via RPC and API
- Bonding Curve Support: Full Pump.fun bonding curve integration
src/
βββ common/ # Shared utilities and configurations
β βββ logger.rs # Logging system
β βββ utils.rs # Common utilities and AppState
βββ core/ # Core trading functionality
β βββ token.rs # Token operations and ATA management
β βββ tx.rs # Transaction building and execution
βββ dex/ # DEX-specific implementations
β βββ pump_fun.rs # Pump.fun integration
β βββ raydium.rs # Raydium AMM integration
βββ engine/ # Trading engine
β βββ swap.rs # Swap execution logic
βββ services/ # External services
βββ jito.rs # Jito bundle service
- Rust (latest stable version)
- Solana CLI tools
- RPC Endpoint (HTTPS and WSS)
- Private Key for trading wallet
-
Clone the repository
git clone https://github.com/mooncitydev/solana-copytrading-bot.git cd solana-copytrading-bot
-
Install dependencies
cargo build --release
-
Configure environment variables
# Required environment variables export RPC_HTTPS="https://your-rpc-endpoint.com" export RPC_WSS="wss://your-wss-endpoint.com" export PRIVATE_KEY="your_base58_private_key" # Optional configuration export UNIT_PRICE="1" # Compute unit price export UNIT_LIMIT="300000" # Compute unit limit export HTTP_PROXY="http://proxy:port" # HTTP proxy (optional) export LOG="debug" # Log level
-
Run the bot
cargo run --release
Variable | Required | Description | Default |
---|---|---|---|
RPC_HTTPS |
β | Solana RPC HTTPS endpoint | - |
RPC_WSS |
β | Solana WebSocket endpoint | - |
PRIVATE_KEY |
β | Base58 encoded private key | - |
UNIT_PRICE |
β | Compute unit price for priority fees | 1 |
UNIT_LIMIT |
β | Compute unit limit | 300000 |
HTTP_PROXY |
β | HTTP proxy URL | - |
LOG |
β | Log level (debug/info/error) | info |
The bot supports configurable swap parameters:
pub struct SwapConfig {
pub slippage: u64, // Slippage in basis points
pub swap_direction: SwapDirection, // Buy or Sell
pub use_jito: bool, // Enable Jito bundles
}
The bot automatically:
- Monitors target wallets via WebSocket
- Detects new transactions
- Analyzes transaction details
- Executes matching trades on your wallet
- Confirms transaction success
- Bonding curve trading
- Virtual SOL/token reserves
- Automatic pool completion detection
- PDA (Program Derived Address) management
- AMM pool trading
- Market order support
- Pool state management
- API integration for pool discovery
- Use Jito bundles for MEV protection
- Set appropriate priority fees
- Use fast RPC endpoints
- Enable WebSocket for real-time updates
- Set reasonable slippage tolerance
- Monitor gas costs
- Use test wallets for initial testing
- Implement position sizing
# Debug build
cargo build
# Release build (optimized)
cargo build --release
# Run tests
cargo test
# Check code
cargo check
- Create new module in
src/dex/
- Implement swap interface
- Add to DEX router
- Update configuration
The bot includes comprehensive logging:
let logger = Logger::new("[SWAP] => ".to_string());
logger.log("Transaction executed successfully".to_string());
logger.debug("Debug information".to_string());
logger.error("Error occurred".to_string());
IMPORTANT: This software is for educational purposes only. Trading cryptocurrencies involves substantial risk of loss. The authors are not responsible for any financial losses. Use at your own risk.
For support, questions, or collaboration:
π± Telegram: @moooncity
Feel free to reach out for:
- Technical support
- Feature requests
- Bug reports
- Collaboration opportunities
This project is licensed under the MIT License - see the LICENSE file for details.
- Solana Foundation for the excellent blockchain infrastructure
- Jito Labs for MEV protection solutions
- Raydium for AMM implementation
- Pump.fun for innovative bonding curve mechanics
Happy Trading! π
Remember: Always trade responsibly and never invest more than you can afford to lose.