An automated arbitrage bot that monitors and executes profitable trading opportunities between Jupiter and Raydium on Solana.
This bot continuously monitors price differences between Jupiter and Raydium DEXs for configured trading pairs. When a profitable opportunity is detected (accounting for fees and slippage), it executes an atomic arbitrage transaction using flash loans from Mango Markets.
- Real-time price monitoring
- Flash loan integration with Mango Markets
- Atomic execution via smart contract
- Slippage protection
- Gas cost optimization
- Rate limiting
- Health monitoring endpoint
The system consists of two main components:
-
Smart Contract (Rust)
- Handles on-chain execution
- Manages flash loans
- Ensures atomic execution
- Interacts with DEX programs
-
Monitoring Bot (TypeScript)
- Monitors prices
- Detects opportunities
- Triggers smart contract
- Provides health metrics
- Node.js v16+
- Rust and Cargo
- Solana CLI
- Phantom Wallet with SOL and tokens for trading
- Clone the repository:
git clone https://github.com/yourusername/solana-arbitrage-bot.git
cd solana-arbitrage-bot
- Install dependencies:
npm install
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
- Build the smart contract:
cd programs/arbitrage
cargo build-bpf
- Deploy the smart contract:
solana program deploy target/deploy/arbitrage.so
- Set your Phantom wallet private key in
.env
- Configure trading pairs in
src/arbitrage-bot.ts
- Adjust profit thresholds and slippage tolerance
- Set rate limiting parameters
Start the bot:
npm start
Monitor health:
curl http://localhost:3000/health
- Never commit your
.env
file - Secure your private keys
- Start with small trade amounts
- Monitor for unexpected behavior
- Use rate limiting to prevent spam
Currently supported trading pairs:
- USDC/SOL
- (Add other pairs here)
MIT
This bot is provided as-is. Use at your own risk. Cryptocurrency trading carries significant risks.