Solana Arbitrage Trading System
A backend system for detecting and executing arbitrage opportunities on Solana DEXes.
Overview
This FastAPI application provides a robust backend for:
- Monitoring price differences between different Solana DEXes (currently Jupiter and Raydium)
- Identifying profitable arbitrage opportunities based on configurable parameters
- Optionally executing trades to capture these opportunities
- Tracking performance metrics and historical trade data
Features
- Real-time price monitoring across multiple DEXes
- Configurable profit thresholds and slippage tolerance
- Wallet integration for trade execution
- Historical opportunity and trade tracking
- Comprehensive API for monitoring and configuration
- SQLite database for persistent storage
API Endpoints
Base Endpoints
GET /
- Root endpoint with API informationGET /health
- Health check endpointGET /docs
- Swagger UI documentationGET /redoc
- ReDoc documentation
V1 API Endpoints
GET /api/v1/status
- System status and statisticsGET /api/v1/opportunities
- List arbitrage opportunities with filtering optionsGET /api/v1/trades
- List historical trades with filtering options
Environment Variables
Variable | Description | Default |
---|---|---|
SOLANA_RPC_URL |
Solana RPC endpoint URL | https://api.mainnet-beta.solana.com |
SOLANA_NETWORK |
Solana network to use (mainnet-beta, testnet, devnet) | mainnet-beta |
WALLET_KEYPAIR_PATH |
Path to wallet keypair JSON file | None |
PROFIT_THRESHOLD_PERCENT |
Minimum profit percentage to consider | 1.0 |
MAX_SLIPPAGE_PERCENT |
Maximum allowed slippage percentage | 0.5 |
EXECUTION_ENABLED |
Whether to execute trades or just monitor | False |
SCAN_INTERVAL_SECONDS |
How often to scan for opportunities (seconds) | 10 |
MONITORED_TOKENS |
Comma-separated list of token addresses to monitor | [] |
ENABLED_DEXES |
Comma-separated list of DEXes to monitor | jupiter,raydium |
Installation
Prerequisites
- Python 3.9+
- SQLite
Setup
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Configure environment variables (see above)
- Run the application:
uvicorn main:app --host 0.0.0.0 --port 8000
Development
Database Migrations
Database migrations are handled with Alembic:
# Create a new migration
alembic revision -m "description"
# Run migrations
alembic upgrade head
Running Tests
pytest
License
MIT
Description
Languages
Python
99.2%
Mako
0.8%