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