forked from sandwichdevs/Sandwich-Bot-ETH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Read Me
65 lines (59 loc) · 2.69 KB
/
Read Me
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Overview
Sandwich MEV Bot script is designed to perform arbitrage between Uniswap and Sushiswap, two popular decentralized exchanges (DEXes) on the Ethereum network. The bot leverages the Flashbots framework to submit bundles of transactions directly to miners, avoiding the public mempool and minimizing the risk of front-running.
Prerequisites
Node.js: Ensure Node.js is installed on your machine.
Infura Account: Sign up for an Infura account and get an Infura Project ID.
Ethereum Wallet: A funded Ethereum wallet (private key) to execute transactions.
Setup
Clone the Repository:
bash
Copy code
git clone <repository-url>
cd flashbots-mev-bot
Install Dependencies:
bash
Copy code
npm install ethers @flashbots/ethers-provider-bundle @uniswap/v2-sdk @uniswap/sdk-core
Configure Environment Variables:
Create a .env file in the project root directory and add your configuration:
env
Copy code
INFURA_PROJECT_ID=your_infura_project_id
PRIVATE_KEY=your_private_key
Usage
1. Configuration
Router Addresses:
Uniswap V2 Router Address
Sushiswap Router Address
Token Addresses:
TOKEN0_ADDRESS: The address of the first token in the pair.
TOKEN1_ADDRESS: The address of the second token in the pair.
Amount:
AMOUNT_IN: The amount of TOKEN0 to swap.
2. Execute the Script
Run the script to perform the arbitrage:
bash
Copy code
node flashbots_arbitrage.js
Script Explanation
Imports and Setup
Import necessary modules from ethers, Flashbots, and Uniswap SDK.
Configure the Ethereum provider, Flashbots provider, and wallet.
Trade Functions
getTrade: Fetches pair data and constructs a trade route and trade instance for the given tokens and amount using Uniswap SDK.
Arbitrage Execution
Fetch token data for the specified token addresses.
Get trade details for Uniswap and Sushiswap swaps.
Construct transactions for both swaps.
Sign the transactions bundle using Flashbots.
Send the signed bundle to Flashbots for execution.
Key Points
Gas Price and Gas Limit: The script fetches the current gas price and sets a gas limit for the transactions.
Bundle Submission: The signed transactions bundle is submitted to Flashbots, targeting the next block for execution.
Risks and Considerations
Financial Risk: Running arbitrage bots on mainnet involves significant financial risk, including potential losses due to gas fees and market volatility.
Ethical Considerations: MEV extraction strategies can have ethical implications. Ensure you understand and consider these before deploying such strategies.
Disclaimer
This script is for educational purposes and may require modifications for production use. Thoroughly test and understand the risks involved before deploying the bot on the Ethereum mainnet.
License
This project is licensed under the MIT License.