The mechanism
What state the contracts store, which inputs change it, and which invariant the transaction is required to leave behind.
Technical field guide
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 state the contracts store, which inputs change it, and which invariant the transaction is required to leave behind.
Where collateral, reserves, fees, and shares sit after a supply, swap, mint, or withdrawal, including the residual loss when a rule fails.
Which design is deployed, which design it replaced, and which behavior belongs to an older contract that integrations still call.
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.
Pooled overcollateralized borrowing, with utilization-based interest and collateral liquidation.
Constant-product swaps against pooled reserves, with concentrated liquidity in v3 and v4.
Overcollateralized stablecoin debt against vaults, with a governance-set stability fee and a savings rate.
StableSwap and CryptoSwap invariants, with LP tokens minted against pool liquidity rather than a constant-product share.
Share-based claims on pooled staked ether, with oracle accounting and a withdrawal queue.
Each comparison is limited to versions that the cited documentation or repositories actually describe.
V3 gathers supply and debt for a market inside one Pool and reprices every position when risk parameters change. V4 keeps utilization interest at an immutable hub, lets spokes define markets, and adds a collateral risk premium plus a target-health-factor liquidation.
v2 is a fungible constant-product pair with a 0.30 percent fee. v3 keeps constant-product math inside a chosen tick range and represents positions as NFTs. v4 keeps concentrated liquidity, puts every pool in one PoolManager, settles with flash accounting, and lets a hook extend the swap.
Sky did not replace the Vat with a new stablecoin design. DAI remains the internal stablecoin debt. USDS is a one-for-one ERC-20 path onto that debt. sUSDS is a savings vault. MKR converts to SKY at a fixed 24,000-to-1 rate. The vault safety check is still art times rate against ink times spot.
Curve did not ship a single V1-to-V4 exchange. It shipped an invariant for pegged assets, a later invariant for volatile assets, a factory that deploys immutable pool instances, and a separate stablecoin whose liquidation is an AMM. Those are different objects.
Lido withdrawals are a request, an oracle finalization, and a claim. The claim is an NFT until ETH is paid. Dual Governance, live on Ethereum since 4 July 2025 by Lido’s account, lets stETH holders escrow tokens so a DAO proposal cannot finish before they have had time to exit.
Markets
What an AMM prices, which state it stores, and how Uniswap and Curve implement different invariants.
Markets
How a liquidity provider’s claim is tracked in Uniswap v2, Uniswap v3 and v4, and Curve NG pools.
Markets
How the x · y = k invariant sets a Uniswap v2 price, and where v3 and Curve stop using it uniformly.
Markets
How Uniswap v3 and v4 confine LP capital to a tick range, and what happens when price leaves it.
Credit
How a shared lending pool measures utilization and why that ratio, not an order book, sets borrower competition.
Credit
How Aave’s two-slope utilization curve differs from Maker’s governance-set stability fee.