Positions Channel

Real-time position updates with initial snapshot.

Channel: positions
Authentication: Required


Subscribe

{
  "method": "subscribe",
  "params": {
    "channel": "positions",
    "market_ids": [1, 2]
  }
}
ParameterTypeRequiredDescription
market_idsnumber[]NoFilter by market IDs. Empty = all markets
makersstring[]NoAccount filter. Omit it — an authenticated client is scoped to its own account

Authenticate before subscribing: for an authenticated client the subscription is scoped to its own account.

Message Format

Snapshot

Sent immediately after subscribing. Contains your positions in the subscribed markets.

{
  "method": "snapshot",
  "channel": "positions",
  "type": "snapshot",
  "data": [
    {
      "account": "0x1234567890123456789012345678901234567890",
      "market_id": "1",
      "size": "0.020463",
      "quote_amount": "-1456.615970721655103383",
      "side": "BUY",
      "margin_mode": 0,
      "leverage": "25",
      "avg_entry_price": "66819.6",
      "isolated_usdc_balance": "0",
      "last_funding_payment": "-1343.280402365544640442",
      "unsettled_funding": "3.82702329635071426",
      "block_number": "0",
      "log_index": "0",
      "worker_timestamp": "0"
    }
  ],
  "position_count": 1,
  "worker_timestamp": "1786934110123456789"
}

Snapshot rows are rebuilt from current state, so their per-row block_number, log_index and worker_timestamp are all "0". Only rows on update messages carry real block metadata.

Update

Sent when one of your positions is opened, modified, or closed.

{
  "channel": "positions",
  "type": "update",
  "market_id": "1",
  "data": [
    {
      "account": "0xE11651462598edA667b2ca42f523b3a87f559aE0",
      "market_id": "1",
      "size": "0",
      "quote_amount": "0",
      "side": "SELL",
      "margin_mode": 0,
      "leverage": "11",
      "avg_entry_price": "0",
      "isolated_usdc_balance": "0",
      "last_funding_payment": "-1317.375850280955754602",
      "unsettled_funding": "0",
      "block_number": "19328351",
      "log_index": "527",
      "worker_timestamp": "1786934110000000000"
    }
  ],
  "block_number": 19328351,
  "log_index": 527,
  "worker_timestamp": "1786934110234567891"
}

data is always an array. A closed position is reported as size: "0" rather than being omitted.

Snapshot Message Fields

FieldTypeDescription
methodstringAlways "snapshot"
channelstringAlways "positions"
typestringAlways "snapshot"
dataarrayArray of position objects
position_countnumberNumber of positions in the array
worker_timestampstringServer time in nanoseconds

The snapshot carries no market_id and no block metadata.

Update Message Fields

FieldTypeDescription
channelstringAlways "positions"
typestringAlways "update"
market_idstringMarket ID
dataarrayArray of position objects
block_numbernumberBlockchain block number
log_indexnumberLog index within the block
worker_timestampstringServer time in nanoseconds

Position updates carry no tx_hash, and there is no timestamp or block_timestamp field on this channel.

Position Object Fields

FieldTypeDescription
accountstringAccount address
market_idstringMarket ID
sizestringSigned position size, decimal — negative on a short, "0" when flat
quote_amountstringSigned cumulative quote, decimal. Normally the opposite sign to size; a partial reduce folds realised PnL into it and can leave both the same sign
sidestring"BUY" (long) or "SELL" (short)
margin_modenumber0 = cross, 1 = isolated — a number, not a string
leveragestringLeverage multiplier, decimal ("11" = 11×)
avg_entry_pricestringWeighted average entry price, decimal
isolated_usdc_balancestringMargin assigned to this position in isolated mode, decimal
last_funding_paymentstringFunding checkpoint stored on the position, decimal
unsettled_fundingstring(accumulated_funding − last_funding_payment) × size, decimal
block_numberstringBlock of the last update (string, unlike the envelope's number)
log_indexstringLog index of the last update (string, unlike the envelope's number)
worker_timestampstringPer-object server time in nanoseconds; "0" on snapshot rows
🚧

side is not a flat indicator

side mirrors the sign of size on an open position, but a closed position keeps whichever direction it last held while size goes to "0". Read size — its sign is authoritative for both direction and flatness.

Examples

Subscribe to all markets

{
  "method": "subscribe",
  "params": {
    "channel": "positions"
  }
}

Subscribe to specific markets

{
  "method": "subscribe",
  "params": {
    "channel": "positions",
    "market_ids": [1, 2]
  }
}

Unsubscribe

{
  "method": "unsubscribe",
  "params": {
    "channel": "positions"
  }
}

Notes

Price Format

All size, price and USDC fields are decimal strings, not wei.

Private Channel

Authenticate before subscribing. The channel is meant to carry your own positions only.