🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

DeFi Lending: Rates, Collateral, and Liquidations

DeFi AdvancedđŸŸĸ Free Lesson
DeFi Lending

The one-line mental model

A DeFi lending market is a shared pool that prices risk through a utilization curve: depositors earn interest proportional to how much of the pool is borrowed, and the protocol survives only if liquidations keep every loan over-collateralized.

Prerequisites

  • !ERC-20 approve and transferFrom mechanics
  • !How an oracle reports a price and why staleness checks matter

What You'll Learn

  • 1Derive supply and borrow rates from a kinked utilization model
  • 2Compute a health factor and predict the exact price at which a position liquidates
  • 3Explain close factors and liquidation bonuses as the incentive that keeps solvency real
  • 4Separate legitimate flash-loan uses from flash-loan-assisted attacks

The peer-to-pool model, end to end

Peer-to-peer matching never took hold on chain because a borrower wants funds instantly while a lender wants terms. The pool model dissolves that mismatch: anyone deposits an asset into a shared contract and receives a receipt token representing their claim plus accrued interest, while anyone else who posts sufficient collateral borrows from the same pool at a rate set by demand. No individual lender is matched to an individual borrower; the pool is the counterparty to both.

The receipt token is the piece most tutorials rush past. When you deposit into Aave you receive aTokens, which rebase upward in balance as interest accrues, so your claim grows block by block without any claim contract needing a claim. Compound's cTokens take the other approach: the exchange rate of the token against the underlying rises. Both designs let interest be distributed without iterating over every depositor, which is the only way compounding survives on a chain where storage writes cost real money. The second design consequence is that a pool's listed assets become a dependency graph: a receipt token accepted as collateral in a second protocol creates a position whose value depends on two solvency assumptions rather than one, and stress in the first protocol propagates through the second within a single block.

Utilization and the kinked rate curve

Borrow rates track utilization, the fraction of the pool that is currently lent out. A single-slope curve is simple but breaks down at the extremes, so production markets add a kink: rates rise moderately up to an optimal utilization, then climb steeply past it to force borrowers to repay and restore liquidity:

python
def borrow_rate(utilization, base=0.02, slope1=0.06, slope2=2.5, kink=0.8):
    """Kinked model: gentle before the kink, punitive after it."""
    if utilization <= kink:
        return base + slope1 * (utilization / kink)
    excess = (utilization - kink) / (1 - kink)
    kink_rate = base + slope1
    return kink_rate + slope2 * excess


def supply_rate(borrow_rate_, utilization, reserve_factor=0.1):
    return borrow_rate_ * utilization * (1 - reserve_factor)


for u in (0.2, 0.5, 0.8, 0.9, 0.99):
    br = borrow_rate(u)
    print(f"util {u:0.2f}  borrow {br * 100:5.2f}%  supply {supply_rate(br, u) * 100:5.2f}%")
UtilizationBorrow APRSupply APRInterpretation
0.203.50%1.26%Pool idle; cheap to borrow
0.505.75%2.59%Balanced market
0.808.00%4.32%At the kink: equilibrium
0.9053.00%28.62%Punitive zone; repay or be repriced
0.9996.75%52.24%Liquidity nearly exhausted

The steep segment past the kink exists for a solvency reason rather than a profitability one. If utilization approaches one hundred percent, depositors cannot withdraw, confidence collapses, and the pool suffers a bank run. Pricing the last slice of liquidity at punishing rates keeps borrowers from taking it, and keeps a withdrawal queue short enough to clear.

Collateral factors and the health factor

Over-collateralization is what replaces a credit score. Each listed asset carries a collateral factor: the fraction of its value that counts toward your borrowing power. Post 1,000 USDC worth of ETH at a 75 percent factor and you can borrow 750 USDC. The position's safety is then summarized in a single number, the health factor, defined as the value of your collateral times its factor divided by your debt:

python
def health_factor(collateral_usd, collateral_factor, debt_usd):
    if debt_usd == 0:
        return float("inf")
    return (collateral_usd * collateral_factor) / debt_usd


def liquidation_price(collateral_amount, collateral_factor, debt_usd):
    """USD price at which the health factor crosses 1.0."""
    return debt_usd / (collateral_amount * collateral_factor)


eth_collateral = 2.0                    # two ETH posted
cf = 0.75
debt = 3000.0                           # USDC borrowed

print(health_factor(2 * 2000, cf, debt))          # 1.0 at $2000/ETH: on the edge
print(liquidation_price(eth_collateral, cf, debt))  # $2000: the liquidation price

Health factor above one means solvent; at or below one the position is open to liquidation. Because the collateral price is what pushes a position across that line, the protocol's entire safety rests on the price feed behind it, which is why oracle selection is a solvency decision rather than an integration detail.

Liquidations: who benefits and why

When a position goes underwater, an external caller repays part or all of the debt and seizes the collateral at a discount. That discount, the liquidation bonus, is the incentive; the close factor caps how much debt a single liquidation call can repay, which spreads large positions across multiple liquidators and keeps the process competitive rather than monopolized.

Two dynamics matter for protocol health. First, liquidations must remain profitable during volatility, or liquidators stop showing up exactly when they are needed most, and healthy-looking collateral silently becomes bad debt. Second, liquidations generate sell pressure on the collateral asset, which can push its price down further and trigger the next wave of liquidations. Markets that were calm on Tuesday can empty themselves on Thursday afternoon for this reason, and the protocols that survive are the ones whose collateral factors left enough buffer for the cascade to end before reserves were consumed.

Flash loans: uncollateralized by construction

A flash loan is a borrow with no collateral that must be repaid within the same transaction, or the whole transaction reverts. Because the EVM executes atomically, the lender faces no risk of non-repayment; the borrower faces no risk of capital, which makes flash loans a powerful primitive and a permanent feature of the attack surface:

interface IFlashLoanReceiver {
    function executeOperation(
        address asset,
        uint256 amount,
        uint256 premium,
        address initiator,
        bytes calldata params
    ) external returns (bool);
}

contract FlashLoanUser {
    address public pool;
    address public owner;

    constructor(address _pool) {
        pool = _pool;
        owner = msg.sender;
    }

    function go(uint256 amount) external {
        require(msg.sender == owner, "not owner");
        IFlashLender(pool).flashLoan(address(this), address(USDC), amount, "");
    }

    function executeOperation(
        address, address asset, uint256 amount, uint256 premium, address, bytes calldata
    ) external returns (bool) {
        require(msg.sender == pool, "only pool");

        // Arbitrary strategy: arbitrage, self-liquidation, collateral swap.
        _doWork(asset, amount);

        uint256 owing = amount + premium;
        IERC20(asset).approve(pool, owing);
        return true;
    }

    function _doWork(address asset, uint256 amount) internal {
        asset; amount; // strategy specific
    }
}

Legitimate uses include atomic arbitrage across venues, refinancing a position in one transaction instead of two, and swapping collateral without ever holding unsecured risk. The same mechanics power attacks: borrow, manipulate a thin market to fool an oracle, liquidate an innocent position at the manipulated price, repay, and profit — all inside one block, with no capital at risk and no transaction left undone if the profit fails to appear.

Bad debt, oracles, and the death spiral

If collateral falls faster than liquidators can act, a position can end up underwater after the bonus is applied, and the shortfall becomes bad debt that the pool absorbs by socializing losses across depositors or by draining an insurance reserve. The ordering of events during a crash is what decides which outcome occurs: oracle lag, market liquidity, keeper profitability, and gas costs all determine whether liquidations keep pace.

This is why mature markets choose boring collateral. A blue-chip asset with deep liquidity across many venues can be sold by liquidators without moving the market much; a thinly traded governance token cannot, and its collateral factor should reflect that even when its volatility statistics look acceptable. The listing decision is a forecast about how the asset behaves during exactly the week nobody wants to think about.

âš ī¸Health factor one is not a suggestion

A position at health factor 1.0 is not "close to liquidatable" — it is liquidatable. Set a personal floor well above it, monitor it with an alert rather than a browser tab, and remember that liquidation bots watch the same number you do, with faster infrastructure and no hesitation.

Common Mistakes

Treating deposited liquidity as risk-free yield

Fix: Depositors carry smart contract risk, oracle risk, and the tail risk of bad debt socialization; size positions accordingly

Borrowing against volatile collateral at the maximum factor the protocol allows

Fix: Choose your own conservative factor, because the protocol's maximum is calibrated for its solvency, not for your risk tolerance

Assuming a price feed cannot be manipulated because it comes from a major oracle

Fix: Check how the feed sources its observations and whether a thin market can move it within one block, which is the flash-loan attack window

Ignoring utilization when predicting your supply rate

Fix: Supply APR is utilization times borrow rate net of reserves; a quiet pool can pay almost nothing no matter what the headline rate says

Best Practices

  • Monitor health factor with an automated alert and keep collateral that is not correlated with your debt
  • Read the liquidation bonus and close factor before borrowing, because both determine how violently your position unwinds
  • Prefer markets that separate the insurance reserve from depositor principal, and check how large that reserve is
  • When integrating a lending protocol in your own contract, whitelist interest-bearing receipt tokens explicitly rather than trusting any token that claims a balance function

Interview Questions

Q1: Why do interest rate models have a kink?

Below optimal utilization, rates rise gently to encourage borrowing and keep capital productive. Above it, rates rise steeply so that borrowers repay and depositors can withdraw, preventing a liquidity crisis that would end in a bank run.

Q2: What exactly is the health factor measuring?

The ratio of risk-adjusted collateral value to outstanding debt. Values above one are solvent; one is the liquidation threshold; below one, liquidators may repay debt and seize collateral at a bonus.

Q3: How can a flash loan cause a protocol to lose money without any capital at risk?

The borrower uses the loan to move a price the protocol trusts, such as a thin-market spot price, then liquidates or borrows against a now-mispriced position, all within one transaction, repays the loan, and keeps the difference.

Key Takeaways

  • Peer-to-pool lending prices risk through utilization, and receipt tokens let interest compound without iterating depositors
  • The kink in the rate curve protects withdrawal liquidity rather than maximizing revenue
  • Health factor and liquidation price are computable by hand, and every borrower should know their own numbers
  • Liquidation bonuses and close factors are the incentive mechanism that keeps solvency real during volatility
  • Flash loans remove capital requirements from both refinancing and attacks, so oracle and market depth design dominate protocol safety
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-13

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Related Tutorials

Content with similar topics across other courses

Need Expert Blockchain Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement