UNPKG

@nktkas/hyperliquid

Version:

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

67 lines (66 loc) 2.98 kB
/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/info/_methods/subAccounts.ts" /> import * as v from "valibot"; import type { ClearinghouseStateResponse } from "./clearinghouseState.js"; import type { SpotClearinghouseStateResponse } from "./spotClearinghouseState.js"; /** * Request user sub-accounts. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-subaccounts */ export declare const SubAccountsRequest: v.ObjectSchema<{ /** Type of request. */ readonly type: v.LiteralSchema<"subAccounts", undefined>; /** User address. */ readonly user: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, `0x${string}`>]>, v.LengthAction<`0x${string}`, 42, undefined>]>; }, undefined>; export type SubAccountsRequest = v.InferOutput<typeof SubAccountsRequest>; /** * Array of user sub-account or null if the user does not have any sub-accounts. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-subaccounts */ export type SubAccountsResponse = { /** Sub-account name. */ name: string; /** * Sub-account address. * @pattern ^0x[a-fA-F0-9]{40}$ */ subAccountUser: `0x${string}`; /** * Master account address. * @pattern ^0x[a-fA-F0-9]{40}$ */ master: `0x${string}`; /** Perpetual trading clearinghouse state summary. */ clearinghouseState: ClearinghouseStateResponse; /** Spot tokens clearinghouse state. */ spotState: SpotClearinghouseStateResponse; }[] | null; import type { InfoConfig } from "./_base/mod.js"; /** Request parameters for the {@linkcode subAccounts} function. */ export type SubAccountsParameters = Omit<v.InferInput<typeof SubAccountsRequest>, "type">; /** * Request user sub-accounts. * * @param config General configuration for Info API requests. * @param params Parameters specific to the API request. * @param signal {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | AbortSignal} to cancel the request. * @return Array of user sub-account or null if the user does not have any sub-accounts. * * @throws {ValidationError} When the request parameters fail validation (before sending). * @throws {TransportError} When the transport layer throws an error. * * @example * ```ts * import { HttpTransport } from "@nktkas/hyperliquid"; * import { subAccounts } from "@nktkas/hyperliquid/api/info"; * * const transport = new HttpTransport(); // or `WebSocketTransport` * * const data = await subAccounts({ transport }, { * user: "0x...", * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-subaccounts */ export declare function subAccounts(config: InfoConfig, params: SubAccountsParameters, signal?: AbortSignal): Promise<SubAccountsResponse>;