@lifi/perps-sdk (getAccount, getPositions, getOrders, getFills, getActivity, getOrder). They are not LI.FI HTTP endpoints. This page documents the data shapes those calls return.
getAccount
Returns the account summary including balances, margin, and fee tier.Parameters
| Name | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | Provider identifier |
address | string | Yes | User’s wallet address |
Shape
AccountResponse fields
| Field | Type | Description |
|---|---|---|
provider | string | Provider identifier |
address | string | User’s wallet address |
balances | Balance[] | Flat, non-collateral holdings. Each Balance is { categoryId, asset, units, valueUsd }. |
collateralBalances | Balance[] | SDK-determined collateral subset (spot balances in a category’s quote asset). |
marginUsed | string | Total margin used across all positions |
unrealizedPnl | string | Total unrealized PnL across all positions |
feeTier | FeeTier | Maker and taker fee rates |
config | AccountConfig | Provider-specific account state — see AccountConfig |
AccountConfig
Discriminated union of per-provider account configuration state. Narrow withconfig.provider === '<key>' to access provider-specific fields.
Hyperliquid (provider: "hyperliquid"):
| Field | Type | Description |
|---|---|---|
provider | "hyperliquid" | Discriminator |
abstractionMode | string | null | Active abstraction variant (e.g. "unifiedAccount", "dexAbstraction", "disabled"). null when abstraction has never been set — the widget falls back to the descriptor’s default ParamOption. |
agents | HyperliquidAgent[] | Currently-authorised agent wallets. The approveAgent setup descriptor consults this to detect expiry. |
builderFeeApproval | HyperliquidBuilderFeeApproval? | Builder fee approval state. Absent when no builder is configured. |
provider: "lighter"):
| Field | Type | Description |
|---|---|---|
provider | "lighter" | Discriminator |
accountIndex | number | L2 integer account identifier — used by the SDK for WASM signing and by the widget when rendering transfer counterparties |
apiKeyIndex | number | Slot the SDK has registered (or will register) the session API key in |
apiKeyRegistered | boolean | Whether a key is currently live in apiKeyIndex. The registerApiKey setup descriptor consults this to gate trading. |
accountType | number | Raw integer fee/latency tier from Lighter’s /api/v1/account.account_type. Decoded to a human label by the widget once Lighter publishes the numeric→string mapping. |
Positions and orders are fetched separately: getPositions and getOrders.
getAccount()
getPositions
Returns the user’s open positions. Results are paginated.Parameters
| Name | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | Provider identifier |
address | string | Yes | User’s wallet address |
marketId | string | No | Filter by the canonical Market.id (not display symbol) |
limit | integer | No | Items per page (default 50, max 100) |
cursor | string | No | Pagination cursor from previous response |
Shape
Position fields
| Field | Type | Description |
|---|---|---|
market | MarketDisplay | Market reference (see below) |
side | 'LONG' | 'SHORT' | Position direction |
size | string | Position size |
entryPrice | string | Average entry price |
markPrice | string | Current mark price |
liquidationPrice | string | Estimated liquidation price |
unrealizedPnl | string | Unrealized profit/loss |
leverage | number | Current leverage |
marginUsed | string | Margin allocated |
marginMode | 'ISOLATED' | 'CROSS' | Margin mode |
MarketDisplay
TheMarketDisplay object is used across positions, orders, fills, and activity to identify the market and its underlying assets:
| Field | Type | Description |
|---|---|---|
providerId | string | Provider that owns the market (e.g., "hyperliquid") |
id | string | Provider’s canonical, stringified market id that uniquely identifies the trading instrument (e.g., "BTC", "xyz:PURR", "@142"; numeric on Lighter) |
categoryId | string | Provider category id (e.g., "hyperliquid", "xyz", "spot") |
baseAsset | Asset | Base leg of the market |
quoteAsset | Asset | Quote leg of the market |
getPositions()
getOrders
Returns the user’s open orders and trigger orders. Results are paginated.Parameters
| Name | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | Provider identifier |
address | string | Yes | User’s wallet address |
marketId | string | No | Filter by the canonical Market.id (not display symbol) |
limit | integer | No | Items per page (default 50, max 100) |
cursor | string | No | Pagination cursor from previous response |
Shape
OpenOrder fields
| Field | Type | Description |
|---|---|---|
orderId | string | Order ID |
market | MarketDisplay | Market reference |
side | 'BUY' | 'SELL' | Order direction |
type | OrderType | Order type: MARKET, LIMIT, STOP_MARKET, STOP_LIMIT, TAKE_PROFIT_MARKET, TAKE_PROFIT_LIMIT, TRIGGER_ONLY |
size | string | Order size |
price | string | Limit price |
filledSize | string | Amount filled |
reduceOnly | boolean | Whether reduce-only |
label | string? | Optional order label |
createdAt | string | ISO 8601 timestamp |
TriggerOrder fields
| Field | Type | Description |
|---|---|---|
orderId | string | Order ID |
market | MarketDisplay | Market reference |
type | OrderType | Trigger order type (e.g., TAKE_PROFIT_MARKET, STOP_LIMIT) |
size | string | Order size |
triggerPrice | string | Price at which the order activates |
limitPrice | string? | Execution limit price (market order if omitted) |
label | string? | Optional order label |
createdAt | string | ISO 8601 timestamp |
getOrders()
getFills
Returns paginated order fills. Results are sorted by creation time, newest first.Parameters
| Name | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | Provider identifier |
address | string | Yes | User’s wallet address |
startTime | integer | No | Filter: fills after this timestamp (ms) |
endTime | integer | No | Filter: fills before this timestamp (ms) |
cursor | string | No | Pagination cursor from previous response |
limit | integer | No | Items per page (default 50, max 100) |
Shape
ThefilledSize, fee, and realizedPnl fields are optional — they may be absent on cancelled or rejected orders, and realizedPnl is null when the order did not close a position.
Fill fields
| Field | Type | Description |
|---|---|---|
id | string | Fill ID |
orderId | string | ID of the parent order |
market | MarketDisplay | Market reference |
side | 'BUY' | 'SELL' | Order direction |
type | OrderType | Order type |
size | string | Original order size |
price | string | Fill price |
status | FillStatus | FILLED, PARTIALLY_FILLED, CANCELLED, REJECTED |
liquidity | LiquidityRole | 'maker' or 'taker' — whether the fill provided or removed liquidity |
filledSize | string? | Amount filled (absent if no fills yet) |
fee | string? | Total fees paid (absent if no fills yet) |
realizedPnl | string | null? | Realized PnL (present only when closing a position, null otherwise) |
startPosition | string? | Position size before this fill |
classification | FillClassification | How this fill affected the position (see below) |
createdAt | string | ISO 8601 timestamp |
explorerLink | string? | Block-explorer URL for the settling on-chain tx. Absent when the fill has no on-chain tx (every Hyperliquid fill is off-chain). |
FillClassification
Describes how the fill affected the user’s position. Wire values are Title Case strings:| Value | Description |
|---|---|
"Opened Long" | Opened a new long position from zero |
"Opened Short" | Opened a new short position from zero |
"Increased Long" | Added to an existing long position |
"Increased Short" | Added to an existing short position |
"Reduced Long" | Partially closed a long position |
"Reduced Short" | Partially closed a short position |
"Closed Long" | Fully closed a long position |
"Closed Short" | Fully closed a short position |
"Switched Long" | Closed a short and opened a long (crossed zero) |
"Switched Short" | Closed a long and opened a short (crossed zero) |
"Spot Buy" | Spot market buy |
"Spot Sell" | Spot market sell |
Pagination
Use thecursor from the response to fetch the next page:
hasMore is false, there are no more pages.
SDK: getFills()
getActivity
Returns paginated account activity: deposits, withdrawals, liquidations, and funding payments.Parameters
| Name | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | Provider identifier |
address | string | Yes | User’s wallet address |
startTime | integer | No | Filter: activity after this timestamp (ms) |
endTime | integer | No | Filter: activity before this timestamp (ms) |
cursor | string | No | Pagination cursor from previous response |
limit | integer | No | Items per page (default 50, max 200) |
type | ActivityType[] | No | Filter by activity type(s): DEPOSIT, WITHDRAWAL, FUNDING, LIQUIDATION, TRANSFER |
Shape
The response contains a discriminated union of activity items — thetype field determines which fields are present.
Activity Types
All activity items share these base fields:| Field | Type | Description |
|---|---|---|
id | string | Activity ID |
provider | string | Provider identifier |
type | string | Activity type (discriminator) |
timestamp | string | ISO 8601 timestamp |
| Field | Type | Description |
|---|---|---|
amount | string | Deposit amount |
explorerLink | string? | Block-explorer URL for the on-chain deposit tx |
| Field | Type | Description |
|---|---|---|
amount | string | Withdrawal amount |
fee | string | Withdrawal fee |
explorerLink | string? | Block-explorer URL for the on-chain withdrawal tx |
| Field | Type | Description |
|---|---|---|
market | MarketDisplay | Market reference |
amount | string | Funding amount (negative = paid) |
positionSize | string | Position size at time of funding |
fundingRate | string | Funding rate applied |
| Field | Type | Description |
|---|---|---|
liquidatedNotionalPosition | string | Total notional value liquidated |
accountValue | string | Account value at time of liquidation |
leverageType | string | Leverage type (e.g., "Cross") |
liquidatedPositions | LiquidatedPosition[] | Positions that were liquidated |
LiquidatedPosition:
| Field | Type | Description |
|---|---|---|
market | MarketDisplay | Market reference |
size | string | Position size liquidated |
counterpartyAccountIndex / counterpartyAddress MUST be present, and either may appear alone or alongside the other. Consumers that render counterparties should prefer counterpartyAccountIndex when present (canonical handle on index-based providers) and fall back to a truncated counterpartyAddress otherwise.
| Field | Type | Description |
|---|---|---|
direction | 'IN' | 'OUT' | Direction relative to the queried account |
counterpartyAccountIndex | number? | The other side’s account index (required when counterpartyAddress is absent) |
counterpartyAddress | string? | The other side’s wallet address (required when counterpartyAccountIndex is absent) |
asset | string | Asset symbol (e.g., "USDC") |
amount | string | Transfer amount |
meta | object? | Provider-specific metadata |
explorerLink | string? | Block-explorer URL for the on-chain transfer tx |
Pagination
Use thecursor from the response to fetch the next page:
hasMore is false, there are no more pages.
SDK: getActivity()