Lending and Borrowing (Aave, Compound)

Lending & Borrowing in DeFi (Aave, Compound)

How supply/borrow markets work, APYs, collateral, liquidations, and the risks to understand before you click “deposit”.

TL;DR: You supply assets to earn variable APY and receive receipt tokens (aTokens on Aave, cTokens on Compound). You can borrow against posted collateral within limits. If your health factor drops (price moves / interest accrues), you risk liquidation. Start small and monitor utilization & collateral ratios.

1) Markets, APYs & Utilization

Protocols like Aave and Compound run pool-based money markets. Suppliers deposit assets into a shared pool and receive interest; borrowers draw liquidity from that same pool and pay interest. Interest rates aren’t voted each day, they’re algorithmic and respond to utilization:

Utilization U = Total Borrowed / Total Supplied
Rate models: piecewise curves with a “kink” utilization where slopes change
• As U ↑ → borrow APY ↑ sharply, supply APY ↑ too (but less steeply)
• As U ↓ → both APYs ↓

Intuition: when a pool is heavily borrowed (high U), liquidity is scarce, so the protocol raises borrow costs to attract more supply and discourage excessive borrowing. When there’s slack liquidity, rates soften. Many markets use a “kinked” model: below the kink, rates rise gently; above it, they accelerate to protect solvency and restore balance.

Two quick implications:

  • Supply APY is variable. Don’t expect a fixed rate; it changes with utilization.
  • Borrow APY is path-dependent. If U spikes after you borrow, your cost can increase; risk budgets should assume rate volatility.

2) Receipt Tokens (aTokens, cTokens)

When you deposit, the protocol mints receipt tokens that represent your claim on the pool:

  • Aave (aTokens): Your aToken balance increases as interest accrues. Redeeming burns aTokens and returns the underlying.
  • Compound (cTokens): Your cToken exchange rate to the underlying increases over time; your cToken balance may stay constant while each unit is worth more underlying.

These tokens are portable and sometimes composable in other DeFi apps (e.g., staking or collateral elsewhere). That flexibility is powerful but stacks risk: if downstream apps fail, you still face the original lending risk plus the new protocol’s risk.

3) Collateral, LTV & Health Factor

Not every deposited asset is automatically collateral; you typically toggle “use as collateral.” Each asset has risk parameters:

  • LTV (Loan-to-Value): The target maximum you can borrow against collateral (e.g., 70%). If you deposit $10,000 of collateral with 70% LTV, your suggested borrow limit is ~$7,000.
  • Liquidation threshold: A stricter boundary (e.g., 75% of collateral value × weight) at which liquidations become possible. It’s set to protect the pool when prices move.
  • Health factor (HF): A combined solvency meter. Roughly:
    HF ≈ (Σ collateral_value × liquidation_threshold) / (Σ debt_value)

    HF > 1 means safe; HF ≤ 1 allows liquidations. Many users keep HF > 1.5–2.0 to absorb volatility.

Example. You deposit $10,000 of ETH; liquidation threshold weight is 80%. You borrow $6,000 USDC. HF ≈ (10,000 × 0.8) / 6,000 = 1.33. A ~20% drop in ETH price reduces collateral value to $8,000 → HF ≈ (8,000 × 0.8)/6,000 = 1.07 (dangerously close to 1). A further 10% drop could trigger liquidation. Keep buffers.

Using volatile collateral to borrow stables is popular, but drawdowns compress HF fast. Conversely, using stable collateral to borrow stables reduces price risk but can expose you to depeg or rate spikes.

4) Liquidations: How and Why

Liquidations keep the pool solvent. When HF drifts to ~1, liquidators can repay a portion of your debt and seize collateral at a discount (a penalty to you). This shrinks your position and pushes HF up again.

If Health Factor → 1.0:
• Liquidator repays part of your loan
• Receives your collateral at discount (liquidation bonus)
• Your position shrinks; you lose value and may incur fees

Important variables:

  • Close factor: Max percentage of debt a liquidator may repay in one go (prevents total wipeout at once).
  • Liquidation bonus/penalty: The discount at which collateral is sold; larger bonuses incentivize liquidators but increase user loss.
  • Oracle behavior: Price updates drive HF. Robust oracles (aggregated feeds, time-weighted prices) reduce manipulation risk.

5) Borrow Mechanics: Rates, Caps, Modes

Beyond headline APYs, mature markets add controls to balance risk:

  • Variable vs. “stable” borrow rates: Some markets offer a rate that moves slowly (“stable”) versus a fully variable rate. Stable can be safer for budgeting but may cost more; variable can be cheaper on average but spikes in stress.
  • Reserve factor: A portion of interest may be routed to a protocol reserve/safety module rather than suppliers, affects net supply APY.
  • Supply/borrow caps & pausing: Risk managers can cap how much of an asset can be supplied or borrowed, or temporarily pause a market to contain incidents.
  • Isolation & efficiency modes (conceptual): Correlated assets (e.g., similar stablecoins or LSTs) may allow higher effective LTVs in a special “efficiency” mode; riskier assets may be isolated so that borrowing is limited to select assets (often stables), limiting contagion.
  • Interest rate spikes during stress: If utilization hits the kink (or max), borrow rates can jump. be prepared for cost surges; consider repaying or deleveraging proactively.
  • Flash loans & credit delegation: Advanced features let you borrow without posting your own collateral (flash loans repaid in-tx; credit delegation uses someone else’s collateral with explicit permission). Powerful, but only for users who understand the hazards.

6) End-to-End Workflow (Deposit → Borrow → Repay)

  1. Choose network & asset. Prefer deep, battle-tested markets. Check each asset’s LTV, liquidation threshold, and oracle quality.
  2. Deposit funds. Approve token, then supply. You’ll receive aTokens or cTokens.
  3. Enable collateral. Toggle “use as collateral” only on assets you’re comfortable risking.
  4. Size the borrow. Target an HF buffer (e.g., 1.8–2.5) to survive volatility. Simulate a −20% and −40% move on your collateral and verify HF stays >1.
  5. Select rate type (if offered). Pick variable vs. “stable” depending on your time horizon and risk tolerance.
  6. Set alerts & automation. Use dashboards/bots to watch HF, utilization, and rate changes. Consider partial repayments when markets stress.
  7. Repay & withdraw. When finished, repay debt (including accrued interest), then withdraw your collateral by redeeming receipt tokens.
Practical tip: If you borrow stables against volatile collateral and plan to hold long, periodically skim trading gains into debt repayment to keep HF healthy. Small, frequent de-leverages beat emergency liquidations.

7) Key Risks & Mitigations

  • Price volatility: Main driver of liquidations. Keep conservative LTV; maintain an HF buffer. Avoid using highly illiquid/volatile tokens as collateral.
  • Oracle design: Prefer markets powered by robust oracles (aggregated, time-weighted). Thin or manipulable oracles = higher risk of wrongful liquidations.
  • Smart-contract risk: Even audited code can fail. Size positions prudently; avoid concentrating your entire stack in one protocol.
  • Stablecoin risk: If you borrow or collateralize with stables, understand depeg scenarios and how they propagate through LTVs and liquidations.
  • Rate risk: Borrow costs can surge during high utilization. Model worst-case interest for your intended holding period.
  • Composability risk: Using receipt tokens in other apps multiplies failure modes. Keep it simple unless you need the extra yield.
Mitigation checklist: Large HF buffer • diversify collateral • avoid maxing LTV • monitor with alerts • repay early when stressed • stick to deep, liquid markets • understand each asset’s risk params.

Quick check

  1. How does utilization affect supply and borrow APYs?
  2. What do aTokens and cTokens represent, and how do they accrue interest?
  3. Explain Health Factor in your own words and what happens near HF = 1.
  4. List two practical ways to avoid liquidation when borrowing against volatile collateral.
Show answers
  • Higher utilization → higher borrow APY (steeper above the kink) and higher supply APY; lower utilization → both fall.
  • They are receipt tokens that prove your claim on the pool; aTokens grow in balance, cTokens grow in exchange rate.
  • HF ≈ (weighted collateral value)/(debt). HF > 1 is safe; at ≤ 1, liquidations can occur.
  • Keep a wide HF buffer (e.g., 1.8–2.5), borrow less than max LTV, monitor prices/oracle feeds, and repay or add collateral proactively during drawdowns.

Go deeper

Tip: Before using leverage, simulate a −30% and −50% collateral move and verify your Health Factor stays above 1 with room to spare.

Further lectures (suggested next modules)

  1. Interest Rate Models Deep Dive: Kink math, slope tuning, and how utilization shocks transmit into APY changes.
  2. Collateral Optimization & e-Mode: Building safer portfolios with correlated assets and isolation rules.
  3. Liquidation Mechanics & Strategy: Close factor, bonuses, oracle timing, and how to set alerts that actually help.
  4. Stablecoin Risk Primer: Depeg case studies, circuit breakers, and safe borrowing practices.
  5. Automation & Tooling: Setting up dashboards, notifications, and partial auto-repay to keep HF healthy.

Next up: how swaps work under the hood : AMMs like Uniswap & Curve.

Next: AMMs & DEXs →