Ecosystem
Oracles and liquidations explained: how DeFi lending decides when your collateral is sold
· 6 min read

DeFi lending lets you borrow without a credit check, a bank, or a loan officer. In place of trust, it uses two things: more collateral than you borrow, and a rule that sells some of that collateral if its value falls too far. That rule depends on knowing prices, and blockchains can't see prices on their own. This post explains how oracles bring prices on-chain, how health factors and liquidations work, and walks through a full example.
Why DeFi loans are over-collateralized
A lending protocol doesn't know who you are, so it can't chase you for repayment. Instead, it requires you to deposit collateral worth more than your loan. If you deposit $10,000 of ETH, you might be able to borrow $7,000 of stablecoins, not $10,000.
That buffer exists for one reason: crypto prices move. The buffer gives the protocol time to recover its money before the collateral is worth less than the debt. The yield post covers why people borrow and how lenders earn interest; this post covers what happens when the buffer runs thin.
Three numbers every borrower should know
| Term | What it means | Typical example |
|---|---|---|
| Loan-to-value (LTV) | The most you can borrow when you open a position, as a share of your collateral | 75%: $10,000 of collateral lets you borrow up to $7,500 |
| Liquidation threshold | The point at which your position becomes eligible for liquidation | 80%: liquidation starts once debt passes 80% of collateral value |
| Liquidation bonus (penalty) | The discount a liquidator receives on your collateral, which you pay | 5%: the liquidator gets $1.05 of collateral for every $1 of debt repaid |
The gap between LTV and the liquidation threshold is your safety margin. Each protocol sets these values per asset, with riskier assets getting lower limits and higher penalties.
The health factor
Most lending protocols sum these up in one number, the health factor:
Health factor = (collateral value × liquidation threshold) ÷ debt value
- Above 1: your position is safe from liquidation.
- Exactly 1: you're at the edge.
- Below 1: anyone can liquidate part of your position.
The health factor falls when your collateral loses value, when the asset you borrowed gains value, or when interest slowly adds to your debt.
What an oracle does
A smart contract can only read data that's already on the blockchain. It can't check a price on an exchange website. An oracle is the system that brings external data, like the price of ETH in dollars, onto the chain so contracts can use it.
Every health factor in DeFi depends on an oracle price. If the oracle says ETH is $3,000, that's the price the protocol uses, whatever any single exchange shows. That's why oracle design is one of the most important security choices in DeFi.
There are three common designs:
- Push oracles. A network of independent node operators collects prices from many sources, agrees on a value, and writes it on-chain. Updates happen on a schedule or when the price moves past a set percentage. Chainlink is the best-known example.
- Pull oracles. Prices are published off-chain at high frequency, and the user or app pulls the latest signed price on-chain only when needed. This gives fresher prices at lower ongoing cost. Pyth uses this model.
- On-chain TWAP oracles. The price is read from a DEX pool and averaged over time, known as a time-weighted average price. Averaging makes the price harder to push around in a single block, though it reacts more slowly to real moves.
What goes wrong when an oracle is wrong
If an oracle can be pushed to a false price, the protocol makes decisions on that false price. An attacker can inflate the value of their collateral and borrow far more than it's really worth, or deflate someone else's collateral to trigger liquidations.
The best-known case is the Mango Markets exploit in October 2022. A trader pushed up the price of the thinly traded MNGO token on the markets the protocol's oracle relied on, used the inflated position as collateral, and took over $110 million out of the protocol. The lesson for builders is that an oracle is only as strong as the markets it reads. The lesson for users is to be careful lending or borrowing against tokens with little trading volume.
How a liquidation works
Liquidations are open to anyone. Once your health factor drops below 1:
- A liquidator, usually an automated bot, spots your position.
- It repays part of your debt on your behalf.
- In return, it receives an equal value of your collateral plus the liquidation bonus.
- Your debt shrinks, your collateral shrinks by slightly more, and your health factor rises back above 1.
Many protocols cap how much debt can be repaid in one liquidation, often up to 50%, with some allowing more if a position is far underwater. Bots compete to be first, which is why liquidations are also a form of MEV.
A worked example
You deposit 10 ETH at $3,000 ($30,000) and borrow 15,000 USDC. The liquidation threshold is 80% and the liquidation bonus is 5%.
- Starting health factor: 30,000 × 0.80 ÷ 15,000 = 1.6.
- Liquidation price: the health factor reaches 1 when your ETH is worth $18,750, so when ETH falls to $1,875, a 37.5% drop.
- The liquidation: ETH hits $1,875. A bot repays 7,500 USDC (half your debt) and receives $7,875 of your ETH (7,500 plus the 5% bonus), which is 4.2 ETH.
- After: you hold 5.8 ETH ($10,875) and owe 7,500 USDC. Your health factor is back to about 1.16. The liquidation cost you $375 on top of the debt repaid.
Note what didn't happen: you didn't lose everything. Liquidation is partial by design. But the penalty is real, and in a fast-falling market, several liquidations can hit the same position in a row.
How borrowers manage liquidation risk
- Borrow well below the maximum. A health factor of 1.5 to 2 leaves room for normal volatility; 1.1 leaves almost none.
- Know your liquidation price. Most lending interfaces show it. Treat it as the number that matters, not today's price.
- Watch both sides. Borrowing a volatile asset against a stablecoin means a rise in the borrowed asset can trigger liquidation too.
- Add collateral or repay early. Either one lifts your health factor. Doing it before a sharp move is far cheaper than paying a liquidation bonus during one.
- Mind correlated assets. If your collateral and the broader market tend to fall together, a single bad day can move several numbers against you at once.
The bottom line
DeFi lending replaces trust with rules. Over-collateralization gives the protocol a buffer, the health factor measures it, oracles feed it prices, and liquidations close positions before bad debt builds up. Understanding how each piece works, and that your position is only as safe as the price it's measured against, makes you a more confident borrower.
Sources: CFTC, charges over the Mango Markets oracle manipulation, January 2023, for the 11 October 2022 exploit and the over $110 million misappropriated; Aave V3 LiquidationLogic for the 50% close factor and the larger cap on deeply underwater positions; Chainlink data feeds and Pyth pull updates for the push and pull oracle models.
Disclaimer: These materials are for general information purposes only and do not constitute financial, investment, tax, or legal advice, nor a recommendation or solicitation to buy, sell, stake, or hold any crypto-asset. LCX Liberty Labs will not undertake efforts to increase the value of any crypto-asset that you buy. Crypto-assets are highly volatile and you may lose your entire investment. Past performance is not indicative of future results. Some crypto products and markets are unregulated, and you may not be protected by government compensation or regulatory protection schemes.