DeFi Primitives: AMMs, Lending & Stablecoins

How constant-product pools price trades, how overcollateralized lending markets work, and the mechanics behind different stablecoin designs.

12 min read·5 quiz questions

Automated market makers

An AMM replaces an order book with a pool of two (or more) tokens and a pricing formula. The most common is the constant-product formula x * y = k, where price shifts automatically as the ratio of reserves changes with each trade. Liquidity providers deposit both tokens and earn a share of trading fees, taking on impermanent loss if the pair's price ratio diverges from when they deposited.

  • Bigger trades relative to pool size cause more slippage.
  • LP tokens represent a claim on a share of the pool's reserves and fees.
  • Impermanent loss shrinks if the price ratio returns to the deposit-time level.

Lending and borrowing markets

Protocols like Aave or Compound let users supply assets to earn interest and borrow against collateral, usually overcollateralized: you must deposit more value than you borrow. Interest rates float based on utilization — the fraction of supplied assets currently borrowed — rising as a pool gets tighter to pull in more supply.

  • Collateral factor caps how much you can borrow against a given deposit.
  • Health factor tracks how close a position is to liquidation.
  • Liquidators repay unhealthy debt and seize discounted collateral.

Liquidations

If collateral value falls (or debt value rises) enough that a position's health factor drops below one, anyone can trigger a liquidation: repaying part of the debt in exchange for a bonus slice of the borrower's collateral. This keeps the protocol solvent without needing a central credit desk, at the cost of borrowers needing to actively manage their margin.

Stablecoin designs

Fiat-collateralized stablecoins (USDC, USDT) hold off-chain reserves and rely on a centralized issuer to mint/redeem 1:1. Crypto-collateralized stablecoins (DAI) are backed by overcollateralized on-chain vaults and stay pegged partly through liquidations and stability fees. Algorithmic designs try to hold a peg through supply-adjustment incentives alone; several high-profile ones have de-pegged catastrophically because that incentive loop can break under stress.

  • Fiat-backed: simplest, but introduces custodial and regulatory trust.
  • Crypto-backed: trust-minimized but capital-inefficient (overcollateralization).
  • Algorithmic: capital-efficient but historically the most fragile under panic.

Key terms

AMM
Automated market maker; prices trades from pool reserves via a formula instead of an order book.
Impermanent loss
LP's opportunity cost versus holding, from the pool's price ratio diverging.
Overcollateralization
Requiring collateral worth more than the amount borrowed.
Health factor
Ratio measuring how close a borrowing position is to liquidation.
Liquidation
Forced repayment of undercollateralized debt in exchange for discounted collateral.

Chapter quiz

5 questions · pass mark 75%
  1. 1. In a constant-product AMM (x * y = k), what happens to price as a trade removes token Y from the pool?

  2. 2. What is impermanent loss?

  3. 3. Why do lending protocols require overcollateralization?

  4. 4. A position's health factor drops below one. What happens?

  5. 5. Which stablecoin design has historically proven most fragile under market stress?

Answer every question to submit. Progress for defi-primitives-amms-lending-stablecoins is saved in this browser.