This repository contains a simple, mechanical system for blindly submitting atomic arbitrage opportunities to the Flashbots MEV-Share Node. For more details on MEV-Share please see this beta launch announcement and the docs. For high level design details see the design document on the Flashbots Forum.
Although user trade details are hidden by default to prevent frontrunning, this script can atomically backrun Uniswap v2 transactions from the Node by calculating the optimal arbitrage between two Uniswap v2 pools entirely on-chain. Off-chain logic is relatively simple and no trade details are needed beyond the pool that the user is trading on to discover and attempt to execute atomic arbitrage opportunities.
Contained in this repository are two things. First, a smart contract that attempts to execute an atomic arbitrage between two Uniswap v2 pools. Second, a script that listens to the Flashbots MEV-Share Node and submits attempted arbitrages.
This script is intended to be used as an example of blind atomic MEV and how to integrate with the Flashbots MEV-Share Node. Please do your own research and understand the code before using it or putting your money in it. We hope that you will use this code to build your own MEV strategies and share them with the community.
Clone the repository:
git clone https://github.com/yourusername/simple-blind-arbitrage.git
Change to the project directory:
cd simple-blind-arbitrage/execute
Install the required dependencies:
npm install
Note that this repo also uses Foundry.
rpcUrl=<YOUR_RPC_URL>
privateKey=<YOUR_PRIVATE_KEY>
executorContractAddress=<CONTRACT_ADDRESS>
Replace
By default this bot bids 50% of its profits to block.coinbase
but this can be configured by changing percentageToKeep
in the config file. After a short time after open sourcing it is likely that you will need to increase percentageToKeep
for your bundles to be competitive.
To start listening to the Flashbots MEV-Share Node and submitting blind arbitrage transactions, run the following command:
node index.js -n <network>
Replace
A test in Foundry for the smart contract is provided. Please test using a fork of Goerli, from the root folder please run forge test -f <GOERLI_RPC_URL>
and run with -vv
to display console.log()
s with relevant information during execution.
If you would like to test the monitoring and execution script, please configure for Goerli and run node index.js -n goerli
.
Before using this tool, make sure you have the following software installed on your system:
The tool requires a private key for signing transactions. Make sure you don't share your private key or .env file with anyone or commit it to a public repository.
Contributions are welcome! If you'd like to contribute to this project, feel free to open a pull request. simple-blind-arbitrage
is a starting point that can be extended to encompass other MEV strategies. Here are a few improvements we would like to see:
This project is licensed under the MIT License - see the LICENSE file for details.