Technical field guide

Protocol Anatomy

Understand the code. Follow the money. Trace the evolution.

A technical field guide to how major DeFi protocols account for assets, price trades, liquidate collateral, and change their contracts.

What a guide is for

The mechanism

What state the contracts store, which inputs change it, and which invariant the transaction is required to leave behind.

The money

Where collateral, reserves, fees, and shares sit after a supply, swap, mint, or withdrawal, including the residual loss when a rule fails.

The version

Which design is deployed, which design it replaced, and which behavior belongs to an older contract that integrations still call.

Five protocols

A lending market, an automated market maker, a collateralized stablecoin, a specialized AMM, and a liquid staking pool. They are not five copies of one architecture.

  1. 01 Aave Lending

    Pooled overcollateralized borrowing, with utilization-based interest and collateral liquidation.

  2. 02 Uniswap Automated market maker

    Constant-product swaps against pooled reserves, with concentrated liquidity in v3 and v4.

  3. 03 MakerDAO / Sky Collateralized stablecoin

    Overcollateralized stablecoin debt against vaults, with a governance-set stability fee and a savings rate.

  4. 04 Curve Finance Automated market maker

    StableSwap and CryptoSwap invariants, with LP tokens minted against pool liquidity rather than a constant-product share.

  5. 05 Lido Liquid staking

    Share-based claims on pooled staked ether, with oracle accounting and a withdrawal queue.

Version and architecture

Each comparison is limited to versions that the cited documentation or repositories actually describe.

Concepts

Markets

Automated market makers

What an AMM prices, which state it stores, and how Uniswap and Curve implement different invariants.

Markets

Constant-product pricing

How the x · y = k invariant sets a Uniswap v2 price, and where v3 and Curve stop using it uniformly.

Markets

Concentrated liquidity

How Uniswap v3 and v4 confine LP capital to a tick range, and what happens when price leaves it.

Credit

Lending pools and utilization

How a shared lending pool measures utilization and why that ratio, not an order book, sets borrower competition.

Credit

Interest-rate models

How Aave’s two-slope utilization curve differs from Maker’s governance-set stability fee.

All concepts · Glossary