Exploring the Dark Forest


Suppose you're swapping your Ethereum (ETH) for the hottest new Dog coin, suppose Shiba Inu (SHIB), on Uniswap. Who doesn't like dogs? For simplicity let's say 1 ETH is 100 SHIB and you want to get in on the action right now. When you click "swap" with 10% slippage, your transaction hits mempool where your transaction is pending, waiting to be picked up by miners and mined into a block.

A few things can happen to your innocent transaction (TX) from here:

  1. You see ~100 SHIB in your wallet

  2. You get sandwich attacked and get 90 SHIB

  3. Your TX is so big relative to the pool that it moves the price of SHIB up on Uniswap, creating arb opportunities to back-run you (not hurting you, but helping feed the bots some food)

That's just a glimpse of what MEV can be competed away; here's how else bots are taking advantage of inefficiencies (or flaws) in eth:

Arbitrage bots

Classic arb bots. You see ETH cheaper on Uniswap v2 than Binance so you short on Binance, long on Uniswap and wait for price to match to close your position for a small profit. Or maybe you see ETH more expensive on Sushiswap than Uniswap v2 and you buy on sushi, sell on uni in 1 tx for another small profit.

Arb bots are great because they provide liquidity, don't hurt anyone, and you make some money in the end.


Suppose you're running and arb bot between Sushi and Uni and find an opportunity that'll net you $100 considering the low gas fees. Next thing you know you a frontrunning bot snipes that opportunity (because everyone sees your pending tx in the mempool) and bids a higher gas fee which give their TX higher priority in the block (and wins that opportunity) which kicks off a Priority Gas Auction (PGA) where you and the frontrunner are bidding higher and higher gas fees to complete their TX until either bot gives up or starts losing money. Remembering you still have to pay for losing/reverted TX's, at some point it becomes infeasible for you and the frontrunner to bid who gets the prize/MEV (suppose loser pays $10 in tx fees while winner pays $15 in tx fees but gets $20 arb opportunity)


Instead of whale hunting, you're whale stalking; seeing where whales go. Suppose Vitalik wakes up tomorrow and finds Cat tokens in his wallet and dumps on Uniswap; backrunners place tx's right behind Vitalk's dump tx, arbing between exchanges and protocols.

Other examples include liquidating wallets when oracle update prices (explain more). You can get in on some of that action at twitter.com/definitelyrekt


Sandwich Attacks

Suppose you don't like Vitalik market dumping his Cat tokens; what you do is send the same TX as Vitalik with higher gas to the maximum slippage Vitalk's TX will accept (in the case of selling you're trying to find the lowest price of CAT/ETH), let his dump TX go through, and then buy at a much lower price for ETH to make a profit.



This diagram from Igor Igamberdiev shows how you can screw over someone by sandwich attacking them

Salmonella Traps

In an attempt to trap either new arb bots (frontrunning, backrunning, sandwhich) Nathan Worsley made a token that sends 10% of the specific amount of tokens whenever transacted not from the original owner

Uncle Bandit Attacks

Sometimes multiple blocks are made at the same times, rendering one to be an orphan and the other one as valid. Sort of like backrunning where you're stalking whale TX's, here you stalk orphan blocks' TXs to see if you can run them yourself in your block for an opportunity; sort of like cheating off of the person next to you during a test, but you pass because they got some answers right but ultimately fail.

Mother of all attacks - Omnipotent Attack

Ethereum is a state machine, extracted MEV is found brute force and once the alpha is public (salmonella traps, sandwich attacks) everyone can see it and it decays fast. In that way MEV is probabilistic, you have various inputs, various ouputs, and a lot of data. So in theory you could make this into OpenAI Gym environment and run it millions of times until you get a trained agent; exactly what https://twitter.com/mevalphaleak is doing.

Creating the Omnipotent attack, one that sees all, acts immediately, and decays alpha faster than sugar dissolves in water. Realistically this would compete away MEV into the people who have the most capital to expend and possibly make TX spam lesser given that you can optimize for gas fees.

You can see his TX's at https://etherscan.io/address/apebank.eth where you can see a variety of arbing, whether or not the omnipotent attack will come true; only time will tell.