Introduction
Maximal Extractable Value (MEV) is the profit made by arbitrarily including, excluding, or re-ordering transactions on the blockchain. This is a new phenomenon that has only been possible since the introduction of smart contracts and decentralized exchanges. It is a hot topic in the Ethereum community and is being actively researched.
Lots of the professionals are using Rust to build their bots. This is because Rust is faster than other languages and speed is pretty important when it comes to PvP situations.
Motivation
I stumbled on this tweet that made ~80ETH from sniping shares on a new platform called friend.tech. Someone in the comments made another ~100ETH. This may not be classified as MEV, but it is the same idea in many respects.
Because this was a new platform that was gaining a lot of attention, the motivated searchers were able to find new opportunities and act on them. In hindsight, it was a very simple opportunity that was ripe for the taking.
- Read more about the friend.tech snipers here.
My motivation comes from these kinds of stories– developers who built a bot that automates a task to make a bunch of money. It never lasts forever, but opportunities like this are everywhere. I want to learn how to build these bots and find these opportunities.
The Rundown
The space is competitive but there isn’t a bot that can act on every opportunity. There are also actors who target specific bots and try to exploit them (see Uncle Bandit Attacks.) This is a cat and mouse game that will continue to evolve. There is a lot of research and “alpha” to be found that increases the chances of success.
Much like security research, MEV “Searchers” have to think of ways to break and abuse systems. This is a specific mindset and requires creativity and patience. Once an opportunity is found, it’s up to the searcher to build a bot that can act on it. This is a whole other skill that involves simulations, on-chain data parsing, mempools, transaction construction, and out of the box thinking.
Unsorted Material
Introduction
- The 0 to 1 Guide for MEV
- What I learned from a month of intensive MEV bot study (by @SolidQuant)
- Transaction prediction through EVM tracing (by @SolidQuant)
- Simulate DEX trades
Templates
- Rust sandwich bot template
- MEV templates in Python, Javascript, and Rust (by @SolidQuant)
- Rust MEV template
- ethers-rs boilerplate
Diving Deeper
- Using assembly to reduce your gas costs (by @SolidQuant)
- Huff Guide - EVM Basics
- Sothis - Replay and track historical state
- Decoding calldata, bytecode, MEV bots, etc. (deep dive)
- Unearthing Alpha through Decompiled Contracts
- MEV on L2 paper
CTFs and Challenges
AMMs
Simulation Services
Static Analysis
- Slither - Static analyzer for Solidity
- Dedaub byecode decompiler
- ethervm.io decompiler
- Helpful for harder to read contracts
Web Tools
Encoding
Explorers
Bootcamps and Academies
Researchers
Communities
Thoughts While Practicing
- A tool to export all enums/structs from a Solidity file would be nice
- MEV feel more like a game than a profession. During my short journey, I think I’ve noticed what I really enjoy– it’s the puzzle and the reward.
- Whitehat security research looks quite appealing. There’s a lot of funds to protect and the space is still young. I think I’ll start looking into this more.