Perps L2 Grouped

l2:perps:grouped

Price-bucketed depth snapshot for depth chart rendering. Conservative bucketing: bids floor, asks ceil — each side rounds away from the spread so grouped depth never overstates near-spread liquidity. Published every 250ms when the book has updates.

Channel: l2:perps:grouped:{bucket}:{instrument} Example: l2:perps:grouped:0.5:ETH_USDC-PERPETUAL

Payload

{
  "timestamp": 1704067200000,
  "bids": [
    ["2495", "15000.5", "15000.5"],
    ["2494.5", "8200", "23200.5"]
  ],
  "asks": [
    ["2495.5", "12000", "12000"],
    ["2496", "9500", "21500"]
  ]
}
FieldTypeDescription
timestampintegerUnix timestamp in milliseconds
bidsarrayBid levels, best (highest) first. Each: [price, amount, cumulative]
asksarrayAsk levels, best (lowest) first. Each: [price, amount, cumulative]

Level array elements:

IndexTypeDescription
0stringBucket boundary price (bids floored, asks ceiled)
1stringTotal amount at this bucket (notional USD)
2stringCumulative amount from best to this level

Available Buckets

InstrumentBuckets
ETH_USDC-PERPETUAL0.1, 0.2, 0.5, 1, 10, 100
BTC_USDC-PERPETUAL1, 2, 5, 10, 100, 1000

Subscribe — Raw WebSocket

const ws = new WebSocket("wss://staging.kyan.sh/stream/websocket");
let id = 0;

ws.onopen = () => ws.send(JSON.stringify({ id: ++id, connect: {} }));

ws.onmessage = (e) => {
  const msg = JSON.parse(e.data);

  if (Object.keys(msg).length === 0) { ws.send("{}"); return; } // ping

  if (msg.id === 1) {
    ws.send(JSON.stringify({
      id: ++id,
      subscribe: { channel: "l2:perps:grouped:0.5:ETH_USDC-PERPETUAL", recover: true },
    }));
    return;
  }

  if (msg.push?.pub) {
    const { timestamp, bids, asks } = msg.push.pub.data;
    // Each level: [bucketPrice, amount, cumulativeAmount] — all strings
    // bids: price floored to bucket boundary
    // asks: price ceiled to bucket boundary
  }
};

Recovery

Subscribe with since: {} to receive the last known snapshot on subscribe. On reconnect, the SDK automatically recovers.

Related channels

Channels providing related data.

ChannelWhy
Perps L2Raw ungrouped depth with exact prices and order counts. This channel is a bucketed aggregation of that data.
Perps BBOExact top-of-book prices. Grouped bucketing rounds away from the spread, so the first grouped level may differ from BBO.
Index PriceSpot price for the underlying pair.