Présentation générale
Le StreamL4BookUpdates stream delivers typed order-level book changes as NEW, UPDATE, et REMOVE diffs for one or more coins. It gives clients per-order L4 movement without consuming full L4 book snapshots every block, and without parsing JSON-encoded payloads: every diff is a strongly typed protobuf message.
gRPC : OrderBookStreaming
gRPC : StreamL4BookUpdates
Modèle de mise à jour : Full reset snapshot on subscribe and for mid-stream replacement resets, then typed per-order diffs per block
Comment ça marche ?
- Lors de l'inscription : The first message has
snapshot: trueand contains every resting order as aL4_ORDER_DIFF_TYPE_NEWdiff, a full reset snapshot of the book - Par bloc supplémentaire : Each
L4BookUpdatesUpdatecontains typed diffs for orders that changed:NEW(order entered the book),UPDATE(order size changed),REMOVE(order left the book,szis omitted) - Apply diffs to a local order map keyed by
oidto maintain the current book - Replacement resets: Any later message can also have
snapshot: true, for example when an ALO priority fee insertion changes queue order or when stream state is rebuilt. Whenever a message hassnapshot: true, clear the keyed local order state before applying its diffs, not only on the first message
Unlike StreamL4Book, which sends diffs as a JSON-encoded données string, every field here is a typed protobuf field, so no secondary JSON parsing is required. A single stream can cover multiple coins (or all coins with an empty coins list).
Structure de données
Each L4BookUpdatesUpdate message contains the typed diffs for one block:
{
"time": 1781109115476,
"height": 586405189,
"diffs": [
{ "diff_type": "L4_ORDER_DIFF_TYPE_NEW", "coin": "ETH", "oid": 54764586686,
"user": "0x768484F7e2EBB675C57838366C02Ae99ba2A9B08", "side": "B", "px": "1649.1", "sz": "1.022" }
]
}
Paramètres de requête
| Champ | Type | Obligatoire | Description |
|---|---|---|---|
| coins | repeated string | Non | List of symbols to subscribe to (e.g., "BTC", "ETH"). Empty means all coins |
Dénomination des pièces
Le coins Ce paramètre respecte la convention de nommage Hyperliquid, qui distingue sans ambiguïté les contrats à durée indéterminée des contrats au comptant :
- Titre perpétuel: Human-readable names, such as
« BTC »,« ETH »,« HYPE »,« SOL » - Jetons au comptant:
@{index}format, such as« @1 »,« @107 »,« @142 »,« @166 » - Marchés des résultats (HIP-4):
#Nformat. Chaque résultat comporte deux#Ncoins, one per side (Yes and No). Multi-price question markets consist of multiple grouped outcomes (price buckets plus a fallback), each with its own Yes/No coin pair. Use theoutcomeMetaendpoint mettre en correspondance les indices des cryptomonnaies avec les noms et les côtés du marché. - Exception:
« PURR/USDC »C'est la seule pièce de monnaie dont le nom est lisible.
Il n'y a pas de chevauchement entre les formats. « BTC » fait toujours référence au contrat à terme perpétuel sur BTC ; le BTC au comptant est « @142 ». Pour découvrir @index mappages pour les jetons ponctuels, interroger le méta ou spotMeta points de terminaison d'information.
Champs de réponse
L4BookUpdatesUpdate
| Champ | Type | Description |
|---|---|---|
| temps | uint64 | Horodatage du bloc en millisecondes |
| hauteur | uint64 | Hauteur du bloc |
| instantané | bool | True when the diffs carry a full reset snapshot of all resting orders (sent on subscribe and for mid-stream replacement resets) |
| diffs | L4OrderDiff[] | Typed per-order diffs for this block |
L4OrderDiff
| Champ | Type | Description |
|---|---|---|
| diff_type | L4OrderDiffType | L4_ORDER_DIFF_TYPE_NEW (order entered the book), L4_ORDER_DIFF_TYPE_UPDATE (order size changed), or L4_ORDER_DIFF_TYPE_REMOVE (order left the book) |
| pièce de monnaie | chaîne de caractères | Symbole (par exemple, « BTC », « ETH ») |
| oid | uint64 | Référence unique de la commande |
| utilisateur | chaîne de caractères | Ethereum du titulaire de la commande |
| côté | chaîne de caractères | « A » (Cours vendeur/Vente) ou « B » (Cours acheteur/Achat) |
| px | chaîne de caractères | Order price as a decimal string |
| sz | chaîne de caractères | New/current order size for NEW and UPDATE diffs. Omitted on REMOVE |
Définition de « proto »
StreamL4BookUpdates est défini dans orderbook.proto:
service OrderBookStreaming {
rpc StreamL4BookUpdates (L4BookUpdatesRequest) returns (stream L4BookUpdatesUpdate);
}
message L4BookUpdatesRequest {
repeated string coins = 1;
}
enum L4OrderDiffType {
L4_ORDER_DIFF_TYPE_UNSPECIFIED = 0;
L4_ORDER_DIFF_TYPE_NEW = 1;
L4_ORDER_DIFF_TYPE_UPDATE = 2;
L4_ORDER_DIFF_TYPE_REMOVE = 3;
}
message L4BookUpdatesUpdate {
uint64 time = 1;
uint64 height = 2;
repeated L4OrderDiff diffs = 3;
bool snapshot = 4;
}
message L4OrderDiff {
L4OrderDiffType diff_type = 1;
string coin = 2;
uint64 oid = 3;
string user = 4;
string side = 5;
string px = 6;
string sz = 7;
}
Exemples de mises à jour
Initial Snapshot (first message, truncated)
The first message has snapshot: true and contains every resting order as a NEW diff. Later messages can also carry snapshot: true as a replacement reset; handle each one the same way:
{
"time": 1781109063794,
"height": 586404872,
"snapshot": true,
"diffs": [
{ "diff_type": "L4_ORDER_DIFF_TYPE_NEW", "coin": "BTC", "oid": 54764492622,
"user": "0x039442e06b482Bf01A1a65742cf061bD73A80f31", "side": "B", "px": "62963", "sz": "0.00009" },
{ "diff_type": "L4_ORDER_DIFF_TYPE_NEW", "coin": "BTC", "oid": 54764537698,
"user": "0x3643290CD5DE72b37d2f10A351Ce57c30d103969", "side": "B", "px": "62963", "sz": "0.00024" },
{ "diff_type": "L4_ORDER_DIFF_TYPE_NEW", "coin": "BTC", "oid": 54764482173,
"user": "0x4547B9E33F07965711f67d0bE2423939A4E33aF5", "side": "B", "px": "62955", "sz": "0.00015" }
]
}
Per-Block Update with Removals
sz is omitted on REMOVE diffs:
{
"time": 1781109083796,
"height": 586404997,
"diffs": [
{ "diff_type": "L4_ORDER_DIFF_TYPE_REMOVE", "coin": "BTC", "oid": 54764554671,
"user": "0xc64cc00B46101bd40aA1C3121195E85c0B0918d8", "side": "B", "px": "62389.0" },
{ "diff_type": "L4_ORDER_DIFF_TYPE_REMOVE", "coin": "BTC", "oid": 54764557274,
"user": "0xc64cc00B46101bd40aA1C3121195E85c0B0918d8", "side": "B", "px": "62421.0" }
]
}
New Order and Size Update
A new order entering the book:
{
"time": 1781109115476,
"height": 586405189,
"diffs": [
{ "diff_type": "L4_ORDER_DIFF_TYPE_NEW", "coin": "ETH", "oid": 54764586686,
"user": "0x768484F7e2EBB675C57838366C02Ae99ba2A9B08", "side": "B", "px": "1649.1", "sz": "1.022" }
]
}
A size change on a resting order (sz is the new current size):
{ "diff_type": "L4_ORDER_DIFF_TYPE_UPDATE", "coin": "ETH", "oid": 54764551695,
"user": "0x4547B9E33F07965711f67d0bE2423939A4E33aF5", "side": "B", "px": "1702.9", "sz": "0.0032" }
Utilisation de l'API
gRPC
// Single coin
const request = {
coins: ['BTC']
};
// Multiple coins in one stream
const multiRequest = {
coins: ['BTC', 'ETH']
};
// All coins
const allCoinsRequest = {
coins: []
};
StreamL4BookUpdates n'est disponible que via l'API gRPC (OrderBookStreaming service). Il n'est pas disponible via JSON-RPC ou WebSocket.
Comparison: L4 Book Updates vs L4 Book vs Book Updates Dataset
| Fonctionnalité | StreamL4BookUpdates | StreamL4Book | MISE À JOUR DES LIVRES |
|---|---|---|---|
| Granularité | Individual orders, typed diffs | Commandes individuelles | Différences au niveau des commandes individuelles |
| Diff encoding | Typed protobuf (NEW/UPDATE/REMOVE) | JSON-encoded data string | JSON objects |
| Comprend l'état actuel | Yes (reset snapshot as NEW diffs) | Yes (initial snapshot) | No (forward-only) |
| Nécessite le démarrage REST | Non | Non | Oui |
| Coins per stream | Multiple (or all coins) | One coin per stream | Filterable |
| Détails par commande | User, oid, side, px, sz | Utilisateur, oid, déclencheurs, horodatages, tif | Utilisateur, oid, taille |
| Idéal pour | Per-order book tracking without JSON parsing | Full order detail (triggers, tif, cloid) | Les clients qui ont uniquement besoin de mises à jour de livres |
Remarques importantes
- Reset on every
snapshot: truemessage: The first message is a full reset with all resting orders asNEWdiffs, and replacement resets can arrive mid-stream (for example after an ALO priority fee queue insertion). Clear any local state and rebuild wheneverinstantanéis true, not only on subscribe and reconnect REMOVEomitssz: Remove diffs identify the order byoid(withpièce de monnaie,utilisateur,côté,px) but carry no size. Delete the order from your local map- Typed alternative to StreamL4Book: If you need trigger info, timestamps,
tif, orcloïdeper order, useStreamL4Book; if you need lean typed per-order movement, use this stream - zstd compression recommended: Enable zstd compression on your gRPC channel to reduce bandwidth, especially when streaming multiple coins
Streams associés
- StreamL4Book - Full order book at order granularity with snapshot + JSON-encoded diffs
- StreamL2BookDiff - Incremental L2 price-level changes with sequence numbers
- Commandes - Événements liés au cycle de vie des commandes (en cours, exécutées, annulées, etc.)