Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

queryPerpsEvents

Read perps events — fills, liquidations, deleverages — paginated cursor-style. Optional filters by user, event type, pair, or block height.

Signature

function queryPerpsEvents(
  client: Client,
  parameters: {
    after?: string
    before?: string
    first?: number
    last?: number
    sortBy?: "BLOCK_HEIGHT_ASC" | "BLOCK_HEIGHT_DESC"
    userAddr?: string
    eventType?: string
    pairId?: string
    blockHeight?: number
  },
): Promise<GraphqlQueryResult<PerpsEvent>>

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const page = await client.queryPerpsEvents({
  pairId: "BTC-PERP",
  eventType: "order_filled",
  first: 100,
  sortBy: "BLOCK_HEIGHT_DESC",
})

Parameters

after, before, first, last — pagination cursors and sizes.

sortBy"BLOCK_HEIGHT_ASC" | "BLOCK_HEIGHT_DESC", optional.

userAddrstring, optional. Filter by trader.

eventTypestring, optional. "order_filled", "liquidated", or "deleveraged". order_filled events carry a fill_id and are emitted for both regular and liquidation fills; liquidated and deleveraged (ADL) events carry no fill_id because they are position transfers at the bankruptcy price, not order-book matches.

pairIdstring, optional. Filter by pair.

blockHeightnumber, optional. Filter by block.

Returns

GraphqlQueryResult<PerpsEvent>{ pageInfo, nodes }. Each PerpsEvent has idx, blockHeight, txHash, eventType, userAddr, pairId, and a discriminated data payload.

See also