Formiga.

Unit 1 · Level 3 · AMMs & DEXes

x·y=k, minus the fear

Take a tiny pool: 10 ETH and €20,000 in stablecoins. Multiply them: 10 × 20,000 = 200,000. That's k, and the pool's only job is to keep x·y equal to k after every trade. Want ETH out? The ETH side shrinks, so the euro side must grow to compensate. The scarcer the ETH in the pool gets, the more euros each extra ETH costs. The formula IS the price impact.

Start this lesson →

Free to play. No ads, no token, no account needed to start.

What you get asked

  1. In an x·y=k pool, what stays (roughly) constant when someone trades?

    Not the price and not the token count: the PRODUCT. One side shrinks, the other grows, and x times y lands back on k.

  2. Pool: 10 ETH and €20,000, so k = 200,000. A trader buys 2 ETH, leaving 8 ETH. The euro side must become 200,000 ÷ 8 = €25,000. How many euros did the trader pay in?

    €25,000 − €20,000 = €5,000 for 2 ETH, an average of €2,500 each while the pool 'spot' price was €2,000. That gap is price impact, and you just computed it.

  3. Why did that trader pay €2,500 per ETH when the pool priced ETH at €2,000?

    Big trade, small pool: the first slice is near spot, every next slice costs more. In a pool 100× deeper, the same order would barely move the price.

  4. A whale market-buys from a small pool. Put the chain of events in order:

    Arbitrageurs are the glue: they profit from any gap between pools and the wider market, dragging AMM prices back in line within seconds.

  5. You want to swap a large amount with less price impact. What actually helps?

    Depth is the cure: deeper pools bend less. Maxing your slippage tolerance does the opposite: it tells the pool 'charge me whatever', and sandwich bots happily will. 🐜

The rest of this unit

How a pot of tokens and one formula replaced the order book.