DeFi lending protocols like Aave and Compound let you borrow against supplied collateral, but a falling collateral price can trigger an automatic liquidation. This calculator computes the two key safety metrics — the collateral ratio and the health factor — plus how much more you can safely borrow and the exact collateral price that would push your position into liquidation.
How it works
The health factor follows the Aave definition, using the liquidation threshold rather than the maximum LTV:
health factor = (collateral × liquidation threshold) / borrow
collateral ratio = collateral / borrow × 100%
borrow headroom = collateral × liquidation threshold − borrow
liquidation price = current collateral price × (borrow / (collateral × threshold))
Liquidation becomes possible when the health factor reaches 1, which is the moment the collateral value times the liquidation threshold equals the borrowed amount. The liquidation price is simply the current collateral value scaled by the ratio that drives the health factor to 1, holding the borrow fixed.
Example and tips
Suppose you supply 10,000 of ETH collateral, borrow 4,000 of a stablecoin, and ETH has an 80 percent liquidation threshold. Your health factor is 10,000 times 0.8 divided by 4,000, which is 2.0 — comfortably safe. ETH would need to fall by half before the health factor hits 1. Keep a generous buffer on volatile collateral: a health factor near 1 leaves no room for a sudden wick, and interest accruing on the debt erodes the buffer over time even when prices hold.