Tracks the full lifecycle of a trading position from open through close. Mutable — updated on increase, reduction, margin changes, and settlement.
type Position @entity { id: ID! # positionId (uint256) account: Account! # Owner (indexed for filtering) pairId: Bytes! # Currency pair identifier side: Int! # 0 = LONG, 1 = SHORT tenorSeconds: BigInt! # Tenor duration in seconds (dynamic registry) notional: BigInt! # Position size (USDC 6 decimals) entryStrike: BigInt! # Forward price at open (18 decimals, signed) fixingTimestamp: BigInt! # Maturity date imLocked: BigInt! # Locked initial margin initialMargin: BigInt! # Margin originally posted at open marginBeforeClose: BigInt! # Snapshot of locked margin at close (for analytics) mmThreshold: BigInt! # Maintenance margin threshold snapshotImBps: Int! # IM factor at open snapshotMmBps: Int! # MM factor at open openTradingFee: BigInt! # Trading fee paid at open openOracleFee: BigInt! # Oracle fee paid at open closeTradingFee: BigInt # Trading fee paid at close (null while open) closeOracleFee: BigInt # Oracle fee paid at close (null while open) closeLiquidationPenalty: BigInt # Liquidation penalty (null unless liquidated) status: String! # "OPEN", "CLOSED_MATURITY", "CLOSED_EARLY", "LIQUIDATED", "REDUCED" (indexed) closeReason: String # null while open closedPrice: BigInt # Settlement price (null while open) realizedPnl: BigInt # Capped PnL (null while open, signed) marketPnl: BigInt # Uncapped PnL (null while open, signed) openTxHash: Bytes! closeTxHash: Bytes openBlock: BigInt! closeBlock: BigInt openTimestamp: BigInt! # Indexed for time-range queries closeTimestamp: BigInt createdAt: BigInt! updatedAt: BigInt!}
Indexed fields:account, status, openTimestamp
There is no Tenor enum in the contracts — tenors are stored as uint32 seconds in a dynamic registry on Config. The subgraph mirrors this with tenorSeconds: BigInt! (e.g., 86400 for 1D, 2592000 for 1M). Use the string status field rather than enum ordinals when filtering positions.
Tracks forward price rounds published by the publisher. Append-only — to find the latest round for a fixing timestamp, query oracleRounds(orderBy: publishTime, orderDirection: desc, first: 200) and dedupe by fixingTimestamp client-side.
Per-transaction accumulator that lets the subgraph attribute trading and oracle fees collected through multiple events in the same tx to a single PoolTransaction row. Mutable.
type TxFeeAccumulator @entity { id: ID! # txHash tradingFee: BigInt! # Sum of trading fees collected in this tx oracleFee: BigInt! # Sum of oracle fees collected in this tx}
Per-tenor open-interest snapshot. Mutable — updated on every position open / increase / close that lands in this tenor.
type TenorState @entity { id: ID! # tenorSeconds (as string) tenorSeconds: BigInt! openInterest: BigInt! # Aggregate open notional in this tenor longNotional: BigInt! shortNotional: BigInt! positionCount: Int! # Currently open positions in this tenor}
Per-(pair, maturity) cohort tracking the pool’s bucket-level exposure. The pool’s risk caps are enforced against Σ |bucketNetExposure| across active buckets, so this entity exposes the same shape the contract uses internally. Mutable.
type BucketState @entity { id: ID! # "pairId-fixingTimestamp" pairId: Bytes! # Currency pair (indexed) tenorSeconds: BigInt! # Tenor that produced this maturity fixingTimestamp: BigInt! # Maturity timestamp (indexed) longNotional: BigInt! shortNotional: BigInt! netExposure: BigInt! # longNotional - shortNotional (signed) positionCount: Int! # Open positions in this bucket updatedAt: BigInt!}