Skip to content

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.

Notifications You must be signed in to change notification settings

sfyr111/MEV-Hunter

Repository files navigation

MEV Hunter 🚀

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.

Features

  • ✅ 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)

Project Structure

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)

Setup

  1. Install dependencies:
npm install
  1. 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
  1. Deploy the contract:
npx hardhat run scripts/deploy.js --network mainnet

Usage

  1. Run arbitrage monitoring:
node scripts/checkArbitrage.js
  1. Send transactions via Flashbots to prevent frontrunning:
node flashbots/sendFlashbotsTx.js
  1. Withdraw profits:
node scripts/withdrawProfits.js

references

example-video example-code

Advanced Features

  • Multi-hop arbitrage (A → B → C → A)
  • Gas optimization
  • Support for multiple DEXs

License

MIT

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published