Skip to content

Lesson 2 · 1 min · Intermediate

The building blocks, and how an AMM works

On this page

The building blocks of DeFi

  • Lending protocols — supply assets to earn yield, or borrow against collateral. Rates adjust automatically based on supply and demand.
  • AMMs / DEXes — swap one token for another via liquidity pools rather than an order book. Providers deposit token pairs and earn fees.
  • Yield — returns from lending, staking, or providing liquidity. Higher yield almost always means higher risk.
  • Staking — lock tokens to help secure a PoS network and earn rewards (technically not DeFi, but often grouped with it).
  • Governance tokens — tokens that let holders propose and vote on protocol changes.

How an AMM works (with a lemonade-stand analogy)

An AMM holds a pool of two tokens (say USDC and ETH). A formula (like the constant-product x · y = k) sets the price based on the pool’s ratio. When you swap, you add one token and remove the other, shifting the ratio and therefore the price. Liquidity providers earn a share of the swap fees in return for supplying the pool.

A swap against an x · y = k pool

pool before10 ETH · 20,000 USDCk = 200,000price 2,000 USDC per ETHpool after9.09 ETH · 22,000 USDCk = 200,000price 2,420you add 2,000 USDCyou receive 0.91 ETHaverage paid ≈ 2,200x · y = kliquidity providers earn a share of swap fees
The pool keeps x · y constant. Adding USDC and removing ETH moves the ratio, so ETH gets dearer as you buy: this swap averages about 2,200 USDC per ETH and leaves the price at 2,420. Fees are left out; the numbers are illustrative.
Educational only, not financial or legal advice.