Skip to content

hyperliquid-dex/order_book_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Local WebSocket Server

Disclaimer

This was a standalone project, not written by the Hyperliquid Labs core team. It is made available "as is", without warranty of any kind, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, or noninfringement. Use at your own risk. It is intended for educational or illustrative purposes only and may be incomplete, insecure, or incompatible with future systems. No commitment is made to maintain, update, or fix any issues in this repository.

Functionality

This server provides the l2book and trades endpoints from Hyperliquid’s official API, with roughly the same API.

  • The l2book subscription now includes an optional field: n_levels, which can be up to 100 and defaults to 20.
  • This server also introduces a new endpoint: l4book.

The l4book subscription first sends a snapshot of the entire book and then forwards order diffs by block. The subscription format is:

{
  "method": "subscribe",
  "subscription": {
    "type": "l4Book",
    "coin": "<coin_symbol>"
  }
}

Setup

  1. Run a non-validating node (from hyperliquid-dex/node). Requires batching by block. Requires recording fills, order statuses, and raw book diffs.

  2. Then run this local server:

cargo run --release --bin websocket_server -- --address 0.0.0.0 --port 8000

If this local server does not detect the node writing down any new events, it will automatically exit after some amount of time (currently set to 5 seconds). In addition, the local server periodically fetches order book snapshots from the node, and compares to its own internal state. If a difference is detected, it will exit.

If you want logging, prepend the command with RUST_LOG=info.

The WebSocket server comes with compression built-in. The compression ratio can be tuned using the --websocket-compression-level flag.

Caveats

  • This server does not show untriggered trigger orders.
  • It currently does not support spot order books.
  • The current implementation batches node outputs by block, making the order book a few milliseconds slower than a streaming implementation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages