@liq/subgraph
Typed GraphQL client for the Liq perps-market subgraph.
Overview
@liq/subgraph provides the LiqSubgraph client class with typed query methods for fetching onchain event data from The Graph — accounts, markets, order settlements, collateral changes, liquidations, and market updates. The subgraph URL is resolved automatically from @liq/core chain config when a chainId is provided, or can be supplied directly.
Key Exports
LiqSubgraph
Constructed with LiqSubgraphConfig ({ chainId? } | { url? }).
| Method | Return type | Description |
|---|---|---|
getAccount(accountId) | SubgraphAccount | null | Account + collateral balances |
getMarket(marketId) | SubgraphMarket | null | Market metadata |
getOrderSettlements(filter, pagination) | SubgraphOrderSettled[] | Settled order history |
getCollateralHistory(filter, pagination) | SubgraphCollateralModified[] | Collateral deposit/withdraw events |
getLiquidations(filter, pagination) | SubgraphPositionLiquidated[] | Liquidation events |
getMarketUpdates(filter, pagination) | SubgraphMarketUpdated[] | Funding rate + skew updates |
Types
SubgraphAccount,SubgraphMarket— core entity typesSubgraphOrderSettled,SubgraphCollateralModified,SubgraphPositionLiquidated,SubgraphMarketUpdated— event typesOrderSettledFilter,CollateralFilter,LiquidationFilter,MarketUpdatedFilter— filter inputsPaginationOpts—{ first?, skip? }pagination
Usage
import { LiqSubgraph } from '@liq/subgraph';
const subgraph = new LiqSubgraph({ chainId: 6343 });
// or: new LiqSubgraph({ url: 'https://...' })
const account = await subgraph.getAccount(12345n);
const settlements = await subgraph.getOrderSettlements({ accountId: '12345' }, { first: 50 });
Install
pnpm add @liq/subgraph graphql
Dependencies
@liq/core— chain config and subgraph URL resolutiongraphql-request— lightweight GraphQL client
Peer Dependencies
graphql^16
Build
moon run liq-subgraph:build # tsup → dist/