UNPKG

@nktkas/hyperliquid

Version:

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

139 lines 10.1 kB
import * as v from "valibot"; /** * Request frontend open orders. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders-with-additional-frontend-info */ export declare const FrontendOpenOrdersRequest: v.SchemaWithPipe<readonly [v.ObjectSchema<{ /** Type of request. */ readonly type: v.SchemaWithPipe<readonly [v.LiteralSchema<"frontendOpenOrders", undefined>, v.DescriptionAction<"frontendOpenOrders", "Type of request.">]>; /** User address. */ readonly user: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, `0x${string}`>]>, v.LengthAction<`0x${string}`, 42, undefined>]>, v.DescriptionAction<`0x${string}`, "User address.">]>; /** DEX name (empty string for main dex). */ readonly dex: v.SchemaWithPipe<readonly [v.OptionalSchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string | undefined, "DEX name (empty string for main dex).">]>; }, undefined>, v.DescriptionAction<{ type: "frontendOpenOrders"; user: `0x${string}`; dex?: string | undefined; }, "Request frontend open orders.">]>; export type FrontendOpenOrdersRequest = v.InferOutput<typeof FrontendOpenOrdersRequest>; /** * Array of open orders with additional display information. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders-with-additional-frontend-info */ export declare const FrontendOpenOrdersResponse: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{ /** Asset symbol. */ readonly coin: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Asset symbol.">]>; /** Order side ("B" = Bid/Buy, "A" = Ask/Sell). */ readonly side: v.SchemaWithPipe<readonly [v.PicklistSchema<["B", "A"], undefined>, v.DescriptionAction<"B" | "A", "Order side (\"B\" = Bid/Buy, \"A\" = Ask/Sell).">]>; /** Limit price. */ readonly limitPx: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, string>, v.StringSchema<undefined>, v.TransformAction<string, string>, v.RegexAction<string, undefined>]>, v.DescriptionAction<string, "Limit price.">]>; /** Size. */ readonly sz: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, string>, v.StringSchema<undefined>, v.TransformAction<string, string>, v.RegexAction<string, undefined>]>, v.DescriptionAction<string, "Size.">]>; /** Order ID. */ readonly oid: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, number>, v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.DescriptionAction<number, "Order ID.">]>; /** Timestamp when the order was placed (in ms since epoch). */ readonly timestamp: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, number>, v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.DescriptionAction<number, "Timestamp when the order was placed (in ms since epoch).">]>; /** Original size at order placement. */ readonly origSz: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, string>, v.StringSchema<undefined>, v.TransformAction<string, string>, v.RegexAction<string, undefined>]>, v.DescriptionAction<string, "Original size at order placement.">]>; /** Condition for triggering the order. */ readonly triggerCondition: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Condition for triggering the order.">]>; /** Indicates if the order is a trigger order. */ readonly isTrigger: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Indicates if the order is a trigger order.">]>; /** Trigger price. */ readonly triggerPx: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, string>, v.StringSchema<undefined>, v.TransformAction<string, string>, v.RegexAction<string, undefined>]>, v.DescriptionAction<string, "Trigger price.">]>; /** Child orders associated with this order. */ readonly children: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnknownSchema, undefined>, v.DescriptionAction<unknown[], "Child orders associated with this order.">]>; /** Indicates if the order is a position TP/SL order. */ readonly isPositionTpsl: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Indicates if the order is a position TP/SL order.">]>; /** Indicates whether the order is reduce-only. */ readonly reduceOnly: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Indicates whether the order is reduce-only.">]>; /** * Order type for market execution. * - `"Market"`: Executes immediately at the market price. * - `"Limit"`: Executes at the specified limit price or better. * - `"Stop Market"`: Activates as a market order when a stop price is reached. * - `"Stop Limit"`: Activates as a limit order when a stop price is reached. * - `"Take Profit Market"`: Executes as a market order when a take profit price is reached. * - `"Take Profit Limit"`: Executes as a limit order when a take profit price is reached. * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/order-types */ readonly orderType: v.SchemaWithPipe<readonly [v.PicklistSchema<["Market", "Limit", "Stop Market", "Stop Limit", "Take Profit Market", "Take Profit Limit"], undefined>, v.DescriptionAction<"Market" | "Limit" | "Stop Market" | "Stop Limit" | "Take Profit Market" | "Take Profit Limit", string>]>; /** * Time-in-force options. * - `"Gtc"`: Remains active until filled or canceled. * - `"Ioc"`: Fills immediately or cancels any unfilled portion. * - `"Alo"`: Adds liquidity only. * - `"FrontendMarket"`: Similar to Ioc, used in Hyperliquid UI. * - `"LiquidationMarket"`: Similar to Ioc, used in Hyperliquid UI. */ readonly tif: v.SchemaWithPipe<readonly [v.NullableSchema<v.PicklistSchema<["Gtc", "Ioc", "Alo", "FrontendMarket", "LiquidationMarket"], undefined>, undefined>, v.DescriptionAction<"Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket" | null, string>]>; /** Client Order ID. */ readonly cloid: v.SchemaWithPipe<readonly [v.NullableSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, `0x${string}`>]>, v.LengthAction<`0x${string}`, 34, undefined>]>, undefined>, v.DescriptionAction<`0x${string}` | null, "Client Order ID.">]>; }, undefined>, v.DescriptionAction<{ coin: string; side: "B" | "A"; limitPx: string; sz: string; oid: number; timestamp: number; origSz: string; triggerCondition: string; isTrigger: boolean; triggerPx: string; children: unknown[]; isPositionTpsl: boolean; reduceOnly: boolean; orderType: "Market" | "Limit" | "Stop Market" | "Stop Limit" | "Take Profit Market" | "Take Profit Limit"; tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket" | null; cloid: `0x${string}` | null; }, "Open order with additional display information.">]>, undefined>, v.DescriptionAction<{ coin: string; side: "B" | "A"; limitPx: string; sz: string; oid: number; timestamp: number; origSz: string; triggerCondition: string; isTrigger: boolean; triggerPx: string; children: unknown[]; isPositionTpsl: boolean; reduceOnly: boolean; orderType: "Market" | "Limit" | "Stop Market" | "Stop Limit" | "Take Profit Market" | "Take Profit Limit"; tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket" | null; cloid: `0x${string}` | null; }[], "Array of open orders with additional display information.">]>; export type FrontendOpenOrdersResponse = v.InferOutput<typeof FrontendOpenOrdersResponse>; import type { InfoConfig } from "./_types.js"; /** Request parameters for the {@linkcode frontendOpenOrders} function. */ export type FrontendOpenOrdersParameters = Omit<v.InferInput<typeof FrontendOpenOrdersRequest>, "type">; /** * Request frontend open orders. * * @param config - General configuration for Info API requests. * @param params - Parameters specific to the API request. * @param signal - [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to cancel the request. * * @returns Array of open orders with additional display information. * * @throws {ValiError} 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 { frontendOpenOrders } from "@nktkas/hyperliquid/api/info"; * * const transport = new HttpTransport(); // or `WebSocketTransport` * * const data = await frontendOpenOrders( * { transport }, * { user: "0x..." }, * ); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders-with-additional-frontend-info */ export declare function frontendOpenOrders(config: InfoConfig, params: FrontendOpenOrdersParameters, signal?: AbortSignal): Promise<FrontendOpenOrdersResponse>; //# sourceMappingURL=frontendOpenOrders.d.ts.map