UNPKG

@nktkas/hyperliquid

Version:

Hyperliquid API SDK for all major JS runtimes, written in TypeScript.

47 lines (46 loc) 2.12 kB
/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/subscription/_methods/spotAssetCtxs.ts" /> import * as v from "valibot"; import type { SpotAssetCtx } from "../../info/_methods/_base/mod.js"; /** * Subscription to context events for all spot assets. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions */ export declare const SpotAssetCtxsRequest: v.ObjectSchema<{ /** Type of subscription. */ readonly type: v.LiteralSchema<"spotAssetCtxs", undefined>; }, undefined>; export type SpotAssetCtxsRequest = v.InferOutput<typeof SpotAssetCtxsRequest>; /** * Event of spot asset contexts. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions */ export type SpotAssetCtxsEvent = SpotAssetCtx[]; import type { ISubscription } from "../../../transport/mod.js"; import type { SubscriptionConfig, SubscriptionOptions } from "./_base/mod.js"; /** * Subscribe to context updates for all spot assets. * * @param config General configuration for Subscription API subscriptions. * @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 { WebSocketTransport } from "@nktkas/hyperliquid"; * import { spotAssetCtxs } from "@nktkas/hyperliquid/api/subscription"; * * const transport = new WebSocketTransport(); * * const sub = await spotAssetCtxs( * { transport }, * (data) => console.log(data), * ); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions */ export declare function spotAssetCtxs(config: SubscriptionConfig, listener: (data: SpotAssetCtxsEvent) => void, options?: SubscriptionOptions): Promise<ISubscription>;