Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Measuring MEV: who gets the value

After this lesson: I can measure how extracted value is shared out and how concentrated block building is.

65 min lesson2 commandsBlock building and MEV lab: mempool, sandwiches, auctions and defences in Python

Following the value of one attack

Measuring MEV means following the value taken by ordering, from the user who lost it to everybody who ends up with a share. It also means asking how few builders make most blocks.

Both numbers matter for design. Today you split the value of one sandwich and measure how concentrated a toy builder market is.

By the end of this lesson

Note

I can measure how extracted value is shared out and how concentrated block building is.

Key words

WordWhat it meansExample
Extracted valuewhat an ordering attack takes, measured in tokens
Shareone party's part of the whole, as a percentage
Market sharethe percentage of blocks one builder makes
Concentrationhow much of a market a few players hold
HHIthe sum of every market share squared55 squared plus 20 squared ...

The cells students fill in are left blank in this preview.

The value of an attack is passed along

A bot rarely keeps all it takes. To be placed around the user, it tips the builder. To win the block, the builder bids most of what it earns to the proposer.

In the lab, Ana loses 81 blue and the bot gains 88 red. The bot tips the builder 60, and the builder bids 50 to the proposer. So the proposer ends with the biggest share.

Follow the value of one sandwich

Command
docker exec jupyter python3 steps/measure.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Worked example: who keeps the 88 red

WhoKeepsShare of the gain
The bot88 minus 60 = 28 red32%
The builder60 minus 50 = 10 red11%
The proposer50 red57%

The cells students fill in are left blank in this preview.

Try it: split another gain

Code: python
gain = 200
to_builder = 150
to_proposer = 120
shares = [["bot", gain - to_builder], ["builder", to_builder - to_proposer], ["proposer", to_proposer]]
for share in shares:
    print(share[0], "keeps", share[1], "which is", 100 * share[1] // gain, "in every 100")
# Builders compete harder: change to_proposer to 145. Who gains from the competition?

How many builders make the blocks?

Count which builder won each block, then work out each one's market share. The top share, and the top two together, are quick measures.

A fuller one is the HHI: square every market share and add them up. A market split evenly between many has a low HHI. One builder with everything scores 10000. In the lab, 100 auctions gave north 55 blocks, an HHI of 3684.

Count the winners of 100 auctions

Command
docker exec jupyter python3 steps/builders.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Worked example: 100 toy auctions

BuilderBlocksShare squared
north553025
east20400
south13169
quay981
west39
All five100HHI 3684

The cells students fill in are left blank in this preview.

Why concentration is a risk

If one or two builders make most blocks, they can leave out transactions they dislike, which is censorship. One failure can also stall many blocks.

These measures turn a worry into a number you can watch over time. A design that spreads building out, or limits what a builder can see, should push the HHI down.

A common mistake

Warning

Many people think MEV is all profit for bots. When builders compete, most of the value is bid on to proposers, as the lab's 57% shows. The user still loses it either way, so the measure that matters for users is the loss.

About this lab and its source: Block building and MEV lab: mempool, sandwiches, auctions and defences in Python

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.