Skip to main content

Module account

Module account 

Source
Expand description

Isolated margin accounting for simulated perpetual futures.

Models per-instrument isolated margin positions:

  • Tracks qty, avg entry price, leverage, reserved margin
  • Computes unrealized PnL at any mark price
  • Computes liquidation price using the Hyperliquid formula
  • Determines required initial margin for new orders

The MarginLedger manages all positions + free USDC, providing a single source of truth for the simulated account.

Structsยง

IsolatedPosition
Per-instrument isolated margin position.
MarginLedger
Manages all isolated margin positions and free USDC balance.