NOTE: This project is currently under development and not all functionality is available. Do not use this in production yet. Please check back soon!
This project is a Solana-based trading bot and API system, designed to monitor specific wallets on the Solana blockchain and execute trades based on user-defined settings.
The project is organized as a Rust workspace with four main components:
-
trading-common
: Core functionality and shared components- Shared models and types
- Database interactions (Supabase)
- Event system for real-time updates
- gRPC protocol definitions
- DEX integration utilities (pump.fun, Raydium)
- Transaction processing and validation
-
trading-api
: REST API server- CRUD operations for tracked wallets and settings
- Trade execution endpoints
- Multi-DEX integration endpoints
- Redis-based event broadcasting
-
trading-bot
: Core trading engine- WebSocket-based wallet monitoring
- Automated copy trading execution
- Real-time balance tracking
- WebSocket server for real-time updates to the front-end
- Event-driven architecture
- Redis subscription for settings updates
-
trading-wallet
: Wallet management service- gRPC-based wallet operations
- Centralized wallet state management
- Token balance tracking
- Transaction execution
- Real-time balance updates
-
trading-price-feed
: Price feed service- WebSocket-based price feed
- Token price updates
- Real-time wallet monitoring via WebSocket
- Customizable trading parameters:
- Maximum open positions
- Per-position trade amount
- Slippage tolerance
- Allowed tokens whitelist
- Additional buy settings
- Minimum balance requirements
- pump.fun integration
- Raydium integration
- Remaining DEXs to be added soon
- Unified trading interface
- DEX-specific optimizations
- Event-driven architecture
- Real-time updates via WebSocket
- gRPC-based wallet management
- Redis-based settings propagation
- Automatic token balance tracking
- Graceful shutdown handling
- Comprehensive error handling and retry logic
- Rust (latest stable version)
- Cargo
- Solana CLI tools
- Redis server
- Supabase account and project
- Dedicated server wallet (fresh Solana wallet)
- Helius RPC node (or equivalent Solana RPC provider)
- Protocol Buffers compiler (protoc)
- docker and docker-compose
- protobuf
The project uses gRPC for communication between services and the wallet manager. The protocol definitions are located in:
trading-common/proto/wallet.proto
When you build the project:
-
The build script (
trading-common/build.rs
) automatically compiles the proto definitions -
Generated code is placed in
trading-common/src/generated/wallet.rs
-
This generated code is then available to all services through
trading-common
If you modify the wallet.proto
file, the code will automatically regenerate during the next build. You can also force regeneration with:
cargo clean -p trading-common
cargo build
- Clone the repository:
git clone https://github.com/yourusername/solana-trading-project.git
cd solana-trading-project
- Set up environment variables:
cp .env.example .env
- Build the project:
cargo build --workspace
- Start the redis server:
docker-compose up -d redis
Verify that the redis server is running:
docker-compose ps
- Start the wallet service:
cargo run --bin trading-wallet
- Then start the API server:
cargo run --bin trading-api
- Finally start the trading bot:
cargo run --bin trading-bot
The trading API provides the following endpoints:
GET /wallet/info
: Get wallet info
GET /tracked_wallets
: Get all tracked walletsPOST /tracked_wallets
: Add a new tracked walletPUT /tracked_wallets/archive/:wallet_address
: Archive a tracked walletPUT /tracked_wallets/unarchive/:wallet_address
: Unarchive a tracked walletDELETE /tracked_wallets/:wallet_address
: Delete a tracked walletPUT /tracked_wallets/update
: Update a tracked wallet
GET /copy_trade_settings
: Get all copy trade settingsPOST /copy_trade_settings
: Create new copy trade settingsPUT /copy_trade_settings
: Update copy trade settingsDELETE /copy_trade_settings/:tracked_wallet_id
: Delete copy trade settings for a specific tracked wallet
POST /pump_fun/buy
: Execute buy on pump.funPOST /pump_fun/sell
: Execute sell on pump.funPOST /raydium/buy
: Execute buy on RaydiumPOST /raydium/sell
: Execute sell on Raydium
GET /transaction_history
: Get transaction history
All endpoints require the database to be set up. Please see the tables.sql
file for the schema and you can use the rest-client.http file to test the endpoints.
All configuration is done through environment variables. Please see the .env.example
file for more information.
Contributions are welcome! Please feel free to submit a Pull Request.