@nktkas/hyperliquid 0.23.1 → 0.24.1

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 (165) hide show
  1. package/CONTRIBUTING.md +3 -2
  2. package/README.md +178 -194
  3. package/esm/mod.d.ts +2 -1
  4. package/esm/mod.d.ts.map +1 -1
  5. package/esm/src/base.d.ts +0 -5
  6. package/esm/src/base.d.ts.map +1 -1
  7. package/esm/src/clients/exchange.d.ts +485 -392
  8. package/esm/src/clients/exchange.d.ts.map +1 -1
  9. package/esm/src/clients/exchange.js +517 -912
  10. package/esm/src/clients/info.d.ts +249 -203
  11. package/esm/src/clients/info.d.ts.map +1 -1
  12. package/esm/src/clients/info.js +258 -368
  13. package/esm/src/clients/multiSign.d.ts +14 -1184
  14. package/esm/src/clients/multiSign.d.ts.map +1 -1
  15. package/esm/src/clients/multiSign.js +37 -2004
  16. package/esm/src/clients/subscription.d.ts +101 -99
  17. package/esm/src/clients/subscription.d.ts.map +1 -1
  18. package/esm/src/clients/subscription.js +107 -152
  19. package/esm/src/signing/_signTypedData/ethers.d.ts +16 -4
  20. package/esm/src/signing/_signTypedData/ethers.d.ts.map +1 -1
  21. package/esm/src/signing/_signTypedData/ethers.js +1 -1
  22. package/esm/src/signing/_signTypedData/mod.d.ts +12 -12
  23. package/esm/src/signing/_signTypedData/mod.d.ts.map +1 -1
  24. package/esm/src/signing/_signTypedData/mod.js +52 -24
  25. package/esm/src/signing/_signTypedData/private_key.d.ts +6 -5
  26. package/esm/src/signing/_signTypedData/private_key.d.ts.map +1 -1
  27. package/esm/src/signing/_signTypedData/private_key.js +40 -19
  28. package/esm/src/signing/_signTypedData/viem.d.ts +27 -6
  29. package/esm/src/signing/_signTypedData/viem.d.ts.map +1 -1
  30. package/esm/src/signing/_signTypedData/viem.js +1 -1
  31. package/esm/src/signing/_sorter.d.ts +18 -19
  32. package/esm/src/signing/_sorter.d.ts.map +1 -1
  33. package/esm/src/signing/_sorter.js +57 -59
  34. package/esm/src/signing/mod.d.ts +179 -129
  35. package/esm/src/signing/mod.d.ts.map +1 -1
  36. package/esm/src/signing/mod.js +184 -132
  37. package/esm/src/transports/base.d.ts +2 -1
  38. package/esm/src/transports/base.d.ts.map +1 -1
  39. package/esm/src/transports/http/http_transport.d.ts +3 -2
  40. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  41. package/esm/src/transports/http/http_transport.js +4 -4
  42. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +14 -6
  43. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  44. package/esm/src/transports/websocket/_hyperliquid_event_target.js +1 -2
  45. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts +2 -1
  46. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  47. package/esm/src/transports/websocket/_reconnecting_websocket.js +1 -0
  48. package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
  49. package/esm/src/transports/websocket/_websocket_async_request.js +17 -21
  50. package/esm/src/transports/websocket/websocket_transport.d.ts +4 -4
  51. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  52. package/esm/src/transports/websocket/websocket_transport.js +6 -6
  53. package/esm/src/types/exchange/requests.d.ts +547 -306
  54. package/esm/src/types/exchange/requests.d.ts.map +1 -1
  55. package/esm/src/types/exchange/responses.d.ts +105 -25
  56. package/esm/src/types/exchange/responses.d.ts.map +1 -1
  57. package/esm/src/types/explorer/requests.d.ts +3 -3
  58. package/esm/src/types/explorer/requests.d.ts.map +1 -1
  59. package/esm/src/types/explorer/responses.d.ts +1 -1
  60. package/esm/src/types/explorer/responses.d.ts.map +1 -1
  61. package/esm/src/types/info/accounts.d.ts +405 -98
  62. package/esm/src/types/info/accounts.d.ts.map +1 -1
  63. package/esm/src/types/info/assets.d.ts +131 -35
  64. package/esm/src/types/info/assets.d.ts.map +1 -1
  65. package/esm/src/types/info/markets.d.ts +29 -8
  66. package/esm/src/types/info/markets.d.ts.map +1 -1
  67. package/esm/src/types/info/orders.d.ts +64 -17
  68. package/esm/src/types/info/orders.d.ts.map +1 -1
  69. package/esm/src/types/info/requests.d.ts +126 -51
  70. package/esm/src/types/info/requests.d.ts.map +1 -1
  71. package/esm/src/types/info/validators.d.ts +44 -14
  72. package/esm/src/types/info/validators.d.ts.map +1 -1
  73. package/esm/src/types/info/vaults.d.ts +25 -10
  74. package/esm/src/types/info/vaults.d.ts.map +1 -1
  75. package/esm/src/types/mod.d.ts +1 -1
  76. package/esm/src/types/mod.d.ts.map +1 -1
  77. package/esm/src/types/subscriptions/requests.d.ts +21 -66
  78. package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
  79. package/esm/src/types/subscriptions/responses.d.ts +46 -55
  80. package/esm/src/types/subscriptions/responses.d.ts.map +1 -1
  81. package/package.json +2 -3
  82. package/script/mod.d.ts +2 -1
  83. package/script/mod.d.ts.map +1 -1
  84. package/script/src/base.d.ts +0 -5
  85. package/script/src/base.d.ts.map +1 -1
  86. package/script/src/clients/exchange.d.ts +485 -392
  87. package/script/src/clients/exchange.d.ts.map +1 -1
  88. package/script/src/clients/exchange.js +516 -911
  89. package/script/src/clients/info.d.ts +249 -203
  90. package/script/src/clients/info.d.ts.map +1 -1
  91. package/script/src/clients/info.js +258 -368
  92. package/script/src/clients/multiSign.d.ts +14 -1184
  93. package/script/src/clients/multiSign.d.ts.map +1 -1
  94. package/script/src/clients/multiSign.js +38 -2005
  95. package/script/src/clients/subscription.d.ts +101 -99
  96. package/script/src/clients/subscription.d.ts.map +1 -1
  97. package/script/src/clients/subscription.js +107 -152
  98. package/script/src/signing/_signTypedData/ethers.d.ts +16 -4
  99. package/script/src/signing/_signTypedData/ethers.d.ts.map +1 -1
  100. package/script/src/signing/_signTypedData/ethers.js +2 -2
  101. package/script/src/signing/_signTypedData/mod.d.ts +12 -12
  102. package/script/src/signing/_signTypedData/mod.d.ts.map +1 -1
  103. package/script/src/signing/_signTypedData/mod.js +51 -26
  104. package/script/src/signing/_signTypedData/private_key.d.ts +6 -5
  105. package/script/src/signing/_signTypedData/private_key.d.ts.map +1 -1
  106. package/script/src/signing/_signTypedData/private_key.js +40 -18
  107. package/script/src/signing/_signTypedData/viem.d.ts +27 -6
  108. package/script/src/signing/_signTypedData/viem.d.ts.map +1 -1
  109. package/script/src/signing/_signTypedData/viem.js +2 -2
  110. package/script/src/signing/_sorter.d.ts +18 -19
  111. package/script/src/signing/_sorter.d.ts.map +1 -1
  112. package/script/src/signing/_sorter.js +57 -59
  113. package/script/src/signing/mod.d.ts +179 -129
  114. package/script/src/signing/mod.d.ts.map +1 -1
  115. package/script/src/signing/mod.js +187 -150
  116. package/script/src/transports/base.d.ts +2 -1
  117. package/script/src/transports/base.d.ts.map +1 -1
  118. package/script/src/transports/http/http_transport.d.ts +3 -2
  119. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  120. package/script/src/transports/http/http_transport.js +4 -4
  121. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +14 -6
  122. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  123. package/script/src/transports/websocket/_hyperliquid_event_target.js +1 -2
  124. package/script/src/transports/websocket/_reconnecting_websocket.d.ts +2 -1
  125. package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  126. package/script/src/transports/websocket/_reconnecting_websocket.js +1 -0
  127. package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
  128. package/script/src/transports/websocket/_websocket_async_request.js +17 -21
  129. package/script/src/transports/websocket/websocket_transport.d.ts +4 -4
  130. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  131. package/script/src/transports/websocket/websocket_transport.js +6 -6
  132. package/script/src/types/exchange/requests.d.ts +547 -306
  133. package/script/src/types/exchange/requests.d.ts.map +1 -1
  134. package/script/src/types/exchange/responses.d.ts +105 -25
  135. package/script/src/types/exchange/responses.d.ts.map +1 -1
  136. package/script/src/types/explorer/requests.d.ts +3 -3
  137. package/script/src/types/explorer/requests.d.ts.map +1 -1
  138. package/script/src/types/explorer/responses.d.ts +1 -1
  139. package/script/src/types/explorer/responses.d.ts.map +1 -1
  140. package/script/src/types/info/accounts.d.ts +405 -98
  141. package/script/src/types/info/accounts.d.ts.map +1 -1
  142. package/script/src/types/info/assets.d.ts +131 -35
  143. package/script/src/types/info/assets.d.ts.map +1 -1
  144. package/script/src/types/info/markets.d.ts +29 -8
  145. package/script/src/types/info/markets.d.ts.map +1 -1
  146. package/script/src/types/info/orders.d.ts +64 -17
  147. package/script/src/types/info/orders.d.ts.map +1 -1
  148. package/script/src/types/info/requests.d.ts +126 -51
  149. package/script/src/types/info/requests.d.ts.map +1 -1
  150. package/script/src/types/info/validators.d.ts +44 -14
  151. package/script/src/types/info/validators.d.ts.map +1 -1
  152. package/script/src/types/info/vaults.d.ts +25 -10
  153. package/script/src/types/info/vaults.d.ts.map +1 -1
  154. package/script/src/types/mod.d.ts +1 -1
  155. package/script/src/types/mod.d.ts.map +1 -1
  156. package/script/src/types/subscriptions/requests.d.ts +21 -66
  157. package/script/src/types/subscriptions/requests.d.ts.map +1 -1
  158. package/script/src/types/subscriptions/responses.d.ts +46 -55
  159. package/script/src/types/subscriptions/responses.d.ts.map +1 -1
  160. package/esm/src/signing/_signTypedData/window.d.ts +0 -29
  161. package/esm/src/signing/_signTypedData/window.d.ts.map +0 -1
  162. package/esm/src/signing/_signTypedData/window.js +0 -30
  163. package/script/src/signing/_signTypedData/window.d.ts +0 -29
  164. package/script/src/signing/_signTypedData/window.d.ts.map +0 -1
  165. package/script/src/signing/_signTypedData/window.js +0 -34
@@ -1,13 +1,17 @@
1
- import { type DeepImmutable, type Hex, HyperliquidError, type MaybePromise } from "../base.js";
1
+ import { HyperliquidError } from "../base.js";
2
2
  import type { IRequestTransport } from "../transports/base.js";
3
- import type { ApproveAgentRequest, ApproveBuilderFeeRequest, BatchModifyRequest, CancelByCloidRequest, CancelRequest, CDepositRequest, ConvertToMultiSigUserRequest_Signers, CreateSubAccountRequest, CreateVaultRequest, CSignerActionRequest_JailSelf, CSignerActionRequest_UnjailSelf, CValidatorActionRequest_ChangeProfile, CValidatorActionRequest_Register, CValidatorActionRequest_Unregister, CWithdrawRequest, EvmUserModifyRequest, ModifyRequest, MultiSigRequest, OrderRequest, PerpDeployRequest_RegisterAsset, PerpDeployRequest_SetOracle, PerpDexClassTransferRequest, PerpDexTransferRequest, RegisterReferrerRequest, ReserveRequestWeightRequest, ScheduleCancelRequest, SetDisplayNameRequest, SetReferrerRequest, SpotDeployRequest_Genesis, SpotDeployRequest_RegisterHyperliquidity, SpotDeployRequest_RegisterSpot, SpotDeployRequest_RegisterToken2, SpotDeployRequest_SetDeployerTradingFeeShare, SpotDeployRequest_UserGenesis, SpotSendRequest, SpotUserRequest, SubAccountSpotTransferRequest, SubAccountTransferRequest, TokenDelegateRequest, TwapCancelRequest, TwapOrderRequest, UpdateIsolatedMarginRequest, UpdateLeverageRequest, UsdClassTransferRequest, UsdSendRequest, VaultDistributeRequest, VaultModifyRequest, VaultTransferRequest, Withdraw3Request } from "../types/exchange/requests.js";
4
- import type { CancelResponse, CreateSubAccountResponse, CreateVaultResponse, ErrorResponse, OrderResponse, SuccessResponse, TwapCancelResponse, TwapOrderResponse } from "../types/exchange/responses.js";
5
- import { type AbstractWallet } from "../signing/mod.js";
3
+ import type { ApproveAgentRequest, ApproveBuilderFeeRequest, BatchModifyRequest, CancelByCloidRequest, CancelRequest, CancelResponse, CancelSuccessResponse, CDepositRequest, ClaimRewardsRequest, ConvertToMultiSigUserRequest, ConvertToMultiSigUserRequestWithoutStringify, CreateSubAccountRequest, CreateSubAccountResponse, CreateVaultRequest, CreateVaultResponse, CSignerActionRequest, CValidatorActionRequest, CWithdrawRequest, ErrorResponse, EvmUserModifyRequest, Hex, ModifyRequest, MultiSigRequest, NoopRequest, OrderRequest, OrderResponse, OrderSuccessResponse, PerpDeployRequest, RegisterReferrerRequest, ReserveRequestWeightRequest, ScheduleCancelRequest, SendAssetRequest, SetDisplayNameRequest, SetReferrerRequest, SpotDeployRequest, SpotSendRequest, SpotUserRequest, SubAccountModifyRequest, SubAccountSpotTransferRequest, SubAccountTransferRequest, SuccessResponse, TokenDelegateRequest, TwapCancelRequest, TwapCancelResponse, TwapCancelSuccessResponse, TwapOrderRequest, TwapOrderResponse, TwapOrderSuccessResponse, UpdateIsolatedMarginRequest, UpdateLeverageRequest, UsdClassTransferRequest, UsdSendRequest, VaultDistributeRequest, VaultModifyRequest, VaultTransferRequest, Withdraw3Request } from "../types/mod.js";
4
+ import { type AbstractWallet, actionSorter, userSignedActionEip712Types } from "../signing/mod.js";
5
+ type MaybePromise<T> = T | Promise<T>;
6
+ /** @see https://github.com/microsoft/TypeScript/issues/13923#issuecomment-2191862501 */
7
+ type DeepImmutable<T> = {
8
+ readonly [K in keyof T]: DeepImmutable<T[K]>;
9
+ };
6
10
  /** Parameters for the {@linkcode ExchangeClient} constructor. */
7
11
  export interface ExchangeClientParameters<T extends IRequestTransport = IRequestTransport, W extends AbstractWallet = AbstractWallet> {
8
12
  /** The transport used to connect to the Hyperliquid API. */
9
13
  transport: T;
10
- /** The `viem`, `ethers.js`, or `window.ethereum` wallet used for signing transactions. */
14
+ /** The viem or ethers.js wallet used for signing transactions. */
11
15
  wallet: W;
12
16
  /**
13
17
  * Specifies whether the client uses testnet.
@@ -23,7 +27,7 @@ export interface ExchangeClientParameters<T extends IRequestTransport = IRequest
23
27
  * The network that will be used to sign transactions.
24
28
  * Must match the network of the {@link wallet}.
25
29
  *
26
- * Defaults to trying to get the current wallet network. Otherwise `0xa4b1` for `isTestnet = false` or `0x66eee` for `isTestnet = true` will be used.
30
+ * Defaults to get chain id from wallet otherwise `0x1`.
27
31
  */
28
32
  signatureChainId?: Hex | (() => MaybePromise<Hex>);
29
33
  /**
@@ -33,156 +37,188 @@ export interface ExchangeClientParameters<T extends IRequestTransport = IRequest
33
37
  */
34
38
  nonceManager?: () => MaybePromise<number>;
35
39
  }
36
- /** Parameters for the {@linkcode ExchangeClient.approveAgent} method. */
37
- export type ApproveAgentParameters = Omit<ApproveAgentRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
38
- /** Parameters for the {@linkcode ExchangeClient.approveBuilderFee} method. */
39
- export type ApproveBuilderFeeParameters = Omit<ApproveBuilderFeeRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
40
- /** Parameters for the {@linkcode ExchangeClient.batchModify} method. */
41
- export type BatchModifyParameters = Omit<BatchModifyRequest["action"], "type"> & Partial<Pick<BatchModifyRequest, "vaultAddress">> & Partial<Pick<BatchModifyRequest, "expiresAfter">>;
42
- /** Parameters for the {@linkcode ExchangeClient.cancel} method. */
43
- export type CancelParameters = Omit<CancelRequest["action"], "type"> & Partial<Pick<CancelRequest, "vaultAddress">> & Partial<Pick<CancelRequest, "expiresAfter">>;
44
- /** Parameters for the {@linkcode ExchangeClient.cancelByCloid} method. */
45
- export type CancelByCloidParameters = Omit<CancelByCloidRequest["action"], "type"> & Partial<Pick<CancelByCloidRequest, "vaultAddress">> & Partial<Pick<CancelByCloidRequest, "expiresAfter">>;
46
- /** Parameters for the {@linkcode ExchangeClient.cDeposit} method. */
47
- export type CDepositParameters = Omit<CDepositRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
48
- /** Parameters for the {@linkcode ExchangeClient.convertToMultiSigUser} method. */
49
- export type ConvertToMultiSigUserParameters = ConvertToMultiSigUserRequest_Signers;
50
- /** Parameters for the {@linkcode ExchangeClient.createSubAccount} method. */
51
- export type CreateSubAccountParameters = Omit<CreateSubAccountRequest["action"], "type">;
52
- /** Parameters for the {@linkcode ExchangeClient.createVault} method. */
53
- export type CreateVaultParameters = Omit<CreateVaultRequest["action"], "type" | "nonce">;
54
- /** Parameters for the {@linkcode ExchangeClient.cSignerAction} method. */
55
- export type CSignerActionParameters = CSignerActionParameters_JailSelf | CSignerActionParameters_UnjailSelf;
56
- /** One of the parameters for the {@linkcode ExchangeClient.cSignerAction} method. */
57
- export type CSignerActionParameters_JailSelf = Omit<CSignerActionRequest_JailSelf["action"], "type"> & Partial<Pick<CSignerActionRequest_JailSelf, "expiresAfter">>;
58
- /** One of the parameters for the {@linkcode ExchangeClient.cSignerAction} method. */
59
- export type CSignerActionParameters_UnjailSelf = Omit<CSignerActionRequest_UnjailSelf["action"], "type"> & Partial<Pick<CSignerActionRequest_UnjailSelf, "expiresAfter">>;
60
- /** Parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
61
- export type CValidatorActionParameters = CValidatorActionParameters_ChangeProfile | CValidatorActionParameters_Register | CValidatorActionParameters_Unregister;
62
- /** One of the parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
63
- export type CValidatorActionParameters_ChangeProfile = Omit<CValidatorActionRequest_ChangeProfile["action"], "type"> & Partial<Pick<CValidatorActionRequest_ChangeProfile, "expiresAfter">>;
64
- /** One of the parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
65
- export type CValidatorActionParameters_Register = Omit<CValidatorActionRequest_Register["action"], "type"> & Partial<Pick<CValidatorActionRequest_Register, "expiresAfter">>;
66
- /** One of the parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
67
- export type CValidatorActionParameters_Unregister = Omit<CValidatorActionRequest_Unregister["action"], "type"> & Partial<Pick<CValidatorActionRequest_Unregister, "expiresAfter">>;
68
- /** Parameters for the {@linkcode ExchangeClient.cWithdraw} method. */
69
- export type CWithdrawParameters = Omit<CWithdrawRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
70
- /** Parameters for the {@linkcode ExchangeClient.evmUserModify} method. */
71
- export type EvmUserModifyParameters = Omit<EvmUserModifyRequest["action"], "type">;
72
- /** Parameters for the {@linkcode ExchangeClient.modify} method. */
73
- export type ModifyParameters = Omit<ModifyRequest["action"], "type"> & Partial<Pick<ModifyRequest, "vaultAddress">> & Partial<Pick<ModifyRequest, "expiresAfter">>;
74
- /** Parameters for the {@linkcode ExchangeClient.multiSig} method. */
75
- export type MultiSigParameters = Omit<MultiSigRequest["action"], "type" | "signatureChainId"> & Partial<Pick<MultiSigRequest, "vaultAddress">> & Partial<Pick<MultiSigRequest, "expiresAfter">> & {
76
- /** Must be the same for all signers. */
77
- nonce: number;
78
- };
79
- /** Parameters for the {@linkcode ExchangeClient.order} method. */
80
- export type OrderParameters = Omit<OrderRequest["action"], "type"> & Partial<Pick<OrderRequest, "vaultAddress">> & Partial<Pick<OrderRequest, "expiresAfter">>;
81
- /** Parameters for the {@linkcode ExchangeClient.perpDeploy} method. */
82
- export type PerpDeployParameters = PerpDeployParameters_RegisterAsset | PerpDeployParameters_SetOracle;
83
- /** One of the parameters for the {@linkcode ExchangeClient.perpDeploy} method. */
84
- export type PerpDeployParameters_RegisterAsset = Omit<PerpDeployRequest_RegisterAsset["action"], "type">;
85
- /** One of the parameters for the {@linkcode ExchangeClient.perpDeploy} method. */
86
- export type PerpDeployParameters_SetOracle = Omit<PerpDeployRequest_SetOracle["action"], "type">;
87
- /** Parameters for the {@linkcode ExchangeClient.perpDexClassTransfer} method. */
88
- export type PerpDexClassTransferParameters = Omit<PerpDexClassTransferRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
89
- /** Parameters for the {@linkcode ExchangeClient.perpDexTransfer} method. */
90
- export type PerpDexTransferParameters = Omit<PerpDexTransferRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
91
- /** Parameters for the {@linkcode ExchangeClient.registerReferrer} method. */
92
- export type RegisterReferrerParameters = Omit<RegisterReferrerRequest["action"], "type">;
93
- /** Parameters for the {@linkcode ExchangeClient.reserveRequestWeight} method. */
94
- export type ReserveRequestWeightParameters = Omit<ReserveRequestWeightRequest["action"], "type"> & Partial<Pick<ReserveRequestWeightRequest, "expiresAfter">>;
95
- /** Parameters for the {@linkcode ExchangeClient.scheduleCancel} method. */
96
- export type ScheduleCancelParameters = Omit<ScheduleCancelRequest["action"], "type"> & Partial<Pick<ScheduleCancelRequest, "vaultAddress">> & Partial<Pick<ScheduleCancelRequest, "expiresAfter">>;
97
- /** Parameters for the {@linkcode ExchangeClient.setDisplayName} method. */
98
- export type SetDisplayNameParameters = Omit<SetDisplayNameRequest["action"], "type">;
99
- /** Parameters for the {@linkcode ExchangeClient.setReferrer} method. */
100
- export type SetReferrerParameters = Omit<SetReferrerRequest["action"], "type">;
101
- /** Parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
102
- export type SpotDeployParameters = SpotDeployParameters_Genesis | SpotDeployParameters_RegisterHyperliquidity | SpotDeployParameters_RegisterSpot | SpotDeployParameters_RegisterToken2 | SpotDeployParameters_SetDeployerTradingFeeShare | SpotDeployParameters_UserGenesis;
103
- /** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
104
- export type SpotDeployParameters_Genesis = Omit<SpotDeployRequest_Genesis["action"], "type">;
105
- /** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
106
- export type SpotDeployParameters_RegisterHyperliquidity = Omit<SpotDeployRequest_RegisterHyperliquidity["action"], "type">;
107
- /** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
108
- export type SpotDeployParameters_RegisterSpot = Omit<SpotDeployRequest_RegisterSpot["action"], "type">;
109
- /** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
110
- export type SpotDeployParameters_RegisterToken2 = Omit<SpotDeployRequest_RegisterToken2["action"], "type">;
111
- /** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
112
- export type SpotDeployParameters_SetDeployerTradingFeeShare = Omit<SpotDeployRequest_SetDeployerTradingFeeShare["action"], "type">;
113
- /** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
114
- export type SpotDeployParameters_UserGenesis = Omit<SpotDeployRequest_UserGenesis["action"], "type">;
115
- /** Parameters for the {@linkcode ExchangeClient.spotSend} method. */
116
- export type SpotSendParameters = Omit<SpotSendRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time">;
117
- /** Parameters for the {@linkcode ExchangeClient.spotUser} method. */
118
- export type SpotUserParameters = Omit<SpotUserRequest["action"], "type">;
119
- /** Parameters for the {@linkcode ExchangeClient.subAccountSpotTransfer} method. */
120
- export type SubAccountSpotTransferParameters = Omit<SubAccountSpotTransferRequest["action"], "type">;
121
- /** Parameters for the {@linkcode ExchangeClient.subAccountTransfer} method. */
122
- export type SubAccountTransferParameters = Omit<SubAccountTransferRequest["action"], "type">;
123
- /** Parameters for the {@linkcode ExchangeClient.tokenDelegate} method. */
124
- export type TokenDelegateParameters = Omit<TokenDelegateRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
125
- /** Parameters for the {@linkcode ExchangeClient.twapCancel} method. */
126
- export type TwapCancelParameters = Omit<TwapCancelRequest["action"], "type"> & Partial<Pick<TwapCancelRequest, "vaultAddress">> & Partial<Pick<TwapCancelRequest, "expiresAfter">>;
127
- /** Parameters for the {@linkcode ExchangeClient.twapOrder} method. */
128
- export type TwapOrderParameters = TwapOrderRequest["action"]["twap"] & Partial<Pick<TwapOrderRequest, "vaultAddress">> & Partial<Pick<TwapOrderRequest, "expiresAfter">>;
129
- /** Parameters for the {@linkcode ExchangeClient.updateIsolatedMargin} method. */
130
- export type UpdateIsolatedMarginParameters = Omit<UpdateIsolatedMarginRequest["action"], "type"> & Partial<Pick<UpdateIsolatedMarginRequest, "vaultAddress">> & Partial<Pick<UpdateIsolatedMarginRequest, "expiresAfter">>;
131
- /** Parameters for the {@linkcode ExchangeClient.updateLeverage} method. */
132
- export type UpdateLeverageParameters = Omit<UpdateLeverageRequest["action"], "type"> & Partial<Pick<UpdateLeverageRequest, "vaultAddress">> & Partial<Pick<UpdateLeverageRequest, "expiresAfter">>;
133
- /** Parameters for the {@linkcode ExchangeClient.usdClassTransfer} method. */
134
- export type UsdClassTransferParameters = Omit<UsdClassTransferRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
135
- /** Parameters for the {@linkcode ExchangeClient.usdSend} method. */
136
- export type UsdSendParameters = Omit<UsdSendRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time">;
137
- /** Parameters for the {@linkcode ExchangeClient.vaultDistribute} method. */
138
- export type VaultDistributeParameters = Omit<VaultDistributeRequest["action"], "type">;
139
- /** Parameters for the {@linkcode ExchangeClient.vaultModify} method. */
140
- export type VaultModifyParameters = Omit<VaultModifyRequest["action"], "type">;
141
- /** Parameters for the {@linkcode ExchangeClient.vaultTransfer} method. */
142
- export type VaultTransferParameters = Omit<VaultTransferRequest["action"], "type"> & Partial<Pick<VaultTransferRequest, "expiresAfter">>;
143
- /** Parameters for the {@linkcode ExchangeClient.withdraw3} method. */
144
- export type Withdraw3Parameters = Omit<Withdraw3Request["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time">;
145
- /** Successful variant of {@linkcode CancelResponse} without error statuses. */
146
- export type CancelResponseSuccess = CancelResponse & {
147
- response: {
148
- data: {
149
- statuses: Exclude<CancelResponse["response"]["data"]["statuses"][number], {
150
- error: string;
151
- }>[];
152
- };
153
- };
154
- };
155
- /** Successful variant of {@linkcode OrderResponse} without error statuses. */
156
- export type OrderResponseSuccess = OrderResponse & {
157
- response: {
158
- data: {
159
- statuses: Exclude<OrderResponse["response"]["data"]["statuses"][number], {
160
- error: string;
161
- }>[];
162
- };
163
- };
164
- };
165
- /** Successful variant of {@linkcode TwapCancelResponse} without error status. */
166
- export type TwapCancelResponseSuccess = TwapCancelResponse & {
167
- response: {
168
- data: {
169
- status: Exclude<TwapCancelResponse["response"]["data"]["status"], {
170
- error: string;
171
- }>;
172
- };
173
- };
174
- };
175
- /** Successful variant of {@linkcode TwapOrderResponse} without error status. */
176
- export type TwapOrderResponseSuccess = TwapOrderResponse & {
177
- response: {
178
- data: {
179
- status: Exclude<TwapOrderResponse["response"]["data"]["status"], {
180
- error: string;
181
- }>;
182
- };
183
- };
184
- };
185
- /** Error thrown when the API returns an error response. */
40
+ type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
41
+ type ExtractRequestAction<T extends {
42
+ action: Record<string, unknown>;
43
+ }> = T["action"] extends {
44
+ signatureChainId: unknown;
45
+ } ? DistributiveOmit<T["action"], "type" | "signatureChainId" | "hyperliquidChain" | "nonce" | "time"> : DistributiveOmit<T["action"], "type">;
46
+ /** Action parameters for the {@linkcode ExchangeClient.approveAgent} method. */
47
+ export type ApproveAgentParameters = ExtractRequestAction<ApproveAgentRequest>;
48
+ /** Action parameters for the {@linkcode ExchangeClient.approveBuilderFee} method. */
49
+ export type ApproveBuilderFeeParameters = ExtractRequestAction<ApproveBuilderFeeRequest>;
50
+ /** Action parameters for the {@linkcode ExchangeClient.batchModify} method. */
51
+ export type BatchModifyParameters = ExtractRequestAction<BatchModifyRequest>;
52
+ /** Action parameters for the {@linkcode ExchangeClient.cancel} method. */
53
+ export type CancelParameters = ExtractRequestAction<CancelRequest>;
54
+ /** Action parameters for the {@linkcode ExchangeClient.cancelByCloid} method. */
55
+ export type CancelByCloidParameters = ExtractRequestAction<CancelByCloidRequest>;
56
+ /** Action parameters for the {@linkcode ExchangeClient.cDeposit} method. */
57
+ export type CDepositParameters = ExtractRequestAction<CDepositRequest>;
58
+ /** Action parameters for the {@linkcode ExchangeClient.convertToMultiSigUser} method. */
59
+ export type ConvertToMultiSigUserParameters = ExtractRequestAction<ConvertToMultiSigUserRequestWithoutStringify>;
60
+ /** Action parameters for the {@linkcode ExchangeClient.createSubAccount} method. */
61
+ export type CreateSubAccountParameters = ExtractRequestAction<CreateSubAccountRequest>;
62
+ /** Action parameters for the {@linkcode ExchangeClient.createVault} method. */
63
+ export type CreateVaultParameters = ExtractRequestAction<CreateVaultRequest>;
64
+ /** Action parameters for the {@linkcode ExchangeClient.cSignerAction} method. */
65
+ export type CSignerActionParameters = ExtractRequestAction<CSignerActionRequest>;
66
+ /** Action parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
67
+ export type CValidatorActionParameters = ExtractRequestAction<CValidatorActionRequest>;
68
+ /** Action parameters for the {@linkcode ExchangeClient.cWithdraw} method. */
69
+ export type CWithdrawParameters = ExtractRequestAction<CWithdrawRequest>;
70
+ /** Action parameters for the {@linkcode ExchangeClient.evmUserModify} method. */
71
+ export type EvmUserModifyParameters = ExtractRequestAction<EvmUserModifyRequest>;
72
+ /** Action parameters for the {@linkcode ExchangeClient.modify} method. */
73
+ export type ModifyParameters = ExtractRequestAction<ModifyRequest>;
74
+ /** Action parameters for the {@linkcode ExchangeClient.multiSig} method. */
75
+ export type MultiSigParameters = ExtractRequestAction<MultiSigRequest> & Pick<MultiSigRequest, "nonce">;
76
+ /** Action parameters for the {@linkcode ExchangeClient.order} method. */
77
+ export type OrderParameters = ExtractRequestAction<OrderRequest>;
78
+ /** Action parameters for the {@linkcode ExchangeClient.perpDeploy} method. */
79
+ export type PerpDeployParameters = ExtractRequestAction<PerpDeployRequest>;
80
+ /** Action parameters for the {@linkcode ExchangeClient.registerReferrer} method. */
81
+ export type RegisterReferrerParameters = ExtractRequestAction<RegisterReferrerRequest>;
82
+ /** Action parameters for the {@linkcode ExchangeClient.reserveRequestWeight} method. */
83
+ export type ReserveRequestWeightParameters = ExtractRequestAction<ReserveRequestWeightRequest>;
84
+ /** Action parameters for the {@linkcode ExchangeClient.scheduleCancel} method. */
85
+ export type ScheduleCancelParameters = ExtractRequestAction<ScheduleCancelRequest>;
86
+ /** Action parameters for the {@linkcode ExchangeClient.sendAsset} method. */
87
+ export type SendAssetParameters = ExtractRequestAction<SendAssetRequest>;
88
+ /** Action parameters for the {@linkcode ExchangeClient.setDisplayName} method. */
89
+ export type SetDisplayNameParameters = ExtractRequestAction<SetDisplayNameRequest>;
90
+ /** Action parameters for the {@linkcode ExchangeClient.setReferrer} method. */
91
+ export type SetReferrerParameters = ExtractRequestAction<SetReferrerRequest>;
92
+ /** Action parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
93
+ export type SpotDeployParameters = ExtractRequestAction<SpotDeployRequest>;
94
+ /** Action parameters for the {@linkcode ExchangeClient.spotSend} method. */
95
+ export type SpotSendParameters = ExtractRequestAction<SpotSendRequest>;
96
+ /** Action parameters for the {@linkcode ExchangeClient.spotUser} method. */
97
+ export type SpotUserParameters = ExtractRequestAction<SpotUserRequest>;
98
+ /** Action parameters for the {@linkcode ExchangeClient.subAccountModify} method. */
99
+ export type SubAccountModifyParameters = ExtractRequestAction<SubAccountModifyRequest>;
100
+ /** Action parameters for the {@linkcode ExchangeClient.subAccountSpotTransfer} method. */
101
+ export type SubAccountSpotTransferParameters = ExtractRequestAction<SubAccountSpotTransferRequest>;
102
+ /** Action parameters for the {@linkcode ExchangeClient.subAccountTransfer} method. */
103
+ export type SubAccountTransferParameters = ExtractRequestAction<SubAccountTransferRequest>;
104
+ /** Action parameters for the {@linkcode ExchangeClient.tokenDelegate} method. */
105
+ export type TokenDelegateParameters = ExtractRequestAction<TokenDelegateRequest>;
106
+ /** Action parameters for the {@linkcode ExchangeClient.twapCancel} method. */
107
+ export type TwapCancelParameters = ExtractRequestAction<TwapCancelRequest>;
108
+ /** Action parameters for the {@linkcode ExchangeClient.twapOrder} method. */
109
+ export type TwapOrderParameters = ExtractRequestAction<TwapOrderRequest>;
110
+ /** Action parameters for the {@linkcode ExchangeClient.updateIsolatedMargin} method. */
111
+ export type UpdateIsolatedMarginParameters = ExtractRequestAction<UpdateIsolatedMarginRequest>;
112
+ /** Action parameters for the {@linkcode ExchangeClient.updateLeverage} method. */
113
+ export type UpdateLeverageParameters = ExtractRequestAction<UpdateLeverageRequest>;
114
+ /** Action parameters for the {@linkcode ExchangeClient.usdClassTransfer} method. */
115
+ export type UsdClassTransferParameters = ExtractRequestAction<UsdClassTransferRequest>;
116
+ /** Action parameters for the {@linkcode ExchangeClient.usdSend} method. */
117
+ export type UsdSendParameters = ExtractRequestAction<UsdSendRequest>;
118
+ /** Action parameters for the {@linkcode ExchangeClient.vaultDistribute} method. */
119
+ export type VaultDistributeParameters = ExtractRequestAction<VaultDistributeRequest>;
120
+ /** Action parameters for the {@linkcode ExchangeClient.vaultModify} method. */
121
+ export type VaultModifyParameters = ExtractRequestAction<VaultModifyRequest>;
122
+ /** Action parameters for the {@linkcode ExchangeClient.vaultTransfer} method. */
123
+ export type VaultTransferParameters = ExtractRequestAction<VaultTransferRequest>;
124
+ /** Action parameters for the {@linkcode ExchangeClient.withdraw3} method. */
125
+ export type Withdraw3Parameters = ExtractRequestAction<Withdraw3Request>;
126
+ interface BaseRequestOptions {
127
+ /**
128
+ * An {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | AbortSignal}
129
+ * If this option is set, the request can be canceled by calling {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort | abort()}
130
+ * on the corresponding {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/AbortController | AbortController}.
131
+ */
132
+ signal?: AbortSignal;
133
+ }
134
+ type ExtractRequestOptions<T extends {
135
+ action: Record<string, unknown>;
136
+ }> = BaseRequestOptions & Omit<T, "action" | "nonce" | "signature">;
137
+ /** Request options for the {@linkcode ExchangeClient.approveAgent} method. */
138
+ export type ApproveAgentOptions = ExtractRequestOptions<ApproveAgentRequest>;
139
+ /** Request options for the {@linkcode ExchangeClient.approveBuilderFee} method. */
140
+ export type ApproveBuilderFeeOptions = ExtractRequestOptions<ApproveBuilderFeeRequest>;
141
+ /** Request options for the {@linkcode ExchangeClient.batchModify} method. */
142
+ export type BatchModifyOptions = ExtractRequestOptions<BatchModifyRequest>;
143
+ /** Request options for the {@linkcode ExchangeClient.cancel} method. */
144
+ export type CancelOptions = ExtractRequestOptions<CancelRequest>;
145
+ /** Request options for the {@linkcode ExchangeClient.cancelByCloid} method. */
146
+ export type CancelByCloidOptions = ExtractRequestOptions<CancelByCloidRequest>;
147
+ /** Request options for the {@linkcode ExchangeClient.cDeposit} method. */
148
+ export type CDepositOptions = ExtractRequestOptions<CDepositRequest>;
149
+ /** Request options for the {@linkcode ExchangeClient.claimRewards} method. */
150
+ export type ClaimRewardsOptions = ExtractRequestOptions<ClaimRewardsRequest>;
151
+ /** Request options for the {@linkcode ExchangeClient.convertToMultiSigUser} method. */
152
+ export type ConvertToMultiSigUserOptions = ExtractRequestOptions<ConvertToMultiSigUserRequest>;
153
+ /** Request options for the {@linkcode ExchangeClient.createSubAccount} method. */
154
+ export type CreateSubAccountOptions = ExtractRequestOptions<CreateSubAccountRequest>;
155
+ /** Request options for the {@linkcode ExchangeClient.createVault} method. */
156
+ export type CreateVaultOptions = ExtractRequestOptions<CreateVaultRequest>;
157
+ /** Request options for the {@linkcode ExchangeClient.cSignerAction} method. */
158
+ export type CSignerActionOptions = ExtractRequestOptions<CSignerActionRequest>;
159
+ /** Request options for the {@linkcode ExchangeClient.cValidatorAction} method. */
160
+ export type CValidatorActionOptions = ExtractRequestOptions<CValidatorActionRequest>;
161
+ /** Request options for the {@linkcode ExchangeClient.cWithdraw} method. */
162
+ export type CWithdrawOptions = ExtractRequestOptions<CWithdrawRequest>;
163
+ /** Request options for the {@linkcode ExchangeClient.evmUserModify} method. */
164
+ export type EvmUserModifyOptions = ExtractRequestOptions<EvmUserModifyRequest>;
165
+ /** Request options for the {@linkcode ExchangeClient.modify} method. */
166
+ export type ModifyOptions = ExtractRequestOptions<ModifyRequest>;
167
+ /** Request options for the {@linkcode ExchangeClient.multiSig} method. */
168
+ export type MultiSigOptions = ExtractRequestOptions<MultiSigRequest>;
169
+ /** Request options for the {@linkcode ExchangeClient.noop} method. */
170
+ export type NoopOptions = ExtractRequestOptions<NoopRequest>;
171
+ /** Request options for the {@linkcode ExchangeClient.order} method. */
172
+ export type OrderOptions = ExtractRequestOptions<OrderRequest>;
173
+ /** Request options for the {@linkcode ExchangeClient.perpDeploy} method. */
174
+ export type PerpDeployOptions = ExtractRequestOptions<PerpDeployRequest>;
175
+ /** Request options for the {@linkcode ExchangeClient.registerReferrer} method. */
176
+ export type RegisterReferrerOptions = ExtractRequestOptions<RegisterReferrerRequest>;
177
+ /** Request options for the {@linkcode ExchangeClient.reserveRequestWeight} method. */
178
+ export type ReserveRequestWeightOptions = ExtractRequestOptions<ReserveRequestWeightRequest>;
179
+ /** Request options for the {@linkcode ExchangeClient.scheduleCancel} method. */
180
+ export type ScheduleCancelOptions = ExtractRequestOptions<ScheduleCancelRequest>;
181
+ /** Request options for the {@linkcode ExchangeClient.sendAsset} method. */
182
+ export type SendAssetOptions = ExtractRequestOptions<SendAssetRequest>;
183
+ /** Request options for the {@linkcode ExchangeClient.setDisplayName} method. */
184
+ export type SetDisplayNameOptions = ExtractRequestOptions<SetDisplayNameRequest>;
185
+ /** Request options for the {@linkcode ExchangeClient.setReferrer} method. */
186
+ export type SetReferrerOptions = ExtractRequestOptions<SetReferrerRequest>;
187
+ /** Request options for the {@linkcode ExchangeClient.spotDeploy} method. */
188
+ export type SpotDeployOptions = ExtractRequestOptions<SpotDeployRequest>;
189
+ /** Request options for the {@linkcode ExchangeClient.spotSend} method. */
190
+ export type SpotSendOptions = ExtractRequestOptions<SpotSendRequest>;
191
+ /** Request options for the {@linkcode ExchangeClient.spotUser} method. */
192
+ export type SpotUserOptions = ExtractRequestOptions<SpotUserRequest>;
193
+ /** Request options for the {@linkcode ExchangeClient.subAccountModify} method. */
194
+ export type SubAccountModifyOptions = ExtractRequestOptions<SubAccountModifyRequest>;
195
+ /** Request options for the {@linkcode ExchangeClient.subAccountSpotTransfer} method. */
196
+ export type SubAccountSpotTransferOptions = ExtractRequestOptions<SubAccountSpotTransferRequest>;
197
+ /** Request options for the {@linkcode ExchangeClient.subAccountTransfer} method. */
198
+ export type SubAccountTransferOptions = ExtractRequestOptions<SubAccountTransferRequest>;
199
+ /** Request options for the {@linkcode ExchangeClient.tokenDelegate} method. */
200
+ export type TokenDelegateOptions = ExtractRequestOptions<TokenDelegateRequest>;
201
+ /** Request options for the {@linkcode ExchangeClient.twapCancel} method. */
202
+ export type TwapCancelOptions = ExtractRequestOptions<TwapCancelRequest>;
203
+ /** Request options for the {@linkcode ExchangeClient.twapOrder} method. */
204
+ export type TwapOrderOptions = ExtractRequestOptions<TwapOrderRequest>;
205
+ /** Request options for the {@linkcode ExchangeClient.updateIsolatedMargin} method. */
206
+ export type UpdateIsolatedMarginOptions = ExtractRequestOptions<UpdateIsolatedMarginRequest>;
207
+ /** Request options for the {@linkcode ExchangeClient.updateLeverage} method. */
208
+ export type UpdateLeverageOptions = ExtractRequestOptions<UpdateLeverageRequest>;
209
+ /** Request options for the {@linkcode ExchangeClient.usdClassTransfer} method. */
210
+ export type UsdClassTransferOptions = ExtractRequestOptions<UsdClassTransferRequest>;
211
+ /** Request options for the {@linkcode ExchangeClient.usdSend} method. */
212
+ export type UsdSendOptions = ExtractRequestOptions<UsdSendRequest>;
213
+ /** Request options for the {@linkcode ExchangeClient.vaultDistribute} method. */
214
+ export type VaultDistributeOptions = ExtractRequestOptions<VaultDistributeRequest>;
215
+ /** Request options for the {@linkcode ExchangeClient.vaultModify} method. */
216
+ export type VaultModifyOptions = ExtractRequestOptions<VaultModifyRequest>;
217
+ /** Request options for the {@linkcode ExchangeClient.vaultTransfer} method. */
218
+ export type VaultTransferOptions = ExtractRequestOptions<VaultTransferRequest>;
219
+ /** Request options for the {@linkcode ExchangeClient.withdraw3} method. */
220
+ export type Withdraw3Options = ExtractRequestOptions<Withdraw3Request>;
221
+ /** Custom error class for API request errors. */
186
222
  export declare class ApiRequestError extends HyperliquidError {
187
223
  response: ErrorResponse | OrderResponse | CancelResponse | TwapOrderResponse | TwapCancelResponse;
188
224
  constructor(response: ErrorResponse | OrderResponse | CancelResponse | TwapOrderResponse | TwapCancelResponse);
@@ -217,7 +253,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
217
253
  * @example [Viem](https://viem.sh/docs/clients/wallet#local-accounts-private-key-mnemonic-etc)
218
254
  * ```ts
219
255
  * import * as hl from "@nktkas/hyperliquid";
220
- * import { privateKeyToAccount } from "viem/accounts";
256
+ * import { privateKeyToAccount } from "npm:viem/accounts";
221
257
  *
222
258
  * const account = privateKeyToAccount("0x...");
223
259
  *
@@ -228,7 +264,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
228
264
  * @example [ethers.js](https://docs.ethers.org/v6/api/wallet/#Wallet) or [ethers.js v5](https://docs.ethers.org/v5/api/signer/#Wallet)
229
265
  * ```ts
230
266
  * import * as hl from "@nktkas/hyperliquid";
231
- * import { ethers } from "ethers";
267
+ * import { ethers } from "npm:ethers";
232
268
  *
233
269
  * const wallet = new ethers.Wallet("0x...");
234
270
  *
@@ -239,30 +275,21 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
239
275
  * @example External wallet (e.g. MetaMask) via [viem](https://viem.sh/docs/clients/wallet)
240
276
  * ```ts
241
277
  * import * as hl from "@nktkas/hyperliquid";
242
- * import { createWalletClient, custom } from "viem";
278
+ * import { createWalletClient, custom } from "npm:viem";
243
279
  *
244
280
  * const ethereum = (window as any).ethereum;
245
- * const [account] = await ethereum.request({ method: "eth_requestAccounts" });
281
+ * const [account] = await ethereum.request({ method: "eth_requestAccounts" }) as `0x${string}`[];
246
282
  * const wallet = createWalletClient({ account, transport: custom(ethereum) });
247
283
  *
248
284
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
249
285
  * const exchClient = new hl.ExchangeClient({ wallet, transport });
250
286
  * ```
251
- *
252
- * @example External wallet (e.g. MetaMask) via [`window.ethereum`](https://eips.ethereum.org/EIPS/eip-1193)
253
- * ```ts
254
- * import * as hl from "@nktkas/hyperliquid";
255
- *
256
- * const ethereum = (window as any).ethereum;
257
- * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
258
- * const exchClient = new hl.ExchangeClient({ wallet: ethereum, transport });
259
- * ```
260
287
  */
261
288
  constructor(args: ExchangeClientParameters<T, W>);
262
289
  /**
263
290
  * Approve an agent to sign on behalf of the master account.
264
- * @param args - The parameters for the request.
265
- * @param signal - An optional abort signal
291
+ * @param params - Action-specific parameters.
292
+ * @param opts - Request execution options.
266
293
  * @returns Successful response without specific data.
267
294
  *
268
295
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -273,18 +300,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
273
300
  * ```ts
274
301
  * import * as hl from "@nktkas/hyperliquid";
275
302
  *
276
- * const privateKey = "0x..."; // or `viem`, `ethers`
303
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
277
304
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
278
305
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
279
306
  *
280
307
  * await exchClient.approveAgent({ agentAddress: "0x...", agentName: "..." });
281
308
  * ```
282
309
  */
283
- approveAgent(args: DeepImmutable<ApproveAgentParameters>, signal?: AbortSignal): Promise<SuccessResponse>;
310
+ approveAgent(params: DeepImmutable<ApproveAgentParameters>, opts?: ApproveAgentOptions): Promise<SuccessResponse>;
284
311
  /**
285
312
  * Approve a maximum fee rate for a builder.
286
- * @param args - The parameters for the request.
287
- * @param signal - An optional abort signal.
313
+ * @param params - Action-specific parameters.
314
+ * @param opts - Request execution options.
288
315
  * @returns Successful response without specific data.
289
316
  *
290
317
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -295,18 +322,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
295
322
  * ```ts
296
323
  * import * as hl from "@nktkas/hyperliquid";
297
324
  *
298
- * const privateKey = "0x..."; // or `viem`, `ethers`
325
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
299
326
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
300
327
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
301
328
  *
302
329
  * await exchClient.approveBuilderFee({ maxFeeRate: "0.01%", builder: "0x..." });
303
330
  * ```
304
331
  */
305
- approveBuilderFee(args: DeepImmutable<ApproveBuilderFeeParameters>, signal?: AbortSignal): Promise<SuccessResponse>;
332
+ approveBuilderFee(params: DeepImmutable<ApproveBuilderFeeParameters>, opts?: ApproveBuilderFeeOptions): Promise<SuccessResponse>;
306
333
  /**
307
334
  * Modify multiple orders.
308
- * @param args - The parameters for the request.
309
- * @param signal - An optional abort signal.
335
+ * @param params - Action-specific parameters.
336
+ * @param opts - Request execution options.
310
337
  * @returns Successful variant of {@link OrderResponse} without error statuses.
311
338
  *
312
339
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -317,7 +344,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
317
344
  * ```ts
318
345
  * import * as hl from "@nktkas/hyperliquid";
319
346
  *
320
- * const privateKey = "0x..."; // or `viem`, `ethers`
347
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
321
348
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
322
349
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
323
350
  *
@@ -338,11 +365,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
338
365
  * });
339
366
  * ```
340
367
  */
341
- batchModify(args: DeepImmutable<BatchModifyParameters>, signal?: AbortSignal): Promise<OrderResponseSuccess>;
368
+ batchModify(params: DeepImmutable<BatchModifyParameters>, opts?: BatchModifyOptions): Promise<OrderSuccessResponse>;
342
369
  /**
343
370
  * Cancel order(s).
344
- * @param args - The parameters for the request.
345
- * @param signal - An optional abort signal.
371
+ * @param params - Action-specific parameters.
372
+ * @param opts - Request execution options.
346
373
  * @returns Successful variant of {@link CancelResponse} without error statuses.
347
374
  *
348
375
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -353,7 +380,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
353
380
  * ```ts
354
381
  * import * as hl from "@nktkas/hyperliquid";
355
382
  *
356
- * const privateKey = "0x..."; // or `viem`, `ethers`
383
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
357
384
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
358
385
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
359
386
  *
@@ -364,11 +391,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
364
391
  * });
365
392
  * ```
366
393
  */
367
- cancel(args: CancelParameters, signal?: AbortSignal): Promise<CancelResponseSuccess>;
394
+ cancel(params: DeepImmutable<CancelParameters>, opts?: CancelOptions): Promise<CancelSuccessResponse>;
368
395
  /**
369
396
  * Cancel order(s) by cloid.
370
- * @param args - The parameters for the request.
371
- * @param signal - An optional abort signal.
397
+ * @param params - Action-specific parameters.
398
+ * @param opts - Request execution options.
372
399
  * @returns Successful variant of {@link CancelResponse} without error statuses.
373
400
  *
374
401
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -379,7 +406,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
379
406
  * ```ts
380
407
  * import * as hl from "@nktkas/hyperliquid";
381
408
  *
382
- * const privateKey = "0x..."; // or `viem`, `ethers`
409
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
383
410
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
384
411
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
385
412
  *
@@ -390,11 +417,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
390
417
  * });
391
418
  * ```
392
419
  */
393
- cancelByCloid(args: CancelByCloidParameters, signal?: AbortSignal): Promise<CancelResponseSuccess>;
420
+ cancelByCloid(params: DeepImmutable<CancelByCloidParameters>, opts?: CancelByCloidOptions): Promise<CancelSuccessResponse>;
394
421
  /**
395
422
  * Transfer native token from the user's spot account into staking for delegating to validators.
396
- * @param args - The parameters for the request.
397
- * @param signal - An optional abort signal.
423
+ * @param params - Action-specific parameters.
424
+ * @param opts - Request execution options.
398
425
  * @returns Successful response without specific data.
399
426
  *
400
427
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -405,18 +432,17 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
405
432
  * ```ts
406
433
  * import * as hl from "@nktkas/hyperliquid";
407
434
  *
408
- * const privateKey = "0x..."; // or `viem`, `ethers`
435
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
409
436
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
410
437
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
411
438
  *
412
439
  * await exchClient.cDeposit({ wei: 1 * 1e8 });
413
440
  * ```
414
441
  */
415
- cDeposit(args: CDepositParameters, signal?: AbortSignal): Promise<SuccessResponse>;
442
+ cDeposit(params: DeepImmutable<CDepositParameters>, opts?: CDepositOptions): Promise<SuccessResponse>;
416
443
  /**
417
444
  * Claim rewards from referral program.
418
- * @param args - The parameters for the request.
419
- * @param signal - An optional abort signal.
445
+ * @param opts - Request execution options.
420
446
  * @returns Successful response without specific data.
421
447
  *
422
448
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -427,18 +453,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
427
453
  * ```ts
428
454
  * import * as hl from "@nktkas/hyperliquid";
429
455
  *
430
- * const privateKey = "0x..."; // or `viem`, `ethers`
456
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
431
457
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
432
458
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
433
459
  *
434
460
  * await exchClient.claimRewards();
435
461
  * ```
436
462
  */
437
- claimRewards(signal?: AbortSignal): Promise<SuccessResponse>;
463
+ claimRewards(opts?: ClaimRewardsOptions): Promise<SuccessResponse>;
438
464
  /**
439
465
  * Convert a single-signature account to a multi-signature account or vice versa.
440
- * @param args - The parameters for the request.
441
- * @param signal - An optional abort signal.
466
+ * @param params - Action-specific parameters.
467
+ * @param opts - Request execution options.
442
468
  * @returns Successful response without specific data.
443
469
  *
444
470
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -449,25 +475,27 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
449
475
  * ```ts
450
476
  * import * as hl from "@nktkas/hyperliquid";
451
477
  *
452
- * const privateKey = "0x..."; // or `viem`, `ethers`
478
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
453
479
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
454
480
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
455
481
  *
456
482
  * // Convert to multi-sig user
457
483
  * await exchClient.convertToMultiSigUser({
458
- * authorizedUsers: ["0x...", "0x...", "0x..."],
459
- * threshold: 2,
484
+ * signers: {
485
+ * authorizedUsers: ["0x...", "0x...", "0x..."],
486
+ * threshold: 2,
487
+ * },
460
488
  * });
461
489
  *
462
490
  * // Convert to single-sig user
463
- * await exchClient.convertToMultiSigUser(null);
491
+ * await exchClient.convertToMultiSigUser({ signers: null });
464
492
  * ```
465
493
  */
466
- convertToMultiSigUser(args: ConvertToMultiSigUserParameters, signal?: AbortSignal): Promise<SuccessResponse>;
494
+ convertToMultiSigUser(params: DeepImmutable<ConvertToMultiSigUserParameters>, opts?: ConvertToMultiSigUserOptions): Promise<SuccessResponse>;
467
495
  /**
468
496
  * Create a sub-account.
469
- * @param args - The parameters for the request.
470
- * @param signal - An optional abort signal.
497
+ * @param params - Action-specific parameters.
498
+ * @param opts - Request execution options.
471
499
  * @returns Response for creating a sub-account.
472
500
  *
473
501
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -478,18 +506,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
478
506
  * ```ts
479
507
  * import * as hl from "@nktkas/hyperliquid";
480
508
  *
481
- * const privateKey = "0x..."; // or `viem`, `ethers`
509
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
482
510
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
483
511
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
484
512
  *
485
513
  * const data = await exchClient.createSubAccount({ name: "..." });
486
514
  * ```
487
515
  */
488
- createSubAccount(args: CreateSubAccountParameters, signal?: AbortSignal): Promise<CreateSubAccountResponse>;
516
+ createSubAccount(params: DeepImmutable<CreateSubAccountParameters>, opts?: CreateSubAccountOptions): Promise<CreateSubAccountResponse>;
489
517
  /**
490
518
  * Create a vault.
491
- * @param args - The parameters for the request.
492
- * @param signal - An optional abort signal.
519
+ * @param params - Action-specific parameters.
520
+ * @param opts - Request execution options.
493
521
  * @returns Response for creating a vault.
494
522
  *
495
523
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -500,18 +528,23 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
500
528
  * ```ts
501
529
  * import * as hl from "@nktkas/hyperliquid";
502
530
  *
503
- * const privateKey = "0x..."; // or `viem`, `ethers`
531
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
504
532
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
505
533
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
506
534
  *
507
- * const data = await exchClient.createVault({ name: "...", description: "...", initialUsd: 100 * 1e6 });
535
+ * const data = await exchClient.createVault({
536
+ * name: "...",
537
+ * description: "...",
538
+ * initialUsd: 100 * 1e6,
539
+ * nonce: Date.now(),
540
+ * });
508
541
  * ```
509
542
  */
510
- createVault(args: CreateVaultParameters, signal?: AbortSignal): Promise<CreateVaultResponse>;
543
+ createVault(params: DeepImmutable<CreateVaultParameters>, opts?: CreateVaultOptions): Promise<CreateVaultResponse>;
511
544
  /**
512
545
  * Jail or unjail self as a validator signer.
513
- * @param args - The parameters for the request.
514
- * @param signal - An optional abort signal.
546
+ * @param params - Action-specific parameters.
547
+ * @param opts - Request execution options.
515
548
  * @returns Successful response without specific data.
516
549
  *
517
550
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -522,7 +555,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
522
555
  * ```ts
523
556
  * import * as hl from "@nktkas/hyperliquid";
524
557
  *
525
- * const privateKey = "0x..."; // or `viem`, `ethers`
558
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
526
559
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
527
560
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
528
561
  *
@@ -533,11 +566,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
533
566
  * await exchClient.cSignerAction({ unjailSelf: null });
534
567
  * ```
535
568
  */
536
- cSignerAction(args: CSignerActionParameters, signal?: AbortSignal): Promise<SuccessResponse>;
569
+ cSignerAction(params: DeepImmutable<CSignerActionParameters>, opts?: CSignerActionOptions): Promise<SuccessResponse>;
537
570
  /**
538
571
  * Action related to validator management.
539
- * @param args - The parameters for the request.
540
- * @param signal - An optional abort signal.
572
+ * @param params - Action-specific parameters.
573
+ * @param opts - Request execution options.
541
574
  * @returns Successful response without specific data.
542
575
  *
543
576
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -548,17 +581,21 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
548
581
  * ```ts
549
582
  * import * as hl from "@nktkas/hyperliquid";
550
583
  *
551
- * const privateKey = "0x..."; // or `viem`, `ethers`
584
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
552
585
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
553
586
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
554
587
  *
555
588
  * // Change validator profile
556
589
  * await exchClient.cValidatorAction({
557
590
  * changeProfile: {
591
+ * node_ip: { Ip: "1.2.3.4" },
558
592
  * name: "...",
559
593
  * description: "...",
560
594
  * unjailed: true,
561
- * }
595
+ * disable_delegations: false,
596
+ * commission_bps: null,
597
+ * signer: null,
598
+ * },
562
599
  * });
563
600
  *
564
601
  * // Register a new validator
@@ -581,11 +618,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
581
618
  * await exchClient.cValidatorAction({ unregister: null });
582
619
  * ```
583
620
  */
584
- cValidatorAction(args: CValidatorActionParameters, signal?: AbortSignal): Promise<SuccessResponse>;
621
+ cValidatorAction(params: DeepImmutable<CValidatorActionParameters>, opts?: CValidatorActionOptions): Promise<SuccessResponse>;
585
622
  /**
586
623
  * Transfer native token from staking into the user's spot account.
587
- * @param args - The parameters for the request.
588
- * @param signal - An optional abort signal.
624
+ * @param params - Action-specific parameters.
625
+ * @param opts - Request execution options.
589
626
  * @returns Successful response without specific data.
590
627
  *
591
628
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -596,40 +633,40 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
596
633
  * ```ts
597
634
  * import * as hl from "@nktkas/hyperliquid";
598
635
  *
599
- * const privateKey = "0x..."; // or `viem`, `ethers`
636
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
600
637
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
601
638
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
602
639
  *
603
640
  * await exchClient.cWithdraw({ wei: 1 * 1e8 });
604
641
  * ```
605
642
  */
606
- cWithdraw(args: CWithdrawParameters, signal?: AbortSignal): Promise<SuccessResponse>;
643
+ cWithdraw(params: DeepImmutable<CWithdrawParameters>, opts?: CWithdrawOptions): Promise<SuccessResponse>;
607
644
  /**
608
645
  * Configure block type for EVM transactions.
609
- * @param args - The parameters for the request.
610
- * @param signal - An optional abort signal.
646
+ * @param params - Action-specific parameters.
647
+ * @param opts - Request execution options.
611
648
  * @returns Response for creating a sub-account.
612
649
  *
613
650
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
614
651
  * @throws {TransportError} When the transport layer throws an error.
615
652
  *
616
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/evm/dual-block-architecture
653
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/dual-block-architecture
617
654
  * @example
618
655
  * ```ts
619
656
  * import * as hl from "@nktkas/hyperliquid";
620
657
  *
621
- * const privateKey = "0x..."; // or `viem`, `ethers`
658
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
622
659
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
623
660
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
624
661
  *
625
662
  * const data = await exchClient.evmUserModify({ usingBigBlocks: true });
626
663
  * ```
627
664
  */
628
- evmUserModify(args: EvmUserModifyParameters, signal?: AbortSignal): Promise<SuccessResponse>;
665
+ evmUserModify(params: DeepImmutable<EvmUserModifyParameters>, opts?: EvmUserModifyOptions): Promise<SuccessResponse>;
629
666
  /**
630
667
  * Modify an order.
631
- * @param args - The parameters for the request.
632
- * @param signal - An optional abort signal.
668
+ * @param params - Action-specific parameters.
669
+ * @param opts - Request execution options.
633
670
  * @returns Successful response without specific data.
634
671
  *
635
672
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -640,7 +677,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
640
677
  * ```ts
641
678
  * import * as hl from "@nktkas/hyperliquid";
642
679
  *
643
- * const privateKey = "0x..."; // or `viem`, `ethers`
680
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
644
681
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
645
682
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
646
683
  *
@@ -658,11 +695,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
658
695
  * });
659
696
  * ```
660
697
  */
661
- modify(args: ModifyParameters, signal?: AbortSignal): Promise<SuccessResponse>;
698
+ modify(params: DeepImmutable<ModifyParameters>, opts?: ModifyOptions): Promise<SuccessResponse>;
662
699
  /**
663
700
  * A multi-signature request.
664
- * @param args - The parameters for the request.
665
- * @param signal - An optional abort signal.
701
+ * @param params - Action-specific parameters.
702
+ * @param opts - Request execution options.
666
703
  * @returns Any successful response.
667
704
  *
668
705
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -673,7 +710,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
673
710
  * ```ts
674
711
  * import * as hl from "@nktkas/hyperliquid";
675
712
  * import { actionSorter, signL1Action } from "@nktkas/hyperliquid/signing";
676
- * import { privateKeyToAccount } from "viem/accounts";
713
+ * import { privateKeyToAccount } from "npm:viem/accounts";
677
714
  *
678
715
  * const wallet = privateKeyToAccount("0x..."); // or any other wallet libraries
679
716
  * const multiSigUser = "0x...";
@@ -682,20 +719,36 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
682
719
  * const exchClient = new hl.ExchangeClient({ wallet, transport });
683
720
  *
684
721
  * const nonce = Date.now();
685
- * const action = {
722
+ * const action = actionSorter.scheduleCancel({
686
723
  * type: "scheduleCancel",
687
724
  * time: Date.now() + 10000,
688
- * } as const;
689
- *
690
- * // Create the required number of signatures
691
- * const signature = await signL1Action({
692
- * wallet,
693
- * action: [multiSigUser.toLowerCase(), wallet.address.toLowerCase(), actionSorter[action.type](action)],
694
- * nonce,
695
725
  * });
696
726
  *
727
+ * // Create the required number of signatures
728
+ * const signatures = await Promise.all(["0x...", "0x..."].map(async (signerPrivKey) => {
729
+ * return await signL1Action({
730
+ * wallet: signerPrivKey as `0x${string}`,
731
+ * action: [multiSigUser.toLowerCase(), wallet.address.toLowerCase(), action],
732
+ * nonce,
733
+ * });
734
+ * }));
735
+ *
736
+ * // or user-signed action
737
+ * // const signatures = await Promise.all(["0x...", "0x..."].map(async (signerPrivKey) => {
738
+ * // return await signUserSignedAction({
739
+ * // wallet: signerPrivKey as `0x${string}`,
740
+ * // action: {
741
+ * // ...action,
742
+ * // payloadMultiSigUser: multiSigUser,
743
+ * // outerSigner: wallet.address,
744
+ * // },
745
+ * // types: userSignedActionEip712Types[action.type],
746
+ * // });
747
+ * // }));
748
+ *
749
+ * // Then use signatures in the `multiSig` action
697
750
  * const data = await exchClient.multiSig({
698
- * signatures: [signature],
751
+ * signatures,
699
752
  * payload: {
700
753
  * multiSigUser,
701
754
  * outerSigner: wallet.address,
@@ -705,11 +758,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
705
758
  * });
706
759
  * ```
707
760
  */
708
- multiSig<T extends SuccessResponse | CancelResponseSuccess | CreateSubAccountResponse | CreateVaultResponse | OrderResponseSuccess | TwapOrderResponseSuccess | TwapCancelResponseSuccess>(args: MultiSigParameters, signal?: AbortSignal): Promise<T>;
761
+ multiSig<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(params_and_nonce: DeepImmutable<MultiSigParameters>, opts?: MultiSigOptions): Promise<T>;
709
762
  /**
710
763
  * Place an order(s).
711
- * @param args - The parameters for the request.
712
- * @param signal - An optional abort signal.
764
+ * @param params - Action-specific parameters.
765
+ * @param opts - Request execution options.
713
766
  * @returns Successful variant of {@link OrderResponse} without error statuses.
714
767
  *
715
768
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -720,7 +773,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
720
773
  * ```ts
721
774
  * import * as hl from "@nktkas/hyperliquid";
722
775
  *
723
- * const privateKey = "0x..."; // or `viem`, `ethers`
776
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
724
777
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
725
778
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
726
779
  *
@@ -740,156 +793,163 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
740
793
  * });
741
794
  * ```
742
795
  */
743
- order(args: OrderParameters, signal?: AbortSignal): Promise<OrderResponseSuccess>;
796
+ order(params: DeepImmutable<OrderParameters>, opts?: OrderOptions): Promise<OrderSuccessResponse>;
744
797
  /**
745
- * Deploying HIP-3 assets.
746
- * @param args - The parameters for the request.
747
- * @param signal - An optional abort signal.
798
+ * This action does not do anything (no operation), but causes the nonce to be marked as used.
799
+ * @param opts - Request execution options.
748
800
  * @returns Successful response without specific data.
749
801
  *
750
802
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
751
803
  * @throws {TransportError} When the transport layer throws an error.
752
804
  *
753
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/deploying-hip-3-assets
805
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
754
806
  * @example
755
807
  * ```ts
756
808
  * import * as hl from "@nktkas/hyperliquid";
757
809
  *
758
- * const privateKey = "0x..."; // or `viem`, `ethers`
810
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
759
811
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
760
812
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
761
813
  *
762
- * await exchClient.perpDeploy({
763
- * registerAsset: {
764
- * maxGas: 1000000,
765
- * assetRequest: {
766
- * coin: "USDC",
767
- * szDecimals: 8,
768
- * oraclePx: "1",
769
- * marginTableId: 1,
770
- * onlyIsolated: false,
771
- * },
772
- * dex: "test",
773
- * },
774
- * });
814
+ * await exchClient.noop();
775
815
  * ```
776
816
  */
777
- perpDeploy(args: PerpDeployParameters, signal?: AbortSignal): Promise<SuccessResponse>;
817
+ noop(opts?: NoopOptions): Promise<SuccessResponse>;
778
818
  /**
779
- * Transfer funds between Spot account and Perp dex account.
780
- * @param args - The parameters for the request.
781
- * @param signal - An optional abort signal.
819
+ * Deploying HIP-3 assets.
820
+ * @param params - Action-specific parameters.
821
+ * @param opts - Request execution options.
782
822
  * @returns Successful response without specific data.
783
823
  *
784
824
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
785
825
  * @throws {TransportError} When the transport layer throws an error.
786
826
  *
787
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#transfer-from-spot-account-to-perp-account-and-vice-versa
827
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/deploying-hip-3-assets
788
828
  * @example
789
829
  * ```ts
790
830
  * import * as hl from "@nktkas/hyperliquid";
791
831
  *
792
- * const privateKey = "0x..."; // or `viem`, `ethers`
832
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
793
833
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
794
834
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
795
835
  *
796
- * await exchClient.perpDexClassTransfer({ dex: "test", token: "USDC", amount: "1", toPerp: true });
836
+ * await exchClient.perpDeploy({
837
+ * registerAsset: {
838
+ * maxGas: 1000000,
839
+ * assetRequest: {
840
+ * coin: "USDC",
841
+ * szDecimals: 8,
842
+ * oraclePx: "1",
843
+ * marginTableId: 1,
844
+ * onlyIsolated: false,
845
+ * },
846
+ * dex: "test",
847
+ * schema: null,
848
+ * },
849
+ * });
797
850
  * ```
798
851
  */
799
- perpDexClassTransfer(args: PerpDexClassTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
852
+ perpDeploy(params: DeepImmutable<PerpDeployParameters>, opts?: PerpDeployOptions): Promise<SuccessResponse>;
800
853
  /**
801
- * Transfer collateral tokens between different perp dexes for the same user.
802
- * @param args - The parameters for the request.
803
- * @param signal - An optional abort signal.
854
+ * Create a referral code.
855
+ * @param params - Action-specific parameters.
856
+ * @param opts - Request execution options.
804
857
  * @returns Successful response without specific data.
805
858
  *
806
859
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
807
860
  * @throws {TransportError} When the transport layer throws an error.
808
861
  *
809
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#transfer-from-perp-account-to-perp-account-for-builder-deployed-dex
862
+ * @see null
810
863
  * @example
811
864
  * ```ts
812
865
  * import * as hl from "@nktkas/hyperliquid";
813
866
  *
814
- * const privateKey = "0x..."; // or `viem`, `ethers`
867
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
815
868
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
816
869
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
817
870
  *
818
- * await exchClient.perpDexTransfer({ sourceDex: "", destinationDex: "test", amount: "1" });
871
+ * await exchClient.registerReferrer({ code: "..." });
819
872
  * ```
820
873
  */
821
- perpDexTransfer(args: PerpDexTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
874
+ registerReferrer(params: DeepImmutable<RegisterReferrerParameters>, opts?: RegisterReferrerOptions): Promise<SuccessResponse>;
822
875
  /**
823
- * Create a referral code.
824
- * @param args - The parameters for the request.
825
- * @param signal - An optional abort signal.
876
+ * Reserve additional rate-limited actions for a fee.
877
+ * @param params - Action-specific parameters.
878
+ * @param opts - Request execution options.
826
879
  * @returns Successful response without specific data.
827
880
  *
828
881
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
829
882
  * @throws {TransportError} When the transport layer throws an error.
830
883
  *
831
- * @see null
884
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#reserve-additional-actions
832
885
  * @example
833
886
  * ```ts
834
887
  * import * as hl from "@nktkas/hyperliquid";
835
888
  *
836
- * const privateKey = "0x..."; // or `viem`, `ethers`
889
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
837
890
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
838
891
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
839
892
  *
840
- * await exchClient.registerReferrer({ code: "..." });
893
+ * await exchClient.reserveRequestWeight({ weight: 10 });
841
894
  * ```
842
895
  */
843
- registerReferrer(args: RegisterReferrerParameters, signal?: AbortSignal): Promise<SuccessResponse>;
896
+ reserveRequestWeight(params: DeepImmutable<ReserveRequestWeightParameters>, opts?: ReserveRequestWeightOptions): Promise<SuccessResponse>;
844
897
  /**
845
- * Reserve additional rate-limited actions for a fee.
846
- * @param args - The parameters for the request.
847
- * @param signal - An optional abort signal.
898
+ * Schedule a cancel-all operation at a future time.
899
+ * @param params - An optional action-specific parameters.
900
+ * @param opts - Request execution options.
848
901
  * @returns Successful response without specific data.
849
902
  *
850
903
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
851
904
  * @throws {TransportError} When the transport layer throws an error.
852
905
  *
853
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#reserve-additional-actions
906
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#schedule-cancel-dead-mans-switch
854
907
  * @example
855
908
  * ```ts
856
909
  * import * as hl from "@nktkas/hyperliquid";
857
910
  *
858
- * const privateKey = "0x..."; // or `viem`, `ethers`
911
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
859
912
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
860
913
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
861
914
  *
862
- * await exchClient.reserveRequestWeight({ weight: 10 });
915
+ * await exchClient.scheduleCancel({ time: Date.now() + 10_000 });
863
916
  * ```
864
917
  */
865
- reserveRequestWeight(args: ReserveRequestWeightParameters, signal?: AbortSignal): Promise<SuccessResponse>;
918
+ scheduleCancel(params?: DeepImmutable<ScheduleCancelParameters>, opts?: ScheduleCancelOptions): Promise<SuccessResponse>;
919
+ scheduleCancel(opts?: ScheduleCancelOptions): Promise<SuccessResponse>;
866
920
  /**
867
- * Schedule a cancel-all operation at a future time.
868
- * @param args - The parameters for the request.
869
- * @param signal - An optional abort signal.
921
+ * Transfer tokens between different perp DEXs, spot balance, users, and/or sub-accounts.
922
+ * @param params - Action-specific parameters.
923
+ * @param opts - Request execution options.
870
924
  * @returns Successful response without specific data.
871
925
  *
872
926
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
873
927
  * @throws {TransportError} When the transport layer throws an error.
874
928
  *
875
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#schedule-cancel-dead-mans-switch
929
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#send-asset-testnet-only
876
930
  * @example
877
931
  * ```ts
878
932
  * import * as hl from "@nktkas/hyperliquid";
879
933
  *
880
- * const privateKey = "0x..."; // or `viem`, `ethers`
934
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
881
935
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
882
936
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
883
937
  *
884
- * await exchClient.scheduleCancel({ time: Date.now() + 10_000 });
938
+ * await exchClient.sendAsset({
939
+ * destination: "0x0000000000000000000000000000000000000001",
940
+ * sourceDex: "",
941
+ * destinationDex: "test",
942
+ * token: "USDC:0xeb62eee3685fc4c43992febcd9e75443",
943
+ * amount: "1",
944
+ * fromSubAccount: "",
945
+ * });
885
946
  * ```
886
947
  */
887
- scheduleCancel(args?: ScheduleCancelParameters, signal?: AbortSignal): Promise<SuccessResponse>;
888
- scheduleCancel(signal?: AbortSignal): Promise<SuccessResponse>;
948
+ sendAsset(params: DeepImmutable<SendAssetParameters>, opts?: SendAssetOptions): Promise<SuccessResponse>;
889
949
  /**
890
950
  * Set the display name in the leaderboard.
891
- * @param args - The parameters for the request.
892
- * @param signal - An optional abort signal.
951
+ * @param params - Action-specific parameters.
952
+ * @param opts - Request execution options.
893
953
  * @returns Successful response without specific data.
894
954
  *
895
955
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -900,18 +960,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
900
960
  * ```ts
901
961
  * import * as hl from "@nktkas/hyperliquid";
902
962
  *
903
- * const privateKey = "0x..."; // or `viem`, `ethers`
963
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
904
964
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
905
965
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
906
966
  *
907
967
  * await exchClient.setDisplayName({ displayName: "..." });
908
968
  * ```
909
969
  */
910
- setDisplayName(args: SetDisplayNameParameters, signal?: AbortSignal): Promise<SuccessResponse>;
970
+ setDisplayName(params: DeepImmutable<SetDisplayNameParameters>, opts?: SetDisplayNameOptions): Promise<SuccessResponse>;
911
971
  /**
912
972
  * Set a referral code.
913
- * @param args - The parameters for the request.
914
- * @param signal - An optional abort signal.
973
+ * @param params - Action-specific parameters.
974
+ * @param opts - Request execution options.
915
975
  * @returns Successful response without specific data.
916
976
  *
917
977
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -922,18 +982,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
922
982
  * ```ts
923
983
  * import * as hl from "@nktkas/hyperliquid";
924
984
  *
925
- * const privateKey = "0x..."; // or `viem`, `ethers`
985
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
926
986
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
927
987
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
928
988
  *
929
989
  * await exchClient.setReferrer({ code: "..." });
930
990
  * ```
931
991
  */
932
- setReferrer(args: SetReferrerParameters, signal?: AbortSignal): Promise<SuccessResponse>;
992
+ setReferrer(params: DeepImmutable<SetReferrerParameters>, opts?: SetReferrerOptions): Promise<SuccessResponse>;
933
993
  /**
934
994
  * Deploying HIP-1 and HIP-2 assets.
935
- * @param args - The parameters for the request.
936
- * @param signal - An optional abort signal.
995
+ * @param params - Action-specific parameters.
996
+ * @param opts - Request execution options.
937
997
  * @returns Successful response without specific data.
938
998
  *
939
999
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -944,7 +1004,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
944
1004
  * ```ts
945
1005
  * import * as hl from "@nktkas/hyperliquid";
946
1006
  *
947
- * const privateKey = "0x..."; // or `viem`, `ethers`
1007
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
948
1008
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
949
1009
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
950
1010
  *
@@ -961,11 +1021,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
961
1021
  * });
962
1022
  * ```
963
1023
  */
964
- spotDeploy(args: SpotDeployParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1024
+ spotDeploy(params: DeepImmutable<SpotDeployParameters>, opts?: SpotDeployOptions): Promise<SuccessResponse>;
965
1025
  /**
966
1026
  * Send spot assets to another address.
967
- * @param args - The parameters for the request.
968
- * @param signal - An optional abort signal.
1027
+ * @param params - Action-specific parameters.
1028
+ * @param opts - Request execution options.
969
1029
  * @returns Successful response without specific data.
970
1030
  *
971
1031
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -976,7 +1036,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
976
1036
  * ```ts
977
1037
  * import * as hl from "@nktkas/hyperliquid";
978
1038
  *
979
- * const privateKey = "0x..."; // or `viem`, `ethers`
1039
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
980
1040
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
981
1041
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
982
1042
  *
@@ -987,11 +1047,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
987
1047
  * });
988
1048
  * ```
989
1049
  */
990
- spotSend(args: SpotSendParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1050
+ spotSend(params: DeepImmutable<SpotSendParameters>, opts?: SpotSendOptions): Promise<SuccessResponse>;
991
1051
  /**
992
1052
  * Opt Out of Spot Dusting.
993
- * @param args - The parameters for the request.
994
- * @param signal - An optional abort signal.
1053
+ * @param params - Action-specific parameters.
1054
+ * @param opts - Request execution options.
995
1055
  * @returns Successful response without specific data.
996
1056
  *
997
1057
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1002,18 +1062,40 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1002
1062
  * ```ts
1003
1063
  * import * as hl from "@nktkas/hyperliquid";
1004
1064
  *
1005
- * const privateKey = "0x..."; // or `viem`, `ethers`
1065
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1006
1066
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1007
1067
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1008
1068
  *
1009
1069
  * await exchClient.spotUser({ toggleSpotDusting: { optOut: false } });
1010
1070
  * ```
1011
1071
  */
1012
- spotUser(args: SpotUserParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1072
+ spotUser(params: DeepImmutable<SpotUserParameters>, opts?: SpotUserOptions): Promise<SuccessResponse>;
1073
+ /**
1074
+ * Modify a sub-account's.
1075
+ * @param params - Action-specific parameters.
1076
+ * @param opts - Request execution options.
1077
+ * @returns Successful response without specific data.
1078
+ *
1079
+ * @throws {ApiRequestError} When the API returns an unsuccessful response.
1080
+ * @throws {TransportError} When the transport layer throws an error.
1081
+ *
1082
+ * @see null
1083
+ * @example
1084
+ * ```ts
1085
+ * import * as hl from "@nktkas/hyperliquid";
1086
+ *
1087
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1088
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1089
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1090
+ *
1091
+ * await exchClient.subAccountModify({ subAccountUser: "0x...", name: "..." });
1092
+ * ```
1093
+ */
1094
+ subAccountModify(params: DeepImmutable<SubAccountModifyParameters>, opts?: SubAccountModifyOptions): Promise<SuccessResponse>;
1013
1095
  /**
1014
1096
  * Transfer between sub-accounts (spot).
1015
- * @param args - The parameters for the request.
1016
- * @param signal - An optional abort signal.
1097
+ * @param params - Action-specific parameters.
1098
+ * @param opts - Request execution options.
1017
1099
  * @returns Successful response without specific data.
1018
1100
  *
1019
1101
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1024,7 +1106,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1024
1106
  * ```ts
1025
1107
  * import * as hl from "@nktkas/hyperliquid";
1026
1108
  *
1027
- * const privateKey = "0x..."; // or `viem`, `ethers`
1109
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1028
1110
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1029
1111
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1030
1112
  *
@@ -1036,11 +1118,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1036
1118
  * });
1037
1119
  * ```
1038
1120
  */
1039
- subAccountSpotTransfer(args: SubAccountSpotTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1121
+ subAccountSpotTransfer(params: DeepImmutable<SubAccountSpotTransferParameters>, opts?: SubAccountSpotTransferOptions): Promise<SuccessResponse>;
1040
1122
  /**
1041
1123
  * Transfer between sub-accounts (perpetual).
1042
- * @param args - The parameters for the request.
1043
- * @param signal - An optional abort signal.
1124
+ * @param params - Action-specific parameters.
1125
+ * @param opts - Request execution options.
1044
1126
  * @returns Successful response without specific data.
1045
1127
  *
1046
1128
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1051,18 +1133,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1051
1133
  * ```ts
1052
1134
  * import * as hl from "@nktkas/hyperliquid";
1053
1135
  *
1054
- * const privateKey = "0x..."; // or `viem`, `ethers`
1136
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1055
1137
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1056
1138
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1057
1139
  *
1058
1140
  * await exchClient.subAccountTransfer({ subAccountUser: "0x...", isDeposit: true, usd: 1 * 1e6 });
1059
1141
  * ```
1060
1142
  */
1061
- subAccountTransfer(args: SubAccountTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1143
+ subAccountTransfer(params: DeepImmutable<SubAccountTransferParameters>, opts?: SubAccountTransferOptions): Promise<SuccessResponse>;
1062
1144
  /**
1063
1145
  * Delegate or undelegate native tokens to or from a validator.
1064
- * @param args - The parameters for the request.
1065
- * @param signal - An optional abort signal.
1146
+ * @param params - Action-specific parameters.
1147
+ * @param opts - Request execution options.
1066
1148
  * @returns Successful response without specific data.
1067
1149
  *
1068
1150
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1073,18 +1155,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1073
1155
  * ```ts
1074
1156
  * import * as hl from "@nktkas/hyperliquid";
1075
1157
  *
1076
- * const privateKey = "0x..."; // or `viem`, `ethers`
1158
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1077
1159
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1078
1160
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1079
1161
  *
1080
1162
  * await exchClient.tokenDelegate({ validator: "0x...", isUndelegate: true, wei: 1 * 1e8 });
1081
1163
  * ```
1082
1164
  */
1083
- tokenDelegate(args: TokenDelegateParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1165
+ tokenDelegate(params: DeepImmutable<TokenDelegateParameters>, opts?: TokenDelegateOptions): Promise<SuccessResponse>;
1084
1166
  /**
1085
1167
  * Cancel a TWAP order.
1086
- * @param args - The parameters for the request.
1087
- * @param signal - An optional abort signal.
1168
+ * @param params - Action-specific parameters.
1169
+ * @param opts - Request execution options.
1088
1170
  * @returns Successful variant of {@link TwapCancelResponse} without error status.
1089
1171
  *
1090
1172
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1095,18 +1177,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1095
1177
  * ```ts
1096
1178
  * import * as hl from "@nktkas/hyperliquid";
1097
1179
  *
1098
- * const privateKey = "0x..."; // or `viem`, `ethers`
1180
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1099
1181
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1100
1182
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1101
1183
  *
1102
1184
  * const data = await exchClient.twapCancel({ a: 0, t: 1 });
1103
1185
  * ```
1104
1186
  */
1105
- twapCancel(args: TwapCancelParameters, signal?: AbortSignal): Promise<TwapCancelResponseSuccess>;
1187
+ twapCancel(params: DeepImmutable<TwapCancelParameters>, opts?: TwapCancelOptions): Promise<TwapCancelSuccessResponse>;
1106
1188
  /**
1107
1189
  * Place a TWAP order.
1108
- * @param args - The parameters for the request.
1109
- * @param signal - An optional abort signal.
1190
+ * @param params - Action-specific parameters.
1191
+ * @param opts - Request execution options.
1110
1192
  * @returns Successful variant of {@link TwapOrderResponse} without error status.
1111
1193
  *
1112
1194
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1117,25 +1199,27 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1117
1199
  * ```ts
1118
1200
  * import * as hl from "@nktkas/hyperliquid";
1119
1201
  *
1120
- * const privateKey = "0x..."; // or `viem`, `ethers`
1202
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1121
1203
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1122
1204
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1123
1205
  *
1124
1206
  * const data = await exchClient.twapOrder({
1125
- * a: 0,
1126
- * b: true,
1127
- * s: "1",
1128
- * r: false,
1129
- * m: 10,
1130
- * t: true,
1207
+ * twap: {
1208
+ * a: 0,
1209
+ * b: true,
1210
+ * s: "1",
1211
+ * r: false,
1212
+ * m: 10,
1213
+ * t: true,
1214
+ * },
1131
1215
  * });
1132
1216
  * ```
1133
1217
  */
1134
- twapOrder(args: TwapOrderParameters, signal?: AbortSignal): Promise<TwapOrderResponseSuccess>;
1218
+ twapOrder(params: DeepImmutable<TwapOrderParameters>, opts?: TwapOrderOptions): Promise<TwapOrderSuccessResponse>;
1135
1219
  /**
1136
1220
  * Add or remove margin from isolated position.
1137
- * @param args - The parameters for the request.
1138
- * @param signal - An optional abort signal.
1221
+ * @param params - Action-specific parameters.
1222
+ * @param opts - Request execution options.
1139
1223
  * @returns Successful response without specific data.
1140
1224
  *
1141
1225
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1146,18 +1230,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1146
1230
  * ```ts
1147
1231
  * import * as hl from "@nktkas/hyperliquid";
1148
1232
  *
1149
- * const privateKey = "0x..."; // or `viem`, `ethers`
1233
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1150
1234
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1151
1235
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1152
1236
  *
1153
1237
  * await exchClient.updateIsolatedMargin({ asset: 0, isBuy: true, ntli: 1 * 1e6 });
1154
1238
  * ```
1155
1239
  */
1156
- updateIsolatedMargin(args: UpdateIsolatedMarginParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1240
+ updateIsolatedMargin(params: DeepImmutable<UpdateIsolatedMarginParameters>, opts?: UpdateIsolatedMarginOptions): Promise<SuccessResponse>;
1157
1241
  /**
1158
1242
  * Update cross or isolated leverage on a coin.
1159
- * @param args - The parameters for the request.
1160
- * @param signal - An optional abort signal.
1243
+ * @param params - Action-specific parameters.
1244
+ * @param opts - Request execution options.
1161
1245
  * @returns Successful response without specific data.
1162
1246
  *
1163
1247
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1168,18 +1252,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1168
1252
  * ```ts
1169
1253
  * import * as hl from "@nktkas/hyperliquid";
1170
1254
  *
1171
- * const privateKey = "0x..."; // or `viem`, `ethers`
1255
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1172
1256
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1173
1257
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1174
1258
  *
1175
1259
  * await exchClient.updateLeverage({ asset: 0, isCross: true, leverage: 5 });
1176
1260
  * ```
1177
1261
  */
1178
- updateLeverage(args: UpdateLeverageParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1262
+ updateLeverage(params: DeepImmutable<UpdateLeverageParameters>, opts?: UpdateLeverageOptions): Promise<SuccessResponse>;
1179
1263
  /**
1180
1264
  * Transfer funds between Spot account and Perp account.
1181
- * @param args - The parameters for the request.
1182
- * @param signal - An optional abort signal.
1265
+ * @param params - Action-specific parameters.
1266
+ * @param opts - Request execution options.
1183
1267
  * @returns Successful response without specific data.
1184
1268
  *
1185
1269
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1190,18 +1274,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1190
1274
  * ```ts
1191
1275
  * import * as hl from "@nktkas/hyperliquid";
1192
1276
  *
1193
- * const privateKey = "0x..."; // or `viem`, `ethers`
1277
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1194
1278
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1195
1279
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1196
1280
  *
1197
1281
  * await exchClient.usdClassTransfer({ amount: "1", toPerp: true });
1198
1282
  * ```
1199
1283
  */
1200
- usdClassTransfer(args: UsdClassTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1284
+ usdClassTransfer(params: DeepImmutable<UsdClassTransferParameters>, opts?: UsdClassTransferOptions): Promise<SuccessResponse>;
1201
1285
  /**
1202
1286
  * Send usd to another address.
1203
- * @param args - The parameters for the request.
1204
- * @param signal - An optional abort signal.
1287
+ * @param params - Action-specific parameters.
1288
+ * @param opts - Request execution options.
1205
1289
  * @returns Successful response without specific data.
1206
1290
  *
1207
1291
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1212,18 +1296,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1212
1296
  * ```ts
1213
1297
  * import * as hl from "@nktkas/hyperliquid";
1214
1298
  *
1215
- * const privateKey = "0x..."; // or `viem`, `ethers`
1299
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1216
1300
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1217
1301
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1218
1302
  *
1219
1303
  * await exchClient.usdSend({ destination: "0x...", amount: "1" });
1220
1304
  * ```
1221
1305
  */
1222
- usdSend(args: UsdSendParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1306
+ usdSend(params: DeepImmutable<UsdSendParameters>, opts?: UsdSendOptions): Promise<SuccessResponse>;
1223
1307
  /**
1224
1308
  * Distribute funds from a vault between followers.
1225
- * @param args - The parameters for the request.
1226
- * @param signal - An optional abort signal.
1309
+ * @param params - Action-specific parameters.
1310
+ * @param opts - Request execution options.
1227
1311
  * @returns Successful response without specific data.
1228
1312
  *
1229
1313
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1234,18 +1318,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1234
1318
  * ```ts
1235
1319
  * import * as hl from "@nktkas/hyperliquid";
1236
1320
  *
1237
- * const privateKey = "0x..."; // or `viem`, `ethers`
1321
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1238
1322
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1239
1323
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1240
1324
  *
1241
1325
  * await exchClient.vaultDistribute({ vaultAddress: "0x...", usd: 10 * 1e6 });
1242
1326
  * ```
1243
1327
  */
1244
- vaultDistribute(args: VaultDistributeParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1328
+ vaultDistribute(params: DeepImmutable<VaultDistributeParameters>, opts?: VaultDistributeOptions): Promise<SuccessResponse>;
1245
1329
  /**
1246
1330
  * Modify a vault's configuration.
1247
- * @param args - The parameters for the request.
1248
- * @param signal - An optional abort signal.
1331
+ * @param params - Action-specific parameters.
1332
+ * @param opts - Request execution options.
1249
1333
  * @returns Successful response without specific data.
1250
1334
  *
1251
1335
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1256,7 +1340,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1256
1340
  * ```ts
1257
1341
  * import * as hl from "@nktkas/hyperliquid";
1258
1342
  *
1259
- * const privateKey = "0x..."; // or `viem`, `ethers`
1343
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1260
1344
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1261
1345
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1262
1346
  *
@@ -1267,11 +1351,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1267
1351
  * });
1268
1352
  * ```
1269
1353
  */
1270
- vaultModify(args: VaultModifyParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1354
+ vaultModify(params: DeepImmutable<VaultModifyParameters>, opts?: VaultModifyOptions): Promise<SuccessResponse>;
1271
1355
  /**
1272
1356
  * Deposit or withdraw from a vault.
1273
- * @param args - The parameters for the request.
1274
- * @param signal - An optional abort signal.
1357
+ * @param params - Action-specific parameters.
1358
+ * @param opts - Request execution options.
1275
1359
  * @returns Successful response without specific data.
1276
1360
  *
1277
1361
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1282,18 +1366,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1282
1366
  * ```ts
1283
1367
  * import * as hl from "@nktkas/hyperliquid";
1284
1368
  *
1285
- * const privateKey = "0x..."; // or `viem`, `ethers`
1369
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1286
1370
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1287
1371
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1288
1372
  *
1289
1373
  * await exchClient.vaultTransfer({ vaultAddress: "0x...", isDeposit: true, usd: 10 * 1e6 });
1290
1374
  * ```
1291
1375
  */
1292
- vaultTransfer(args: VaultTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
1376
+ vaultTransfer(params: DeepImmutable<VaultTransferParameters>, opts?: VaultTransferOptions): Promise<SuccessResponse>;
1293
1377
  /**
1294
1378
  * Initiate a withdrawal request.
1295
- * @param args - The parameters for the request.
1296
- * @param signal - An optional abort signal.
1379
+ * @param params - Action-specific parameters.
1380
+ * @param opts - Request execution options.
1297
1381
  * @returns Successful response without specific data.
1298
1382
  *
1299
1383
  * @throws {ApiRequestError} When the API returns an unsuccessful response.
@@ -1304,24 +1388,33 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
1304
1388
  * ```ts
1305
1389
  * import * as hl from "@nktkas/hyperliquid";
1306
1390
  *
1307
- * const privateKey = "0x..."; // or `viem`, `ethers`
1391
+ * const privateKey = "0x..."; // `viem`, `ethers`, or private key directly`
1308
1392
  * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1309
1393
  * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1310
1394
  *
1311
1395
  * await exchClient.withdraw3({ destination: "0x...", amount: "1" });
1312
1396
  * ```
1313
1397
  */
1314
- withdraw3(args: Withdraw3Parameters, signal?: AbortSignal): Promise<SuccessResponse>;
1315
- /** Guesses the chain ID based on the wallet type or the isTestnet flag. */
1316
- protected _guessSignatureChainId(): Promise<Hex>;
1317
- /** Get the default expiration time for an action. */
1398
+ withdraw3(params: DeepImmutable<Withdraw3Parameters>, opts?: Withdraw3Options): Promise<SuccessResponse>;
1399
+ protected _executeL1Action<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(request: {
1400
+ action: Parameters<typeof actionSorter[Exclude<keyof typeof actionSorter, keyof typeof userSignedActionEip712Types>]>[0];
1401
+ vaultAddress?: Hex;
1402
+ expiresAfter: number | undefined;
1403
+ }, signal?: AbortSignal): Promise<T>;
1404
+ protected _executeUserSignedAction<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(request: {
1405
+ action: Parameters<typeof actionSorter[Exclude<Extract<keyof typeof actionSorter, keyof typeof userSignedActionEip712Types>, "multiSig">]>[0];
1406
+ }, signal?: AbortSignal): Promise<T>;
1407
+ protected _executeMultiSigAction<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(request: {
1408
+ action: Parameters<typeof actionSorter["multiSig"]>[0];
1409
+ nonce: number;
1410
+ vaultAddress?: Hex;
1411
+ expiresAfter?: number;
1412
+ }, signal?: AbortSignal): Promise<T>;
1318
1413
  protected _getDefaultExpiresAfter(): Promise<number | undefined>;
1319
- /** Get the signature chain ID for the wallet. */
1320
1414
  protected _getSignatureChainId(): Promise<Hex>;
1321
- /** Get the Hyperliquid chain based on the isTestnet flag. */
1322
1415
  protected _getHyperliquidChain(): "Mainnet" | "Testnet";
1323
- /** Validate a response from the API. */
1324
- protected _validateResponse(response: SuccessResponse | ErrorResponse | CancelResponse | CreateSubAccountResponse | CreateVaultResponse | OrderResponse | TwapOrderResponse | TwapCancelResponse): asserts response is SuccessResponse | CancelResponseSuccess | CreateSubAccountResponse | CreateVaultResponse | OrderResponseSuccess | TwapOrderResponseSuccess | TwapCancelResponseSuccess;
1416
+ protected _validateResponse<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(response: SuccessResponse | ErrorResponse | CancelResponse | CreateSubAccountResponse | CreateVaultResponse | OrderResponse | TwapOrderResponse | TwapCancelResponse): asserts response is T;
1325
1417
  [Symbol.asyncDispose](): Promise<void>;
1326
1418
  }
1419
+ export {};
1327
1420
  //# sourceMappingURL=exchange.d.ts.map