UNPKG

@nktkas/hyperliquid

Version:

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

1,082 lines 94.8 kB
/** * Client for the Hyperliquid Exchange API endpoint. * @module */ /// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/exchange/client.ts" /> import type { ExchangeConfig, ExchangeSingleWalletConfig } from "./_methods/_base/mod.js"; import { type AgentEnableDexAbstractionOptions, type AgentEnableDexAbstractionSuccessResponse } from "./_methods/agentEnableDexAbstraction.js"; import { type AgentSendAssetOptions, type AgentSendAssetParameters, type AgentSendAssetSuccessResponse } from "./_methods/agentSendAsset.js"; import { type AgentSetAbstractionOptions, type AgentSetAbstractionParameters, type AgentSetAbstractionSuccessResponse } from "./_methods/agentSetAbstraction.js"; import { type ApproveAgentOptions, type ApproveAgentParameters, type ApproveAgentSuccessResponse } from "./_methods/approveAgent.js"; import { type ApproveBuilderFeeOptions, type ApproveBuilderFeeParameters, type ApproveBuilderFeeSuccessResponse } from "./_methods/approveBuilderFee.js"; import { type AuthorizeAqav2RoleOptions, type AuthorizeAqav2RoleParameters, type AuthorizeAqav2RoleSuccessResponse } from "./_methods/authorizeAqav2Role.js"; import { type BatchModifyOptions, type BatchModifyParameters, type BatchModifySuccessResponse } from "./_methods/batchModify.js"; import { type BorrowLendOptions, type BorrowLendParameters, type BorrowLendSuccessResponse } from "./_methods/borrowLend.js"; import { type CancelOptions, type CancelParameters, type CancelSuccessResponse } from "./_methods/cancel.js"; import { type CancelByCloidOptions, type CancelByCloidParameters, type CancelByCloidSuccessResponse } from "./_methods/cancelByCloid.js"; import { type CDepositOptions, type CDepositParameters, type CDepositSuccessResponse } from "./_methods/cDeposit.js"; import { type ClaimRewardsOptions, type ClaimRewardsSuccessResponse } from "./_methods/claimRewards.js"; import { type ConvertToMultiSigUserOptions, type ConvertToMultiSigUserParameters, type ConvertToMultiSigUserSuccessResponse } from "./_methods/convertToMultiSigUser.js"; import { type CreateSubAccountOptions, type CreateSubAccountParameters, type CreateSubAccountSuccessResponse } from "./_methods/createSubAccount.js"; import { type CreateVaultOptions, type CreateVaultParameters, type CreateVaultSuccessResponse } from "./_methods/createVault.js"; import { type CSignerActionOptions, type CSignerActionParameters, type CSignerActionSuccessResponse } from "./_methods/cSignerAction.js"; import { type CValidatorActionOptions, type CValidatorActionParameters, type CValidatorActionSuccessResponse } from "./_methods/cValidatorAction.js"; import { type CWithdrawOptions, type CWithdrawParameters, type CWithdrawSuccessResponse } from "./_methods/cWithdraw.js"; import { type EvmUserModifyOptions, type EvmUserModifyParameters, type EvmUserModifySuccessResponse } from "./_methods/evmUserModify.js"; import { type FinalizeEvmContractOptions, type FinalizeEvmContractParameters, type FinalizeEvmContractSuccessResponse } from "./_methods/finalizeEvmContract.js"; import { type GossipPriorityBidOptions, type GossipPriorityBidParameters, type GossipPriorityBidSuccessResponse } from "./_methods/gossipPriorityBid.js"; import { type Hip3LiquidatorTransferOptions, type Hip3LiquidatorTransferParameters, type Hip3LiquidatorTransferSuccessResponse } from "./_methods/hip3LiquidatorTransfer.js"; import { type LinkStakingUserOptions, type LinkStakingUserParameters, type LinkStakingUserSuccessResponse } from "./_methods/linkStakingUser.js"; import { type ModifyOptions, type ModifyParameters, type ModifySuccessResponse } from "./_methods/modify.js"; import { type NoopOptions, type NoopParameters, type NoopSuccessResponse } from "./_methods/noop.js"; import { type OrderOptions, type OrderParameters, type OrderSuccessResponse } from "./_methods/order.js"; import { type PerpDeployOptions, type PerpDeployParameters, type PerpDeploySuccessResponse } from "./_methods/perpDeploy.js"; import { type RegisterReferrerOptions, type RegisterReferrerParameters, type RegisterReferrerSuccessResponse } from "./_methods/registerReferrer.js"; import { type ReserveRequestWeightOptions, type ReserveRequestWeightParameters, type ReserveRequestWeightSuccessResponse } from "./_methods/reserveRequestWeight.js"; import { type ScheduleCancelOptions, type ScheduleCancelParameters, type ScheduleCancelSuccessResponse } from "./_methods/scheduleCancel.js"; import { type SendAssetOptions, type SendAssetParameters, type SendAssetSuccessResponse } from "./_methods/sendAsset.js"; import { type SendToEvmWithDataOptions, type SendToEvmWithDataParameters, type SendToEvmWithDataSuccessResponse } from "./_methods/sendToEvmWithData.js"; import { type SetDisplayNameOptions, type SetDisplayNameParameters, type SetDisplayNameSuccessResponse } from "./_methods/setDisplayName.js"; import { type SetReferrerOptions, type SetReferrerParameters, type SetReferrerSuccessResponse } from "./_methods/setReferrer.js"; import { type SpotDeployOptions, type SpotDeployParameters, type SpotDeploySuccessResponse } from "./_methods/spotDeploy.js"; import { type SpotSendOptions, type SpotSendParameters, type SpotSendSuccessResponse } from "./_methods/spotSend.js"; import { type SpotUserOptions, type SpotUserParameters, type SpotUserSuccessResponse } from "./_methods/spotUser.js"; import { type StakingLinkDisableTradingUserOptions, type StakingLinkDisableTradingUserParameters, type StakingLinkDisableTradingUserSuccessResponse } from "./_methods/stakingLinkDisableTradingUser.js"; import { type SubAccountModifyOptions, type SubAccountModifyParameters, type SubAccountModifySuccessResponse } from "./_methods/subAccountModify.js"; import { type SubAccountSpotTransferOptions, type SubAccountSpotTransferParameters, type SubAccountSpotTransferSuccessResponse } from "./_methods/subAccountSpotTransfer.js"; import { type SubAccountTransferOptions, type SubAccountTransferParameters, type SubAccountTransferSuccessResponse } from "./_methods/subAccountTransfer.js"; import { type TokenDelegateOptions, type TokenDelegateParameters, type TokenDelegateSuccessResponse } from "./_methods/tokenDelegate.js"; import { type TopUpIsolatedOnlyMarginOptions, type TopUpIsolatedOnlyMarginParameters, type TopUpIsolatedOnlyMarginSuccessResponse } from "./_methods/topUpIsolatedOnlyMargin.js"; import { type TwapCancelOptions, type TwapCancelParameters, type TwapCancelSuccessResponse } from "./_methods/twapCancel.js"; import { type TwapOrderOptions, type TwapOrderParameters, type TwapOrderSuccessResponse } from "./_methods/twapOrder.js"; import { type UpdateIsolatedMarginOptions, type UpdateIsolatedMarginParameters, type UpdateIsolatedMarginSuccessResponse } from "./_methods/updateIsolatedMargin.js"; import { type UpdateLeverageOptions, type UpdateLeverageParameters, type UpdateLeverageSuccessResponse } from "./_methods/updateLeverage.js"; import { type UsdClassTransferOptions, type UsdClassTransferParameters, type UsdClassTransferSuccessResponse } from "./_methods/usdClassTransfer.js"; import { type UsdSendOptions, type UsdSendParameters, type UsdSendSuccessResponse } from "./_methods/usdSend.js"; import { type UserDexAbstractionOptions, type UserDexAbstractionParameters, type UserDexAbstractionSuccessResponse } from "./_methods/userDexAbstraction.js"; import { type UserOutcomeOptions, type UserOutcomeParameters, type UserOutcomeSuccessResponse } from "./_methods/userOutcome.js"; import { type UserPortfolioMarginOptions, type UserPortfolioMarginParameters, type UserPortfolioMarginSuccessResponse } from "./_methods/userPortfolioMargin.js"; import { type UserSetAbstractionOptions, type UserSetAbstractionParameters, type UserSetAbstractionSuccessResponse } from "./_methods/userSetAbstraction.js"; import { type ValidatorL1StreamOptions, type ValidatorL1StreamParameters, type ValidatorL1StreamSuccessResponse } from "./_methods/validatorL1Stream.js"; import { type VaultDistributeOptions, type VaultDistributeParameters, type VaultDistributeSuccessResponse } from "./_methods/vaultDistribute.js"; import { type VaultModifyOptions, type VaultModifyParameters, type VaultModifySuccessResponse } from "./_methods/vaultModify.js"; import { type VaultTransferOptions, type VaultTransferParameters, type VaultTransferSuccessResponse } from "./_methods/vaultTransfer.js"; import { type Withdraw3Options, type Withdraw3Parameters, type Withdraw3SuccessResponse } from "./_methods/withdraw3.js"; /** * Execute actions: place orders, cancel orders, transfer funds, etc. * * Corresponds to the {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint | Exchange endpoint}. */ export declare class ExchangeClient<C extends ExchangeConfig = ExchangeSingleWalletConfig> { config_: C; /** * Creates an instance of the ExchangeClient. * * @param config Configuration for Exchange API requests. See {@link ExchangeConfig}. * * @example [viem](https://viem.sh/docs/clients/wallet#local-accounts-private-key-mnemonic-etc) * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * * const client = new hl.ExchangeClient({ transport, wallet }); * ``` * * @example [ethers.js](https://docs.ethers.org/v6/api/wallet/#Wallet) * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { ethers } from "npm:ethers"; * * const wallet = new ethers.Wallet("0x..."); * const transport = new hl.HttpTransport(); * * const client = new hl.ExchangeClient({ transport, wallet }); * ``` * * @example Multi-sig * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * import { ethers } from "npm:ethers"; * * const signer1 = privateKeyToAccount("0x..."); * const signer2 = new ethers.Wallet("0x..."); * // ... and more signers * * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * * const client = new hl.ExchangeClient({ * transport, * signers: [signer1, signer2], * multiSigUser: "0x...", * }); * ``` */ constructor(config: C); /** * Enable HIP-3 DEX abstraction. * * Signing: L1 Action. * * @deprecated use {@linkcode agentSetAbstraction} instead. * * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.agentEnableDexAbstraction(); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#enable-hip-3-dex-abstraction-agent */ agentEnableDexAbstraction(opts?: AgentEnableDexAbstractionOptions): Promise<AgentEnableDexAbstractionSuccessResponse>; /** * Transfer tokens on behalf of the principal via an agent wallet. * * Like {@link sendAsset} but signed as an L1 action by the agent wallet (instead of EIP-712 by the principal). * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const agentWallet = privateKeyToAccount("0x..."); // approved agent's private key * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet: agentWallet }); * * await client.agentSendAsset({ * destination: "0x0000000000000000000000000000000000000001", * sourceDex: "", * destinationDex: "test", * token: "USDC:0xeb62eee3685fc4c43992febcd9e75443", * amount: "1", * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#agent-send-asset */ agentSendAsset(params: AgentSendAssetParameters, opts?: AgentSendAssetOptions): Promise<AgentSendAssetSuccessResponse>; /** * Set user abstraction mode (method for agent wallet). * * Like {@link userSetAbstraction} but signed as an L1 action by the agent wallet (instead of EIP-712 by the principal). * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.agentSetAbstraction({ abstraction: "u" }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#set-user-abstraction-agent */ agentSetAbstraction(params: AgentSetAbstractionParameters, opts?: AgentSetAbstractionOptions): Promise<AgentSetAbstractionSuccessResponse>; /** * Approve an agent to sign on behalf of the master account. * * Signing: User-Signed EIP-712. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 Basic usage * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.approveAgent({ agentAddress: "0x...", agentName: "myAgent" }); * ``` * @example With expiration timestamp * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * const expirationTimestamp = Date.now() + 24 * 60 * 60 * 1000; * await client.approveAgent({ * agentAddress: "0x...", * agentName: `myAgent valid_until ${expirationTimestamp}`, * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#approve-an-api-wallet */ approveAgent(params: ApproveAgentParameters, opts?: ApproveAgentOptions): Promise<ApproveAgentSuccessResponse>; /** * Approve a maximum fee rate for a builder. * * Signing: User-Signed EIP-712. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.approveBuilderFee({ maxFeeRate: "0.01%", builder: "0x..." }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#approve-a-builder-fee */ approveBuilderFee(params: ApproveBuilderFeeParameters, opts?: ApproveBuilderFeeOptions): Promise<ApproveBuilderFeeSuccessResponse>; /** * Authorize an AQAv2 role. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.authorizeAqav2Role({ * token: 0, * role: "technical", * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#authorize-aqav2-role */ authorizeAqav2Role(params: AuthorizeAqav2RoleParameters, opts?: AuthorizeAqav2RoleOptions): Promise<AuthorizeAqav2RoleSuccessResponse>; /** * Modify multiple orders. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful variant of {@link OrderResponse} without error statuses. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * const data = await client.batchModify({ * 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 */ batchModify(params: BatchModifyParameters, opts?: BatchModifyOptions): Promise<BatchModifySuccessResponse>; /** * Borrow or lend assets. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.borrowLend({ operation: "supply", token: 0, amount: "20" }); * ``` * * @see null */ borrowLend(params: BorrowLendParameters, opts?: BorrowLendOptions): Promise<BorrowLendSuccessResponse>; /** * Cancel order(s). * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful variant of {@link CancelResponse} without error statuses. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.cancel({ cancels: [{ a: 0, o: 123 }] }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s */ cancel(params: CancelParameters, opts?: CancelOptions): Promise<CancelSuccessResponse>; /** * Cancel order(s) by cloid. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful variant of {@link CancelResponse} without error statuses. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.cancelByCloid({ * cancels: [ * { asset: 0, cloid: "0x..." }, * ], * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid */ cancelByCloid(params: CancelByCloidParameters, opts?: CancelByCloidOptions): Promise<CancelByCloidSuccessResponse>; /** * Transfer native token from the user spot account into staking for delegating to validators. * * Signing: User-Signed EIP-712. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.cDeposit({ wei: 1 * 1e8 }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-into-staking */ cDeposit(params: CDepositParameters, opts?: CDepositOptions): Promise<CDepositSuccessResponse>; /** * Claim rewards from referral program. * * Signing: L1 Action. * * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.claimRewards(); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#claim-rewards */ claimRewards(opts?: ClaimRewardsOptions): Promise<ClaimRewardsSuccessResponse>; /** * Convert a single-signature account to a multi-signature account or vice versa. * * Signing: User-Signed EIP-712. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 Convert to multi-sig * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.convertToMultiSigUser({ * signers: { * authorizedUsers: ["0x...", "0x...", "0x..."], * threshold: 2, * }, * }); * ``` * * @example Convert to single-sig * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.convertToMultiSigUser({ signers: null }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/multi-sig */ convertToMultiSigUser(params: ConvertToMultiSigUserParameters, opts?: ConvertToMultiSigUserOptions): Promise<ConvertToMultiSigUserSuccessResponse>; /** * Create a sub-account. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Response for creating a sub-account. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * const data = await client.createSubAccount({ name: "..." }); * ``` * * @see null */ createSubAccount(params: CreateSubAccountParameters, opts?: CreateSubAccountOptions): Promise<CreateSubAccountSuccessResponse>; /** * Create a vault. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Response for creating a vault. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * const data = await client.createVault({ * name: "...", * description: "...", * initialUsd: 100 * 1e6, * }); * ``` * * @see null */ createVault(params: CreateVaultParameters, opts?: CreateVaultOptions): Promise<CreateVaultSuccessResponse>; /** * Jail or unjail self as a validator signer. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 Jail self * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.cSignerAction({ jailSelf: null }); * ``` * * @example Unjail self * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.cSignerAction({ unjailSelf: null }); * ``` * * @see null */ cSignerAction(params: CSignerActionParameters, opts?: CSignerActionOptions): Promise<CSignerActionSuccessResponse>; /** * Action related to validator management. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.cValidatorAction({ * changeProfile: { * node_ip: { Ip: "1.2.3.4" }, * name: "...", * description: "...", * unjailed: true, * disable_delegations: false, * commission_bps: null, * signer: null, * }, * }); * ``` * * @see null */ cValidatorAction(params: CValidatorActionParameters, opts?: CValidatorActionOptions): Promise<CValidatorActionSuccessResponse>; /** * Transfer native token from staking into the user's spot account. * * Signing: User-Signed EIP-712. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.cWithdraw({ wei: 1 * 1e8 }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#withdraw-from-staking */ cWithdraw(params: CWithdrawParameters, opts?: CWithdrawOptions): Promise<CWithdrawSuccessResponse>; /** * Configure block type for EVM transactions. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.evmUserModify({ usingBigBlocks: true }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/dual-block-architecture */ evmUserModify(params: EvmUserModifyParameters, opts?: EvmUserModifyOptions): Promise<EvmUserModifySuccessResponse>; /** * Finalize the link between a HyperCore spot token and an ERC-20 contract on the HyperEVM. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 Finalize from an EOA-deployed contract * ```ts * import * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.finalizeEvmContract({ token: 200, input: { create: { nonce: 0 } } }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/hypercore-less-than-greater-than-hyperevm-transfers */ finalizeEvmContract(params: FinalizeEvmContractParameters, opts?: FinalizeEvmContractOptions): Promise<FinalizeEvmContractSuccessResponse>; /** * Bid in a gossip priority Dutch auction to receive prioritized mempool data for an IP. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.gossipPriorityBid({ * slotId: 0, * ip: "1.2.3.4", * maxGas: 100_000_000, // 1 HYPE * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/priority-fees */ gossipPriorityBid(params: GossipPriorityBidParameters, opts?: GossipPriorityBidOptions): Promise<GossipPriorityBidSuccessResponse>; /** * Deposit into or withdraw from the HIP-3 DEX backstop liquidator. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.hip3LiquidatorTransfer({ * dex: "test", * ntl: 1_000_000_000, // 1000 quote tokens (1e-6 units) * isDeposit: true, * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-an-hip-3-dexs-backstop-liquidator */ hip3LiquidatorTransfer(params: Hip3LiquidatorTransferParameters, opts?: Hip3LiquidatorTransferOptions): Promise<Hip3LiquidatorTransferSuccessResponse>; /** * Link staking and trading accounts for fee discount attribution. * * Signing: User-Signed EIP-712. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.linkStakingUser({ user: "0x...", isFinalize: false }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#staking-linking */ linkStakingUser(params: LinkStakingUserParameters, opts?: LinkStakingUserOptions): Promise<LinkStakingUserSuccessResponse>; /** * Modify an order. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.modify({ * 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-an-order */ modify(params: ModifyParameters, opts?: ModifyOptions): Promise<ModifySuccessResponse>; /** * Place an order(s). * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful variant of {@link OrderResponse} without error statuses. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * const data = await client.order({ * orders: [ * { * a: 0, * b: true, * p: "30000", * s: "0.1", * r: false, * t: { limit: { tif: "Gtc" } }, * }, * ], * grouping: "na", * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order */ order(params: OrderParameters, opts?: OrderOptions): Promise<OrderSuccessResponse>; /** * This action does not do anything (no operation), but causes the nonce to be marked as used. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.noop({ nonce: 1730000000000 }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#invalidate-pending-nonce-noop */ noop(params: NoopParameters, opts?: NoopOptions): Promise<NoopSuccessResponse>; /** * Deploying HIP-3 assets. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.perpDeploy({ * registerAsset: { * maxGas: 1000000, * assetRequest: { * coin: "USDC", * szDecimals: 8, * oraclePx: "1", * marginTableId: 1, * onlyIsolated: false, * }, * dex: "test", * schema: null, * }, * }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/hip-3-deployer-actions */ perpDeploy(params: PerpDeployParameters, opts?: PerpDeployOptions): Promise<PerpDeploySuccessResponse>; /** * Create a referral code. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.registerReferrer({ code: "..." }); * ``` * * @see null */ registerReferrer(params: RegisterReferrerParameters, opts?: RegisterReferrerOptions): Promise<RegisterReferrerSuccessResponse>; /** * Reserve additional rate-limited actions for a fee. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * const transport = new hl.HttpTransport(); // or `WebSocketTransport` * const client = new hl.ExchangeClient({ transport, wallet }); * * await client.reserveRequestWeight({ weight: 10 }); * ``` * * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#reserve-additional-actions */ reserveRequestWeight(params: ReserveRequestWeightParameters, opts?: ReserveRequestWeightOptions): Promise<ReserveRequestWeightSuccessResponse>; /** * Schedule a cancel-all operation at a future time. * * Signing: L1 Action. * * @param params Parameters specific to the API request. * @param opts Request execution options. * @return Successful response without specific data. * * @throws {ValidationError} 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 * as hl from "@nktkas/hyperliquid"; * import { privateKeyToAccount } from "npm:viem/accounts"; * * const wallet = privateKeyToAccount("0x..."); // viem or ethers * co