Definition
Health factor (HF) compares an account’s liquidation-threshold-weighted collateral against its total debt, both valued in USD-WAD (10^18):
calculate_health_factor (contracts/controller/src/helpers/math.rs:49). The division floors (div_floor), so rounding always reports the more conservative value. An account with no debt returns i128::MAX — an effectively infinite health factor. An account is liquidatable when HF < 1e18 (one WAD).
Each term is built from a scaled position, its market index, and the asset price:
AccountPositionRaw) from the account’s spoke asset config. The health factor is always evaluated post-execution on cached indexes, so a borrow or withdraw is checked against the state it would produce.
Health factor is separate from the LTV gate. Borrow and withdraw additionally require
Σ position_value(supply_i) · loan_to_value_i / BPS ≥ total_debt_usd. Because LTV is always below the liquidation threshold, an account reaches its borrow limit before it becomes liquidatable.Worked example
An account supplies 500. All USD values are WAD-scaled, so 500 is500e18.
1.56e18, comfortably above the 1e18 boundary, so the account is solvent and not liquidatable. If the collateral price halved, weighted_collateral would fall to 390e18 and HF to 0.78e18 — below 1e18, and the account would become liquidatable. Recompute after any supply, borrow, repay, withdraw, price change, or liquidation.
Decision table
| Condition | Meaning | What it allows |
|---|---|---|
HF ≥ 1e18 | Solvent. | Borrow or withdraw, subject to the LTV gate. |
HF < 1e18 | Liquidatable. | A liquidator may repay eligible debt and seize collateral. |
No debt (HF = i128::MAX) | No borrow-side risk. | Withdraw freely; supply and borrow checks still apply per market. |
Edge cases
| Case | Behavior |
|---|---|
| Account has no debt | calculate_health_factor returns i128::MAX; treat as unbounded, never as a finite large number. |
| Price unavailable, risk-increasing flow | The oracle is fail-closed: a missing primary price under a strict policy reverts the whole operation rather than pricing the position at zero. See Oracles. |
| Near-boundary rounding | The floor division and integer math can flip an account just over 1e18 to just under after a price tick; keep a buffer in any UI or simulation. |
| Dust positions | A partial withdraw or repay leaving sub-floor residue is expanded to a full close before HF is finalized; see Risk parameters. |
Next
Liquidations
What happens once an account crosses below
HF = 1.Risk parameters
The liquidation thresholds and LTVs that weight the formula.
Accounts and risk
Position snapshotting, spoke risk, and risk gates.
Oracles
The prices that feed every position value.

