Skip to content

Add fast option to Hyperliquid l2Book subscriptions#68

Merged
ifdario merged 2 commits into
infinitefield:mainfrom
felix5572:fix/l2book-fast
Jun 19, 2026
Merged

Add fast option to Hyperliquid l2Book subscriptions#68
ifdario merged 2 commits into
infinitefield:mainfrom
felix5572:fix/l2book-fast

Conversation

@felix5572

Copy link
Copy Markdown
Contributor

On June 9th 2026. Hyperliquid announced a websocket push-frequency migration for l2Book:
the default l2Book subscription remains the deeper 20-level snapshot feed,
while clients can opt into fast: true to receive a 5-level book at a
higher cadence(0.5s).

The Rust SDK did not expose the new fast subscription field, forcing
clients to bypass the typed API or hand-roll subscription JSON.

Add fast: Option<bool> to Subscription::L2Book, keep it omitted by
default, update examples/docs/CLI call sites, and add a serialization
round-trip test for both default and fast l2Book subscriptions.

Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions

  Hyperliquid announced a websocket push-frequency migration for l2Book:
  the default l2Book subscription remains the deeper 20-level snapshot feed,
  while clients can opt into `fast: true` to receive a 5-level book at a
  higher cadence.

  The Rust SDK did not expose the new `fast` subscription field, forcing
  clients to bypass the typed API or hand-roll subscription JSON.

  Add `fast: Option<bool>` to `Subscription::L2Book`, keep it omitted by
  default, update examples/docs/CLI call sites, and add a serialization
  round-trip test for both default and fast l2Book subscriptions.

  Docs: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions

@ifdario ifdario left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use fast: bool and skip_serializing_if = "std::ops::Not::not"

  Represent l2Book fast mode as a two-state bool instead of Option<bool>.
  The default false value is omitted from serialized subscription payloads via
  skip_serializing_if = "std::ops::Not::not", while true emits `fast: true`.

  Update examples, docs, CLI subscription construction, and serialization tests.
@felix5572

Copy link
Copy Markdown
Contributor Author

@ifdario Fix, use std::ops::Not::not

@ifdario ifdario merged commit b5ce159 into infinitefield:main Jun 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants