freecoding.school100% FREE · NO SIGNUP
Ledger LandISSUE #49 of 90

amms · constant product · uniswap math

BlockyVSDouble-Spend Dan
Blocky saysAMMs let you trade against a pool using a formula — no order book or counterparty.

Automated Market Makers (Uniswap) replace buyers-matching-sellers with liquidity pools priced by a formula — classically x * y = k (constant product). Traders swap against the pool; the formula moves the price along a curve. Liquidity providers deposit both assets and earn fees but face impermanent loss. AMMs made permissionless, always-available token trading possible.

Power-ups you unlock

Double-Spend Dan attacks — common mistakes

Boss battleExplain how x*y=k sets the price after a swap.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>pool: 100 ETH * 200000 USDC = k
buy ETH → ETH down, USDC up → price moves along curve
LP earns fees, risks impermanent loss</pre></body></html>
▶ Open the interactive comic issue
‹ Defi · The Open Finance StackLending · Aave · Compound · Health Factor ›