@nktkas/hyperliquid
Version:
Hyperliquid API SDK for all major JS runtimes, written in TypeScript.
704 lines • 41.4 kB
TypeScript
import * as v from "valibot";
import { OrderResponse } from "./order.js";
/**
* Modify multiple orders.
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
*/
export declare const BatchModifyRequest: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/** Action to perform. */
readonly action: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/** Type of action. */
readonly type: v.SchemaWithPipe<readonly [v.LiteralSchema<"batchModify", undefined>, v.DescriptionAction<"batchModify", "Type of action.">]>;
/** Order modifications. */
readonly modifies: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
/** Order ID or Client Order ID. */
readonly oid: v.SchemaWithPipe<readonly [v.UnionSchema<[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.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<number | `0x${string}`, "Order ID or Client Order ID.">]>;
/** New order parameters. */
readonly order: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/** Asset ID. */
readonly a: 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, "Asset ID.">]>;
/** Position side (`true` for long, `false` for short). */
readonly b: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Position side (`true` for long, `false` for short).">]>;
/** Price. */
readonly p: 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, "Price.">]>;
/** Size (in base currency units). */
readonly s: 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 (in base currency units).">]>;
/** Is reduce-only? */
readonly r: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Is reduce-only?">]>;
/** Order type. */
readonly t: v.SchemaWithPipe<readonly [v.UnionSchema<[v.ObjectSchema<{
/** Limit order parameters. */
readonly limit: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/**
* Time-in-force.
* - `"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.PicklistSchema<["Gtc", "Ioc", "Alo", "FrontendMarket", "LiquidationMarket"], undefined>, v.DescriptionAction<"Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket", string>]>;
}, undefined>, v.DescriptionAction<{
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
}, "Limit order parameters.">]>;
}, undefined>, v.ObjectSchema<{
/** Trigger order parameters. */
readonly trigger: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/** Is market order? */
readonly isMarket: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Is market 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.">]>;
/** Indicates whether it is take profit or stop loss. */
readonly tpsl: v.SchemaWithPipe<readonly [v.PicklistSchema<["tp", "sl"], undefined>, v.DescriptionAction<"tp" | "sl", "Indicates whether it is take profit or stop loss.">]>;
}, undefined>, v.DescriptionAction<{
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
}, "Trigger order parameters.">]>;
}, undefined>], undefined>, v.DescriptionAction<{
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
}, "Order type.">]>;
/** Client Order ID. */
readonly c: v.SchemaWithPipe<readonly [v.OptionalSchema<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}` | undefined, "Client Order ID.">]>;
}, undefined>, v.DescriptionAction<{
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
}, "New order parameters.">]>;
}, undefined>, undefined>, v.DescriptionAction<{
oid: number | `0x${string}`;
order: {
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
};
}[], "Order modifications.">]>;
}, undefined>, v.DescriptionAction<{
type: "batchModify";
modifies: {
oid: number | `0x${string}`;
order: {
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
};
}[];
}, "Action to perform.">]>;
/** Nonce (timestamp in ms) used to prevent replay attacks. */
readonly nonce: 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, "Nonce (timestamp in ms) used to prevent replay attacks.">]>;
/** ECDSA signature components. */
readonly signature: v.SchemaWithPipe<readonly [v.ObjectSchema<{
readonly r: 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}`, 66, undefined>]>, v.DescriptionAction<`0x${string}`, "First 32-byte component.">]>;
readonly s: 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}`, 66, undefined>]>, v.DescriptionAction<`0x${string}`, "Second 32-byte component.">]>;
readonly v: v.SchemaWithPipe<readonly [v.PicklistSchema<[27, 28], undefined>, v.DescriptionAction<27 | 28, "Recovery identifier.">]>;
}, undefined>, v.DescriptionAction<{
r: `0x${string}`;
s: `0x${string}`;
v: 27 | 28;
}, "ECDSA signature components.">]>;
/** Vault address (for vault trading). */
readonly vaultAddress: v.SchemaWithPipe<readonly [v.OptionalSchema<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>, v.DescriptionAction<`0x${string}` | undefined, "Vault address (for vault trading).">]>;
/** Expiration time of the action. */
readonly expiresAfter: v.SchemaWithPipe<readonly [v.OptionalSchema<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>]>, undefined>, v.DescriptionAction<number | undefined, "Expiration time of the action.">]>;
}, undefined>, v.DescriptionAction<{
action: {
type: "batchModify";
modifies: {
oid: number | `0x${string}`;
order: {
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
};
}[];
};
nonce: number;
signature: {
r: `0x${string}`;
s: `0x${string}`;
v: 27 | 28;
};
vaultAddress?: `0x${string}` | undefined;
expiresAfter?: number | undefined;
}, "Modify multiple orders.">]>;
export type BatchModifyRequest = v.InferOutput<typeof BatchModifyRequest>;
/**
* Response for order batch modifications.
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
*/
export declare const BatchModifyResponse: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.ObjectSchema<{
readonly status: v.SchemaWithPipe<readonly [v.LiteralSchema<"ok", undefined>, v.DescriptionAction<"ok", "Successful status.">]>;
readonly response: v.SchemaWithPipe<readonly [v.ObjectSchema<{
readonly type: v.SchemaWithPipe<readonly [v.LiteralSchema<"order", undefined>, v.DescriptionAction<"order", "Type of response.">]>;
readonly data: v.SchemaWithPipe<readonly [v.ObjectSchema<{
readonly statuses: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
readonly resting: v.SchemaWithPipe<readonly [v.ObjectSchema<{
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.">]>;
readonly cloid: v.SchemaWithPipe<readonly [v.OptionalSchema<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}` | undefined, "Client Order ID.">]>;
}, undefined>, v.DescriptionAction<{
oid: number;
cloid?: `0x${string}` | undefined;
}, "Resting order status.">]>;
}, undefined>, v.ObjectSchema<{
readonly filled: v.SchemaWithPipe<readonly [v.ObjectSchema<{
readonly totalSz: 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, "Total size filled.">]>;
readonly avgPx: 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, "Average price of fill.">]>;
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.">]>;
readonly cloid: v.SchemaWithPipe<readonly [v.OptionalSchema<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}` | undefined, "Client Order ID.">]>;
}, undefined>, v.DescriptionAction<{
totalSz: string;
avgPx: string;
oid: number;
cloid?: `0x${string}` | undefined;
}, "Filled order status.">]>;
}, undefined>, v.ObjectSchema<{
readonly error: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Error message.">]>;
}, undefined>], undefined>, undefined>, v.DescriptionAction<({
resting: {
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
filled: {
totalSz: string;
avgPx: string;
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
error: string;
})[], "Array of statuses or error messages.">]>;
}, undefined>, v.DescriptionAction<{
statuses: ({
resting: {
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
filled: {
totalSz: string;
avgPx: string;
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
error: string;
})[];
}, "Specific data.">]>;
}, undefined>, v.DescriptionAction<{
type: "order";
data: {
statuses: ({
resting: {
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
filled: {
totalSz: string;
avgPx: string;
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
error: string;
})[];
};
}, "Response details.">]>;
}, undefined>, v.DescriptionAction<{
status: "ok";
response: {
type: "order";
data: {
statuses: ({
resting: {
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
filled: {
totalSz: string;
avgPx: string;
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
error: string;
})[];
};
};
}, "Response for order placement.">]>, v.DescriptionAction<{
status: "ok";
response: {
type: "order";
data: {
statuses: ({
resting: {
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
filled: {
totalSz: string;
avgPx: string;
oid: number;
cloid?: `0x${string}` | undefined;
};
} | {
error: string;
})[];
};
};
}, "Response for order batch modifications.">]>;
export type BatchModifyResponse = OrderResponse;
import { type ExchangeConfig, type ExtractRequestOptions } from "./_base/execute.js";
import type { ExcludeErrorResponse } from "./_base/errors.js";
/** Schema for user-provided action parameters (excludes system fields). */
declare const BatchModifyParameters: Omit<v.ObjectSchema<{
/** Type of action. */
readonly type: v.SchemaWithPipe<readonly [v.LiteralSchema<"batchModify", undefined>, v.DescriptionAction<"batchModify", "Type of action.">]>;
/** Order modifications. */
readonly modifies: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
/** Order ID or Client Order ID. */
readonly oid: v.SchemaWithPipe<readonly [v.UnionSchema<[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.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<number | `0x${string}`, "Order ID or Client Order ID.">]>;
/** New order parameters. */
readonly order: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/** Asset ID. */
readonly a: 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, "Asset ID.">]>;
/** Position side (`true` for long, `false` for short). */
readonly b: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Position side (`true` for long, `false` for short).">]>;
/** Price. */
readonly p: 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, "Price.">]>;
/** Size (in base currency units). */
readonly s: 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 (in base currency units).">]>;
/** Is reduce-only? */
readonly r: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Is reduce-only?">]>;
/** Order type. */
readonly t: v.SchemaWithPipe<readonly [v.UnionSchema<[v.ObjectSchema<{
/** Limit order parameters. */
readonly limit: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/**
* Time-in-force.
* - `"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.PicklistSchema<["Gtc", "Ioc", "Alo", "FrontendMarket", "LiquidationMarket"], undefined>, v.DescriptionAction<"Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket", string>]>;
}, undefined>, v.DescriptionAction<{
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
}, "Limit order parameters.">]>;
}, undefined>, v.ObjectSchema<{
/** Trigger order parameters. */
readonly trigger: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/** Is market order? */
readonly isMarket: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Is market 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.">]>;
/** Indicates whether it is take profit or stop loss. */
readonly tpsl: v.SchemaWithPipe<readonly [v.PicklistSchema<["tp", "sl"], undefined>, v.DescriptionAction<"tp" | "sl", "Indicates whether it is take profit or stop loss.">]>;
}, undefined>, v.DescriptionAction<{
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
}, "Trigger order parameters.">]>;
}, undefined>], undefined>, v.DescriptionAction<{
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
}, "Order type.">]>;
/** Client Order ID. */
readonly c: v.SchemaWithPipe<readonly [v.OptionalSchema<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}` | undefined, "Client Order ID.">]>;
}, undefined>, v.DescriptionAction<{
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
}, "New order parameters.">]>;
}, undefined>, undefined>, v.DescriptionAction<{
oid: number | `0x${string}`;
order: {
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
};
}[], "Order modifications.">]>;
}, undefined>, "entries" | "~types" | "~run" | "~standard"> & {
readonly entries: Omit<{
/** Type of action. */
readonly type: v.SchemaWithPipe<readonly [v.LiteralSchema<"batchModify", undefined>, v.DescriptionAction<"batchModify", "Type of action.">]>;
/** Order modifications. */
readonly modifies: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
/** Order ID or Client Order ID. */
readonly oid: v.SchemaWithPipe<readonly [v.UnionSchema<[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.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<number | `0x${string}`, "Order ID or Client Order ID.">]>;
/** New order parameters. */
readonly order: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/** Asset ID. */
readonly a: 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, "Asset ID.">]>;
/** Position side (`true` for long, `false` for short). */
readonly b: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Position side (`true` for long, `false` for short).">]>;
/** Price. */
readonly p: 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, "Price.">]>;
/** Size (in base currency units). */
readonly s: 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 (in base currency units).">]>;
/** Is reduce-only? */
readonly r: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Is reduce-only?">]>;
/** Order type. */
readonly t: v.SchemaWithPipe<readonly [v.UnionSchema<[v.ObjectSchema<{
/** Limit order parameters. */
readonly limit: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/**
* Time-in-force.
* - `"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.PicklistSchema<["Gtc", "Ioc", "Alo", "FrontendMarket", "LiquidationMarket"], undefined>, v.DescriptionAction<"Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket", string>]>;
}, undefined>, v.DescriptionAction<{
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
}, "Limit order parameters.">]>;
}, undefined>, v.ObjectSchema<{
/** Trigger order parameters. */
readonly trigger: v.SchemaWithPipe<readonly [v.ObjectSchema<{
/** Is market order? */
readonly isMarket: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Is market 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.">]>;
/** Indicates whether it is take profit or stop loss. */
readonly tpsl: v.SchemaWithPipe<readonly [v.PicklistSchema<["tp", "sl"], undefined>, v.DescriptionAction<"tp" | "sl", "Indicates whether it is take profit or stop loss.">]>;
}, undefined>, v.DescriptionAction<{
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
}, "Trigger order parameters.">]>;
}, undefined>], undefined>, v.DescriptionAction<{
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
}, "Order type.">]>;
/** Client Order ID. */
readonly c: v.SchemaWithPipe<readonly [v.OptionalSchema<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}` | undefined, "Client Order ID.">]>;
}, undefined>, v.DescriptionAction<{
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
}, "New order parameters.">]>;
}, undefined>, undefined>, v.DescriptionAction<{
oid: number | `0x${string}`;
order: {
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
};
}[], "Order modifications.">]>;
}, "type">;
readonly "~standard": v.StandardProps<{
modifies: {
oid: string | number;
order: {
a: string | number;
b: boolean;
p: string | number;
s: string | number;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string | number;
tpsl: "tp" | "sl";
};
};
c?: string | undefined;
};
}[];
}, {
modifies: {
oid: number | `0x${string}`;
order: {
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
};
}[];
}>;
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
modifies: {
oid: number | `0x${string}`;
order: {
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
};
}[];
}, v.StringIssue | v.ArrayIssue | v.ObjectIssue | v.NumberIssue | v.UnionIssue<v.StringIssue | v.NumberIssue> | v.RegexIssue<string> | v.IntegerIssue<number> | v.SafeIntegerIssue<number> | v.MinValueIssue<number, 0> | v.PicklistIssue | v.BooleanIssue | v.UnionIssue<v.StringIssue | v.ObjectIssue | v.NumberIssue | v.UnionIssue<v.StringIssue | v.NumberIssue> | v.RegexIssue<string> | v.PicklistIssue | v.BooleanIssue> | v.LengthIssue<`0x${string}`, 34> | v.UnionIssue<v.StringIssue | v.NumberIssue | v.UnionIssue<v.StringIssue | v.NumberIssue> | v.RegexIssue<string> | v.IntegerIssue<number> | v.SafeIntegerIssue<number> | v.MinValueIssue<number, 0> | v.LengthIssue<`0x${string}`, 34>>>;
readonly "~types"?: {
readonly input: {
modifies: {
oid: string | number;
order: {
a: string | number;
b: boolean;
p: string | number;
s: string | number;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string | number;
tpsl: "tp" | "sl";
};
};
c?: string | undefined;
};
}[];
};
readonly output: {
modifies: {
oid: number | `0x${string}`;
order: {
a: number;
b: boolean;
p: string;
s: string;
r: boolean;
t: {
limit: {
tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
};
} | {
trigger: {
isMarket: boolean;
triggerPx: string;
tpsl: "tp" | "sl";
};
};
c?: `0x${string}` | undefined;
};
}[];
};
readonly issue: v.StringIssue | v.ArrayIssue | v.ObjectIssue | v.NumberIssue | v.UnionIssue<v.StringIssue | v.NumberIssue> | v.RegexIssue<string> | v.IntegerIssue<number> | v.SafeIntegerIssue<number> | v.MinValueIssue<number, 0> | v.PicklistIssue | v.BooleanIssue | v.UnionIssue<v.StringIssue | v.ObjectIssue | v.NumberIssue | v.UnionIssue<v.StringIssue | v.NumberIssue> | v.RegexIssue<string> | v.PicklistIssue | v.BooleanIssue> | v.LengthIssue<`0x${string}`, 34> | v.UnionIssue<v.StringIssue | v.NumberIssue | v.UnionIssue<v.StringIssue | v.NumberIssue> | v.RegexIssue<string> | v.IntegerIssue<number> | v.SafeIntegerIssue<number> | v.MinValueIssue<number, 0> | v.LengthIssue<`0x${string}`, 34>>;
} | undefined;
};
/** Action parameters for the {@linkcode batchModify} function. */
export type BatchModifyParameters = v.InferInput<typeof BatchModifyParameters>;
/** Request options for the {@linkcode batchModify} function. */
export type BatchModifyOptions = ExtractRequestOptions<v.InferInput<typeof BatchModifyRequest>>;
/** Successful variant of {@linkcode BatchModifyResponse} without errors. */
export type BatchModifySuccessResponse = ExcludeErrorResponse<BatchModifyResponse>;
/**
* Modify multiple orders.
*
* @param config - General configuration for Exchange API requests.
* @param params - Parameters specific to the API request.
* @param opts - Request execution options.
*
* @returns Successful variant of {@link OrderResponse} without error statuses.
*
* @throws {ValiError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
* @throws {ApiRequestError} When the API returns an unsuccessful response.
*
* @example
* ```ts
* import { HttpTransport } from "@nktkas/hyperliquid";
* import { batchModify } from "@nktkas/hyperliquid/api/exchange";
* import { privateKeyToAccount } from "npm:viem/accounts";
*
* const wallet = privateKeyToAccount("0x..."); // viem or ethers
* const transport = new HttpTransport(); // or `WebSocketTransport`
*
* const data = await batchModify(
* { transport, wallet },
* {
* modifies: [
* {
* oid: 123,
* order: {
* a: 0,
* b: true,
* p: "31000",
* s: "0.2",
* r: false,
* t: { limit: { tif: "Gtc" } },
* },
* },
* ],
* },
* );
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
*/
export declare function batchModify(config: ExchangeConfig, params: BatchModifyParameters, opts?: BatchModifyOptions): Promise<BatchModifySuccessResponse>;
export {};
//# sourceMappingURL=batchModify.d.ts.map