DocsProtocol
Risk engine
Credit limit, health and status formulas.
All money is in USD with 6 decimals, like HyperCore. The same formulas run in the contracts (RiskMath.sol) and in TypeScript; both are tested to match on 500 vectors.
notional = size × price uPnL = size × price − sign(size) × entryNtl spendable = max(0, uPnL × (1 − haircut) − buffer) equity = (collateral − margin used) × LTV limit = min(spendable, equity, vault cap, pool cap) health = collateral × liqThreshold ÷ debt
Conservative pricing
Longs use the lower of mark and oracle; shorts use the higher. This dampens short-lived price manipulation.
Status
- ok: no debt, or health above the warning level.
- warning: health below the warning level, debt above the new limit, or too close to HyperCore liquidation. New credit is refused.
- margin_call: health below 1.2.
- liquidatable: health below 1.0. Anyone can start a liquidation.
- liquidating: a liquidation is in progress.
While in debt, orders that add to a position are capped at 5x leverage, measured at the market price rather than the limit price you send.
Updated 2026-12-01