@nktkas/hyperliquid
Version:
Hyperliquid API SDK for all major JS runtimes, written in TypeScript.
844 lines (843 loc) • 42.9 kB
TypeScript
/**
* Client for the Hyperliquid Subscription API endpoint.
* @module
*/
/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/subscription/client.ts" />
import type { ISubscription } from "../../transport/mod.js";
import type { SubscriptionConfig, SubscriptionOptions } from "./_methods/_base/mod.js";
import { type ActiveAssetCtxEvent, type ActiveAssetCtxParameters } from "./_methods/activeAssetCtx.js";
import { type ActiveAssetDataEvent, type ActiveAssetDataParameters } from "./_methods/activeAssetData.js";
import { type ActiveSpotAssetCtxEvent, type ActiveSpotAssetCtxParameters } from "./_methods/activeSpotAssetCtx.js";
import { type AllDexsAssetCtxsEvent } from "./_methods/allDexsAssetCtxs.js";
import { type AllDexsClearinghouseStateEvent, type AllDexsClearinghouseStateParameters } from "./_methods/allDexsClearinghouseState.js";
import { type AllMidsEvent, type AllMidsParameters } from "./_methods/allMids.js";
import { type AssetCtxsEvent, type AssetCtxsParameters } from "./_methods/assetCtxs.js";
import { type BboEvent, type BboParameters } from "./_methods/bbo.js";
import { type CandleEvent, type CandleParameters } from "./_methods/candle.js";
import { type ClearinghouseStateEvent, type ClearinghouseStateParameters } from "./_methods/clearinghouseState.js";
import { type FastAssetCtxsEvent } from "./_methods/fastAssetCtxs.js";
import { type L2BookEvent, type L2BookParameters } from "./_methods/l2Book.js";
import { type NotificationEvent, type NotificationParameters } from "./_methods/notification.js";
import { type OpenOrdersEvent, type OpenOrdersParameters } from "./_methods/openOrders.js";
import { type OrderUpdatesEvent, type OrderUpdatesParameters } from "./_methods/orderUpdates.js";
import { type OutcomeMetaUpdatesEvent } from "./_methods/outcomeMetaUpdates.js";
import { type SpotAssetCtxsEvent } from "./_methods/spotAssetCtxs.js";
import { type SpotStateEvent, type SpotStateParameters } from "./_methods/spotState.js";
import { type TradesEvent, type TradesParameters } from "./_methods/trades.js";
import { type TwapStatesEvent, type TwapStatesParameters } from "./_methods/twapStates.js";
import { type UserEventsEvent, type UserEventsParameters } from "./_methods/userEvents.js";
import { type UserFillsEvent, type UserFillsParameters } from "./_methods/userFills.js";
import { type UserFundingsEvent, type UserFundingsParameters } from "./_methods/userFundings.js";
import { type UserHistoricalOrdersEvent, type UserHistoricalOrdersParameters } from "./_methods/userHistoricalOrders.js";
import { type UserNonFundingLedgerUpdatesEvent, type UserNonFundingLedgerUpdatesParameters } from "./_methods/userNonFundingLedgerUpdates.js";
import { type UserTwapHistoryEvent, type UserTwapHistoryParameters } from "./_methods/userTwapHistory.js";
import { type UserTwapSliceFillsEvent, type UserTwapSliceFillsParameters } from "./_methods/userTwapSliceFills.js";
import { type WebData2Event, type WebData2Parameters } from "./_methods/webData2.js";
import { type WebData3Event, type WebData3Parameters } from "./_methods/webData3.js";
/**
* Real-time data via WebSocket subscriptions.
*
* Corresponds to {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | WebSocket subscriptions}.
*/
export declare class SubscriptionClient<C extends SubscriptionConfig = SubscriptionConfig> {
config_: C;
/**
* Creates an instance of the SubscriptionClient.
*
* @param config Configuration for Subscription API requests. See {@link SubscriptionConfig}.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
*
* const subsClient = new hl.SubscriptionClient({ transport });
* ```
*/
constructor(config: C);
/**
* Subscribe to context updates for a specific perpetual asset.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.activeAssetCtx({ coin: "ETH" }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
activeAssetCtx(params: ActiveAssetCtxParameters, listener: (data: ActiveAssetCtxEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to trading data updates for a specific asset and user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.activeAssetData({ coin: "ETH", user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
activeAssetData(params: ActiveAssetDataParameters, listener: (data: ActiveAssetDataEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to context updates for a specific spot asset.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.activeSpotAssetCtx({ coin: "@1" }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
activeSpotAssetCtx(params: ActiveSpotAssetCtxParameters, listener: (data: ActiveSpotAssetCtxEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to asset contexts for all DEXs.
*
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.allDexsAssetCtxs((data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
allDexsAssetCtxs(listener: (data: AllDexsAssetCtxsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to clearinghouse states for all DEXs for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.allDexsClearinghouseState({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
allDexsClearinghouseState(params: AllDexsClearinghouseStateParameters, listener: (data: AllDexsClearinghouseStateEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to mid prices for all actively traded assets.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.allMids((data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
allMids(listener: (data: AllMidsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
allMids(params: AllMidsParameters, listener: (data: AllMidsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to asset contexts for all perpetual assets.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.assetCtxs((data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
assetCtxs(listener: (data: AssetCtxsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
assetCtxs(params: AssetCtxsParameters, listener: (data: AssetCtxsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to best bid and offer updates for a specific asset.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.bbo({ coin: "ETH" }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
bbo(params: BboParameters, listener: (data: BboEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to candlestick data updates for a specific asset.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.candle({ coin: "ETH", interval: "1h" }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
candle(params: CandleParameters, listener: (data: CandleEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to clearinghouse state updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.clearinghouseState({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
clearinghouseState(params: ClearinghouseStateParameters, listener: (data: ClearinghouseStateEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to mark and mid prices for all assets.
*
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.fastAssetCtxs((data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
fastAssetCtxs(listener: (data: FastAssetCtxsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to L2 order book updates for a specific asset.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.l2Book({ coin: "ETH" }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
l2Book(params: L2BookParameters, listener: (data: L2BookEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to notification updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.notification({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
notification(params: NotificationParameters, listener: (data: NotificationEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to open orders updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.openOrders({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
openOrders(params: OpenOrdersParameters, listener: (data: OpenOrdersEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to order status updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.orderUpdates({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
orderUpdates(params: OrderUpdatesParameters, listener: (data: OrderUpdatesEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to prediction market outcome/question metadata updates.
*
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.outcomeMetaUpdates((data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
outcomeMetaUpdates(listener: (data: OutcomeMetaUpdatesEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to context updates for all spot assets.
*
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.spotAssetCtxs((data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
spotAssetCtxs(listener: (data: SpotAssetCtxsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to spot state updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.spotState({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
spotState(params: SpotStateParameters, listener: (data: SpotStateEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to real-time trade updates for a specific asset.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.trades({ coin: "ETH" }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
trades(params: TradesParameters, listener: (data: TradesEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to TWAP states updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.twapStates({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
twapStates(params: TwapStatesParameters, listener: (data: TwapStatesEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to non-order events for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.userEvents({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
userEvents(params: UserEventsParameters, listener: (data: UserEventsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to trade fill updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.userFills({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
userFills(params: UserFillsParameters, listener: (data: UserFillsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to funding payment updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.userFundings({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
userFundings(params: UserFundingsParameters, listener: (data: UserFundingsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to historical order updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.userHistoricalOrders({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
userHistoricalOrders(params: UserHistoricalOrdersParameters, listener: (data: UserHistoricalOrdersEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to non-funding ledger updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.userNonFundingLedgerUpdates({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
userNonFundingLedgerUpdates(params: UserNonFundingLedgerUpdatesParameters, listener: (data: UserNonFundingLedgerUpdatesEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to TWAP order history updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.userTwapHistory({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
userTwapHistory(params: UserTwapHistoryParameters, listener: (data: UserTwapHistoryEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to TWAP execution updates for a specific user.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.userTwapSliceFills({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
userTwapSliceFills(params: UserTwapSliceFillsParameters, listener: (data: UserTwapSliceFillsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to comprehensive user and market data updates.
*
* @deprecated use {@linkcode webData3} and other component subscriptions instead.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.webData2({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
webData2(params: WebData2Parameters, listener: (data: WebData2Event) => void, options?: SubscriptionOptions): Promise<ISubscription>;
/**
* Subscribe to comprehensive user and market data updates.
*
* @param params Parameters specific to the API subscription.
* @param listener A callback function to be called when the event is received.
* @param options Options to control the subscription lifecycle.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const transport = new hl.WebSocketTransport();
* const client = new hl.SubscriptionClient({ transport });
*
* const sub = await client.webData3({ user: "0x..." }, (data) => {
* console.log(data);
* });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
webData3(params: WebData3Parameters, listener: (data: WebData3Event) => void, options?: SubscriptionOptions): Promise<ISubscription>;
}
export type { SubscriptionConfig, SubscriptionOptions } from "./_methods/_base/mod.js";
export type { ActiveAssetCtxEvent as ActiveAssetCtxWsEvent, ActiveAssetCtxParameters as ActiveAssetCtxWsParameters, } from "./_methods/activeAssetCtx.js";
export type { ActiveAssetDataEvent as ActiveAssetDataWsEvent, ActiveAssetDataParameters as ActiveAssetDataWsParameters, } from "./_methods/activeAssetData.js";
export type { ActiveSpotAssetCtxEvent as ActiveSpotAssetCtxWsEvent, ActiveSpotAssetCtxParameters as ActiveSpotAssetCtxWsParameters, } from "./_methods/activeSpotAssetCtx.js";
export type { AllDexsAssetCtxsEvent as AllDexsAssetCtxsWsEvent } from "./_methods/allDexsAssetCtxs.js";
export type { AllDexsClearinghouseStateEvent as AllDexsClearinghouseStateWsEvent, AllDexsClearinghouseStateParameters as AllDexsClearinghouseStateWsParameters, } from "./_methods/allDexsClearinghouseState.js";
export type { AllMidsEvent as AllMidsWsEvent, AllMidsParameters as AllMidsWsParameters } from "./_methods/allMids.js";
export type { AssetCtxsEvent as AssetCtxsWsEvent, AssetCtxsParameters as AssetCtxsWsParameters, } from "./_methods/assetCtxs.js";
export type { BboEvent as BboWsEvent, BboParameters as BboWsParameters } from "./_methods/bbo.js";
export type { CandleEvent as CandleWsEvent, CandleParameters as CandleWsParameters } from "./_methods/candle.js";
export type { ClearinghouseStateEvent as ClearinghouseStateWsEvent, ClearinghouseStateParameters as ClearinghouseStateWsParameters, } from "./_methods/clearinghouseState.js";
export type { FastAssetCtxsEvent as FastAssetCtxsWsEvent } from "./_methods/fastAssetCtxs.js";
export type { L2BookEvent as L2BookWsEvent, L2BookParameters as L2BookWsParameters } from "./_methods/l2Book.js";
export type { NotificationEvent as NotificationWsEvent, NotificationParameters as NotificationWsParameters, } from "./_methods/notification.js";
export type { OpenOrdersEvent as OpenOrdersWsEvent, OpenOrdersParameters as OpenOrdersWsParameters, } from "./_methods/openOrders.js";
export type { OrderUpdatesEvent as OrderUpdatesWsEvent, OrderUpdatesParameters as OrderUpdatesWsParameters, } from "./_methods/orderUpdates.js";
export type { OutcomeMetaUpdatesEvent as OutcomeMetaUpdatesWsEvent } from "./_methods/outcomeMetaUpdates.js";
export type { SpotAssetCtxsEvent as SpotAssetCtxsWsEvent } from "./_methods/spotAssetCtxs.js";
export type { SpotStateEvent as SpotStateWsEvent, SpotStateParameters as SpotStateWsParameters, } from "./_methods/spotState.js";
export type { TradesEvent as TradesWsEvent, TradesParameters as TradesWsParameters } from "./_methods/trades.js";
export type { TwapStatesEvent as TwapStatesWsEvent, TwapStatesParameters as TwapStatesWsParameters, } from "./_methods/twapStates.js";
export type { UserEventsEvent as UserEventsWsEvent, UserEventsParameters as UserEventsWsParameters, } from "./_methods/userEvents.js";
export type { UserFillsEvent as UserFillsWsEvent, UserFillsParameters as UserFillsWsParameters, } from "./_methods/userFills.js";
export type { UserFundingsEvent as UserFundingsWsEvent, UserFundingsParameters as UserFundingsWsParameters, } from "./_methods/userFundings.js";
export type { UserHistoricalOrdersEvent as UserHistoricalOrdersWsEvent, UserHistoricalOrdersParameters as UserHistoricalOrdersWsParameters, } from "./_methods/userHistoricalOrders.js";
export type { UserNonFundingLedgerUpdatesEvent as UserNonFundingLedgerUpdatesWsEvent, UserNonFundingLedgerUpdatesParameters as UserNonFundingLedgerUpdatesWsParameters, } from "./_methods/userNonFundingLedgerUpdates.js";
export type { UserTwapHistoryEvent as UserTwapHistoryWsEvent, UserTwapHistoryParameters as UserTwapHistoryWsParameters, } from "./_methods/userTwapHistory.js";
export type { UserTwapSliceFillsEvent as UserTwapSliceFillsWsEvent, UserTwapSliceFillsParameters as UserTwapSliceFillsWsParameters, } from "./_methods/userTwapSliceFills.js";
export type { WebData2Event as WebData2WsEvent, WebData2Parameters as WebData2WsParameters, } from "./_methods/webData2.js";
export type { WebData3Event as WebData3WsEvent, WebData3Parameters as WebData3WsParameters, } from "./_methods/webData3.js";