DeFi
How DeFi lending works: collateral, liquidation, rates
A DeFi lending pool lends to anyone who locks up more collateral than they borrow, and it enforces the loan with a price feed and a liquidation that anyone can carry out. Four numbers decide what happens to a position: the loan-to-value at which it may borrow, the threshold at which it may be liquidated, the health factor that compares the two, and the utilisation that sets the interest rate. The weak point is the price feed, and the record of hacks shows it. Aave V3 and Compound III serve as the worked examples here; other pools set their own rules.
Why the collateral is worth more than the loan
A lending contract cannot check credit, take a guarantee or go to court. It knows only what the borrower has locked inside it. So it lends less than the collateral is worth and keeps the right to sell the collateral if the gap closes. Lenders deposit an asset into a pool, borrowers take it out against collateral, and the interest borrowers pay goes, less the protocol’s share, to the lenders, a flow that where crypto yield comes from follows from the lender’s side.
Aave V3 calls each asset in a pool a reserve and gives it its own parameters: a loan-to-value, a liquidation threshold, whether it can be borrowed, caps on supply and borrowing, and an interest-rate model, according to Aave’s page on reserves. The parameters vary between markets, even for the same token, and change through governance. Compound III is built differently. Each market lends one base asset, collateral earns no interest, and an account’s balance in the base asset is a signed number, positive when it supplies and negative when it borrows, according to Compound’s page on collateral and borrowing.
Protocols that mint their own stablecoin against collateral, instead of lending out deposits, run on the same logic and are filed separately by DefiLlama, under CDP; what holds a stablecoin peg covers them as crypto-collateralised stablecoins.
Loan-to-value and the liquidation threshold
Two ratios bound a position, and the gap between them is the borrower’s margin.
Loan-to-value caps what can be borrowed. Aave’s example is an LTV of 75%, which allows borrowing up to 75% of the collateral’s value; an asset with an LTV of zero cannot serve as collateral at all. Compound III calls the same thing a borrow collateral factor.
The liquidation threshold sits higher and marks the point at which the position can be liquidated. Compound’s liquidation page gives the reason for keeping the two apart: the liquidation collateral factor is set above the borrow collateral factor so that every new position starts with a price buffer, and so that governance can lower the borrow factor without pushing existing positions into liquidation.
Both ratios belong to the asset, not to the loan. In Aave V3 the pool configurator lets a risk admin or pool admin set an asset’s LTV, liquidation threshold and liquidation bonus. A borrower who opened a position under one set of parameters holds it under whichever set applies later.
The health factor
Aave folds the threshold and the debt into one number. In the contract that computes it, the health factor is the sum of each collateral asset’s value multiplied by its liquidation threshold, divided by the total debt, all priced in the oracle’s base currency. Above 1, the position cannot be liquidated; below 1, anyone may liquidate it. A new borrow must leave the health factor at 1 or more and pass a check against the LTV, which the validation code describes as a guard against borrowing close to liquidation by accident, and one that sophisticated users can work around.
An illustration with invented numbers, not the settings of any asset. A borrower deposits collateral worth $10,000 in an asset with an LTV of 75% and a liquidation threshold of 80%. The most they can borrow is $7,500, and they borrow $6,000. The health factor is $10,000 × 0.80 ÷ $6,000, or 1.33. If the collateral’s price falls by a quarter it is worth $7,500, and $7,500 × 0.80 ÷ $6,000 is exactly 1. Any further fall makes the position liquidatable. The debt does not stand still either. It accrues interest, so even with prices unchanged the health factor drifts down unless the collateral earns more than the debt costs.
The more useful reading runs the formula backwards. The collateral price at which the health factor reaches 1 is the debt divided by the quantity of collateral times its threshold: in the example, $6,000 ÷ 0.80 is $7,500 of collateral value. That is the position’s liquidation price, and it moves every time the borrower adds collateral, repays, or lets interest accrue.
What a liquidation is, and who performs it
A liquidation sells part of a failing position’s collateral to repay its debt
before the collateral is worth less than what is owed. In Aave the pool does not
do this itself. Its liquidationCall function, in Aave’s pool
reference, liquidates a
position whose health factor is below 1, and any address can call it. The caller
repays part of the borrower’s debt and receives the equivalent collateral plus a
bonus, which the contract’s own
comment
says covers market risk. The bonus is set per asset and is always above 100% of
the debt repaid; Aave’s example is 105%, a 5% bonus, which comes out of the
borrower’s collateral.
How much one liquidation may take is the close factor. In the liquidation code the default is 50% of the debt. It rises to 100% when the health factor is at or below 0.95, or when the collateral or debt being liquidated is worth less than $2,000 in a market priced in dollars. Aave’s notes on version 3.3 explain the small-position rule: a half-liquidated small position can shrink to the point where the bonus no longer covers the gas, and nobody liquidates the rest. The same notes cover the failure case, in which the collateral runs out before the debt does and the remaining debt is burned and recorded as a deficit on the reserve.
Nobody is obliged to liquidate. In Aave the bonus is what makes the work worth doing, a wage the yield piece examines from the lender’s side.
Compound III splits the job in two. When an account breaches its liquidation
collateral factor, any address can call absorb; the documentation says the
caller may be a bot, a contract or a user. The protocol takes the account’s debt
and collateral onto its own books, paying with its reserves of the base asset,
and credits the borrower with the collateral’s value minus a penalty, the
liquidation factor. The borrower is left with no debt and, typically, a positive
balance of the base asset. The caller is not paid out of the position: the
protocol records points and the gas the caller spent, which the documentation
says governance could compensate in future. The discount sits in the second
step, the sale of the seized collateral. If the protocol’s reserves are below a
target governance sets, anyone can buy that collateral at a discount to the
price feed through buyCollateral.
Either way, the price that decides whether a position is liquidated is the oracle’s.
The price feed, and why a bad one is the classic attack
Every number above depends on a price, and a contract cannot see a market. It
reads an oracle. In Aave V3 the AaveOracle
contract
takes each asset’s price from a Chainlink aggregator first and falls back to a
second oracle if the aggregator returns zero or less. The contract is owned by
Aave governance, and only a pool admin or an asset-listing admin can change the
sources. Aave’s oracle page adds that
assets which track another asset are priced through adapters: a liquid staking
token such as wstETH at the underlying asset’s price times an exchange rate
whose growth is capped, and stablecoins at a capped price. On that design a
market discount on a liquid staking token does not lower its value as
collateral, the gap between market and redemption that what liquid staking
is describes.
The classic attack reads a price from a place where it can be moved. A pool on a decentralised exchange sets its price from its own reserves, as what an AMM is explains, and a large enough trade shifts that price for as long as the trade stands. A lending contract that takes the pool’s spot price as its oracle can then be shown a false price inside a single transaction. The attacker pushes up the pool price of an asset, deposits that asset as collateral, borrows against the inflated value, and reverses the trade, keeping the loan and leaving the lending pool with collateral worth less than the debt. Flash loans, which Aave’s documentation describes as borrowing without collateral on condition that the amount and a fee come back within the same transaction, mean the capital for that trade need not be the attacker’s own.
Uniswap’s documentation on oracles says the ecosystem has seen numerous high-profile hacks in which the oracle implementation was the primary attack vector. Its version 2 design responds in two steps. Each pair measures its price at the start of a block, before any trade in that block, so that moving the measured price means making a losing trade at the end of the previous block; and it accumulates those prices into a time-weighted average that other contracts can read over any interval. The documentation estimates that the cost of manipulating such an average rises roughly in line with the pool’s liquidity and with the length of the averaging window.
The record bears the history out. As of 22 November 2026, per DefiLlama, its hacks record files 162 incidents under Oracle Manipulation, totalling $894.1M, fifth of its 13 classes by count. 134 of them, worth $835.1M, carry the technique Spot Price Manipulation. The three largest rows in the class are CREAM Lending ($130.0M, 2021), Mango Markets V3 ($115.0M, 2022) and Venus Protocol ($100.0M, 2021). The record gives each a class and a technique and does not describe the oracle involved; how crypto gets hacked sets out what else it leaves out.
An accurate feed fails in its own way. When prices fall fast and together, many positions cross 1 at once and their liquidations sell collateral into the same falling market, the case the stablecoin piece describes for crypto-collateralised designs. The class also holds eight incidents with the technique Stale Oracle Price, $31.6M in all, a label for a price that was out of date when a contract read it.
Interest rates follow utilisation
Utilisation is the share of a pool’s supply that is lent out; Compound’s interest-rate page defines it as total borrows divided by total supply. Both protocols make the rate a function of utilisation, with a bend in it.
In Aave V3’s interest-rate strategy, the variable borrow rate starts from a base rate and climbs along a first slope until utilisation reaches an optimal ratio, then along a second slope from there to 100%. At half the optimal ratio a borrower pays the base rate plus half the first slope; at the optimal ratio, the base plus the whole first slope; halfway from there to full use, the base, the first slope and half the second. Each reserve has its own values for the four parameters. Aave’s reserve page gives the reason for the shape: as more of the pool is borrowed, the rate rises so that enough liquidity remains for withdrawals and liquidations. The supply rate is derived from the borrow rate, scaled down by utilisation and by the protocol’s reserve factor, as the yield piece sets out from the contract.
Compound III uses separate models for supplying and borrowing, each with a kink above which the rate climbs faster, both set by governance, and interest accrues every second. Collateral earns nothing.
The shape works as a feedback loop. When borrowing drains a pool towards full use, the second slope makes borrowing expensive and supplying attractive until utilisation falls back. At 100% the pool holds none of the asset to hand back, so a depositor cannot withdraw until someone repays or someone else supplies. A rate on a screen is a reading of that state at one moment, not a term of the deposit, and APY versus APR covers how such rates are quoted.
The scale, from the snapshot
As of 22 November 2026, per DefiLlama, the protocols it files under Lending with at least $1M each held $44.1B, across 117 protocols listed on the lending category page. $23.9B of that total, 54.2% (computed), was on Ethereum, where 39 of the protocols held at least $1M each. Aave V3 was the largest at $15.1B, 34.3% of the category total, deployed on 21 chains with $13.0B on Ethereum. Compound V3 held $1.0B across 10 chains.
What the figure counts matters more for lending than for most categories. DefiLlama’s data definitions track borrowed value separately from total value locked, so a lending market’s figure is what has been deposited less what has been borrowed out, and a rise in borrowing lowers it with no deposit leaving; what TVL measures sets out the rule. DefiLlama’s fee figure for a lending protocol is all the interest borrowers paid, not the part the protocol keeps. It recorded $42.8M for Aave V3 over the previous 30 days, and the piece on protocol fees and revenue explains how such a figure divides between lenders, the protocol and its token. How lending compares with the other categories in size is the subject of DeFi TVL by category.
Reading a lending position
- The liquidation price. The debt divided by the collateral quantity times its threshold, and how far the current price sits above it.
- The oracle. Which feed prices the collateral, what happens if it fails, and who can change it.
- The parameters, and who sets them. LTV, threshold, bonus and caps belong to a role in the protocol, not to the position.
- The cost of being liquidated. The bonus or penalty, and how much of the debt a single liquidation can take.
- The utilisation of what you supply. A pool near full use pays lenders the most and is the hardest to leave.