@nktkas/hyperliquid 0.22.2 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -49
- package/esm/src/base.d.ts +4 -1
- package/esm/src/base.d.ts.map +1 -1
- package/esm/src/base.js +2 -2
- package/esm/src/clients/exchange.d.ts +289 -207
- package/esm/src/clients/exchange.d.ts.map +1 -1
- package/esm/src/clients/exchange.js +605 -410
- package/esm/src/clients/info.d.ts +137 -41
- package/esm/src/clients/info.d.ts.map +1 -1
- package/esm/src/clients/info.js +124 -28
- package/esm/src/clients/multiSign.d.ts +285 -204
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/multiSign.js +521 -493
- package/esm/src/clients/subscription.d.ts +38 -3
- package/esm/src/clients/subscription.d.ts.map +1 -1
- package/esm/src/clients/subscription.js +36 -3
- package/esm/src/signing/{_ethers.d.ts → _signTypedData/ethers.d.ts} +1 -1
- package/esm/src/signing/_signTypedData/ethers.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/mod.d.ts +35 -0
- package/esm/src/signing/_signTypedData/mod.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/mod.js +59 -0
- package/esm/src/signing/_signTypedData/private_key.d.ts +26 -0
- package/esm/src/signing/_signTypedData/private_key.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/private_key.js +144 -0
- package/esm/src/signing/{_viem.d.ts → _signTypedData/viem.d.ts} +2 -2
- package/esm/src/signing/_signTypedData/viem.d.ts.map +1 -0
- package/{script/src/signing/_window.d.ts → esm/src/signing/_signTypedData/window.d.ts} +18 -12
- package/esm/src/signing/_signTypedData/window.d.ts.map +1 -0
- package/esm/src/signing/{_window.js → _signTypedData/window.js} +3 -2
- package/esm/src/signing/_sorter.d.ts +56 -82
- package/esm/src/signing/_sorter.d.ts.map +1 -1
- package/esm/src/signing/_sorter.js +36 -49
- package/esm/src/signing/mod.d.ts +151 -130
- package/esm/src/signing/mod.d.ts.map +1 -1
- package/esm/src/signing/mod.js +182 -228
- package/esm/src/transports/base.d.ts +1 -1
- package/esm/src/transports/base.d.ts.map +1 -1
- package/esm/src/transports/base.js +2 -2
- package/esm/src/transports/http/http_transport.d.ts +9 -15
- package/esm/src/transports/http/http_transport.d.ts.map +1 -1
- package/esm/src/transports/http/http_transport.js +64 -59
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/esm/src/transports/websocket/_hyperliquid_event_target.js +1 -1
- package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
- package/esm/src/transports/websocket/_reconnecting_websocket.js +17 -4
- package/esm/src/transports/websocket/_websocket_async_request.d.ts +0 -9
- package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
- package/esm/src/transports/websocket/_websocket_async_request.js +14 -20
- package/esm/src/transports/websocket/websocket_transport.d.ts +8 -4
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.js +83 -54
- package/esm/src/types/exchange/requests.d.ts +27 -51
- package/esm/src/types/exchange/requests.d.ts.map +1 -1
- package/esm/src/types/explorer/requests.d.ts +5 -8
- package/esm/src/types/explorer/requests.d.ts.map +1 -1
- package/esm/src/types/info/accounts.d.ts +5 -5
- package/esm/src/types/info/accounts.d.ts.map +1 -1
- package/esm/src/types/info/delegations.d.ts +1 -1
- package/esm/src/types/info/delegations.d.ts.map +1 -1
- package/esm/src/types/info/orders.d.ts +1 -1
- package/esm/src/types/info/orders.d.ts.map +1 -1
- package/esm/src/types/info/requests.d.ts +49 -96
- package/esm/src/types/info/requests.d.ts.map +1 -1
- package/esm/src/types/subscriptions/requests.d.ts +72 -18
- package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
- package/esm/src/types/subscriptions/responses.d.ts +2 -0
- package/esm/src/types/subscriptions/responses.d.ts.map +1 -1
- package/package.json +8 -5
- package/script/mod.js +13 -23
- package/script/src/base.d.ts +4 -1
- package/script/src/base.d.ts.map +1 -1
- package/script/src/base.js +10 -20
- package/script/src/clients/exchange.d.ts +289 -207
- package/script/src/clients/exchange.d.ts.map +1 -1
- package/script/src/clients/exchange.js +2000 -1815
- package/script/src/clients/info.d.ts +137 -41
- package/script/src/clients/info.d.ts.map +1 -1
- package/script/src/clients/info.js +1296 -1210
- package/script/src/clients/multiSign.d.ts +285 -204
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/multiSign.js +2043 -2025
- package/script/src/clients/subscription.d.ts +38 -3
- package/script/src/clients/subscription.d.ts.map +1 -1
- package/script/src/clients/subscription.js +568 -545
- package/script/src/signing/{_ethers.d.ts → _signTypedData/ethers.d.ts} +1 -1
- package/script/src/signing/_signTypedData/ethers.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/ethers.js +16 -0
- package/script/src/signing/_signTypedData/mod.d.ts +35 -0
- package/script/src/signing/_signTypedData/mod.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/mod.js +67 -0
- package/script/src/signing/_signTypedData/private_key.d.ts +26 -0
- package/script/src/signing/_signTypedData/private_key.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/private_key.js +148 -0
- package/script/src/signing/{_viem.d.ts → _signTypedData/viem.d.ts} +2 -2
- package/script/src/signing/_signTypedData/viem.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/viem.js +9 -0
- package/{esm/src/signing/_window.d.ts → script/src/signing/_signTypedData/window.d.ts} +18 -12
- package/script/src/signing/_signTypedData/window.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/window.js +34 -0
- package/script/src/signing/_sorter.d.ts +56 -82
- package/script/src/signing/_sorter.d.ts.map +1 -1
- package/script/src/signing/_sorter.js +655 -678
- package/script/src/signing/mod.d.ts +151 -130
- package/script/src/signing/mod.d.ts.map +1 -1
- package/script/src/signing/mod.js +286 -342
- package/script/src/transports/base.d.ts +1 -1
- package/script/src/transports/base.d.ts.map +1 -1
- package/script/src/transports/base.js +11 -21
- package/script/src/transports/http/http_transport.d.ts +9 -15
- package/script/src/transports/http/http_transport.d.ts.map +1 -1
- package/script/src/transports/http/http_transport.js +97 -102
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/script/src/transports/websocket/_hyperliquid_event_target.js +51 -61
- package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
- package/script/src/transports/websocket/_reconnecting_websocket.js +271 -268
- package/script/src/transports/websocket/_websocket_async_request.d.ts +0 -9
- package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
- package/script/src/transports/websocket/_websocket_async_request.js +157 -174
- package/script/src/transports/websocket/websocket_transport.d.ts +8 -4
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.js +209 -189
- package/script/src/types/exchange/requests.d.ts +27 -51
- package/script/src/types/exchange/requests.d.ts.map +1 -1
- package/script/src/types/exchange/requests.js +2 -12
- package/script/src/types/exchange/responses.js +2 -12
- package/script/src/types/explorer/requests.d.ts +5 -8
- package/script/src/types/explorer/requests.d.ts.map +1 -1
- package/script/src/types/explorer/requests.js +2 -12
- package/script/src/types/explorer/responses.js +2 -12
- package/script/src/types/info/accounts.d.ts +5 -5
- package/script/src/types/info/accounts.d.ts.map +1 -1
- package/script/src/types/info/accounts.js +2 -12
- package/script/src/types/info/assets.js +2 -12
- package/script/src/types/info/delegations.d.ts +1 -1
- package/script/src/types/info/delegations.d.ts.map +1 -1
- package/script/src/types/info/delegations.js +2 -12
- package/script/src/types/info/markets.js +2 -12
- package/script/src/types/info/orders.d.ts +1 -1
- package/script/src/types/info/orders.d.ts.map +1 -1
- package/script/src/types/info/orders.js +2 -12
- package/script/src/types/info/requests.d.ts +49 -96
- package/script/src/types/info/requests.d.ts.map +1 -1
- package/script/src/types/info/requests.js +2 -12
- package/script/src/types/info/vaults.js +2 -12
- package/script/src/types/mod.js +2 -12
- package/script/src/types/subscriptions/requests.d.ts +72 -18
- package/script/src/types/subscriptions/requests.d.ts.map +1 -1
- package/script/src/types/subscriptions/requests.js +2 -12
- package/script/src/types/subscriptions/responses.d.ts +2 -0
- package/script/src/types/subscriptions/responses.d.ts.map +1 -1
- package/script/src/types/subscriptions/responses.js +2 -12
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +0 -2
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +0 -1
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +0 -95
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +0 -1
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +0 -10
- package/esm/deps/jsr.io/@std/async/1.0.13/delay.d.ts +0 -43
- package/esm/deps/jsr.io/@std/async/1.0.13/delay.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/async/1.0.13/delay.js +0 -63
- package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts +0 -9
- package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.js +0 -2
- package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts +0 -21
- package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.js +0 -32
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -51
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -13
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -2
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -87
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +0 -9
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.js +0 -2
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts +0 -39
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.js +0 -237
- package/esm/src/signing/_ethers.d.ts.map +0 -1
- package/esm/src/signing/_private_key.d.ts +0 -22
- package/esm/src/signing/_private_key.d.ts.map +0 -1
- package/esm/src/signing/_private_key.js +0 -124
- package/esm/src/signing/_viem.d.ts.map +0 -1
- package/esm/src/signing/_window.d.ts.map +0 -1
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +0 -2
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +0 -1
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +0 -27
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +0 -95
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +0 -1
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +0 -24
- package/script/deps/jsr.io/@std/async/1.0.13/delay.d.ts +0 -43
- package/script/deps/jsr.io/@std/async/1.0.13/delay.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/async/1.0.13/delay.js +0 -76
- package/script/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts +0 -9
- package/script/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/bytes/1.0.6/_types.js +0 -13
- package/script/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts +0 -21
- package/script/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/bytes/1.0.6/concat.js +0 -45
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -67
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -26
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -13
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -101
- package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +0 -9
- package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.js +0 -13
- package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts +0 -39
- package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.js +0 -250
- package/script/src/signing/_ethers.d.ts.map +0 -1
- package/script/src/signing/_ethers.js +0 -26
- package/script/src/signing/_private_key.d.ts +0 -22
- package/script/src/signing/_private_key.d.ts.map +0 -1
- package/script/src/signing/_private_key.js +0 -138
- package/script/src/signing/_viem.d.ts.map +0 -1
- package/script/src/signing/_viem.js +0 -19
- package/script/src/signing/_window.d.ts.map +0 -1
- package/script/src/signing/_window.js +0 -43
- /package/esm/src/signing/{_ethers.js → _signTypedData/ethers.js} +0 -0
- /package/esm/src/signing/{_viem.js → _signTypedData/viem.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Hex, HyperliquidError, type MaybePromise } from "../base.js";
|
|
1
|
+
import { type DeepImmutable, type Hex, HyperliquidError, type MaybePromise } from "../base.js";
|
|
2
2
|
import type { IRequestTransport } from "../transports/base.js";
|
|
3
|
-
import type { ApproveAgentRequest, ApproveBuilderFeeRequest,
|
|
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
4
|
import type { CancelResponse, CreateSubAccountResponse, CreateVaultResponse, ErrorResponse, OrderResponse, SuccessResponse, TwapCancelResponse, TwapOrderResponse } from "../types/exchange/responses.js";
|
|
5
5
|
import { type AbstractWallet } from "../signing/mod.js";
|
|
6
6
|
/** Parameters for the {@linkcode ExchangeClient} constructor. */
|
|
@@ -86,6 +86,8 @@ export type PerpDeployParameters_RegisterAsset = Omit<PerpDeployRequest_Register
|
|
|
86
86
|
export type PerpDeployParameters_SetOracle = Omit<PerpDeployRequest_SetOracle["action"], "type">;
|
|
87
87
|
/** Parameters for the {@linkcode ExchangeClient.perpDexClassTransfer} method. */
|
|
88
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">;
|
|
89
91
|
/** Parameters for the {@linkcode ExchangeClient.registerReferrer} method. */
|
|
90
92
|
export type RegisterReferrerParameters = Omit<RegisterReferrerRequest["action"], "type">;
|
|
91
93
|
/** Parameters for the {@linkcode ExchangeClient.reserveRequestWeight} method. */
|
|
@@ -202,7 +204,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
202
204
|
* Initialises a new instance.
|
|
203
205
|
* @param args - The parameters for the client.
|
|
204
206
|
*
|
|
205
|
-
* @example Private key
|
|
207
|
+
* @example Private key directly
|
|
206
208
|
* ```ts
|
|
207
209
|
* import * as hl from "@nktkas/hyperliquid";
|
|
208
210
|
*
|
|
@@ -212,18 +214,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
212
214
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
213
215
|
* ```
|
|
214
216
|
*
|
|
215
|
-
* @example
|
|
217
|
+
* @example [Viem](https://viem.sh/docs/clients/wallet#local-accounts-private-key-mnemonic-etc)
|
|
216
218
|
* ```ts
|
|
217
219
|
* import * as hl from "@nktkas/hyperliquid";
|
|
218
220
|
* import { privateKeyToAccount } from "viem/accounts";
|
|
219
221
|
*
|
|
220
|
-
* const
|
|
222
|
+
* const account = privateKeyToAccount("0x...");
|
|
221
223
|
*
|
|
222
224
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
223
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
225
|
+
* const exchClient = new hl.ExchangeClient({ wallet: account, transport });
|
|
224
226
|
* ```
|
|
225
227
|
*
|
|
226
|
-
* @example
|
|
228
|
+
* @example [ethers.js](https://docs.ethers.org/v6/api/wallet/#Wallet) or [ethers.js v5](https://docs.ethers.org/v5/api/signer/#Wallet)
|
|
227
229
|
* ```ts
|
|
228
230
|
* import * as hl from "@nktkas/hyperliquid";
|
|
229
231
|
* import { ethers } from "ethers";
|
|
@@ -234,24 +236,26 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
234
236
|
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
235
237
|
* ```
|
|
236
238
|
*
|
|
237
|
-
* @example External wallet (e.g. MetaMask) via [viem](https://viem.sh/docs/clients/wallet
|
|
239
|
+
* @example External wallet (e.g. MetaMask) via [viem](https://viem.sh/docs/clients/wallet)
|
|
238
240
|
* ```ts
|
|
239
241
|
* import * as hl from "@nktkas/hyperliquid";
|
|
240
242
|
* import { createWalletClient, custom } from "viem";
|
|
241
243
|
*
|
|
242
|
-
* const
|
|
243
|
-
* const
|
|
244
|
+
* const ethereum = (window as any).ethereum;
|
|
245
|
+
* const [account] = await ethereum.request({ method: "eth_requestAccounts" });
|
|
246
|
+
* const wallet = createWalletClient({ account, transport: custom(ethereum) });
|
|
244
247
|
*
|
|
245
248
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
246
249
|
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
247
250
|
* ```
|
|
248
251
|
*
|
|
249
|
-
* @example External wallet (e.g. MetaMask) via `window.ethereum`
|
|
252
|
+
* @example External wallet (e.g. MetaMask) via [`window.ethereum`](https://eips.ethereum.org/EIPS/eip-1193)
|
|
250
253
|
* ```ts
|
|
251
254
|
* import * as hl from "@nktkas/hyperliquid";
|
|
252
255
|
*
|
|
256
|
+
* const ethereum = (window as any).ethereum;
|
|
253
257
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
254
|
-
* const exchClient = new hl.ExchangeClient({ wallet:
|
|
258
|
+
* const exchClient = new hl.ExchangeClient({ wallet: ethereum, transport });
|
|
255
259
|
* ```
|
|
256
260
|
*/
|
|
257
261
|
constructor(args: ExchangeClientParameters<T, W>);
|
|
@@ -260,7 +264,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
260
264
|
* @param args - The parameters for the request.
|
|
261
265
|
* @param signal - An optional abort signal
|
|
262
266
|
* @returns Successful response without specific data.
|
|
263
|
-
*
|
|
267
|
+
*
|
|
268
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
269
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
264
270
|
*
|
|
265
271
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#approve-an-api-wallet
|
|
266
272
|
* @example
|
|
@@ -271,16 +277,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
271
277
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
272
278
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
273
279
|
*
|
|
274
|
-
*
|
|
280
|
+
* await exchClient.approveAgent({ agentAddress: "0x...", agentName: "..." });
|
|
275
281
|
* ```
|
|
276
282
|
*/
|
|
277
|
-
approveAgent(args: ApproveAgentParameters
|
|
283
|
+
approveAgent(args: DeepImmutable<ApproveAgentParameters>, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
278
284
|
/**
|
|
279
285
|
* Approve a maximum fee rate for a builder.
|
|
280
286
|
* @param args - The parameters for the request.
|
|
281
287
|
* @param signal - An optional abort signal.
|
|
282
288
|
* @returns Successful response without specific data.
|
|
283
|
-
*
|
|
289
|
+
*
|
|
290
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
291
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
284
292
|
*
|
|
285
293
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#approve-a-builder-fee
|
|
286
294
|
* @example
|
|
@@ -291,16 +299,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
291
299
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
292
300
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
293
301
|
*
|
|
294
|
-
*
|
|
302
|
+
* await exchClient.approveBuilderFee({ maxFeeRate: "0.01%", builder: "0x..." });
|
|
295
303
|
* ```
|
|
296
304
|
*/
|
|
297
|
-
approveBuilderFee(args: ApproveBuilderFeeParameters
|
|
305
|
+
approveBuilderFee(args: DeepImmutable<ApproveBuilderFeeParameters>, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
298
306
|
/**
|
|
299
307
|
* Modify multiple orders.
|
|
300
308
|
* @param args - The parameters for the request.
|
|
301
309
|
* @param signal - An optional abort signal.
|
|
302
310
|
* @returns Successful variant of {@link OrderResponse} without error statuses.
|
|
303
|
-
*
|
|
311
|
+
*
|
|
312
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
313
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
304
314
|
*
|
|
305
315
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
|
|
306
316
|
* @example
|
|
@@ -312,32 +322,31 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
312
322
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
313
323
|
*
|
|
314
324
|
* const data = await exchClient.batchModify({
|
|
315
|
-
* modifies: [
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* limit: {
|
|
325
|
-
* tif: "Gtc", // Good-til-cancelled
|
|
326
|
-
* },
|
|
325
|
+
* modifies: [
|
|
326
|
+
* {
|
|
327
|
+
* oid: 123,
|
|
328
|
+
* order: {
|
|
329
|
+
* a: 0,
|
|
330
|
+
* b: true,
|
|
331
|
+
* p: "31000",
|
|
332
|
+
* s: "0.2",
|
|
333
|
+
* r: false,
|
|
334
|
+
* t: { limit: { tif: "Gtc" } },
|
|
327
335
|
* },
|
|
328
|
-
* c: "0x...", // Client Order ID (optional)
|
|
329
336
|
* },
|
|
330
|
-
*
|
|
337
|
+
* ],
|
|
331
338
|
* });
|
|
332
339
|
* ```
|
|
333
340
|
*/
|
|
334
|
-
batchModify(args: BatchModifyParameters
|
|
341
|
+
batchModify(args: DeepImmutable<BatchModifyParameters>, signal?: AbortSignal): Promise<OrderResponseSuccess>;
|
|
335
342
|
/**
|
|
336
343
|
* Cancel order(s).
|
|
337
344
|
* @param args - The parameters for the request.
|
|
338
345
|
* @param signal - An optional abort signal.
|
|
339
346
|
* @returns Successful variant of {@link CancelResponse} without error statuses.
|
|
340
|
-
*
|
|
347
|
+
*
|
|
348
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
349
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
341
350
|
*
|
|
342
351
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
|
|
343
352
|
* @example
|
|
@@ -349,10 +358,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
349
358
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
350
359
|
*
|
|
351
360
|
* const data = await exchClient.cancel({
|
|
352
|
-
* cancels: [
|
|
353
|
-
* a: 0,
|
|
354
|
-
*
|
|
355
|
-
* }],
|
|
361
|
+
* cancels: [
|
|
362
|
+
* { a: 0, o: 123 },
|
|
363
|
+
* ],
|
|
356
364
|
* });
|
|
357
365
|
* ```
|
|
358
366
|
*/
|
|
@@ -362,7 +370,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
362
370
|
* @param args - The parameters for the request.
|
|
363
371
|
* @param signal - An optional abort signal.
|
|
364
372
|
* @returns Successful variant of {@link CancelResponse} without error statuses.
|
|
365
|
-
*
|
|
373
|
+
*
|
|
374
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
375
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
366
376
|
*
|
|
367
377
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
|
|
368
378
|
* @example
|
|
@@ -386,7 +396,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
386
396
|
* @param args - The parameters for the request.
|
|
387
397
|
* @param signal - An optional abort signal.
|
|
388
398
|
* @returns Successful response without specific data.
|
|
389
|
-
*
|
|
399
|
+
*
|
|
400
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
401
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
390
402
|
*
|
|
391
403
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-into-staking
|
|
392
404
|
* @example
|
|
@@ -397,7 +409,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
397
409
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
398
410
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
399
411
|
*
|
|
400
|
-
*
|
|
412
|
+
* await exchClient.cDeposit({ wei: 1 * 1e8 });
|
|
401
413
|
* ```
|
|
402
414
|
*/
|
|
403
415
|
cDeposit(args: CDepositParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -406,9 +418,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
406
418
|
* @param args - The parameters for the request.
|
|
407
419
|
* @param signal - An optional abort signal.
|
|
408
420
|
* @returns Successful response without specific data.
|
|
409
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
410
421
|
*
|
|
411
|
-
* @
|
|
422
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
423
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
424
|
+
*
|
|
425
|
+
* @see null
|
|
412
426
|
* @example
|
|
413
427
|
* ```ts
|
|
414
428
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -417,7 +431,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
417
431
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
418
432
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
419
433
|
*
|
|
420
|
-
*
|
|
434
|
+
* await exchClient.claimRewards();
|
|
421
435
|
* ```
|
|
422
436
|
*/
|
|
423
437
|
claimRewards(signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -426,7 +440,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
426
440
|
* @param args - The parameters for the request.
|
|
427
441
|
* @param signal - An optional abort signal.
|
|
428
442
|
* @returns Successful response without specific data.
|
|
429
|
-
*
|
|
443
|
+
*
|
|
444
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
445
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
430
446
|
*
|
|
431
447
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/multi-sig
|
|
432
448
|
* @example
|
|
@@ -437,10 +453,14 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
437
453
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
438
454
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
439
455
|
*
|
|
440
|
-
*
|
|
456
|
+
* // Convert to multi-sig user
|
|
457
|
+
* await exchClient.convertToMultiSigUser({
|
|
441
458
|
* authorizedUsers: ["0x...", "0x...", "0x..."],
|
|
442
459
|
* threshold: 2,
|
|
443
460
|
* });
|
|
461
|
+
*
|
|
462
|
+
* // Convert to single-sig user
|
|
463
|
+
* await exchClient.convertToMultiSigUser(null);
|
|
444
464
|
* ```
|
|
445
465
|
*/
|
|
446
466
|
convertToMultiSigUser(args: ConvertToMultiSigUserParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -449,9 +469,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
449
469
|
* @param args - The parameters for the request.
|
|
450
470
|
* @param signal - An optional abort signal.
|
|
451
471
|
* @returns Response for creating a sub-account.
|
|
452
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
453
472
|
*
|
|
454
|
-
* @
|
|
473
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
474
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
475
|
+
*
|
|
476
|
+
* @see null
|
|
455
477
|
* @example
|
|
456
478
|
* ```ts
|
|
457
479
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -460,7 +482,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
460
482
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
461
483
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
462
484
|
*
|
|
463
|
-
* const data = await exchClient.createSubAccount({ name: "
|
|
485
|
+
* const data = await exchClient.createSubAccount({ name: "..." });
|
|
464
486
|
* ```
|
|
465
487
|
*/
|
|
466
488
|
createSubAccount(args: CreateSubAccountParameters, signal?: AbortSignal): Promise<CreateSubAccountResponse>;
|
|
@@ -469,9 +491,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
469
491
|
* @param args - The parameters for the request.
|
|
470
492
|
* @param signal - An optional abort signal.
|
|
471
493
|
* @returns Response for creating a vault.
|
|
472
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
473
494
|
*
|
|
474
|
-
* @
|
|
495
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
496
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
497
|
+
*
|
|
498
|
+
* @see null
|
|
475
499
|
* @example
|
|
476
500
|
* ```ts
|
|
477
501
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -480,11 +504,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
480
504
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
481
505
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
482
506
|
*
|
|
483
|
-
* const data = await exchClient.createVault({
|
|
484
|
-
* name: "VaultName",
|
|
485
|
-
* description: "Vault description",
|
|
486
|
-
* initialUsd: 100 * 1e6,
|
|
487
|
-
* });
|
|
507
|
+
* const data = await exchClient.createVault({ name: "...", description: "...", initialUsd: 100 * 1e6 });
|
|
488
508
|
* ```
|
|
489
509
|
*/
|
|
490
510
|
createVault(args: CreateVaultParameters, signal?: AbortSignal): Promise<CreateVaultResponse>;
|
|
@@ -493,9 +513,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
493
513
|
* @param args - The parameters for the request.
|
|
494
514
|
* @param signal - An optional abort signal.
|
|
495
515
|
* @returns Successful response without specific data.
|
|
496
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
497
516
|
*
|
|
498
|
-
* @
|
|
517
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
518
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
519
|
+
*
|
|
520
|
+
* @see null
|
|
499
521
|
* @example
|
|
500
522
|
* ```ts
|
|
501
523
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -505,21 +527,23 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
505
527
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
506
528
|
*
|
|
507
529
|
* // Jail self
|
|
508
|
-
*
|
|
530
|
+
* await exchClient.cSignerAction({ jailSelf: null });
|
|
509
531
|
*
|
|
510
532
|
* // Unjail self
|
|
511
|
-
*
|
|
533
|
+
* await exchClient.cSignerAction({ unjailSelf: null });
|
|
512
534
|
* ```
|
|
513
535
|
*/
|
|
514
|
-
cSignerAction(args:
|
|
515
|
-
cSignerAction(args: CSignerActionParameters_UnjailSelf, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
536
|
+
cSignerAction(args: CSignerActionParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
516
537
|
/**
|
|
517
538
|
* Action related to validator management.
|
|
518
539
|
* @param args - The parameters for the request.
|
|
519
540
|
* @param signal - An optional abort signal.
|
|
520
541
|
* @returns Successful response without specific data.
|
|
521
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
522
542
|
*
|
|
543
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
544
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
545
|
+
*
|
|
546
|
+
* @see null
|
|
523
547
|
* @example
|
|
524
548
|
* ```ts
|
|
525
549
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -529,24 +553,43 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
529
553
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
530
554
|
*
|
|
531
555
|
* // Change validator profile
|
|
532
|
-
*
|
|
556
|
+
* await exchClient.cValidatorAction({
|
|
533
557
|
* changeProfile: {
|
|
534
|
-
* name: "
|
|
535
|
-
* description: "
|
|
558
|
+
* name: "...",
|
|
559
|
+
* description: "...",
|
|
536
560
|
* unjailed: true,
|
|
537
561
|
* }
|
|
538
562
|
* });
|
|
563
|
+
*
|
|
564
|
+
* // Register a new validator
|
|
565
|
+
* await exchClient.cValidatorAction({
|
|
566
|
+
* register: {
|
|
567
|
+
* profile: {
|
|
568
|
+
* node_ip: { Ip: "1.2.3.4" },
|
|
569
|
+
* name: "...",
|
|
570
|
+
* description: "...",
|
|
571
|
+
* delegations_disabled: true,
|
|
572
|
+
* commission_bps: 1,
|
|
573
|
+
* signer: "0x...",
|
|
574
|
+
* },
|
|
575
|
+
* unjailed: false,
|
|
576
|
+
* initial_wei: 1,
|
|
577
|
+
* },
|
|
578
|
+
* });
|
|
579
|
+
*
|
|
580
|
+
* // Unregister a validator
|
|
581
|
+
* await exchClient.cValidatorAction({ unregister: null });
|
|
539
582
|
* ```
|
|
540
583
|
*/
|
|
541
|
-
cValidatorAction(args:
|
|
542
|
-
cValidatorAction(args: CValidatorActionParameters_Register, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
543
|
-
cValidatorAction(args: CValidatorActionParameters_Unregister, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
584
|
+
cValidatorAction(args: CValidatorActionParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
544
585
|
/**
|
|
545
586
|
* Transfer native token from staking into the user's spot account.
|
|
546
587
|
* @param args - The parameters for the request.
|
|
547
588
|
* @param signal - An optional abort signal.
|
|
548
589
|
* @returns Successful response without specific data.
|
|
549
|
-
*
|
|
590
|
+
*
|
|
591
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
592
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
550
593
|
*
|
|
551
594
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#withdraw-from-staking
|
|
552
595
|
* @example
|
|
@@ -557,7 +600,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
557
600
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
558
601
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
559
602
|
*
|
|
560
|
-
*
|
|
603
|
+
* await exchClient.cWithdraw({ wei: 1 * 1e8 });
|
|
561
604
|
* ```
|
|
562
605
|
*/
|
|
563
606
|
cWithdraw(args: CWithdrawParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -566,7 +609,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
566
609
|
* @param args - The parameters for the request.
|
|
567
610
|
* @param signal - An optional abort signal.
|
|
568
611
|
* @returns Response for creating a sub-account.
|
|
569
|
-
*
|
|
612
|
+
*
|
|
613
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
614
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
570
615
|
*
|
|
571
616
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/evm/dual-block-architecture
|
|
572
617
|
* @example
|
|
@@ -586,7 +631,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
586
631
|
* @param args - The parameters for the request.
|
|
587
632
|
* @param signal - An optional abort signal.
|
|
588
633
|
* @returns Successful response without specific data.
|
|
589
|
-
*
|
|
634
|
+
*
|
|
635
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
636
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
590
637
|
*
|
|
591
638
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-an-order
|
|
592
639
|
* @example
|
|
@@ -597,20 +644,16 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
597
644
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
598
645
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
599
646
|
*
|
|
600
|
-
*
|
|
647
|
+
* await exchClient.modify({
|
|
601
648
|
* oid: 123,
|
|
602
649
|
* order: {
|
|
603
|
-
* a: 0,
|
|
604
|
-
* b: true,
|
|
605
|
-
* p: "31000",
|
|
606
|
-
* s: "0.2",
|
|
607
|
-
* r: false,
|
|
608
|
-
* t: {
|
|
609
|
-
*
|
|
610
|
-
* tif: "Gtc", // Good-til-cancelled
|
|
611
|
-
* },
|
|
612
|
-
* },
|
|
613
|
-
* c: "0x...", // Client Order ID (optional)
|
|
650
|
+
* a: 0,
|
|
651
|
+
* b: true,
|
|
652
|
+
* p: "31000",
|
|
653
|
+
* s: "0.2",
|
|
654
|
+
* r: false,
|
|
655
|
+
* t: { limit: { tif: "Gtc" } },
|
|
656
|
+
* c: "0x...",
|
|
614
657
|
* },
|
|
615
658
|
* });
|
|
616
659
|
* ```
|
|
@@ -620,28 +663,35 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
620
663
|
* A multi-signature request.
|
|
621
664
|
* @param args - The parameters for the request.
|
|
622
665
|
* @param signal - An optional abort signal.
|
|
623
|
-
* @returns
|
|
624
|
-
*
|
|
666
|
+
* @returns Any successful response.
|
|
667
|
+
*
|
|
668
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
669
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
625
670
|
*
|
|
626
671
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/multi-sig
|
|
627
672
|
* @example
|
|
628
673
|
* ```ts
|
|
629
674
|
* import * as hl from "@nktkas/hyperliquid";
|
|
675
|
+
* import { actionSorter, signL1Action } from "@nktkas/hyperliquid/signing";
|
|
676
|
+
* import { privateKeyToAccount } from "viem/accounts";
|
|
630
677
|
*
|
|
631
|
-
* const
|
|
632
|
-
* const
|
|
633
|
-
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
678
|
+
* const wallet = privateKeyToAccount("0x..."); // or any other wallet libraries
|
|
679
|
+
* const multiSigUser = "0x...";
|
|
634
680
|
*
|
|
635
|
-
* const
|
|
681
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
682
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
636
683
|
*
|
|
637
684
|
* const nonce = Date.now();
|
|
638
|
-
* const action = {
|
|
685
|
+
* const action = {
|
|
686
|
+
* type: "scheduleCancel",
|
|
687
|
+
* time: Date.now() + 10000,
|
|
688
|
+
* } as const;
|
|
639
689
|
*
|
|
640
|
-
*
|
|
690
|
+
* // Create the required number of signatures
|
|
691
|
+
* const signature = await signL1Action({
|
|
641
692
|
* wallet,
|
|
642
|
-
* action: [multiSigUser.toLowerCase(),
|
|
693
|
+
* action: [multiSigUser.toLowerCase(), wallet.address.toLowerCase(), actionSorter[action.type](action)],
|
|
643
694
|
* nonce,
|
|
644
|
-
* isTestnet: true,
|
|
645
695
|
* });
|
|
646
696
|
*
|
|
647
697
|
* const data = await exchClient.multiSig({
|
|
@@ -661,7 +711,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
661
711
|
* @param args - The parameters for the request.
|
|
662
712
|
* @param signal - An optional abort signal.
|
|
663
713
|
* @returns Successful variant of {@link OrderResponse} without error statuses.
|
|
664
|
-
*
|
|
714
|
+
*
|
|
715
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
716
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
665
717
|
*
|
|
666
718
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
|
|
667
719
|
* @example
|
|
@@ -673,20 +725,18 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
673
725
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
674
726
|
*
|
|
675
727
|
* const data = await exchClient.order({
|
|
676
|
-
* orders: [
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
* limit: {
|
|
684
|
-
*
|
|
685
|
-
* },
|
|
728
|
+
* orders: [
|
|
729
|
+
* {
|
|
730
|
+
* a: 0,
|
|
731
|
+
* b: true,
|
|
732
|
+
* p: "30000",
|
|
733
|
+
* s: "0.1",
|
|
734
|
+
* r: false,
|
|
735
|
+
* t: { limit: { tif: "Gtc" } },
|
|
736
|
+
* c: "0x...",
|
|
686
737
|
* },
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
* grouping: "na", // No grouping
|
|
738
|
+
* ],
|
|
739
|
+
* grouping: "na",
|
|
690
740
|
* });
|
|
691
741
|
* ```
|
|
692
742
|
*/
|
|
@@ -696,7 +746,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
696
746
|
* @param args - The parameters for the request.
|
|
697
747
|
* @param signal - An optional abort signal.
|
|
698
748
|
* @returns Successful response without specific data.
|
|
699
|
-
*
|
|
749
|
+
*
|
|
750
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
751
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
700
752
|
*
|
|
701
753
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/deploying-hip-3-assets
|
|
702
754
|
* @example
|
|
@@ -707,7 +759,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
707
759
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
708
760
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
709
761
|
*
|
|
710
|
-
*
|
|
762
|
+
* await exchClient.perpDeploy({
|
|
711
763
|
* registerAsset: {
|
|
712
764
|
* maxGas: 1000000,
|
|
713
765
|
* assetRequest: {
|
|
@@ -722,14 +774,15 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
722
774
|
* });
|
|
723
775
|
* ```
|
|
724
776
|
*/
|
|
725
|
-
perpDeploy(args:
|
|
726
|
-
perpDeploy(args: PerpDeployParameters_SetOracle, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
777
|
+
perpDeploy(args: PerpDeployParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
727
778
|
/**
|
|
728
779
|
* Transfer funds between Spot account and Perp dex account.
|
|
729
780
|
* @param args - The parameters for the request.
|
|
730
781
|
* @param signal - An optional abort signal.
|
|
731
782
|
* @returns Successful response without specific data.
|
|
732
|
-
*
|
|
783
|
+
*
|
|
784
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
785
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
733
786
|
*
|
|
734
787
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#transfer-from-spot-account-to-perp-account-and-vice-versa
|
|
735
788
|
* @example
|
|
@@ -740,23 +793,42 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
740
793
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
741
794
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
742
795
|
*
|
|
743
|
-
*
|
|
744
|
-
* dex: "test",
|
|
745
|
-
* token: "USDC",
|
|
746
|
-
* amount: "1",
|
|
747
|
-
* toPerp: true,
|
|
748
|
-
* });
|
|
796
|
+
* await exchClient.perpDexClassTransfer({ dex: "test", token: "USDC", amount: "1", toPerp: true });
|
|
749
797
|
* ```
|
|
750
798
|
*/
|
|
751
799
|
perpDexClassTransfer(args: PerpDexClassTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
800
|
+
/**
|
|
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.
|
|
804
|
+
* @returns Successful response without specific data.
|
|
805
|
+
*
|
|
806
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
807
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
808
|
+
*
|
|
809
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#transfer-from-perp-account-to-perp-account-for-builder-deployed-dex
|
|
810
|
+
* @example
|
|
811
|
+
* ```ts
|
|
812
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
813
|
+
*
|
|
814
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
815
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
816
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
817
|
+
*
|
|
818
|
+
* await exchClient.perpDexTransfer({ sourceDex: "", destinationDex: "test", amount: "1" });
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
perpDexTransfer(args: PerpDexTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
752
822
|
/**
|
|
753
823
|
* Create a referral code.
|
|
754
824
|
* @param args - The parameters for the request.
|
|
755
825
|
* @param signal - An optional abort signal.
|
|
756
826
|
* @returns Successful response without specific data.
|
|
757
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
758
827
|
*
|
|
759
|
-
* @
|
|
828
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
829
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
830
|
+
*
|
|
831
|
+
* @see null
|
|
760
832
|
* @example
|
|
761
833
|
* ```ts
|
|
762
834
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -765,7 +837,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
765
837
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
766
838
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
767
839
|
*
|
|
768
|
-
*
|
|
840
|
+
* await exchClient.registerReferrer({ code: "..." });
|
|
769
841
|
* ```
|
|
770
842
|
*/
|
|
771
843
|
registerReferrer(args: RegisterReferrerParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -774,7 +846,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
774
846
|
* @param args - The parameters for the request.
|
|
775
847
|
* @param signal - An optional abort signal.
|
|
776
848
|
* @returns Successful response without specific data.
|
|
777
|
-
*
|
|
849
|
+
*
|
|
850
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
851
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
778
852
|
*
|
|
779
853
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#reserve-additional-actions
|
|
780
854
|
* @example
|
|
@@ -785,7 +859,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
785
859
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
786
860
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
787
861
|
*
|
|
788
|
-
*
|
|
862
|
+
* await exchClient.reserveRequestWeight({ weight: 10 });
|
|
789
863
|
* ```
|
|
790
864
|
*/
|
|
791
865
|
reserveRequestWeight(args: ReserveRequestWeightParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -794,7 +868,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
794
868
|
* @param args - The parameters for the request.
|
|
795
869
|
* @param signal - An optional abort signal.
|
|
796
870
|
* @returns Successful response without specific data.
|
|
797
|
-
*
|
|
871
|
+
*
|
|
872
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
873
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
798
874
|
*
|
|
799
875
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#schedule-cancel-dead-mans-switch
|
|
800
876
|
* @example
|
|
@@ -805,7 +881,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
805
881
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
806
882
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
807
883
|
*
|
|
808
|
-
*
|
|
884
|
+
* await exchClient.scheduleCancel({ time: Date.now() + 10_000 });
|
|
809
885
|
* ```
|
|
810
886
|
*/
|
|
811
887
|
scheduleCancel(args?: ScheduleCancelParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -815,9 +891,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
815
891
|
* @param args - The parameters for the request.
|
|
816
892
|
* @param signal - An optional abort signal.
|
|
817
893
|
* @returns Successful response without specific data.
|
|
818
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
819
894
|
*
|
|
820
|
-
* @
|
|
895
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
896
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
897
|
+
*
|
|
898
|
+
* @see null
|
|
821
899
|
* @example
|
|
822
900
|
* ```ts
|
|
823
901
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -826,7 +904,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
826
904
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
827
905
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
828
906
|
*
|
|
829
|
-
*
|
|
907
|
+
* await exchClient.setDisplayName({ displayName: "..." });
|
|
830
908
|
* ```
|
|
831
909
|
*/
|
|
832
910
|
setDisplayName(args: SetDisplayNameParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -835,9 +913,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
835
913
|
* @param args - The parameters for the request.
|
|
836
914
|
* @param signal - An optional abort signal.
|
|
837
915
|
* @returns Successful response without specific data.
|
|
838
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
839
916
|
*
|
|
840
|
-
* @
|
|
917
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
918
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
919
|
+
*
|
|
920
|
+
* @see null
|
|
841
921
|
* @example
|
|
842
922
|
* ```ts
|
|
843
923
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -846,7 +926,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
846
926
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
847
927
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
848
928
|
*
|
|
849
|
-
*
|
|
929
|
+
* await exchClient.setReferrer({ code: "..." });
|
|
850
930
|
* ```
|
|
851
931
|
*/
|
|
852
932
|
setReferrer(args: SetReferrerParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -855,7 +935,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
855
935
|
* @param args - The parameters for the request.
|
|
856
936
|
* @param signal - An optional abort signal.
|
|
857
937
|
* @returns Successful response without specific data.
|
|
858
|
-
*
|
|
938
|
+
*
|
|
939
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
940
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
859
941
|
*
|
|
860
942
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/deploying-hip-1-and-hip-2-assets
|
|
861
943
|
* @example
|
|
@@ -866,7 +948,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
866
948
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
867
949
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
868
950
|
*
|
|
869
|
-
*
|
|
951
|
+
* await exchClient.spotDeploy({
|
|
870
952
|
* registerToken2: {
|
|
871
953
|
* spec: {
|
|
872
954
|
* name: "USDC",
|
|
@@ -879,18 +961,15 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
879
961
|
* });
|
|
880
962
|
* ```
|
|
881
963
|
*/
|
|
882
|
-
spotDeploy(args:
|
|
883
|
-
spotDeploy(args: SpotDeployParameters_RegisterHyperliquidity, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
884
|
-
spotDeploy(args: SpotDeployParameters_RegisterSpot, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
885
|
-
spotDeploy(args: SpotDeployParameters_RegisterToken2, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
886
|
-
spotDeploy(args: SpotDeployParameters_SetDeployerTradingFeeShare, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
887
|
-
spotDeploy(args: SpotDeployParameters_UserGenesis, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
964
|
+
spotDeploy(args: SpotDeployParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
888
965
|
/**
|
|
889
966
|
* Send spot assets to another address.
|
|
890
967
|
* @param args - The parameters for the request.
|
|
891
968
|
* @param signal - An optional abort signal.
|
|
892
969
|
* @returns Successful response without specific data.
|
|
893
|
-
*
|
|
970
|
+
*
|
|
971
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
972
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
894
973
|
*
|
|
895
974
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#core-spot-transfer
|
|
896
975
|
* @example
|
|
@@ -901,7 +980,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
901
980
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
902
981
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
903
982
|
*
|
|
904
|
-
*
|
|
983
|
+
* await exchClient.spotSend({
|
|
905
984
|
* destination: "0x...",
|
|
906
985
|
* token: "USDC:0xeb62eee3685fc4c43992febcd9e75443",
|
|
907
986
|
* amount: "1",
|
|
@@ -914,9 +993,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
914
993
|
* @param args - The parameters for the request.
|
|
915
994
|
* @param signal - An optional abort signal.
|
|
916
995
|
* @returns Successful response without specific data.
|
|
917
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
918
996
|
*
|
|
919
|
-
* @
|
|
997
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
998
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
999
|
+
*
|
|
1000
|
+
* @see null
|
|
920
1001
|
* @example
|
|
921
1002
|
* ```ts
|
|
922
1003
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -925,7 +1006,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
925
1006
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
926
1007
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
927
1008
|
*
|
|
928
|
-
*
|
|
1009
|
+
* await exchClient.spotUser({ toggleSpotDusting: { optOut: false } });
|
|
929
1010
|
* ```
|
|
930
1011
|
*/
|
|
931
1012
|
spotUser(args: SpotUserParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -934,9 +1015,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
934
1015
|
* @param args - The parameters for the request.
|
|
935
1016
|
* @param signal - An optional abort signal.
|
|
936
1017
|
* @returns Successful response without specific data.
|
|
937
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
938
1018
|
*
|
|
939
|
-
* @
|
|
1019
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1020
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1021
|
+
*
|
|
1022
|
+
* @see null
|
|
940
1023
|
* @example
|
|
941
1024
|
* ```ts
|
|
942
1025
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -945,7 +1028,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
945
1028
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
946
1029
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
947
1030
|
*
|
|
948
|
-
*
|
|
1031
|
+
* await exchClient.subAccountSpotTransfer({
|
|
949
1032
|
* subAccountUser: "0x...",
|
|
950
1033
|
* isDeposit: true,
|
|
951
1034
|
* token: "USDC:0xeb62eee3685fc4c43992febcd9e75443",
|
|
@@ -959,9 +1042,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
959
1042
|
* @param args - The parameters for the request.
|
|
960
1043
|
* @param signal - An optional abort signal.
|
|
961
1044
|
* @returns Successful response without specific data.
|
|
962
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
963
1045
|
*
|
|
964
|
-
* @
|
|
1046
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1047
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1048
|
+
*
|
|
1049
|
+
* @see null
|
|
965
1050
|
* @example
|
|
966
1051
|
* ```ts
|
|
967
1052
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -970,11 +1055,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
970
1055
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
971
1056
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
972
1057
|
*
|
|
973
|
-
*
|
|
974
|
-
* subAccountUser: "0x...",
|
|
975
|
-
* isDeposit: true,
|
|
976
|
-
* usd: 1 * 1e6,
|
|
977
|
-
* });
|
|
1058
|
+
* await exchClient.subAccountTransfer({ subAccountUser: "0x...", isDeposit: true, usd: 1 * 1e6 });
|
|
978
1059
|
* ```
|
|
979
1060
|
*/
|
|
980
1061
|
subAccountTransfer(args: SubAccountTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -983,7 +1064,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
983
1064
|
* @param args - The parameters for the request.
|
|
984
1065
|
* @param signal - An optional abort signal.
|
|
985
1066
|
* @returns Successful response without specific data.
|
|
986
|
-
*
|
|
1067
|
+
*
|
|
1068
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1069
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
987
1070
|
*
|
|
988
1071
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#delegate-or-undelegate-stake-from-validator
|
|
989
1072
|
* @example
|
|
@@ -994,11 +1077,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
994
1077
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
995
1078
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
996
1079
|
*
|
|
997
|
-
*
|
|
998
|
-
* validator: "0x...",
|
|
999
|
-
* isUndelegate: true,
|
|
1000
|
-
* wei: 1 * 1e8,
|
|
1001
|
-
* });
|
|
1080
|
+
* await exchClient.tokenDelegate({ validator: "0x...", isUndelegate: true, wei: 1 * 1e8 });
|
|
1002
1081
|
* ```
|
|
1003
1082
|
*/
|
|
1004
1083
|
tokenDelegate(args: TokenDelegateParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -1007,7 +1086,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1007
1086
|
* @param args - The parameters for the request.
|
|
1008
1087
|
* @param signal - An optional abort signal.
|
|
1009
1088
|
* @returns Successful variant of {@link TwapCancelResponse} without error status.
|
|
1010
|
-
*
|
|
1089
|
+
*
|
|
1090
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1091
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1011
1092
|
*
|
|
1012
1093
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-a-twap-order
|
|
1013
1094
|
* @example
|
|
@@ -1018,10 +1099,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1018
1099
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1019
1100
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1020
1101
|
*
|
|
1021
|
-
* const data = await exchClient.twapCancel({
|
|
1022
|
-
* a: 0, // Asset index
|
|
1023
|
-
* t: 1, // TWAP ID
|
|
1024
|
-
* });
|
|
1102
|
+
* const data = await exchClient.twapCancel({ a: 0, t: 1 });
|
|
1025
1103
|
* ```
|
|
1026
1104
|
*/
|
|
1027
1105
|
twapCancel(args: TwapCancelParameters, signal?: AbortSignal): Promise<TwapCancelResponseSuccess>;
|
|
@@ -1030,7 +1108,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1030
1108
|
* @param args - The parameters for the request.
|
|
1031
1109
|
* @param signal - An optional abort signal.
|
|
1032
1110
|
* @returns Successful variant of {@link TwapOrderResponse} without error status.
|
|
1033
|
-
*
|
|
1111
|
+
*
|
|
1112
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1113
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1034
1114
|
*
|
|
1035
1115
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-a-twap-order
|
|
1036
1116
|
* @example
|
|
@@ -1042,12 +1122,12 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1042
1122
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1043
1123
|
*
|
|
1044
1124
|
* const data = await exchClient.twapOrder({
|
|
1045
|
-
* a: 0,
|
|
1046
|
-
* b: true,
|
|
1047
|
-
* s: "1",
|
|
1048
|
-
* r: false,
|
|
1049
|
-
* m: 10,
|
|
1050
|
-
* t: true,
|
|
1125
|
+
* a: 0,
|
|
1126
|
+
* b: true,
|
|
1127
|
+
* s: "1",
|
|
1128
|
+
* r: false,
|
|
1129
|
+
* m: 10,
|
|
1130
|
+
* t: true,
|
|
1051
1131
|
* });
|
|
1052
1132
|
* ```
|
|
1053
1133
|
*/
|
|
@@ -1057,7 +1137,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1057
1137
|
* @param args - The parameters for the request.
|
|
1058
1138
|
* @param signal - An optional abort signal.
|
|
1059
1139
|
* @returns Successful response without specific data.
|
|
1060
|
-
*
|
|
1140
|
+
*
|
|
1141
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1142
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1061
1143
|
*
|
|
1062
1144
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#update-isolated-margin
|
|
1063
1145
|
* @example
|
|
@@ -1068,11 +1150,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1068
1150
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1069
1151
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1070
1152
|
*
|
|
1071
|
-
*
|
|
1072
|
-
* asset: 0,
|
|
1073
|
-
* isBuy: true,
|
|
1074
|
-
* ntli: 1 * 1e6,
|
|
1075
|
-
* });
|
|
1153
|
+
* await exchClient.updateIsolatedMargin({ asset: 0, isBuy: true, ntli: 1 * 1e6 });
|
|
1076
1154
|
* ```
|
|
1077
1155
|
*/
|
|
1078
1156
|
updateIsolatedMargin(args: UpdateIsolatedMarginParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -1081,7 +1159,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1081
1159
|
* @param args - The parameters for the request.
|
|
1082
1160
|
* @param signal - An optional abort signal.
|
|
1083
1161
|
* @returns Successful response without specific data.
|
|
1084
|
-
*
|
|
1162
|
+
*
|
|
1163
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1164
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1085
1165
|
*
|
|
1086
1166
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#update-leverage
|
|
1087
1167
|
* @example
|
|
@@ -1092,11 +1172,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1092
1172
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1093
1173
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1094
1174
|
*
|
|
1095
|
-
*
|
|
1096
|
-
* asset: 0,
|
|
1097
|
-
* isCross: true,
|
|
1098
|
-
* leverage: 5,
|
|
1099
|
-
* });
|
|
1175
|
+
* await exchClient.updateLeverage({ asset: 0, isCross: true, leverage: 5 });
|
|
1100
1176
|
* ```
|
|
1101
1177
|
*/
|
|
1102
1178
|
updateLeverage(args: UpdateLeverageParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -1105,7 +1181,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1105
1181
|
* @param args - The parameters for the request.
|
|
1106
1182
|
* @param signal - An optional abort signal.
|
|
1107
1183
|
* @returns Successful response without specific data.
|
|
1108
|
-
*
|
|
1184
|
+
*
|
|
1185
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1186
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1109
1187
|
*
|
|
1110
1188
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#transfer-from-spot-account-to-perp-account-and-vice-versa
|
|
1111
1189
|
* @example
|
|
@@ -1116,7 +1194,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1116
1194
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1117
1195
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1118
1196
|
*
|
|
1119
|
-
*
|
|
1197
|
+
* await exchClient.usdClassTransfer({ amount: "1", toPerp: true });
|
|
1120
1198
|
* ```
|
|
1121
1199
|
*/
|
|
1122
1200
|
usdClassTransfer(args: UsdClassTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -1125,7 +1203,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1125
1203
|
* @param args - The parameters for the request.
|
|
1126
1204
|
* @param signal - An optional abort signal.
|
|
1127
1205
|
* @returns Successful response without specific data.
|
|
1128
|
-
*
|
|
1206
|
+
*
|
|
1207
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1208
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1129
1209
|
*
|
|
1130
1210
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#core-usdc-transfer
|
|
1131
1211
|
* @example
|
|
@@ -1136,7 +1216,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1136
1216
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1137
1217
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1138
1218
|
*
|
|
1139
|
-
*
|
|
1219
|
+
* await exchClient.usdSend({ destination: "0x...", amount: "1" });
|
|
1140
1220
|
* ```
|
|
1141
1221
|
*/
|
|
1142
1222
|
usdSend(args: UsdSendParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -1145,9 +1225,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1145
1225
|
* @param args - The parameters for the request.
|
|
1146
1226
|
* @param signal - An optional abort signal.
|
|
1147
1227
|
* @returns Successful response without specific data.
|
|
1148
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
1149
1228
|
*
|
|
1150
|
-
* @
|
|
1229
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1230
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1231
|
+
*
|
|
1232
|
+
* @see null
|
|
1151
1233
|
* @example
|
|
1152
1234
|
* ```ts
|
|
1153
1235
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -1156,7 +1238,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1156
1238
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1157
1239
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1158
1240
|
*
|
|
1159
|
-
*
|
|
1241
|
+
* await exchClient.vaultDistribute({ vaultAddress: "0x...", usd: 10 * 1e6 });
|
|
1160
1242
|
* ```
|
|
1161
1243
|
*/
|
|
1162
1244
|
vaultDistribute(args: VaultDistributeParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -1165,9 +1247,11 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1165
1247
|
* @param args - The parameters for the request.
|
|
1166
1248
|
* @param signal - An optional abort signal.
|
|
1167
1249
|
* @returns Successful response without specific data.
|
|
1168
|
-
* @throws {ApiRequestError} When the API returns an error response.
|
|
1169
1250
|
*
|
|
1170
|
-
* @
|
|
1251
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1252
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1253
|
+
*
|
|
1254
|
+
* @see null
|
|
1171
1255
|
* @example
|
|
1172
1256
|
* ```ts
|
|
1173
1257
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -1176,7 +1260,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1176
1260
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1177
1261
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1178
1262
|
*
|
|
1179
|
-
*
|
|
1263
|
+
* await exchClient.vaultModify({
|
|
1180
1264
|
* vaultAddress: "0x...",
|
|
1181
1265
|
* allowDeposits: true,
|
|
1182
1266
|
* alwaysCloseOnWithdraw: false,
|
|
@@ -1189,7 +1273,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1189
1273
|
* @param args - The parameters for the request.
|
|
1190
1274
|
* @param signal - An optional abort signal.
|
|
1191
1275
|
* @returns Successful response without specific data.
|
|
1192
|
-
*
|
|
1276
|
+
*
|
|
1277
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1278
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1193
1279
|
*
|
|
1194
1280
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-a-vault
|
|
1195
1281
|
* @example
|
|
@@ -1200,11 +1286,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1200
1286
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1201
1287
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1202
1288
|
*
|
|
1203
|
-
*
|
|
1204
|
-
* vaultAddress: "0x...",
|
|
1205
|
-
* isDeposit: true,
|
|
1206
|
-
* usd: 10 * 1e6,
|
|
1207
|
-
* });
|
|
1289
|
+
* await exchClient.vaultTransfer({ vaultAddress: "0x...", isDeposit: true, usd: 10 * 1e6 });
|
|
1208
1290
|
* ```
|
|
1209
1291
|
*/
|
|
1210
1292
|
vaultTransfer(args: VaultTransferParameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
@@ -1213,7 +1295,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1213
1295
|
* @param args - The parameters for the request.
|
|
1214
1296
|
* @param signal - An optional abort signal.
|
|
1215
1297
|
* @returns Successful response without specific data.
|
|
1216
|
-
*
|
|
1298
|
+
*
|
|
1299
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1300
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1217
1301
|
*
|
|
1218
1302
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#initiate-a-withdrawal-request
|
|
1219
1303
|
* @example
|
|
@@ -1224,12 +1308,10 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1224
1308
|
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1225
1309
|
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1226
1310
|
*
|
|
1227
|
-
*
|
|
1311
|
+
* await exchClient.withdraw3({ destination: "0x...", amount: "1" });
|
|
1228
1312
|
* ```
|
|
1229
1313
|
*/
|
|
1230
1314
|
withdraw3(args: Withdraw3Parameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
1231
|
-
/** Send an API request and validate the response. */
|
|
1232
|
-
protected _request<T extends SuccessResponse | CancelResponseSuccess | CreateSubAccountResponse | CreateVaultResponse | OrderResponseSuccess | TwapOrderResponseSuccess | TwapCancelResponseSuccess>(payload: BaseExchangeRequest, signal?: AbortSignal): Promise<T>;
|
|
1233
1315
|
/** Guesses the chain ID based on the wallet type or the isTestnet flag. */
|
|
1234
1316
|
protected _guessSignatureChainId(): Promise<Hex>;
|
|
1235
1317
|
/** Get the default expiration time for an action. */
|