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

getPerpsUserState

Read the perps state for a single user.

Returns the raw on-chain state record — deposited USD margin, vault shares, per-pair positions (size, entry price, entry funding accumulator), pending vault unlocks, reserved margin, and open-order count — without computing derived equity, PnL, or liquidation prices. Use getPerpsUserStateExtended for those.

Signature

function getPerpsUserState(
  client: Client,
  parameters: {
    user: Address
    height?: number
  },
): Promise<PerpsUserState | null>

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const user: Address = "0x1234567890abcdef1234567890abcdef12345678"
 
const state = await client.getPerpsUserState({ user })

Parameters

userAddress. The trader.

heightnumber, optional. Block height. Default 0 (latest).

Returns

PerpsUserState | null{ margin, vaultShares, positions, unlocks, reservedMargin, openOrderCount } or null if the user has no perps state.

See also