This repository contains a simple, mechanical system for discovering, evaluating, rating, and submitting arbitrage opportunities to the Flashbots bundle endpoint. This script is very unlikely to be profitable, as many users have access to it, and it is targeting well-known Ethereum opportunities.
We hope you will use this repository as an example of how to integrate Flashbots into your own Flashbot searcher (bot). For more information, see the Flashbots Searcher FAQ
Currently Optimizes finding the optimal arbitrage input amount over the iterative approach used by flashbots.
Will add support for token caching
Create a .env
file in root directory and populate with following variables
- ETHEREUM_RPC_URL - Ethereum RPC Websocket endpoint. e.g
wss://mainnet.infura.io/ws/v3/_INFURA_API_KEY
Can not be the same as FLASHBOTS_RPC_URL - PRIVATE_KEY - Private key for the Ethereum EOA that will be submitting Flashbots Ethereum transactions
- FLASHBOTS_RELAY_SIGNING_KEY [Optional, default: random] - Flashbots submissions require an Ethereum private key to sign transaction payloads. This newly-created account does not need to hold any funds or correlate to any on-chain activity, it just needs to be used across multiple Flashbots RPC requests to identify requests related to same searcher. Please see https://docs.flashbots.net/flashbots-auction/searchers/faq#do-i-need-authentication-to-access-the-flashbots-relay
- MINER_REWARD_PERCENTAGE [Optional, default 80] - 0 -> 100, what percentage of overall profitability to send to miner.
- Generate a new bot wallet address and extract the private key into a raw 32-byte format.
- Deploy the included BundleExecutor.sol to Ethereum, from a secured account, with the address of the newly created wallet as the constructor argument
- Transfer WETH to the newly deployed BundleExecutor
It is important to keep both the bot wallet private key and bundleExecutor owner private key secure. The bot wallet attempts to not lose WETH inside an arbitrage, but a malicious user would be able to drain the contract.
Set environment variablies with export $(cat .env | xargs)
Run with python app.py
Install ganache-cli for enabling mainnet fork tests
Run tests with pytest