@nktkas/hyperliquid 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CONTRIBUTING.md +59 -0
  2. package/LICENSE +21 -0
  3. package/README.md +363 -0
  4. package/SECURITY.md +7 -0
  5. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +2 -0
  6. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +1 -0
  8. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +95 -0
  9. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +1 -0
  10. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +10 -0
  11. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +23 -0
  12. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +1 -0
  13. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +43 -0
  14. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts +55 -0
  15. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +65 -0
  17. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts +2 -0
  18. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +1 -0
  20. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts +52 -0
  21. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +283 -0
  23. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts +120 -0
  24. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +1 -0
  25. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +211 -0
  26. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts +19 -0
  27. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +1 -0
  28. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.js +32 -0
  29. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts +2 -0
  30. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +26 -0
  32. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts +37 -0
  33. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +1 -0
  34. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.js +109 -0
  35. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts +37 -0
  36. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +1 -0
  37. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.js +237 -0
  38. package/esm/mod.d.ts +24 -0
  39. package/esm/mod.d.ts.map +1 -0
  40. package/esm/mod.js +9 -0
  41. package/esm/package.json +3 -0
  42. package/esm/src/clients/event.d.ts +374 -0
  43. package/esm/src/clients/event.d.ts.map +1 -0
  44. package/esm/src/clients/event.js +490 -0
  45. package/esm/src/clients/public.d.ts +695 -0
  46. package/esm/src/clients/public.d.ts.map +1 -0
  47. package/esm/src/clients/public.js +704 -0
  48. package/esm/src/clients/wallet.d.ts +682 -0
  49. package/esm/src/clients/wallet.d.ts.map +1 -0
  50. package/esm/src/clients/wallet.js +984 -0
  51. package/esm/src/transports/base.d.ts +55 -0
  52. package/esm/src/transports/base.d.ts.map +1 -0
  53. package/esm/src/transports/base.js +14 -0
  54. package/esm/src/transports/http/http_transport.d.ts +78 -0
  55. package/esm/src/transports/http/http_transport.d.ts.map +1 -0
  56. package/esm/src/transports/http/http_transport.js +170 -0
  57. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts +66 -0
  58. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -0
  59. package/esm/src/transports/websocket/hyperliquid_event_target.js +33 -0
  60. package/esm/src/transports/websocket/reconnecting_websocket.d.ts +160 -0
  61. package/esm/src/transports/websocket/reconnecting_websocket.d.ts.map +1 -0
  62. package/esm/src/transports/websocket/reconnecting_websocket.js +370 -0
  63. package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts +63 -0
  64. package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts.map +1 -0
  65. package/esm/src/transports/websocket/websocket_request_dispatcher.js +201 -0
  66. package/esm/src/transports/websocket/websocket_transport.d.ts +117 -0
  67. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -0
  68. package/esm/src/transports/websocket/websocket_transport.js +233 -0
  69. package/esm/src/utils/key_sort.d.ts +21 -0
  70. package/esm/src/utils/key_sort.d.ts.map +1 -0
  71. package/esm/src/utils/key_sort.js +124 -0
  72. package/esm/src/utils/signing.d.ts +109 -0
  73. package/esm/src/utils/signing.d.ts.map +1 -0
  74. package/esm/src/utils/signing.js +164 -0
  75. package/package.json +34 -0
  76. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +2 -0
  77. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +1 -0
  78. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +17 -0
  79. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +95 -0
  80. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +1 -0
  81. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +14 -0
  82. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +23 -0
  83. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +1 -0
  84. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +49 -0
  85. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts +55 -0
  86. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +1 -0
  87. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +88 -0
  88. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts +2 -0
  89. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts.map +1 -0
  90. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +4 -0
  91. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts +52 -0
  92. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +1 -0
  93. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +288 -0
  94. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts +120 -0
  95. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +1 -0
  96. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +235 -0
  97. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts +19 -0
  98. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +1 -0
  99. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.js +35 -0
  100. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts +2 -0
  101. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts.map +1 -0
  102. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +29 -0
  103. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts +37 -0
  104. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +1 -0
  105. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.js +113 -0
  106. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts +37 -0
  107. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +1 -0
  108. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.js +240 -0
  109. package/script/mod.d.ts +24 -0
  110. package/script/mod.d.ts.map +1 -0
  111. package/script/mod.js +27 -0
  112. package/script/package.json +3 -0
  113. package/script/src/clients/event.d.ts +374 -0
  114. package/script/src/clients/event.d.ts.map +1 -0
  115. package/script/src/clients/event.js +494 -0
  116. package/script/src/clients/public.d.ts +695 -0
  117. package/script/src/clients/public.d.ts.map +1 -0
  118. package/script/src/clients/public.js +708 -0
  119. package/script/src/clients/wallet.d.ts +682 -0
  120. package/script/src/clients/wallet.d.ts.map +1 -0
  121. package/script/src/clients/wallet.js +989 -0
  122. package/script/src/transports/base.d.ts +55 -0
  123. package/script/src/transports/base.d.ts.map +1 -0
  124. package/script/src/transports/base.js +18 -0
  125. package/script/src/transports/http/http_transport.d.ts +78 -0
  126. package/script/src/transports/http/http_transport.d.ts.map +1 -0
  127. package/script/src/transports/http/http_transport.js +175 -0
  128. package/script/src/transports/websocket/hyperliquid_event_target.d.ts +66 -0
  129. package/script/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -0
  130. package/script/src/transports/websocket/hyperliquid_event_target.js +37 -0
  131. package/script/src/transports/websocket/reconnecting_websocket.d.ts +160 -0
  132. package/script/src/transports/websocket/reconnecting_websocket.d.ts.map +1 -0
  133. package/script/src/transports/websocket/reconnecting_websocket.js +374 -0
  134. package/script/src/transports/websocket/websocket_request_dispatcher.d.ts +63 -0
  135. package/script/src/transports/websocket/websocket_request_dispatcher.d.ts.map +1 -0
  136. package/script/src/transports/websocket/websocket_request_dispatcher.js +206 -0
  137. package/script/src/transports/websocket/websocket_transport.d.ts +117 -0
  138. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -0
  139. package/script/src/transports/websocket/websocket_transport.js +237 -0
  140. package/script/src/utils/key_sort.d.ts +21 -0
  141. package/script/src/utils/key_sort.d.ts.map +1 -0
  142. package/script/src/utils/key_sort.js +127 -0
  143. package/script/src/utils/signing.d.ts +109 -0
  144. package/script/src/utils/signing.d.ts.map +1 -0
  145. package/script/src/utils/signing.js +172 -0
@@ -0,0 +1,682 @@
1
+ import type { Hex } from "../types/common";
2
+ import type { ApproveAgentRequest, ApproveBuilderFeeRequest, BatchModifyRequest, CancelByCloidRequest, CancelRequest, CreateSubAccountRequest, ModifyRequest, OrderRequest, ScheduleCancelRequest, SetReferrerRequest, SpotSendRequest, SubAccountTransferRequest, TwapCancelRequest, TwapOrderRequest, UpdateIsolatedMarginRequest, UpdateLeverageRequest, UsdClassTransferRequest, UsdSendRequest, VaultTransferRequest, Withdraw3Request } from "../types/exchange/requests";
3
+ import type { CancelResponse, CreateSubAccountResponse, ErrorResponse, OrderResponse, SuccessResponse, TwapCancelResponse, TwapOrderResponse } from "../types/exchange/responses";
4
+ import type { IRequestTransport } from "../transports/base.js";
5
+ import { type AbstractEthersSigner, type AbstractEthersV5Signer, type AbstractViemWalletClient } from "../utils/signing.js";
6
+ /** Parameters for the {@linkcode WalletClient} constructor. */
7
+ export interface WalletClientParameters<T extends IRequestTransport = IRequestTransport, W extends AbstractViemWalletClient | AbstractEthersSigner | AbstractEthersV5Signer = AbstractViemWalletClient | AbstractEthersSigner | AbstractEthersV5Signer> {
8
+ /** The transport used to connect to the Hyperliquid API. */
9
+ transport: T;
10
+ /** The WalletClient/Account ([viem](https://viem.sh/docs/clients/wallet)) or Signer ([ethers.js](https://docs.ethers.org/v6/api/providers/#Signer)) used for signing transactions. */
11
+ wallet: W;
12
+ /** Specifies whether the client uses testnet. Defaults to `false`. */
13
+ isTestnet?: boolean;
14
+ /** Sets a default vaultAddress to be used if no vaultAddress is explicitly passed to a method. */
15
+ defaultVaultAddress?: Hex;
16
+ }
17
+ /** Parameters for the {@linkcode WalletClient.approveAgent} method. */
18
+ export type ApproveAgentParameters = Omit<ApproveAgentRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce"> & Partial<Pick<ApproveAgentRequest["action"], "signatureChainId" | "nonce">>;
19
+ /** Parameters for the {@linkcode WalletClient.approveBuilderFee} method. */
20
+ export type ApproveBuilderFeeParameters = Omit<ApproveBuilderFeeRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce"> & Partial<Pick<ApproveBuilderFeeRequest["action"], "signatureChainId" | "nonce">>;
21
+ /** Parameters for the {@linkcode WalletClient.batchModify} method. */
22
+ export type BatchModifyParameters = Omit<BatchModifyRequest["action"], "type"> & Partial<Pick<BatchModifyRequest, "vaultAddress" | "nonce">>;
23
+ /** Parameters for the {@linkcode WalletClient.cancel} method. */
24
+ export type CancelParameters = Omit<CancelRequest["action"], "type"> & Partial<Pick<CancelRequest, "vaultAddress" | "nonce">>;
25
+ /** Parameters for the {@linkcode WalletClient.cancelByCloid} method. */
26
+ export type CancelByCloidParameters = Omit<CancelByCloidRequest["action"], "type"> & Partial<Pick<CancelByCloidRequest, "vaultAddress" | "nonce">>;
27
+ /** Parameters for the {@linkcode WalletClient.createSubAccount} method. */
28
+ export type CreateSubAccountParameters = Omit<CreateSubAccountRequest["action"], "type"> & Partial<Pick<CreateSubAccountRequest, "nonce">>;
29
+ /** Parameters for the {@linkcode WalletClient.modify} method. */
30
+ export type ModifyParameters = Omit<ModifyRequest["action"], "type"> & Partial<Pick<ModifyRequest, "vaultAddress" | "nonce">>;
31
+ /** Parameters for the {@linkcode WalletClient.order} method. */
32
+ export type OrderParameters = Omit<OrderRequest["action"], "type"> & Partial<Pick<OrderRequest, "vaultAddress" | "nonce">>;
33
+ /** Parameters for the {@linkcode WalletClient.scheduleCancel} method. */
34
+ export type ScheduleCancelParameters = Omit<ScheduleCancelRequest["action"], "type"> & Partial<Pick<ScheduleCancelRequest, "vaultAddress" | "nonce">>;
35
+ /** Parameters for the {@linkcode WalletClient.setReferrer} method. */
36
+ export type SetReferrerParameters = Omit<SetReferrerRequest["action"], "type"> & Partial<Pick<SetReferrerRequest, "nonce">>;
37
+ /** Parameters for the {@linkcode WalletClient.spotSend} method. */
38
+ export type SpotSendParameters = Omit<SpotSendRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time"> & Partial<Pick<SpotSendRequest["action"], "signatureChainId" | "time">>;
39
+ /** Parameters for the {@linkcode WalletClient.subAccountTransfer} method. */
40
+ export type SubAccountTransferParameters = Omit<SubAccountTransferRequest["action"], "type"> & Partial<Pick<SubAccountTransferRequest, "nonce">>;
41
+ /** Parameters for the {@linkcode WalletClient.twapCancel} method. */
42
+ export type TwapCancelParameters = Omit<TwapCancelRequest["action"], "type"> & Partial<Pick<TwapCancelRequest, "vaultAddress" | "nonce">>;
43
+ /** Parameters for the {@linkcode WalletClient.twapOrder} method. */
44
+ export type TwapOrderParameters = TwapOrderRequest["action"]["twap"] & Partial<Pick<TwapOrderRequest, "vaultAddress" | "nonce">>;
45
+ /** Parameters for the {@linkcode WalletClient.updateIsolatedMargin} method. */
46
+ export type UpdateIsolatedMarginParameters = Omit<UpdateIsolatedMarginRequest["action"], "type"> & Partial<Pick<UpdateIsolatedMarginRequest, "vaultAddress" | "nonce">>;
47
+ /** Parameters for the {@linkcode WalletClient.updateLeverage} method. */
48
+ export type UpdateLeverageParameters = Omit<UpdateLeverageRequest["action"], "type"> & Partial<Pick<UpdateLeverageRequest, "vaultAddress" | "nonce">>;
49
+ /** Parameters for the {@linkcode WalletClient.usdClassTransfer} method. */
50
+ export type UsdClassTransferParameters = Omit<UsdClassTransferRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce"> & Partial<Pick<UsdClassTransferRequest["action"], "signatureChainId" | "nonce">>;
51
+ /** Parameters for the {@linkcode WalletClient.usdSend} method. */
52
+ export type UsdSendParameters = Omit<UsdSendRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time"> & Partial<Pick<UsdSendRequest["action"], "signatureChainId" | "time">>;
53
+ /** Parameters for the {@linkcode WalletClient.vaultTransfer} method. */
54
+ export type VaultTransferParameters = Omit<VaultTransferRequest["action"], "type"> & Partial<Pick<VaultTransferRequest, "nonce">>;
55
+ /** Parameters for the {@linkcode WalletClient.withdraw3} method. */
56
+ export type Withdraw3Parameters = Omit<Withdraw3Request["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time"> & Partial<Pick<Withdraw3Request["action"], "signatureChainId" | "time">>;
57
+ /** Successful variant of {@linkcode CancelResponse} without error statuses. */
58
+ export type CancelResponseSuccess = CancelResponse & {
59
+ response: {
60
+ data: {
61
+ statuses: Exclude<CancelResponse["response"]["data"]["statuses"][number], {
62
+ error: string;
63
+ }>[];
64
+ };
65
+ };
66
+ };
67
+ /** Successful variant of {@linkcode OrderResponse} without error statuses. */
68
+ export type OrderResponseSuccess = OrderResponse & {
69
+ response: {
70
+ data: {
71
+ statuses: Exclude<OrderResponse["response"]["data"]["statuses"][number], {
72
+ error: string;
73
+ }>[];
74
+ };
75
+ };
76
+ };
77
+ /** Successful variant of {@linkcode TwapCancelResponse} without error status. */
78
+ export type TwapCancelResponseSuccess = TwapCancelResponse & {
79
+ response: {
80
+ data: {
81
+ status: Exclude<TwapCancelResponse["response"]["data"]["status"], {
82
+ error: string;
83
+ }>;
84
+ };
85
+ };
86
+ };
87
+ /** Successful variant of {@linkcode TwapOrderResponse} without error status. */
88
+ export type TwapOrderResponseSuccess = TwapOrderResponse & {
89
+ response: {
90
+ data: {
91
+ status: Exclude<TwapOrderResponse["response"]["data"]["status"], {
92
+ error: string;
93
+ }>;
94
+ };
95
+ };
96
+ };
97
+ /** Error thrown when the API returns an error response. */
98
+ export declare class ApiRequestError extends Error {
99
+ response: ErrorResponse | OrderResponse | CancelResponse | TwapOrderResponse | TwapCancelResponse;
100
+ constructor(response: ErrorResponse | OrderResponse | CancelResponse | TwapOrderResponse | TwapCancelResponse);
101
+ }
102
+ /**
103
+ * Wallet client for interacting with the Hyperliquid API.
104
+ * @typeParam T - The transport used to connect to the Hyperliquid API.
105
+ * @typeParam W - The WalletClient/Account ([viem](https://viem.sh/docs/clients/wallet)) or Signer ([ethers.js](https://docs.ethers.io/v6/api/providers/#Signer)) used for signing transactions.
106
+ */
107
+ export declare class WalletClient<T extends IRequestTransport = IRequestTransport, W extends AbstractViemWalletClient | AbstractEthersSigner | AbstractEthersV5Signer = AbstractViemWalletClient | AbstractEthersSigner | AbstractEthersV5Signer> {
108
+ /** The transport used to connect to the Hyperliquid API. */
109
+ transport: T;
110
+ /** The WalletClient/Account ([viem](https://viem.sh/docs/clients/wallet)) or Signer ([ethers.js](https://docs.ethers.org/v6/api/providers/#Signer)) used for signing transactions. */
111
+ wallet: W;
112
+ /** Specifies whether the client uses testnet. */
113
+ isTestnet: boolean;
114
+ /** Sets a default vaultAddress to be used if no vaultAddress is explicitly passed to a method. */
115
+ defaultVaultAddress?: Hex;
116
+ /**
117
+ * Initialises a new instance.
118
+ * @param args - The parameters for the client.
119
+ *
120
+ * @example Private key via [viem](https://viem.sh/docs/clients/wallet#local-accounts-private-key-mnemonic-etc)
121
+ * ```ts
122
+ * import * as hl from "@nktkas/hyperliquid";
123
+ * import { privateKeyToAccount } from "viem/accounts";
124
+ *
125
+ * const wallet = privateKeyToAccount("0x...");
126
+ *
127
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
128
+ * const client = new hl.WalletClient({ wallet, transport });
129
+ * ```
130
+ *
131
+ * @example Private key via [ethers.js](https://docs.ethers.org/v6/api/wallet/#Wallet)
132
+ * ```ts
133
+ * import * as hl from "@nktkas/hyperliquid";
134
+ * import { ethers } from "ethers";
135
+ *
136
+ * const wallet = new ethers.Wallet("0x...");
137
+ *
138
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
139
+ * const client = new hl.WalletClient({ wallet, transport });
140
+ * ```
141
+ *
142
+ * @example External wallet (e.g. MetaMask) via [viem](https://viem.sh/docs/clients/wallet#optional-hoist-the-account)
143
+ * ```ts
144
+ * import * as hl from "@nktkas/hyperliquid";
145
+ * import { createWalletClient, custom } from "viem";
146
+ * import { arbitrum } from "viem/chains";
147
+ *
148
+ * const [account] = await window.ethereum.request({ method: "eth_requestAccounts" });
149
+ * const wallet = createWalletClient({ account, chain: arbitrum, transport: custom(window.ethereum) });
150
+ *
151
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
152
+ * const client = new hl.WalletClient({ wallet, transport });
153
+ * ```
154
+ */
155
+ constructor(args: WalletClientParameters<T, W>);
156
+ /**
157
+ * Approve an agent to sign on behalf of the master or sub-accounts.
158
+ * @param args - The parameters for the request.
159
+ * @param signal - An optional abort signal
160
+ * @returns {SuccessResponse} Successful response without specific data.
161
+ * @throws {ApiRequestError} When the API returns an error response.
162
+ *
163
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#approve-an-api-wallet | Hyperliquid GitBook}
164
+ * @example
165
+ * ```ts
166
+ * import * as hl from "@nktkas/hyperliquid";
167
+ * import { privateKeyToAccount } from "viem/accounts";
168
+ *
169
+ * const wallet = privateKeyToAccount("0x...");
170
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
171
+ * const client = new hl.WalletClient({ wallet, transport });
172
+ *
173
+ * const result = await client.approveAgent({
174
+ * agentAddress: "0x...",
175
+ * agentName: "agentName",
176
+ * });
177
+ */
178
+ approveAgent(args: ApproveAgentParameters, signal?: AbortSignal): Promise<SuccessResponse>;
179
+ /**
180
+ * Approve a max fee rate for a builder address.
181
+ * @param args - The parameters for the request.
182
+ * @param signal - An optional abort signal.
183
+ * @returns {SuccessResponse} Successful response without specific data.
184
+ * @throws {ApiRequestError} When the API returns an error response.
185
+ *
186
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#approve-a-builder-fee | Hyperliquid GitBook}
187
+ * @example
188
+ * ```ts
189
+ * import * as hl from "@nktkas/hyperliquid";
190
+ * import { privateKeyToAccount } from "viem/accounts";
191
+ *
192
+ * const wallet = privateKeyToAccount("0x...");
193
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
194
+ * const client = new hl.WalletClient({ wallet, transport });
195
+ *
196
+ * const result = await client.approveBuilderFee({
197
+ * maxFeeRate: "0.01%",
198
+ * builder: "0x...",
199
+ * });
200
+ */
201
+ approveBuilderFee(args: ApproveBuilderFeeParameters, signal?: AbortSignal): Promise<SuccessResponse>;
202
+ /**
203
+ * Modify multiple orders.
204
+ * @param args - The parameters for the request.
205
+ * @param signal - An optional abort signal.
206
+ * @returns {OrderResponseSuccess} Successful variant of {@link OrderResponse} without error statuses.
207
+ * @throws {ApiRequestError} When the API returns an error response.
208
+ *
209
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders | Hyperliquid GitBook}
210
+ * @example
211
+ * ```ts
212
+ * import * as hl from "@nktkas/hyperliquid";
213
+ * import { privateKeyToAccount } from "viem/accounts";
214
+ *
215
+ * const wallet = privateKeyToAccount("0x...");
216
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
217
+ * const client = new hl.WalletClient({ wallet, transport });
218
+ *
219
+ * const result = await client.batchModify({
220
+ * modifies: [{
221
+ * oid: 123, // Order ID
222
+ * order: {
223
+ * a: 0, // Asset index
224
+ * b: true, // Buy order
225
+ * p: "31000", // New price
226
+ * s: "0.2", // New size
227
+ * r: false, // Not reduce-only
228
+ * t: {
229
+ * limit: {
230
+ * tif: "Gtc", // Good-til-cancelled
231
+ * },
232
+ * },
233
+ * c: "0x...", // Optional: Client Order ID
234
+ * },
235
+ * }],
236
+ * });
237
+ * ```
238
+ */
239
+ batchModify(args: BatchModifyParameters, signal?: AbortSignal): Promise<OrderResponseSuccess>;
240
+ /**
241
+ * Cancel order(s).
242
+ * @param args - The parameters for the request.
243
+ * @param signal - An optional abort signal.
244
+ * @returns {CancelResponseSuccess} Successful variant of {@link CancelResponse} without error statuses.
245
+ * @throws {ApiRequestError} When the API returns an error response.
246
+ *
247
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s | Hyperliquid GitBook}
248
+ * @example
249
+ * ```ts
250
+ * import * as hl from "@nktkas/hyperliquid";
251
+ * import { privateKeyToAccount } from "viem/accounts";
252
+ *
253
+ * const wallet = privateKeyToAccount("0x...");
254
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
255
+ * const client = new hl.WalletClient({ wallet, transport });
256
+ *
257
+ * const result = await client.cancel({
258
+ * cancels: [{
259
+ * a: 0, // Asset index
260
+ * o: 123, // Order ID
261
+ * }],
262
+ * });
263
+ * ```
264
+ */
265
+ cancel(args: CancelParameters, signal?: AbortSignal): Promise<CancelResponseSuccess>;
266
+ /**
267
+ * Cancel order(s) by Client Order ID.
268
+ * @param args - The parameters for the request.
269
+ * @param signal - An optional abort signal.
270
+ * @returns {CancelResponseSuccess} Successful variant of {@link CancelResponse} without error statuses.
271
+ * @throws {ApiRequestError} When the API returns an error response.
272
+ *
273
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid | Hyperliquid GitBook}
274
+ * @example
275
+ * ```ts
276
+ * import * as hl from "@nktkas/hyperliquid";
277
+ * import { privateKeyToAccount } from "viem/accounts";
278
+ *
279
+ * const wallet = privateKeyToAccount("0x...");
280
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
281
+ * const client = new hl.WalletClient({ wallet, transport });
282
+ *
283
+ * const result = await client.cancelByCloid({
284
+ * cancels: [{
285
+ * asset: 0,
286
+ * cloid: "0x...", // Client Order ID
287
+ * }],
288
+ * });
289
+ * ```
290
+ */
291
+ cancelByCloid(args: CancelByCloidParameters, signal?: AbortSignal): Promise<CancelResponseSuccess>;
292
+ /**
293
+ * Create a sub-account.
294
+ * @param args - The parameters for the request.
295
+ * @param signal - An optional abort signal.
296
+ * @returns {CreateSubAccountResponse} Response for creating a sub-account.
297
+ * @throws {ApiRequestError} When the API returns an error response.
298
+ *
299
+ * @example
300
+ * ```ts
301
+ * import * as hl from "@nktkas/hyperliquid";
302
+ * import { privateKeyToAccount } from "viem/accounts";
303
+ *
304
+ * const wallet = privateKeyToAccount("0x...");
305
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
306
+ * const client = new hl.WalletClient({ wallet, transport });
307
+ *
308
+ * const result = await client.createSubAccount({
309
+ * name: "subAccountName",
310
+ * });
311
+ * ```
312
+ */
313
+ createSubAccount(args: CreateSubAccountParameters, signal?: AbortSignal): Promise<CreateSubAccountResponse>;
314
+ /**
315
+ * Modify an order.
316
+ * @param args - The parameters for the request.
317
+ * @param signal - An optional abort signal.
318
+ * @returns {SuccessResponse} Successful response without specific data.
319
+ * @throws {ApiRequestError} When the API returns an error response.
320
+ *
321
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-an-order | Hyperliquid GitBook}
322
+ * @example
323
+ * ```ts
324
+ * import * as hl from "@nktkas/hyperliquid";
325
+ * import { privateKeyToAccount } from "viem/accounts";
326
+ *
327
+ * const wallet = privateKeyToAccount("0x...");
328
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
329
+ * const client = new hl.WalletClient({ wallet, transport });
330
+ *
331
+ * const result = await client.modify({
332
+ * oid: 123, // Order ID
333
+ * order: {
334
+ * a: 0, // Asset index
335
+ * b: true, // Buy order
336
+ * p: "31000", // New price
337
+ * s: "0.2", // New size
338
+ * r: false, // Not reduce-only
339
+ * t: {
340
+ * limit: {
341
+ * tif: "Gtc", // Good-til-cancelled
342
+ * },
343
+ * },
344
+ * c: "0x...", // Optional: Client Order ID
345
+ * },
346
+ * });
347
+ * ```
348
+ */
349
+ modify(args: ModifyParameters, signal?: AbortSignal): Promise<SuccessResponse>;
350
+ /**
351
+ * Place an order(s).
352
+ * @param args - The parameters for the request.
353
+ * @param signal - An optional abort signal.
354
+ * @returns {OrderResponseSuccess} Successful variant of {@link OrderResponse} without error statuses.
355
+ * @throws {ApiRequestError} When the API returns an error response.
356
+ *
357
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order | Hyperliquid GitBook}
358
+ * @example
359
+ * ```ts
360
+ * import * as hl from "@nktkas/hyperliquid";
361
+ * import { privateKeyToAccount } from "viem/accounts";
362
+ *
363
+ * const wallet = privateKeyToAccount("0x...");
364
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
365
+ * const client = new hl.WalletClient({ wallet, transport });
366
+ *
367
+ * const result = await client.order({
368
+ * orders: [{
369
+ * a: 0, // Asset index
370
+ * b: true, // Buy order
371
+ * p: "30000", // Price
372
+ * s: "0.1", // Size
373
+ * r: false, // Not reduce-only
374
+ * t: {
375
+ * limit: {
376
+ * tif: "Gtc", // Good-til-cancelled
377
+ * },
378
+ * },
379
+ * c: "0x...", // Optional: Client Order ID
380
+ * }],
381
+ * grouping: "na", // No grouping
382
+ * });
383
+ * ```
384
+ */
385
+ order(args: OrderParameters, signal?: AbortSignal): Promise<OrderResponseSuccess>;
386
+ /**
387
+ * Schedule a time to cancel all open orders.
388
+ * @param args - The parameters for the request.
389
+ * @param signal - An optional abort signal.
390
+ * @returns {SuccessResponse} Successful response without specific data.
391
+ * @throws {ApiRequestError} When the API returns an error response.
392
+ *
393
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#schedule-cancel-dead-mans-switch | Hyperliquid GitBook}
394
+ * @example
395
+ * ```ts
396
+ * import * as hl from "@nktkas/hyperliquid";
397
+ * import { privateKeyToAccount } from "viem/accounts";
398
+ *
399
+ * const wallet = privateKeyToAccount("0x...");
400
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
401
+ * const client = new hl.WalletClient({ wallet, transport });
402
+ *
403
+ * const result = await client.scheduleCancel({
404
+ * time: Date.now() + 3600000, // Schedule cancellation 1 hour from now
405
+ * });
406
+ * ```
407
+ */
408
+ scheduleCancel(args?: ScheduleCancelParameters, signal?: AbortSignal): Promise<SuccessResponse>;
409
+ /**
410
+ * Set a referral code.
411
+ * @param args - The parameters for the request.
412
+ * @param signal - An optional abort signal.
413
+ * @returns {SuccessResponse} Successful response without specific data.
414
+ * @throws {ApiRequestError} When the API returns an error response.
415
+ *
416
+ * @example
417
+ * ```ts
418
+ * import * as hl from "@nktkas/hyperliquid";
419
+ * import { privateKeyToAccount } from "viem/accounts";
420
+ *
421
+ * const wallet = privateKeyToAccount("0x...");
422
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
423
+ * const client = new hl.WalletClient({ wallet, transport });
424
+ *
425
+ * const result = await client.setReferrer({
426
+ * code: "TEST",
427
+ * });
428
+ * ```
429
+ */
430
+ setReferrer(args: SetReferrerParameters, signal?: AbortSignal): Promise<SuccessResponse>;
431
+ /**
432
+ * Transfer a spot asset on L1 to another address.
433
+ * @param args - The parameters for the request.
434
+ * @param signal - An optional abort signal.
435
+ * @returns {SuccessResponse} Successful response without specific data.
436
+ * @throws {ApiRequestError} When the API returns an error response.
437
+ *
438
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#l1-spot-transfer | Hyperliquid GitBook}
439
+ * @example
440
+ * ```ts
441
+ * import * as hl from "@nktkas/hyperliquid";
442
+ * import { privateKeyToAccount } from "viem/accounts";
443
+ *
444
+ * const wallet = privateKeyToAccount("0x...");
445
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
446
+ * const client = new hl.WalletClient({ wallet, transport });
447
+ *
448
+ * const result = await client.spotSend({
449
+ * destination: "0x...",
450
+ * token: "USDC:0xeb62eee3685fc4c43992febcd9e75443",
451
+ * amount: "1",
452
+ * });
453
+ * ```
454
+ */
455
+ spotSend(args: SpotSendParameters, signal?: AbortSignal): Promise<SuccessResponse>;
456
+ /**
457
+ * Transfer between sub-accounts.
458
+ * @param args - The parameters for the request.
459
+ * @param signal - An optional abort signal.
460
+ * @returns {SuccessResponse} Successful response without specific data.
461
+ * @throws {ApiRequestError} When the API returns an error response.
462
+ *
463
+ * @example
464
+ * ```ts
465
+ * import * as hl from "@nktkas/hyperliquid";
466
+ * import { privateKeyToAccount } from "viem/accounts";
467
+ *
468
+ * const wallet = privateKeyToAccount("0x...");
469
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
470
+ * const client = new hl.WalletClient({ wallet, transport });
471
+ *
472
+ * const result = await client.subAccountTransfer({
473
+ * subAccountUser: "0x...",
474
+ * isDeposit: true,
475
+ * usd: 1000000, // 1 USD in raw units (float amount * 1e6)
476
+ * });
477
+ * ```
478
+ */
479
+ subAccountTransfer(args: SubAccountTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
480
+ /**
481
+ * Cancel a TWAP order.
482
+ * @param args - The parameters for the request.
483
+ * @param signal - An optional abort signal.
484
+ * @returns {TwapCancelResponseSuccess} Successful variant of {@link TwapCancelResponse} without error status.
485
+ * @throws {ApiRequestError} When the API returns an error response.
486
+ *
487
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-a-twap-order | Hyperliquid GitBook}
488
+ * @example
489
+ * ```ts
490
+ * import * as hl from "@nktkas/hyperliquid";
491
+ * import { privateKeyToAccount } from "viem/accounts";
492
+ *
493
+ * const wallet = privateKeyToAccount("0x...");
494
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
495
+ * const client = new hl.WalletClient({ wallet, transport });
496
+ *
497
+ * const result = await client.twapCancel({
498
+ * a: 0, // Asset index
499
+ * t: 1, // TWAP ID
500
+ * });
501
+ * ```
502
+ */
503
+ twapCancel(args: TwapCancelParameters, signal?: AbortSignal): Promise<TwapCancelResponseSuccess>;
504
+ /**
505
+ * Place a TWAP order.
506
+ * @param args - The parameters for the request.
507
+ * @param signal - An optional abort signal.
508
+ * @returns {TwapOrderResponseSuccess} Successful variant of {@link TwapOrderResponse} without error status.
509
+ * @throws {ApiRequestError} When the API returns an error response.
510
+ *
511
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-a-twap-order | Hyperliquid GitBook}
512
+ * @example
513
+ * ```ts
514
+ * import * as hl from "@nktkas/hyperliquid";
515
+ * import { privateKeyToAccount } from "viem/accounts";
516
+ *
517
+ * const wallet = privateKeyToAccount("0x...");
518
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
519
+ * const client = new hl.WalletClient({ wallet, transport });
520
+ *
521
+ * const result = await client.twapOrder({
522
+ * a: 0, // Asset index
523
+ * b: true, // Buy order
524
+ * s: "1", // Size
525
+ * r: false, // Not reduce-only
526
+ * m: 10, // Duration in minutes
527
+ * t: true, // Randomize order timing
528
+ * });
529
+ * ```
530
+ */
531
+ twapOrder(args: TwapOrderParameters, signal?: AbortSignal): Promise<TwapOrderResponseSuccess>;
532
+ /**
533
+ * Update isolated margin for a position.
534
+ * @param args - The parameters for the request.
535
+ * @param signal - An optional abort signal.
536
+ * @returns {SuccessResponse} Successful response without specific data.
537
+ * @throws {ApiRequestError} When the API returns an error response.
538
+ *
539
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#update-isolated-margin | Hyperliquid GitBook}
540
+ * @example
541
+ * ```ts
542
+ * import * as hl from "@nktkas/hyperliquid";
543
+ * import { privateKeyToAccount } from "viem/accounts";
544
+ *
545
+ * const wallet = privateKeyToAccount("0x...");
546
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
547
+ * const client = new hl.WalletClient({ wallet, transport });
548
+ *
549
+ * const result = await client.updateIsolatedMargin({
550
+ * asset: 0,
551
+ * isBuy: true, // Add to long position
552
+ * ntli: 1000, // Add 1000 USD margin (integer only)
553
+ * });
554
+ * ```
555
+ */
556
+ updateIsolatedMargin(args: UpdateIsolatedMarginParameters, signal?: AbortSignal): Promise<SuccessResponse>;
557
+ /**
558
+ * Update leverage for cross or isolated margin.
559
+ * @param args - The parameters for the request.
560
+ * @param signal - An optional abort signal.
561
+ * @returns {SuccessResponse} Successful response without specific data.
562
+ * @throws {ApiRequestError} When the API returns an error response.
563
+ *
564
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#update-leverage | Hyperliquid GitBook}
565
+ * @example
566
+ * ```ts
567
+ * import * as hl from "@nktkas/hyperliquid";
568
+ * import { privateKeyToAccount } from "viem/accounts";
569
+ *
570
+ * const wallet = privateKeyToAccount("0x...");
571
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
572
+ * const client = new hl.WalletClient({ wallet, transport });
573
+ *
574
+ * const result = await client.updateLeverage({
575
+ * asset: 0,
576
+ * isCross: true,
577
+ * leverage: 5,
578
+ * });
579
+ * ```
580
+ */
581
+ updateLeverage(args: UpdateLeverageParameters, signal?: AbortSignal): Promise<SuccessResponse>;
582
+ /**
583
+ * Transfer funds between Spot and Perp accounts.
584
+ * @param args - The parameters for the request.
585
+ * @param signal - An optional abort signal.
586
+ * @returns {SuccessResponse} Successful response without specific data.
587
+ * @throws {ApiRequestError} When the API returns an error response.
588
+ *
589
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#transfer-from-spot-account-to-perp-account-and-vice-versa | Hyperliquid GitBook}
590
+ * @example
591
+ * ```ts
592
+ * import * as hl from "@nktkas/hyperliquid";
593
+ * import { privateKeyToAccount } from "viem/accounts";
594
+ *
595
+ * const wallet = privateKeyToAccount("0x...");
596
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
597
+ * const client = new hl.WalletClient({ wallet, transport });
598
+ *
599
+ * const result = await client.usdClassTransfer({
600
+ * amount: "1000",
601
+ * toPerp: true, // Transfer from Spot to Perp
602
+ * });
603
+ * ```
604
+ */
605
+ usdClassTransfer(args: UsdClassTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
606
+ /**
607
+ * Transfer USDC on L1 to another address.
608
+ * @param args - The parameters for the request.
609
+ * @param signal - An optional abort signal.
610
+ * @returns {SuccessResponse} Successful response without specific data.
611
+ * @throws {ApiRequestError} When the API returns an error response.
612
+ *
613
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#l1-usdc-transfer | Hyperliquid GitBook}
614
+ * @example
615
+ * ```ts
616
+ * import * as hl from "@nktkas/hyperliquid";
617
+ * import { privateKeyToAccount } from "viem/accounts";
618
+ *
619
+ * const wallet = privateKeyToAccount("0x...");
620
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
621
+ * const client = new hl.WalletClient({ wallet, transport });
622
+ *
623
+ * const result = await client.usdSend({
624
+ * destination: "0x...",
625
+ * amount: "1000",
626
+ * });
627
+ * ```
628
+ */
629
+ usdSend(args: UsdSendParameters, signal?: AbortSignal): Promise<SuccessResponse>;
630
+ /**
631
+ * Transfer funds to/from a vault.
632
+ * @param args - The parameters for the request.
633
+ * @param signal - An optional abort signal.
634
+ * @returns {SuccessResponse} Successful response without specific data.
635
+ * @throws {ApiRequestError} When the API returns an error response.
636
+ *
637
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-a-vault | Hyperliquid GitBook}
638
+ * @example
639
+ * ```ts
640
+ * import * as hl from "@nktkas/hyperliquid";
641
+ * import { privateKeyToAccount } from "viem/accounts";
642
+ *
643
+ * const wallet = privateKeyToAccount("0x...");
644
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
645
+ * const client = new hl.WalletClient({ wallet, transport });
646
+ *
647
+ * const result = await client.vaultTransfer({
648
+ * vaultAddress: "0x...",
649
+ * isDeposit: true,
650
+ * usd: 1000000, // 1 USD in raw units (float amount * 1e6)
651
+ * });
652
+ * ```
653
+ */
654
+ vaultTransfer(args: VaultTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
655
+ /**
656
+ * Initiate a withdrawal request.
657
+ * @param args - The parameters for the request.
658
+ * @param signal - An optional abort signal.
659
+ * @returns {SuccessResponse} Successful response without specific data.
660
+ * @throws {ApiRequestError} When the API returns an error response.
661
+ *
662
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#initiate-a-withdrawal-request | Hyperliquid GitBook}
663
+ * @example
664
+ * ```ts
665
+ * import * as hl from "@nktkas/hyperliquid";
666
+ * import { privateKeyToAccount } from "viem/accounts";
667
+ *
668
+ * const wallet = privateKeyToAccount("0x...");
669
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
670
+ * const client = new hl.WalletClient({ wallet, transport });
671
+ *
672
+ * const result = await client.withdraw3({
673
+ * destination: "0x...",
674
+ * amount: "1000",
675
+ * });
676
+ * ```
677
+ */
678
+ withdraw3(args: Withdraw3Parameters, signal?: AbortSignal): Promise<SuccessResponse>;
679
+ /** Validate a response from the API. */
680
+ protected _validateResponse(response: SuccessResponse | ErrorResponse | CancelResponse | CreateSubAccountResponse | OrderResponse | TwapOrderResponse | TwapCancelResponse): asserts response is SuccessResponse | CancelResponseSuccess | CreateSubAccountResponse | OrderResponseSuccess | TwapOrderResponseSuccess | TwapCancelResponseSuccess;
681
+ }
682
+ //# sourceMappingURL=wallet.d.ts.map