A professional automated cryptocurrency arbitrage bot that identifies and analyzes profitable arbitrage opportunities across multiple DEXes (Uniswap V2, Uniswap V3, SushiSwap, 1inch) on Ethereum mainnet.
โ ๏ธ Disclaimer: This is an educational project. Use at your own risk. Always test thoroughly on testnet before mainnet deployment.
- Multi-DEX Scanning: Monitors Uniswap V2, Uniswap V3, SushiSwap, and 1inch
- Real-time Price Monitoring: Continuously polls for price mismatches
- Flash Loan Integration: Potential profitability even with small capital
- Gas Cost Analysis: Calculates actual gas costs in both ETH and USD
- Persistent Database: Stores all opportunities for historical analysis
- REST API: Express backend for fetching opportunities and stats
- React Frontend: Beautiful UI for monitoring opportunities
- Configurable Thresholds: Adjust minimum profit, gas prices, and more
Backend:
- Node.js + Express
- ethers.js - Ethereum interaction
- Uniswap SDK
- SQLite - Local database
- dotenv - Environment configuration
Frontend:
- React 18
- Tailwind CSS
- Axios
- Node.js >= 14.x
- npm >= 6.x
- Infura API key (free at https://infura.io/)
- Git
-
Clone the repository
git clone https://github.com/francescoguarino/arbitrage-bot.git cd arbitrage-bot -
Set up environment variables
cp .env.example .env
Edit
.envand add your Infura API key:RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY_HERE -
Install root dependencies
npm install
-
Install backend dependencies
cd backend npm install cd ..
-
Install frontend dependencies
cd frontend npm install cd ..
Edit the .env file to configure:
| Variable | Default | Description |
|---|---|---|
RPC_URL |
- | Your Infura mainnet RPC URL |
POLLING_INTERVAL |
7000 | Milliseconds between price checks |
GAS_USED |
300000 | Estimated gas for swap transaction |
GAS_PRICE_GWEI |
30 | Current gas price in Gwei |
MIN_PROFIT_ETH |
0.001 | Minimum profitable profit in ETH |
FLASH_LOAN_FEE_PCT |
0.0009 | Flash loan fee percentage (0.09%) |
ETH_USD_PRICE |
3500 | Current ETH price in USD |
Terminal 1 - Start Backend:
cd backend
npm startTerminal 2 - Start Frontend:
cd frontend
npm startThe frontend will open at http://localhost:3000
The backend API runs at http://localhost:5000
# Build frontend
cd frontend
npm run build
# Backend deployment
cd backend
NODE_ENV=production npm startarbitrage-bot/
โโโ backend/
โ โโโ config.js # Configuration loader (uses .env)
โ โโโ server.js # Express server setup
โ โโโ db.js # SQLite database management
โ โโโ index.cjs # Main entry point
โ โโโ services/
โ โ โโโ arbitrageRunner.js # Core arbitrage detection
โ โ โโโ priceCollector.js # Price fetching
โ โ โโโ quoteOrchestrator.js # Quote aggregation
โ โ โโโ PriceService.js # Price calculations
โ โโโ dexFetchers/
โ โ โโโ UniswapV3Fetcher.js # Uniswap V3 integration
โ โ โโโ SushiswapFetcher.js # SushiSwap integration
โ โ โโโ oneInch.js # 1inch API integration
โ โโโ models/
โ โ โโโ Token.js # Token model
โ โ โโโ Pair.js # Trading pair model
โ โโโ utils/
โ โ โโโ ammMath.js # AMM calculations
โ โ โโโ gasAndFee.js # Gas and fee calculations
โ โ โโโ helpers.js # Utility functions
โ โโโ abis/
โ โโโ UniswapV2Factory.json
โ โโโ UniswapV2Pair.json
โโโ frontend/
โ โโโ src/
โ โ โโโ App.js # Main React component
โ โ โโโ index.js # React entry point
โ โ โโโ App.css # Styling
โ โโโ package.json
โโโ .env.example # Environment template
โโโ .gitignore # Git ignore rules
โโโ package.json # Root package configuration
โโโ README.md # This file
GET /api/opportunities- Latest opportunities foundGET /api/opportunities/history- Historical opportunitiesPOST /api/execute- Execute arbitrage (development only)
Opportunities are stored with:
- Token pair information (tokenA, tokenB, decimals)
- Best buy/sell DEX with prices
- Profit calculations (gross, net, gas costs)
- Timestamp and error logs
- Gas Costs: High gas prices can eliminate profitability
- MEV: Miners/validators can extract value from pending transactions
- Liquidity: Slippage may exceed expected profit
- Price Latency: Price feeds may lag real market prices
- Smart Contract Risk: Audit recommended before mainnet use
- Capital Requirements: Flash loans have fees (0.09% for Aave)
- Add Aave flash loan support
- Integrate real-time transaction simulation
- Add Balancer, Curve DEX support
- Web3 wallet integration for live execution
- Advanced filtering and strategy parameters
- Telegram/Discord notifications
- Performance monitoring dashboard
- Never commit
.envfile - Use only.env.example - Never hardcode API keys - Always use environment variables
- Test on Goerli testnet first - Before mainnet
- Use a separate wallet for bot transactions
- Start with small amounts to test
- Monitor gas prices carefully
โ Check .env file has valid Infura API key
โ Adjust MIN_PROFIT_ETH lower or increase POLLING_INTERVAL
โ Stop all bot instances and remove *.db file
โ Update GAS_PRICE_GWEI in .env or run during low-gas periods
Pull requests are welcome! For major changes, please open an issue first.
MIT License - see LICENSE file for details
This software is provided "as is" without warranty of any kind. Use at your own risk. The author is not responsible for any financial losses or damages resulting from the use of this software. Always do your own research and test thoroughly.
Created by Franceso Guarino
For issues, questions, or suggestions:
- Open an issue on GitHub
- Check existing documentation
- Review code comments
Made with โค๏ธ for the DeFi community