Health Factor Monitoring

Track credit account health factors over time and alert on liquidation risk.

Overview

Health factor monitoring needs to:

  1. Query current health factor for accounts

  2. Track changes over time

  3. Alert when accounts approach liquidation

  4. Provide actionable data for position management

This guide covers each step with SDK patterns.


Understanding Health Factor

WHY: Know what you're measuring before building monitoring.

The Formula

Health Factor = Total Weighted Value / Total Debt

Where:
- Weighted Value = Sum of (Token Balance * Price * Liquidation Threshold)
- Total Debt = Principal + Accrued Interest + Quota Fees

Health factor is scaled by 10000 in the protocol. healthFactor = 10000 means HF = 1.0.

Risk Thresholds

Health Factor
Status
Action

> 1.5 (15000)

Healthy

No action needed

1.1 - 1.5 (11000-15000)

Moderate

Monitor more frequently

1.0 - 1.1 (10000-11000)

Critical

Alert user, suggest adding collateral

< 1.0 (< 10000)

Liquidatable

Account can be liquidated

What Moves Health Factor

Health factor changes when:

  • Token prices change (most common) - market moves affect collateral values

  • Interest accrues - debt grows over time, reducing HF

  • Quota fees accumulate - adds to total debt

  • User actions - adding/removing collateral, borrowing/repaying


Querying Current Health Factor

WHY: Get a snapshot of account health for display or alerting.

Single Account

All Accounts at Risk

Filter for accounts approaching liquidation:


Continuous Monitoring

WHY: Health factors change with every block as prices move and interest accrues.

Polling Pattern

Event-Driven Updates

For more efficient monitoring, watch for events that affect health factor:


Health Factor Breakdown

WHY: Understanding why HF is low helps users take the right corrective action.

Decomposing Health Factor


Alerting Strategies

WHY: Different users need different alert thresholds and delivery methods.

Tiered Alerts

Suggested Actions per Level


Complete Example: Health Monitor Service


Gotchas

Stale Price Feeds

If on-demand price feeds (Pyth, Redstone) haven't been updated recently, the health factor from compressors may not reflect current market prices. For accurate monitoring:

Health Factor Precision

Health factor is an integer scaled by 10000. Small changes (e.g., 10001 to 10000) can cross the liquidation boundary. Always use precise comparison:

Interest Accumulation

Health factor decreases over time even without price changes, because interest accrues continuously. Factor this into alert timing - an account at HF 1.05 today may be liquidatable tomorrow purely from interest.


Next Steps

Last updated