An automated trading bot that monitors Solana (SOL) prices and executes real swaps based on price movements using Jupiter's API.
- 🔄 Real Swap Execution: Uses Jupiter API for actual token swaps
- 📊 Price Monitoring: Checks SOL/USDC price every 10 seconds
- 🧠 Smart Trading Logic:
- Swaps SOL → USDC when price increases 3-5%
- Swaps USDC → SOL when price decreases 3-5%
- ⚡ Risk Management:
- Maximum 3 swaps per 24-hour period
- Configurable slippage protection
- Transaction confirmation monitoring
- 🔐 Secure Wallet Integration: Direct private key signing
- 📈 Balance Tracking: Real-time USD balance tracking
- Initial State: Start with $10 worth of SOL
- Price Increase (3-5%): Swap SOL → USDC to lock in profits
- Price Decrease (3-5%): Swap USDC → SOL to buy the dip
- Daily Limits: Maximum 3 swaps per day to prevent overtrading
- Continuous Monitoring: 10-second price check intervals
# Install Go (version 1.21+)
go mod tidyEdit config.json:
{
"wallet_address": "YOUR_SOLANA_WALLET_ADDRESS",
"private_key": "YOUR_PRIVATE_KEY_BASE58",
"rpc_url": "https://api.mainnet-beta.solana.com",
"initial_balance_usd": 10.0,
"price_check_interval_seconds": 10,
"swap_threshold_min_percent": 3.0,
"swap_threshold_max_percent": 5.0,
"max_swaps_per_day": 3,
"slippage_bps": 50,
"simulate_mode": true,
"priority_fee_microlamports": 10000
}From Solana CLI:
solana-keygen show --keypair ~/.config/solana/id.jsonFrom Phantom/Solflare: Export private key (base58 format)
Keep "simulate_mode": true for testing, then set to false for real trading.
go build && ./solana-trading-bot| Option | Description | Default |
|---|---|---|
wallet_address |
Your Solana wallet public key | Required |
private_key |
Your wallet private key (base58) | Required |
rpc_url |
Solana RPC endpoint | mainnet-beta |
initial_balance_usd |
Starting USD balance | 10.0 |
price_check_interval_seconds |
Price check frequency | 10 |
swap_threshold_min_percent |
Minimum price change | 3.0% |
swap_threshold_max_percent |
Maximum price change | 5.0% |
max_swaps_per_day |
Daily swap limit | 3 |
slippage_bps |
Slippage tolerance (basis points) | 50 (0.5%) |
simulate_mode |
Enable simulation mode | true |
priority_fee_microlamports |
Transaction priority fee | 10000 |
- Jupiter API Integration: Quote + Swap APIs
- Solana Transaction Signing: Direct wallet integration
- Transaction Confirmation: Monitors tx status until confirmed
- Error Handling: Comprehensive error recovery
- Balance Tracking: Real-time asset tracking
- Priority Fees: Configurable transaction fees
- Simulation Mode: Test without real funds
- Daily Limits: Prevents overtrading
- Block Height Validation: Prevents stale transactions
- Slippage Protection: Configurable slippage limits
- Transaction Timeouts: Prevents stuck transactions
Starting Solana Trading Bot
Initial balance: $10.00 in SOL
Wallet address: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRueJD
Price check interval: 10s
Swap thresholds: 3.0% - 5.0%
Max swaps per day: 3
Simulate mode: true
Current SOL price: $195.37 | Holding: SOL ($10.00) | Last swap: $0.00
Swap decision: Initial price set
Current SOL price: $201.24 | Holding: SOL ($10.00) | Last swap: $195.37
Swap decision: SOL price increased by 3.01% (195.37 -> 201.24), swapping to USDC
EXECUTING REAL SWAP: SOL -> USDC
Transaction sent: 4xK2...abc123
Transaction confirmed with status: confirmed
New balance: $10.30 in USDC
Swaps today: 1/3
- Real Money: This bot trades real cryptocurrency
- Market Risk: Crypto prices are highly volatile
- Smart Contract Risk: Jupiter protocol risks
- Bug Risk: Software may have bugs
- Loss Risk: You may lose all invested funds
Start small and test thoroughly!
"rpc_url": "https://solana-mainnet.g.alchemy.com/v2/YOUR-API-KEY""rpc_url": "https://api.devnet.solana.com""priority_fee_microlamports": 50000 // Higher fees = faster executionThe bot logs:
- Price movements and decisions
- Swap executions and confirmations
- Balance changes and profits
- Error conditions and recoveries
- Fork the repository
- Create your feature branch
- Test thoroughly with simulation mode
- Submit a pull request
MIT License - Use at your own risk!