Data Source Strategy
Position monitoring combines two data sources:| Source | Use For |
|---|---|
| Subgraph (GraphQL) | Listing positions, filtering by status/side/tenor, historical data, closed position history |
| RPC (contract reads) | Real-time PnL, current margin health, liquidation proximity, live forward prices |
List Open Positions
Query the subgraph for all open positions belonging to an account.- TypeScript
- CLI
Get Real-Time PnL
The subgraph stores static position data (entry strike, notional, margin). For live PnL, read directly from the contract — it computes PnL against the current forward price.- TypeScript
- CLI
Check Margin Health
A position’s margin health determines how close it is to liquidation. The key values:| Metric | Meaning |
|---|---|
| Equity | imLocked + unrealizedPnL — your effective collateral value |
| Maintenance margin (MM) | mmThreshold — the minimum equity before liquidation |
| Health ratio | equity / mmThreshold — below 1.0 triggers liquidation |
- TypeScript
- CLI
Search Positions with Filters
Use the subgraph or CLI to search across all positions with filters.- TypeScript
- CLI
| Field | Type | Example |
|---|---|---|
side | Int (0=LONG, 1=SHORT) | side: 0 |
tenor | Int (0=1D, 1=1W, 2=1M) | tenor: 1 |
status | String | status: "OPEN" |
account | Address | account: "0x..." |
notional_gte | String (raw 6-decimal) | notional_gte: "5000000000" |
openTimestamp_gte | String (unix seconds) | openTimestamp_gte: "1700000000" |
Monitor Account-Level Margin
Beyond individual positions, track your overall account margin health:- TypeScript
- CLI
Closed Position History
Query the subgraph for settled, liquidated, or early-terminated positions:closeReason field tells you how the position was closed:
| Value | Meaning |
|---|---|
MATURED | Settled at the fixing price after reaching maturity |
LIQUIDATED | Equity fell below maintenance margin |
EARLY_TERMINATION | Trader closed early at the current forward price |
Related Pages
PnL Calculation
Formula and mechanics for how profit and loss is computed.
Liquidation
Maintenance margin thresholds, liquidation process, and penalty fees.
Margin Requirements
Initial and maintenance margin factors by tenor.
Subgraph Queries
Full reference for available GraphQL queries and entity schemas.