View Source Hyperliquid.Api.Subscription.WebData3 (hyperliquid v0.2.2)
WebSocket subscription for comprehensive user and market data (v3 format).
Auto-generated from @nktkas/hyperliquid v0.26.0 Source: src/api/subscription/webData3.ts
Description
Subscription to comprehensive user and market data events with support for multiple perpetual DEXes (HIP-3). This is the newer format that separates user state from per-DEX states.
Key Differences from WebData2
- User state is separated into its own object
- Supports multiple perpetual DEX states (for HIP-3 DEX abstraction)
- More structured data organization
- Includes DEX abstraction flag
Usage
# Subscribe to webData3 events
params = %{user: "0x..."}
Hyperliquid.Api.Subscription.WebData3.subscribe(params, fn event ->
IO.inspect(event.user_state, label: "User State")
IO.inspect(event.perp_dex_states, label: "DEX States")
end)
Summary
Functions
Returns postgres table configurations (multi-table support).
Returns storage configuration for this subscription.
Returns metadata about this subscription endpoint.
Build a cache key from event data using the configured pattern.
Build and validate a subscription request.
Returns true if cache storage is enabled.
Returns the configured cache fields for partial storage, or nil for all fields.
Returns the cache TTL if configured.
Changeset for validating webData3 event data.
Check if DEX abstraction is enabled for this user.
Generate a unique subscription key for this parameter set.
Get the main DEX state (first in the array, usually the primary DEX).
Parses raw WebSocket event data into structured format.
Returns true if postgres storage is enabled.
Returns the configured postgres fields for partial storage, or nil for all fields.
Returns the postgres table name if configured (primary table for legacy support).
Returns true if any storage backend is enabled.
Subscribe to webData3 events for a specific user.
Get total vault equity across all DEXes.
Types
@type request_params() :: %{user: term()}
Functions
Returns postgres table configurations (multi-table support).
Returns storage configuration for this subscription.
Returns metadata about this subscription endpoint.
Build a cache key from event data using the configured pattern.
Returns nil if cache is not enabled or no pattern is configured.
@spec build_request(map()) :: {:ok, map()} | {:error, Ecto.Changeset.t()}
@spec build_request(map()) :: {:ok, map()} | {:error, Ecto.Changeset.t()}
Build and validate a subscription request.
Parameters
params- Map with keys: [:user]
Returns
{:ok, request_map}- Valid subscription request{:error, changeset}- Validation errors
Returns true if cache storage is enabled.
Returns the configured cache fields for partial storage, or nil for all fields.
Returns the cache TTL if configured.
Changeset for validating webData3 event data.
Check if DEX abstraction is enabled for this user.
Generate a unique subscription key for this parameter set.
Parameters
params- Map of subscription parameters
Returns
String key that uniquely identifies this subscription variant.
Get the main DEX state (first in the array, usually the primary DEX).
Parses raw WebSocket event data into structured format.
Returns true if postgres storage is enabled.
Returns the configured postgres fields for partial storage, or nil for all fields.
Returns the postgres table name if configured (primary table for legacy support).
Returns true if any storage backend is enabled.
Subscribe to webData3 events for a specific user.
Parameters
params: Map with:userkey (Ethereum address)callback: Function to handle incoming events
Returns
{:ok, subscription}- Subscription handle{:error, reason}- If subscription fails
Example
WebData3.subscribe(
%{user: "0x1234..."},
fn event ->
IO.inspect(event.user_state.is_vault, label: "Is Vault")
Enum.each(event.perp_dex_states, fn dex_state ->
IO.puts("Vault equity: #{dex_state.total_vault_equity}")
end)
end
)
Get total vault equity across all DEXes.