A sophisticated arbitrage bot that monitors price differences of Liquid Staking Derivative (LSD) tokens across multiple blockchain networks and automatically executes profitable arbitrage trades. The bot can leverage flash loans for capital efficiency when appropriate and uses Socket Protocol and Across Protocol for cross-chain transfers.
- Multi-Chain Support: Monitors Ethereum, Arbitrum, Optimism, Polygon, and Base
- LSD Token Support: Tracks stETH, rETH, cbETH, frxETH
- Flash Loan Integration: Uses AAVE flash loans for capital-efficient arbitrage
- Bridge Selection: Dynamically routes between Socket Protocol and Across Protocol
- Gas Optimization: Smart gas price strategies for each chain
- MEV Protection: Optional private mempool usage
- Inventory Management: Cross-chain balance optimization
- Paper Trading: Simulation mode for testing without risking real funds
- PnL Tracking: Records and analyzes profits and losses over time
The bot consists of several key components:
- Main Bot Logic: Orchestrates the monitoring and execution workflow
- Arbitrage Finder: Scans for price differences and calculates profitability
- Arbitrage Executor: Executes the trades using optimal strategies
- Exchange Connectors: Interfaces with DEXs on different chains
- Bridge Utilities: Handles cross-chain transfers
- Web3 Utilities: Manages blockchain connections and transactions
- Simulation Mode: Tests strategies without risking real funds
- Node.js v16+
- Yarn
- Private keys for executing transactions
- RPC URLs for all supported networks
- Socket Protocol API key
- Across Protocol API key (if using Across)
-
Clone the repository:
git clone https://github.com/yourusername/lsd-arbitrage-bot.git cd lsd-arbitrage-bot -
Install dependencies:
yarn install
-
Create a
.envfile with your configuration (see.env.example):cp .env.example .env
-
Edit the
.envfile with your private keys, RPC URLs, and API keys.
The bot has a flexible configuration system in the config directory. The main configuration file is config/default.js, and you can override settings in config/custom.js.
Key configuration options:
- Networks: RPC URLs, gas settings, and confirmation times
- Tokens: Addresses on each network
- Exchanges: DEX configurations for Uniswap, Curve, and Balancer
- Bridges: Socket and Across configurations
- Flash Loans: AAVE V3 pool addresses and parameters
- Bot Settings: Minimum profit thresholds, max slippage, etc.
Run the bot in simulation mode (no real trades):
yarn start --simulateRun with real trading:
yarn start--simulateor-s: Run in simulation mode without executing trades--monitor-onlyor-m: Monitor opportunities without executing trades--onceor-o: Run once and exit (useful for cron jobs)--token <symbol>or-t <symbol>: Only monitor specific token (e.g., stETH)--chains <chains>or-c <chains>: Comma-separated list of chains to monitor (e.g., ethereum,arbitrum)--no-flashloanor-n: Disable flash loan opportunities--profit <amount>or-p <amount>: Minimum profit threshold in USD
Monitor only stETH on Ethereum and Arbitrum:
yarn start --token stETH --chains ethereum,arbitrum --simulateRun once to check for opportunities:
yarn start --onceSet a higher profit threshold:
yarn start --profit 100 --simulateFlash loans are implemented using AAVE V3 pools. The bot:
- Identifies profitable arbitrage opportunities on the same chain
- Calculates optimal loan amounts
- Executes loans, arbitrage, and repayment in a single transaction
To use flash loans, ensure the FLASH_LOAN_ENABLED setting is set to true in your .env file.
The bot dynamically selects between Socket Protocol and Across Protocol based on:
- Fee comparison
- Estimated transfer time
- Return on investment calculation
You can set PREFERRED_BRIDGE in your .env file to prefer a specific bridge or set it to auto for dynamic selection.
Logs are stored in the logs directory:
logs/arbitrage.log: Main application logslogs/profits.json: Profit/loss records for each trade
- Private keys are stored locally and used to sign transactions
- The bot validates token addresses before interacting with them
- Emergency shutdown can be triggered if suspicious activity is detected
- Optional MEV protection via private mempool
Contributions are welcome! Please fork the repository and submit a pull request with your improvements.
MIT
Trading cryptocurrencies involves significant risk. This software is provided for educational and informational purposes only. Use at your own risk. The authors assume no responsibility for financial losses incurred using this software.