An automated MEV arbitrage bot that leverages price differences on Uniswap V2 to execute profitable trades while using Flashbots to protect transactions from being frontrun. Supports both ETH and ERC20 token trades.
- ✅ Automatic arbitrage opportunity detection (monitoring Uniswap price changes)
- ✅ Arbitrage profit calculation (based on Uniswap price differences)
- ✅ Automatic arbitrage transaction execution (swapExactTokensForTokens)
- ✅ Transaction protection with Flashbots (preventing MEV bots from frontrunning)
- ✅ Automatic profit withdrawal (profits belong to the bot owner)
MEV-Hunter/
│── contracts/ # Solidity smart contracts
│ ├── MEVBot.sol # MEV bot contract
│ ├── UniswapV2RouterABI.json # Uniswap V2 router ABI
│ ├── UniswapV2FactoryABI.json # Uniswap V2 factory ABI
│── scripts/ # Deployment and testing scripts
│ ├── deploy.js # Deploy contract
│ ├── checkArbitrage.js # Monitor arbitrage opportunities
│ ├── executeTrade.js # Execute arbitrage transactions
│ ├── withdrawProfits.js # Withdraw arbitrage profits
│── flashbots/ # Flashbots transaction protection
│ ├── sendFlashbotsTx.js # Send transactions via Flashbots
│── test/ # Unit tests
│ ├── mevBot.test.js # MEV bot tests
│── config/ # Configuration files
│ ├── config.json # Configuration info (RPC, contract addresses)
│ ├── .env # Environment variables (private keys and sensitive info)
│── frontend/ # Web frontend (optional)
│ ├── src/
│ ├── index.html # Bot control panel
│── README.md # Project documentation
│── hardhat.config.js # Hardhat configuration
│── package.json # Node.js dependency management
│── .gitignore # Ignored files (.env, node_modules)
- Install dependencies:
npm install
- Configure environment variables in
.env
:
PRIVATE_KEY=your-private-key
RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_KEY
CONTRACT_ADDRESS=your-deployed-contract-address
- Deploy the contract:
npx hardhat run scripts/deploy.js --network mainnet
- Run arbitrage monitoring:
node scripts/checkArbitrage.js
- Send transactions via Flashbots to prevent frontrunning:
node flashbots/sendFlashbotsTx.js
- Withdraw profits:
node scripts/withdrawProfits.js
- Multi-hop arbitrage (A → B → C → A)
- Gas optimization
- Support for multiple DEXs
MIT