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

perpsTradesSubscription

Subscribe to live perps trades for a pair. Uses WebSocket when available; falls back to HTTP polling.

Signature

function perpsTradesSubscription(
  client: Client,
  parameters: SubscriptionCallbacks<{
    perpsTrades: PerpsTrade
  }> & {
    pairId: string
    httpInterval?: number
  },
): () => void

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const unsubscribe = client.perpsTradesSubscription({
  pairId: "BTC-PERP",
  next: ({ perpsTrades }) => console.log(perpsTrades.fillPrice, perpsTrades.fillSize),
})

Parameters

pairIdstring. Perps pair identifier.

httpIntervalnumber, optional, default 3000. Poll interval (ms) used when WS is unavailable.

next, error, complete — callbacks.

Returns

() => void — unsubscribe.

See also