I decided to build my own MEV bot. Here's how I'm going to do it.
If you can't avoid it, might as well just enjoy it.
Created on June 10, 2023.
Table of Contents
Starting point
I only recently found out about the realm of MEVs despite having traded in the crypto space for some time already. My work mainly revolved around trading in spots and futures markets in CeFi, so I never really bothered to look into DeFi that much.
But one of my clients wanted to build an automated trading bot using Uniswap V3. And I thought: ‘Oh, what the heck. How hard can it be?’, and just took on the project.
Oh boy, was I in for a bumpy ride 🧗🏼.
Though I briefly knew what an AMM was, I never really grasped the math behind it. So I scanned through documentations and public resources I could find on Google. It took me like a week to really get a picture of what DEXs were trying to do. And it took another couple of days to build a JS bot that monitored Uniswap V3 pool prices and sent swapping transactions upon predefined events.
After the project was over, I was intrigued by DeFi and wanted to further pursue this path, but then was met with this giant called MEV.
Instead of just giving up, I decided to tackle the problem head on and face the giant. I would learn everything about MEV bots and just create one for myself. Then I’ll be able to overcome the fear, and maybe even successfully find my own alpha.
But the most important reason for this venture is to understand the cutting edge technologies behind blockchain ecosystems. I hated how I feared leaving my safety zone and considering blockchains and DeFi’s as black boxes. I knew if I put the time in, I would be able to understand the concepts with confidence.
So I am documenting the whole process here to give other starting fellows an idea of how much input you are going to need to put into building MEV bots.
Below, I am sharing the complete road map to learning MEV bot building. Since I am just a beginner in this space, I decided to build a bot from the ground up and gauge the time it would take someone to build such a program with no prior knowledge of this domain whatsoever. But I wanted to do it the right and the robust way.
A little background sharing of myself: I used to build high frequency trading strategies in CeFi for the past 2 years, and I used to be an AI engineer before that for another couple of years. So I’m not entirely new to programming per se. I used Python, Javascript, and C# extensively in multiple projects, but always had the temptation to adopt Rust within my newer ones. So I’ve decided to study Rust this time.
My Roadmap
I embarked on this journey just 3 days ago (June 7th, 2023). (So yes, my resolution might not stick too long) The first 3 days involved planning ahead by understanding what I am trying to accomplish here.
The MEV space was quite secretive so I couldn’t find a good reference for a starting point. But digging around kind of paid off and I noticed that there were pretty huge communities either trying to fix the MEV issue, or profit from it. They were both extremely helpful to begin the journey.
A couple of reference points:
I also noticed that there were many scams out there related to MEVs. So I had to filter out my sources with extra care.
I intend to study all of the following:
1. Rust
2. Solidity/Yul
3. Uniswap
4. Flashloans
5. Gas optimization
6. Flashbots
I’ve also seen on Twitter that studying Geth is probably the best way to get started with MEV. Though for me, that’s a pretty big hurdle. So I’ll see what I can achieve with the minimum amount of knowledge necessary and build up from there if I feel like more is needed.
Go read Twitter thread by 0xEzon 👉
Want to make $2M doing MEV?
— Ezon 🖕 (@0xEzon) June 9, 2023
read bc 99% of you won't make it ⬇️🧵
With this knowledge, I plan on building the 3 types of MEV bots that people are most familiar with:
1. Bot #1: Frontrunning bot
2. Bot #2: Sandwiching bot
3. Bot #3: Uniswap JIT provisioning bot
and share the results to this community.
I’ll try and see how difficult the task is for a layman to get started with, also documenting the sources that I’ve referred to as I move on forward. And by doing this, I feel like I can make my resolution stick this time, and help others trying to get involved with MEVs by giving them an idea of how difficult the task is, and how long it will take for them to get started.
Anyone else with me on this journey? Good luck everyone!
Previous