Your position's Health Factor is a critical metric that determines its safety from liquidation. It is calculated by comparing the value of your collateral to your borrowed assets. Understanding each component helps you manage risk and optimize your DeFi strategy effectively.
How to Calculate Your Position's Health Factor
Core Components of the Health Factor
Total Collateral Value
Total Collateral Value represents the combined USD worth of all assets you have deposited into the lending protocol. This is not a simple sum; each asset's value is adjusted by its specific collateral factor or Loan-to-Value (LTV) ratio, which determines how much can be borrowed against it.
- Asset-Specific Valuation: Each collateral type (e.g., ETH, wBTC) has a real-time price feed from an oracle.
- Risk Adjustment: A $1000 ETH deposit might only contribute $800 to your borrowing power if its LTV is 80%.
- Dynamic Nature: This value fluctuates constantly with market prices, directly impacting your Health Factor.
This is your safety buffer; a higher total collateral value supports a healthier position and allows for more borrowing capacity.
Total Borrowed Value
Total Borrowed Value is the sum of the USD value of all assets you have taken out as loans from the protocol. Like collateral, each borrowed asset has its own price feed, and this total is a live snapshot of your debt obligation.
- Debt Accumulation: Includes the principal amount borrowed plus any accrued interest, which increases over time.
- Multi-Asset Debt: You might borrow stablecoins like DAI and USDC simultaneously, combining their values.
- Real Example: Borrowing 5000 USDC (valued at $1 each) and 1 ETH (valued at $3000) gives a total borrowed value of $8000.
This figure is the liability side of the equation; increasing it without adding collateral will lower your Health Factor.
Liquidation Threshold
The Liquidation Threshold is a risk parameter set by the protocol for each collateral asset, expressed as a percentage. It defines the maximum borrowable value against that collateral before the position becomes eligible for liquidation.
- Asset-Specific Risk: Volatile assets like crypto often have lower thresholds (e.g., 75% for ETH) than stablecoins (e.g., 85% for USDC).
- Safety Buffer: It acts as a buffer below the 100% collateral value to protect the protocol from instant insolvency during price drops.
- Calculation Role: Your total collateral is multiplied by its weighted average threshold to find your "borrowing limit."
This threshold is crucial; crossing it triggers liquidation, where your collateral is sold to repay your debt.
Health Factor Formula
The Health Factor (HF) is the final calculated ratio that signals your position's risk. It is computed as (Total Collateral Value * Average Liquidation Threshold) / Total Borrowed Value. A higher number indicates a safer position.
- The Magic Number: HF > 1 means your position is safe. HF <= 1 risks liquidation.
- Dynamic Calculation: All three components update in real-time with market prices and interest accrual.
- Practical Use Case: If your $10,000 collateral (avg. threshold 80%) backs a $6,000 debt, your HF is ($10,000 * 0.8) / $6,000 = 1.33.
Monitoring this single number is essential for proactive management, allowing you to add collateral or repay debt before reaching dangerous levels.
Liquidation Penalty
The Liquidation Penalty is an additional fee charged if your Health Factor falls below 1 and your position is liquidated. It is applied to the collateral being sold and compensates liquidators for their service while discouraging excessive risk-taking.
- Incentive Mechanism: A typical penalty is 5-10% of the liquidated collateral amount, paid to the liquidator.
- Impact on User: This penalty is taken from your remaining collateral, reducing your net worth beyond the market loss.
- Example Scenario: If $1000 of your ETH is liquidated with an 8% penalty, you lose $1080 worth of ETH to cover a $1000 debt.
Understanding this penalty highlights the real cost of letting your Health Factor deteriorate, emphasizing the need for active position management.
Step-by-Step Calculation Walkthrough
A detailed guide to manually compute your position's Health Factor on a lending protocol like Aave or Compound, ensuring you understand the risk of liquidation.
Step 1: Gather Your Position's Data
Collect all necessary information about your borrowed and supplied assets from the protocol.
Detailed Instructions
First, you must retrieve the current state of your position from the protocol's smart contract or interface. The Health Factor is a ratio that indicates the safety of your borrowed position; a value below 1 risks liquidation. You need the total borrowed value (in USD) and the total collateral value (in USD). For each asset, you require its current market price, the amount you have supplied as collateral, and the amount you have borrowed. Also, note the Loan-to-Value (LTV) ratio for each collateral asset, which is the maximum percentage of its value you can borrow against.
- Sub-step 1: Connect your wallet (e.g., MetaMask) to the protocol's app (app.aave.com) or a blockchain explorer.
- Sub-step 2: Identify your position by your wallet address (e.g.,
0x742d35Cc6634C0532925a3b844Bc9e...). - Sub-step 3: For each asset (e.g., ETH, USDC), record your supplied balance, borrowed balance, and the asset's current USD price from an oracle.
- Sub-step 4: Note the specific LTV for each collateral type from the protocol's documentation (e.g., ETH might have a 75% LTV).
Tip: Use the protocol's
getUserAccountDatafunction on a block explorer to fetch this data in one call for efficiency.
Step 2: Calculate the Total Collateral Value
Sum the USD value of all assets you have supplied as collateral, adjusted for their respective LTV ratios.
Detailed Instructions
Your total collateral value is not simply the sum of your supplied assets' market values. It is the sum of each collateral asset's Liquidation Threshold-adjusted value. The Liquidation Threshold is a percentage (usually lower than the LTV) at which your position becomes eligible for liquidation. For accurate health factor calculation, you must use the Liquidation Threshold, not the maximum LTV. Multiply the amount of each collateral asset by its current USD price and then by its liquidation threshold percentage.
- Sub-step 1: For each collateral asset, calculate:
(Collateral Amount) * (Asset Price) * (Liquidation Threshold). - Sub-step 2: Example: If you supplied 10 ETH at $3,000/ETH with an 80% liquidation threshold:
10 * 3000 * 0.80 = $24,000. - Sub-step 3: Sum all adjusted values from every collateral asset in your position to get the Total Adjusted Collateral Value.
code// Example calculation for two assets: let totalAdjustedCollateral = 0; totalAdjustedCollateral += (10 * 3000 * 0.80); // ETH totalAdjustedCollateral += (5000 * 1.00 * 0.85); // USDC // totalAdjustedCollateral = $24,000 + $4,250 = $28,250
Tip: Always verify the current liquidation thresholds on the protocol's risk parameters page, as they can be updated by governance.
Step 3: Calculate the Total Borrowed Value
Sum the USD value of all assets you have borrowed, including any accrued interest.
Detailed Instructions
The total borrowed value is the sum of the current USD debts for all borrowed assets. Crucially, this must include accrued interest, as most loans use variable or stable interest rates that compound. The debt increases over time, which directly lowers your Health Factor. You can find your current debt balance, which includes interest, directly from the protocol's user interface or by querying the smart contract for your totalDebtETH or similar function.
- Sub-step 1: For each borrowed asset (e.g., DAI, USDT), obtain your current debt balance from the protocol. This is your principal plus interest.
- Sub-step 2: Multiply each debt balance by its current USD market price. For stablecoins, this is typically ~$1.
- Sub-step 3: Sum the USD values of all debts to get the Total Borrowed Value.
code// Example with two borrowed assets: let totalBorrowedValue = 0; totalBorrowedValue += (1500 * 1.00); // 1500 DAI at $1.00 totalBorrowedValue += (0.5 * 3000); // 0.5 ETH at $3,000 // totalBorrowedValue = $1,500 + $1,500 = $3,000
Tip: Interest accrues every block. For precise calculations, especially near the liquidation threshold, use real-time data from the blockchain, not cached UI data.
Step 4: Compute the Final Health Factor
Apply the Health Factor formula using your calculated collateral and borrowed values.
Detailed Instructions
The Health Factor (HF) is calculated as: HF = (Total Adjusted Collateral Value) / (Total Borrowed Value). This formula shows how over-collateralized your position is. An HF of 2.0 means your adjusted collateral is twice your debt. If the HF drops to 1.0 or below, your position becomes eligible for liquidation by keepers. Market volatility can cause HF to fluctuate as asset prices change.
- Sub-step 1: Divide the Total Adjusted Collateral Value (from Step 2) by the Total Borrowed Value (from Step 3).
- Sub-step 2: Interpret the result: HF > 1.5 is generally safe, HF between 1.0 and 1.5 is risky, and HF <= 1.0 is in liquidation territory.
- Sub-step 3: Monitor this value regularly. You can increase your HF by adding more collateral or repaying some debt.
code// Using the example values from previous steps: let healthFactor = 28250 / 3000; // $28,250 / $3,000 // healthFactor = 9.4167
In this example, the HF is 9.42, indicating a very safe position. However, if ETH's price dropped to $2,000, the adjusted collateral would become $16,000 (for ETH) + $4,250 (USDC) = $20,250, resulting in an HF of 20250 / 3000 = 6.75. A more drastic drop could bring it near 1.
Tip: Set up alerts using DeFi monitoring tools to notify you if your Health Factor falls below a threshold you define, such as 1.5.
Health Factor Implementation Across Major Protocols
How to Calculate Your Position's Health Factor
| Protocol | Formula | Liquidation Threshold | Key Variable |
|---|---|---|---|
Aave V3 | (Collateral Value * Collateral Factor) / Total Borrowed | 75% | Collateral Factor (e.g., 0.8 for ETH) |
Compound V3 | Collateral Value / (Borrows * Liquidation Factor) | 83% | Liquidation Factor (e.g., 0.89 for USDC) |
MakerDAO | (Vault Collateral * Spot Price) / (Debt * Liquidation Ratio) | 145% | Liquidation Ratio (e.g., 150% for ETH-A) |
Liquity | (Collateral in ETH * ETH Price) / (LUSD Debt * Minimum Collateral Ratio) | 110% | Minimum Collateral Ratio (e.g., 110%) |
Venus Protocol | (Collateral Balance * Collateral Factor) / Total Borrow Balance | 80% | Collateral Factor (e.g., 0.75 for BTCB) |
Morpho Blue | (Supplied Value * LT) / Borrowed Value | Varies by Market | Liquidation Threshold (LT) set per market |
Spark Protocol | (∑(Collateral * LT)) / Total Debt | Variable by Asset | Liquidation Threshold (LT) per asset (e.g., 80% for stETH) |
Practical Perspectives on Health Factor Management
Understanding the Health Factor
The Health Factor (HF) is a critical metric in DeFi lending protocols like Aave and Compound that measures the safety of your borrowed position. It represents the ratio of your collateral's value to your borrowed value, adjusted for asset risk. If your HF drops below 1.0, your position becomes eligible for liquidation, where your collateral is automatically sold to repay the debt.
Key Points
- Collateralization Ratio: This is the minimum required value of your collateral relative to your loan. For example, if you deposit $1,000 of ETH as collateral, you might only be able to borrow $700 worth of USDC, maintaining a healthy buffer.
- Liquidation Threshold: Each asset has a specific threshold (e.g., 80% for ETH on Aave). If your borrowed value exceeds this percentage of your collateral's value, you risk liquidation.
- Dynamic Calculation: The HF updates in real-time with market prices. A sudden drop in your collateral's value (like an ETH price crash) can rapidly decrease your HF.
A Practical Example
On Aave, if you deposit 1 ETH (worth $3,000) as collateral and borrow $1,500 of USDC, with ETH's liquidation threshold at 80%, your Health Factor is calculated as: (Collateral Value * Liquidation Threshold) / Total Borrows = ($3,000 * 0.80) / $1,500 = 1.6. This is a safe position. If ETH's price falls to $2,000, your HF becomes ($2,000 * 0.80) / $1,500 ≈ 1.07, putting you near the danger zone.
Advanced Monitoring and Risk Mitigation Strategies
A systematic process for calculating and interpreting your DeFi position's Health Factor to proactively manage liquidation risk.
Step 1: Gather Position and Protocol Data
Collect all necessary on-chain data points for your collateralized debt position (CDP).
Detailed Instructions
Begin by querying the blockchain for the real-time state of your position. This requires accessing the specific lending protocol's smart contracts. For Aave V3 on Ethereum Mainnet, you would interact with the Pool contract at 0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2. You need to fetch two core data sets: your supplied collateral assets and your borrowed assets. For each, you must obtain the current market price from a reliable oracle (like Chainlink), the asset's liquidation threshold (the maximum Loan-to-Value ratio before liquidation), and the liquidation bonus (the discount liquidators receive). Use the getUserAccountData function for a summary.
- Sub-step 1: Use a block explorer or direct RPC call to find your wallet's position data in the protocol.
- Sub-step 2: For each collateral token (e.g.,
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2for WETH), note the deposited amount and fetch its USD price. - Sub-step 3: For each debt token (e.g.,
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48for USDC), note the borrowed amount and its price.
Tip: Automate this with a script using libraries like ethers.js or web3.py, querying at regular intervals (e.g., every block) for continuous monitoring.
Step 2: Calculate the Health Factor
Compute the precise Health Factor using the protocol's formula with your gathered data.
Detailed Instructions
The Health Factor (HF) is the cornerstone metric for liquidation risk. It is calculated as HF = (Total Collateral in ETH * Liquidation Threshold) / Total Borrowed in ETH. A value below 1.0 means your position is eligible for liquidation. First, convert all asset values to a common base currency, typically ETH or USD. The liquidation threshold is a percentage (e.g., 80% for WETH on Aave) set by the protocol governance. Multiply your collateral amount by its price and its threshold to get your "borrowing power." Divide this by your total debt value.
- Sub-step 1: For each collateral:
Collateral Value_i = Collateral Amount_i * Price_i. - Sub-step 2: Calculate
Adjusted Collateral_i = Collateral Value_i * (Liquidation Threshold_i / 100). - Sub-step 3: Sum all
Adjusted Collateralvalues. Sum allDebt Value(Debt Amount * Price). - Sub-step 4: Execute the final calculation:
Health Factor = Total Adjusted Collateral / Total Debt.
javascript// Example calculation for a position with 10 WETH ($2,000 each) and 5,000 USDC debt. let totalAdjCollateral = 10 * 2000 * 0.80; // 80% LT for WETH let totalDebt = 5000 * 1.00; let healthFactor = totalAdjCollateral / totalDebt; // 16000 / 5000 = 3.2
Tip: Always use the most recent price from the protocol's oracle, as stale prices are a major risk.
Step 3: Analyze Risk Exposure and Set Alerts
Interpret the Health Factor and configure proactive monitoring thresholds.
Detailed Instructions
A raw Health Factor number is meaningless without context. Risk exposure is defined by how close your HF is to the liquidation threshold of 1.0 and the volatility of your collateral assets. Establish personal safety buffers. For example, if your HF drops below 2.0, consider it a yellow alert; below 1.3, a red alert requiring immediate action. You must also monitor the Loan-to-Value (LTV) ratio, which is similar to HF but uses the collateral's maximum LTV (not liquidation threshold). Use monitoring tools like DeBank, Zapper, or custom scripts with alerting via Discord/Telegram webhooks.
- Sub-step 1: Determine your risk tolerance buffer. If the protocol liquidates at HF < 1.0, set your first warning at HF < 1.5.
- Sub-step 2: Calculate the price drop tolerance for your main collateral. For a WETH position with an HF of 2.0, it can drop ~50% before liquidation (1 / HF).
- Sub-step 3: Implement automated alerts using a service like OpenZeppelin Defender Sentinel or a custom cron job that calls your calculation script.
Tip: Correlated asset drops (e.g., ETH and related altcoins) can crash your HF faster than expected. Diversify collateral types if possible.
Step 4: Execute Proactive Risk Mitigation
Take specific actions to improve your Health Factor and prevent liquidation.
Detailed Instructions
When your Health Factor warning triggers, you must act swiftly. Risk mitigation involves increasing your HF by either adding more collateral or repaying debt. The most efficient action depends on gas costs and asset availability. Use the protocol's interface or smart contract calls directly. For Aave, you can call supply() on the pool contract to add collateral or repay() to reduce debt. Always calculate the minimum required adjustment to reach your target HF, plus a safety margin.
- Sub-step 1: Add Collateral: Transfer more of your collateral asset (e.g., WETH) to the protocol. This directly increases the numerator in the HF formula.
- Sub-step 2: Repay Debt: Send stablecoins (e.g., USDC) to the protocol to reduce your borrowed amount, increasing the HF by reducing the denominator.
- Sub-step 3: Swap and Repay: If you lack stablecoins, you might need to swap other assets for a stablecoin first, incurring slippage and fee costs.
solidity// Example: Repaying 1000 USDC debt on Aave V3 via a smart contract call // Ensure you have approved the pool to spend your USDC first. aavePool.repay(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 1000e6, 2, msg.sender);
Tip: For large positions, consider using stop-loss mechanisms or decentralized insurance (e.g., Unslashed, Nexus Mutual) to hedge against black swan events.
Health Factor FAQs and Edge Cases
The Health Factor for a multi-collateral position is calculated as the weighted sum of your collateral values divided by your total borrowed value. Each collateral asset has a specific liquidation threshold set by the protocol, which acts as a discount factor. The formula is: HF = (Σ (Collateral Amount * Price * Liquidation Threshold)) / Total Borrowed Value. For example, if you deposit 1 ETH ($3,000) with an 80% threshold and 10,000 USDC ($10,000) with a 90% threshold, and borrow $10,000, your HF = (($3,0000.8) + ($10,0000.9)) / $10,000 = 1.14. A HF below 1 risks liquidation. Protocols like Aave provide a live calculator in their app interface.