Curriculum·J302 Swap Execution: AMMs, MEV, and DEX Architectures·about 32 min

AMM generations, properly

By the end of this lesson you can

  • Name each market maker generation and the capability it added
  • Identify the assumption each generation depends on, which is its failure surface
  • Explain why a pricing function reading a wrong balance quotes a wrong price
  • Check whether a specific token violates a specific pool's assumptions

Junior · enrolled learners

This lesson opens with Balancer and the deflationary token, 29 June 2020.

What happened
Balancer's weighted pools generalised constant product pricing to several assets at arbitrary weights, and priced trades from the balances the pool contract recorded. An attacker took a $23M flash loan of ether from dYdX, converted it to wrapped ether, and swapped back and forth into STA, a token that charged a one percent fee on transfer taken from the recipient. Each swap therefore delivered the pool one percent less STA than its accounting recorded. Repeating this around twenty-four times drove the pool's actual STA holding down to a single wei while its recorded balance stayed far higher. The attacker then sold one wei of STA repeatedly: the pool received essentially nothing and released wrapped ether priced off the balance it believed it held. The same procedure drained the pool's WBTC, SNX and LINK. Losses were about $450,000, and only pools containing STA and STONK, both fee-on-transfer tokens, were affected.
The decision point
The pricing function was correct and the balances it read were not. Every market maker generation buys its advantage with an assumption, and the constant product family assumes that transferring an amount moves that amount. A token class existed for which that was false, and the pool priced from a number that no longer described what it held. Nothing in the formula was wrong; the input to it was.
Recorded loss
$450,000

What you will be able to answer

  • What does each AMM generation buy its advantage with?
  • Why did a correct formula produce a wrong price?
  • Which token classes break constant product accounting?
  • What is the check before using a pool?

Orientation and Year One are open: anyone can read them without an account. From Year Two onward the lessons are for enrolled learners, because progress through the later years only means anything if it is tracked against a record.

It is free. We do not sell the list and there is nothing to buy at the end of it.

Terms used here

Sources and review

Confidence high·Volatility low·Reviewed 2026-08-06·Owner unassigned

Contested

J302-01 derives constant product pricing and J303 covers liquidity provision including concentrated positions. This lesson covers the generations as venue architecture and the assumption each one carries. Keep the split and do not re-derive the invariant or the impermanent loss formula here.

Reported losses range from about $450,000 to $500,000 depending on the assets counted and the prices used. The mechanism is not disputed and is the durable part.