Cascade
Account

Subscribe Stats

Subscribe to account statistics (UPnL, cross leverage, maintenance margin, account value, free collateral, etc.). Updates are published at a fixed interval (every 5 seconds). Supports delegation - users can subscribe to accounts they are delegated to access.

Subscribe to account stats (requires authentication, supports delegation)#

Subscribe to account statistics (UPnL, cross leverage, maintenance margin, account value, free collateral, etc.). Updates are published at a fixed interval (every 5 seconds). Supports delegation - users can subscribe to accounts they are delegated to access.

Channel:WEBSOCKET
Tag:
Account

Request to subscribe to account stats (requires authentication, supports delegation)

Parameters

sourcestring

Must be 'stats'

accountstring

Ethereum address of the account (must match authenticated user or user must be a delegate)

subaccountIndicesarray

Array of subaccount indices. - Empty array []: Subscribes to ALL subaccounts (owner only - delegation not allowed) - Non-empty array: Subscribes to the specified subaccounts (delegation allowed) For delegated access, delegation is checked for ALL specified subaccounts. Subscription fails if user lacks delegation for any subaccount in the array.

Payload
{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": {
    "source": "stats",
    "account": "0xe1c03ec3bcf509b3e8e63abcd03edc661ffe6a78",
    "subaccountIndices": [
      0
    ]
  },
  "id": 10
}

Generic success response for subscription requests

Parameters

message?string

Success message

Payload
{
  "jsonrpc": "2.0",
  "result": {
    "message": "Subscribed to trades"
  },
  "usIn": 1234567890123,
  "usOut": 1234567890456,
  "usDiff": 333,
  "id": 2
}

stats#

REPLY

Published at a fixed interval (every 5 seconds) for the subscribed account and subaccount. Contains UPnL, cross leverage, maintenance margin, account value, free collateral, etc. Wrapped with type field to identify the message type.

Parameters

accountstring

Ethereum address of the account

subaccountIndexinteger

Subaccount index

upnlstring

Total unrealized profit and loss across all positions

crossLeveragestring

Cross-margin leverage (cross notional / cross account equity)

crossMarginUsagestring

Cross-margin usage (cross initial margin requirement / cross account equity)

maintMarginstring

Total maintenance margin requirement across all positions

crossMarginRatiostring

Cross-margin ratio (cross account equity / cross maintenance margin requirement)

accountValuestring

Account value (balance + cross UPnL)

initialMarginRequirementstring

Total initial margin requirement for all positions and orders

freeCollateralstring

Amount available for withdrawals

Payload
{
  "type": "Stats",
  "data": {
    "account": "0xe1c03ec3bcf509b3e8e63abcd03edc661ffe6a78",
    "subaccountIndex": 0,
    "upnl": "1234.567",
    "crossLeverage": "2.5",
    "crossMarginUsage": "0.38",
    "maintMargin": "5000.123",
    "crossMarginRatio": "0.4",
    "accountValue": "10000.0",
    "initialMarginRequirement": "5100.0",
    "freeCollateral": "4500.0"
  }
}

Error response for failed requests

Parameters

jsonrpcstring

JSON-RPC version

errorobject
usIninteger

Request received timestamp in milliseconds

usOutinteger

Response sent timestamp in milliseconds

usDiffinteger

Processing time in milliseconds

id?string | integer | null

Request identifier (if provided in request, otherwise null)

Payload
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32602,
    "message": "Invalid subscription params"
  },
  "usIn": 1234567890123,
  "usOut": 1234567890456,
  "usDiff": 333,
  "id": 2
}