Free module · Crypto & decentralized finance
DeFi: AMMs, Liquidity Provision and Lending
Follow reserves, benchmark inventory and test collateral under stress.
constant product · ranges · LP inventory · LVR · lending · liquidation
The building blocks
DeFi contracts automate accounting rules, while prices, liquidity and collateral remain economic risks. Learn the accounting before comparing advertised yields.
- Derive the reserve or debt state transition.
- Compare outcomes with an explicit benchmark.
- Stress price, oracle, fee and execution assumptions.
Lessons in this module
- Constant-product swaps with an input fee
- LP inventory after price changes
- LP value versus holding the original tokens
- Concentrated liquidity and range boundaries
- LVR and the price of stale inventory
- Lending utilization and rate response
- Collateral health factor and correlated shocks
- Liquidation incentives after execution costs
Practice and apply
- Constant-product swaps with an input fee — Reserves 100 base, 10000 quote; input 10 base; fee .003. Find quote output.
- LP inventory after price changes — Invariant 1000000 base×quote and price 400 quote/base. Find base reserve.
- LP value versus holding the original tokens — No-fee constant-product pool; final/initial base price ratio 2. Find relative LP minus hold ratio.
- Concentrated liquidity and range boundaries — L=100, lower price 1, current 4, upper 9. Find quote inventory.
- LVR and the price of stale inventory — Rebalancing value 10030, pool value 10000 before fees, collected fees 40, other costs 8. Find net comparison.
- Lending utilization and rate response — Borrowed 80, supplied 100, base .02, low slope .10, kink .7, high slope 1. Find annual borrow rate.
- Collateral health factor and correlated shocks — Collateral value 12000, liquidation threshold .8, debt 8000. Find health factor.
- Liquidation incentives after execution costs — Repay 1000 USD, bonus .05, sale discount .02, fixed gas/cost 10. Find net profit.
Work through the practice exercises · Quant development tools