Skip to main content
The FX Forward Protocol subgraph indexes all onchain events into a queryable GraphQL API. It powers historical position data, pool analytics, oracle price history, and protocol state tracking that would be expensive or impossible to retrieve via direct RPC calls.

GraphQL Endpoint

http://localhost:8000/subgraphs/name/fx-forward
Run via docker compose with the local Graph Node stack.

Indexed Data Sources

The subgraph listens to events from six contracts:
Data SourceEvents IndexedEntities Updated
PositionManagerPositionOpened, PositionIncreased, PositionClosed, TradingFeeCollected, OracleFeeCollectedPosition, Account, PoolState, PoolTransaction
SettlementEnginePositionSettledAtMaturity, PositionLiquidated, PositionClosedEarly, PositionReduced, FeesCollected, OracleFeeCollectedPosition, PoolState, PositionReduction, PoolTransaction
PoolVaultDeposit, Withdraw, PnlApplied, ExposureUpdatedPoolState, Account, VaultEvent
MarginAccountsCollateralDeposited, CollateralWithdrawn, MarginLocked, MarginUnlocked, PnlSettled, BadDebtAccount
OracleModuleForwardRoundPublished, FixingPriceRecordedOracleRound, OracleState, FixingPrice
ModeControllerModeTransitionModeTransition, ProtocolState

Entity Overview

Fourteen entity types fall into three categories:

Mutable State Entities

Updated as new events arrive. Use these for current-state queries.
EntityID PatternDescription
PositionpositionIdFull position lifecycle data
AccountaddressTrader margin and LP state
PoolState"pool" (singleton)Pool assets, exposure, fees
OracleState"oracle" (singleton)Forward round and fixing counts
ProtocolState"protocol" (singleton)Current operating mode
OracleRoundfixingTimestamp-roundIdForward price rounds
DailyStatsUnix day numberDaily aggregate analytics

Immutable Event Records

Append-only, never updated after creation. Optimized for write performance.
EntityID PatternDescription
FixingPricepairId-fixingTimestampSettlement fixing prices
FeeEventtxHash-logIndexFee collection events
PositionReductiontxHash-logIndexPartial reduction records
VaultEventtxHash-logIndexLP deposit/withdraw history
PoolTransactiontxHash-logIndexUnified activity feed
ModeTransitiontxHash-logIndexMode state change audit trail

Internal Helper

EntityDescription
TxFeeAccumulatorLinks fee events to pool transactions within a single tx. Not queried directly.

Design Principles

Event-driven only — the subgraph uses no block handlers or call handlers. All data comes from emitted events, keeping indexing fast and deterministic. No eth_calls — handler code never calls contract functions. Every data point is derived from event parameters, avoiding RPC round-trips during indexing. Immutable optimization — append-only entities use @entity(immutable: true), skipping block-range versioning and reducing write amplification by 2-3x.

Schema Reference

Complete entity and field definitions.

Query Examples

Common GraphQL query patterns.

Data Source Guide

When to use subgraph vs RPC.