A sophisticated arbitrage bot designed to identify and execute profitable trading opportunities between SOL-USDC pools on Meteora's Dynamic Liquidity Market Maker (DLMM) protocol.
This bot utilizes advanced algorithms to monitor multiple SOL-USDC pools on Meteora, analyzing their bin steps, liquidity distribution, and price differences to find arbitrage opportunities. It incorporates network condition monitoring and transaction simulation to ensure profitable and successful execution.
- Real-time pool analysis and monitoring
- Network-aware priority fee optimization
- Transaction simulation and validation
- Advanced LP optimization for route finding
- Risk management and profitability validation
- Configurable parameters and thresholds
src/arbitrage/
├── index.js # Main orchestrator
├── optimizer.js # LP optimization implementation
├── poolAnalyzer.js # Pool analysis and metrics
├── simulator.js # Transaction simulation
├── networkMonitor.js # Network conditions monitoring
└── utils/
├── constants.js # Configuration constants
└── types.js # TypeScript-like type definitions
-
index.js (ArbitrageManager)
- Main entry point for arbitrage operations
- Orchestrates pool analysis, optimization, and execution
- Manages continuous monitoring and opportunity detection
-
poolAnalyzer.js
- Analyzes SOL-USDC pools on Meteora
- Calculates pool metrics (TVL, liquidity, fees)
- Monitors active bins and liquidity distribution
-
optimizer.js
- Implements Linear Programming optimization
- Finds optimal arbitrage routes
- Calculates expected profits and optimal trade sizes
-
simulator.js
- Simulates arbitrage transactions
- Validates routes and estimates gas costs
- Verifies expected outputs
-
networkMonitor.js
- Monitors Solana network conditions
- Optimizes priority fees
- Tracks network congestion and performance
- Clone the repository:
git clone <repository-url>
cd sol-rebalancer- Install dependencies:
npm install- Set up environment variables in .env:
# Required Environment Variables
SOLANA_RPC_URL= # Your Solana RPC URL
MONGODB_URI= # MongoDB connection URI
PRIVATE_KEY= # Base58 encoded private key or path to keypair.json
TELEGRAM_BOT_TOKEN= # Telegram bot token for notifications
TELEGRAM_CHAT_ID= # Telegram chat ID for notifications
# Optional Configuration
MIN_PROFIT_THRESHOLD=10 # Minimum profit threshold in USD
MAX_SLIPPAGE=0.005 # Maximum allowed slippage (0.5%)
CHECK_INTERVAL=1000 # Monitoring interval in milliseconds- Start the arbitrage bot:
npm start- Monitor logs in console or configured notification channels.
Key parameters can be adjusted in src/arbitrage/utils/constants.js:
export const ARBITRAGE_CONSTANTS = {
MIN_PROFIT_THRESHOLD: 10, // Minimum profit in USD
MAX_SLIPPAGE: 0.005, // Maximum slippage tolerance
MIN_POOL_TVL: 10000, // Minimum pool TVL in USD
PROFIT_SAFETY_MARGIN: 0.8, // 20% safety margin on profits
// ... other constants
};The bot provides several monitoring options:
-
Console logs for:
- Found opportunities
- Network conditions
- Transaction status
- Error reports
-
Telegram notifications for:
- Profitable opportunities
- Successful executions
- Error alerts
- Daily performance reports
-
Pool Discovery and Analysis
- Continuously monitors SOL-USDC pools
- Analyzes liquidity distribution in bins
- Calculates effective prices and spreads
-
Opportunity Detection
- Compares prices across pools
- Considers fees and price impact
- Validates profitability thresholds
-
Route Optimization
- Uses LP optimization for route finding
- Calculates optimal trade sizes
- Considers network conditions
-
Execution and Validation
- Simulates transactions before execution
- Optimizes priority fees
- Validates expected outputs
-
Transaction Simulation
- All routes are simulated before execution
- Validates expected outputs
- Estimates gas costs
-
Network Monitoring
- Tracks network congestion
- Optimizes priority fees
- Avoids high congestion periods
-
Risk Management
- Implements safety margins on profits
- Validates liquidity availability
- Monitors slippage thresholds
- Running tests:
npm test- Running linter:
npm run lint- Building for production:
npm run build- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License - see LICENSE file for details