Dex Arbitrage - MEV Bot
Open sourcing a profitable MEV Arbitrage Bot written in blazing fast Rust.
Before Starting
I am a self-taught programmer, a couple of months ago I decided to pick up the challenge of creating a profitable Arbitrage MEV bot. I started coding at the start of June with absolutely 0 prior experience and knowledge in MEV. That being said, this bot is not optimized to it's full potential, I am aware of that, this repo should be used for reference material.
It's also important to note that this bot wouldn't be profitable on a competitive EVM chain like Ethereum, BSC or Solana. This code is profitable on lesser known EVM compatible chains where there is less competition :)
Although you usually wouldn't share a profitable bot, I wanted to share my work and progress so other aspiring searchers could get motivated and use this repo as reference material.
I started this repo with the following goals:
- Creating a simple functioning Arbitrage Bot
- To further expand my coding knowledge in Rust & understand MEV strategies better
I can confidently say I succeeded in my goals. That being said, the life of a searcher is a lonely road. I want to make my work public as it is so hard to get into the world of MEV, there is very limited information on the topic and it's hard to know where to start. Not only do I want people to learn from this repo, but I also want to inspire others to get into the world of MEV and better understand it.
I hope my journey inspires you, happy searching!
Features
I simplified and cleaned up the code as much as I could. The bot currently sends 1 ETH when a profitable arbitrage path is found, but there is an optimal input amount function.
- Query Uniswap pairs
- Find matching pairs across different exchanges
- Update pair reserves
- Find arbitrage opportunities
Examples
Besides the crossed_pairs
and query_test
functions that are used to test the code. In the "examples" folder I included multiple useful functions for testing, including:
- View pending transactions in the mempool
- View pending Uniswap V2 transactions in the mempool
- Subscribe blocks
Any of these functions can be run using: cargo run --example <name of file>
.
Improvements
As mentioned before, I'm aware this bot isn't optimized by any means, some features that could be implemented:
- A better optimal profit function
- Estimate an array of profitable tokens instead of 1 by 1
- Make the execute function more gas efficient
Notice
If any bugs or optimizations are found, feel free to create a pull request. All pull requests are welcome!
Warning
This software is highly experimental and should be used at your own risk. Although tested, this bot is experimental software and is provided on an "as is" and "as available" basis under the MIT license. We cannot guarantee the stability or reliability of this codebase and are not responsible for any damage or loss caused by its use. We do not give out warranties.