Advanced
Lending Protocols (Mechanics) — Lesson outline
Understand collateral, liquidation, and health factor.
Developer Advanced
5/8 — Lending Protocols (Mechanics) — Lesson outline
RouteKeep this order so code inherits from solid math.
Steps
- Warm-up:Calculate HF, max borrow, and utilization for sample positions.
- Parameter lens:Pick collateral factors, thresholds, and bonuses for two asset types (volatile vs stable).
- Oracle guardrails:Define freshness/bounds checks and what happens on failure (pause borrows?).
- Implement minimal pool:Deposit, withdraw, borrow, repay, accrue interest.
- Liquidation path:Enforce HF, close factor, bonus; emit events.
- Tests:Invariants on HF, utilization, and bad debt prevention.