UNPKG

@nktkas/hyperliquid

Version:

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

148 lines (147 loc) 5.03 kB
/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/info/_methods/spotClearinghouseState.ts" /> import * as v from "valibot"; /** * Request spot clearinghouse state. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances */ export declare const SpotClearinghouseStateRequest: v.ObjectSchema<{ /** Type of request. */ readonly type: v.LiteralSchema<"spotClearinghouseState", 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 SpotClearinghouseStateRequest = v.InferOutput<typeof SpotClearinghouseStateRequest>; /** * Account summary for spot trading. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances */ export type SpotClearinghouseStateResponse = { /** Whether portfolio margin is enabled for the account. */ portfolioMarginEnabled?: boolean; /** Array of available token balances. */ balances: ({ /** Asset symbol (e.g., USDC). */ coin: string; /** Unique identifier for the token. */ token: number; /** * Total balance. * @pattern ^-?[0-9]+(\.[0-9]+)?$ */ total: string; /** * Amount on hold. * @pattern ^-?[0-9]+(\.[0-9]+)?$ */ hold: string; /** * Entry notional value. * @pattern ^-?[0-9]+(\.[0-9]+)?$ */ entryNtl: string; /** * Amount on hold in spot. * @pattern ^-?[0-9]+(\.[0-9]+)?$ */ spotHold?: string; /** * Loan-to-value ratio. * @pattern ^[0-9]+(\.[0-9]+)?$ */ ltv?: string; /** * Borrowed amount. * @pattern ^[0-9]+(\.[0-9]+)?$ */ borrowed?: string; /** * Supplied amount. * @pattern ^[0-9]+(\.[0-9]+)?$ */ supplied?: string; } | { /** Outcome market identifier ("+" followed by `assetId - 100000000`). */ coin: `+${number}`; /** * Total balance. * @pattern ^[0-9]+(\.[0-9]+)?$ */ total: string; /** * Amount on hold. * @pattern ^[0-9]+(\.[0-9]+)?$ */ hold: string; /** * Entry notional value. * @pattern ^[0-9]+(\.[0-9]+)?$ */ entryNtl: string; })[]; /** Array of escrowed balances. */ evmEscrows?: { /** Asset symbol (e.g., USDC). */ coin: string; /** Unique identifier for the token. */ token: number; /** * Total balance. * @pattern ^[0-9]+(\.[0-9]+)?$ */ total: string; }[]; /** * Portfolio margin ratio. * @pattern ^[0-9]+(\.[0-9]+)?$ */ portfolioMarginRatio?: string; /** Portfolio borrow ratio per token. */ tokenToPortfolioBorrowRatio?: [ /** Token identifier. */ token: number, /** * Borrow ratio. * @pattern ^[0-9]+(\.[0-9]+)?$ */ ratio: string ][]; /** Amount available after maintenance per token. */ tokenToAvailableAfterMaintenance?: [ /** Token identifier. */ token: number, /** * Available amount. * @pattern ^[0-9]+(\.[0-9]+)?$ */ amount: string ][]; }; import type { InfoConfig } from "./_base/mod.js"; /** Request parameters for the {@linkcode spotClearinghouseState} function. */ export type SpotClearinghouseStateParameters = Omit<v.InferInput<typeof SpotClearinghouseStateRequest>, "type">; /** * Request spot clearinghouse state. * * @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 Account summary for spot trading. * * @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 { spotClearinghouseState } from "@nktkas/hyperliquid/api/info"; * * const transport = new HttpTransport(); // or `WebSocketTransport` * * const data = await spotClearinghouseState({ transport }, { * user: "0x...", * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances */ export declare function spotClearinghouseState(config: InfoConfig, params: SpotClearinghouseStateParameters, signal?: AbortSignal): Promise<SpotClearinghouseStateResponse>;