@nktkas/hyperliquid
Version:
Hyperliquid API SDK for all major JS runtimes, written in TypeScript.
83 lines (82 loc) • 3.5 kB
TypeScript
/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/info/_methods/meta.ts" />
import * as v from "valibot";
import type { MarginTableResponse } from "./marginTable.js";
/**
* Request trading metadata.
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata-universe-and-margin-tables
*/
export declare const MetaRequest: v.ObjectSchema<{
/** Type of request. */
readonly type: v.LiteralSchema<"meta", undefined>;
/** DEX name (empty string for main dex). */
readonly dex: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
}, undefined>;
export type MetaRequest = v.InferOutput<typeof MetaRequest>;
/**
* Metadata for perpetual assets.
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata-universe-and-margin-tables
*/
export type MetaResponse = {
/** Trading universes available for perpetual trading. */
universe: {
/** Minimum decimal places for order sizes. */
szDecimals: number;
/** Name of the universe. */
name: string;
/** Maximum allowed leverage. */
maxLeverage: number;
/** Unique identifier for the margin requirements table. */
marginTableId: number;
/**
* Indicates if only isolated margin trading is allowed.
*
* @deprecated use `marginMode` instead.
*/
onlyIsolated?: true;
/** Indicates if the universe is delisted. */
isDelisted?: true;
/** Trading margin mode constraint. */
marginMode?: "strictIsolated" | "noCross";
/** Indicates if growth mode is enabled. */
growthMode?: "enabled";
/** Timestamp of the last growth mode change. */
lastGrowthModeChangeTime?: string;
}[];
/** Margin requirement tables for different leverage tiers. */
marginTables: [
/** Margin requirements table ID. */
id: number,
/** Margin requirements table. */
table: MarginTableResponse
][];
/** Collateral token index. */
collateralToken: number;
};
import type { InfoConfig } from "./_base/mod.js";
/** Request parameters for the {@linkcode meta} function. */
export type MetaParameters = Omit<v.InferInput<typeof MetaRequest>, "type">;
/**
* Request trading metadata.
*
* @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 Metadata for perpetual assets.
*
* @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 { meta } from "@nktkas/hyperliquid/api/info";
*
* const transport = new HttpTransport(); // or `WebSocketTransport`
*
* const data = await meta({ transport });
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata-universe-and-margin-tables
*/
export declare function meta(config: InfoConfig, params?: MetaParameters, signal?: AbortSignal): Promise<MetaResponse>;
export declare function meta(config: InfoConfig, signal?: AbortSignal): Promise<MetaResponse>;