@nktkas/hyperliquid 0.19.2 → 0.21.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 +61 -79
- package/esm/mod.d.ts +5 -3
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +4 -3
- package/esm/src/base.d.ts +1 -47
- package/esm/src/base.d.ts.map +1 -1
- package/esm/src/base.js +1 -8
- package/{script/src/clients/wallet.d.ts → esm/src/clients/exchange.d.ts} +111 -112
- package/esm/src/clients/exchange.d.ts.map +1 -0
- package/esm/src/clients/{wallet.js → exchange.js} +96 -306
- package/esm/src/clients/{public.d.ts → info.d.ts} +121 -102
- package/esm/src/clients/info.d.ts.map +1 -0
- package/esm/src/clients/{public.js → info.js} +73 -57
- package/{script/src/clients/event.d.ts → esm/src/clients/subscription.d.ts} +61 -80
- package/esm/src/clients/subscription.d.ts.map +1 -0
- package/esm/src/clients/{event.js → subscription.js} +106 -136
- package/esm/src/signing.d.ts +4 -0
- package/esm/src/signing.d.ts.map +1 -1
- package/esm/src/signing.js +23 -5
- package/esm/src/transports/base.d.ts +47 -0
- package/esm/src/transports/base.d.ts.map +1 -0
- package/esm/src/transports/base.js +8 -0
- package/esm/src/transports/http/http_transport.d.ts +8 -5
- package/esm/src/transports/http/http_transport.d.ts.map +1 -1
- package/esm/src/transports/http/http_transport.js +15 -62
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +36 -39
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/esm/src/transports/websocket/_reconnecting_websocket.d.ts +21 -27
- package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
- package/esm/src/transports/websocket/_reconnecting_websocket.js +89 -182
- package/{script/src/transports/websocket/_websocket_request_dispatcher.d.ts → esm/src/transports/websocket/_websocket_async_request.d.ts} +17 -19
- package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -0
- package/esm/src/transports/websocket/_websocket_async_request.js +177 -0
- package/esm/src/transports/websocket/websocket_transport.d.ts +54 -41
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.js +101 -113
- package/esm/src/types/info/accounts.d.ts +1 -0
- package/esm/src/types/info/accounts.d.ts.map +1 -1
- package/esm/src/types/info/assets.d.ts +0 -48
- package/esm/src/types/info/assets.d.ts.map +1 -1
- package/esm/src/types/info/markets.d.ts +52 -0
- package/esm/src/types/info/markets.d.ts.map +1 -0
- package/esm/src/types/info/markets.js +1 -0
- package/esm/src/types/info/requests.d.ts +9 -0
- package/esm/src/types/info/requests.d.ts.map +1 -1
- package/esm/src/types/mod.d.ts +3 -0
- package/esm/src/types/mod.d.ts.map +1 -1
- package/esm/src/types/mod.js +2 -0
- package/package.json +12 -9
- package/script/mod.d.ts +5 -3
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +5 -4
- package/script/src/base.d.ts +1 -47
- package/script/src/base.d.ts.map +1 -1
- package/script/src/base.js +2 -10
- package/{esm/src/clients/wallet.d.ts → script/src/clients/exchange.d.ts} +111 -112
- package/script/src/clients/exchange.d.ts.map +1 -0
- package/script/src/clients/{wallet.js → exchange.js} +98 -308
- package/script/src/clients/{public.d.ts → info.d.ts} +121 -102
- package/script/src/clients/info.d.ts.map +1 -0
- package/script/src/clients/{public.js → info.js} +75 -59
- package/{esm/src/clients/event.d.ts → script/src/clients/subscription.d.ts} +61 -80
- package/script/src/clients/subscription.d.ts.map +1 -0
- package/script/src/clients/{event.js → subscription.js} +108 -138
- package/script/src/signing.d.ts +4 -0
- package/script/src/signing.d.ts.map +1 -1
- package/script/src/signing.js +25 -7
- package/script/src/transports/base.d.ts +47 -0
- package/script/src/transports/base.d.ts.map +1 -0
- package/script/src/transports/base.js +22 -0
- package/script/src/transports/http/http_transport.d.ts +8 -5
- package/script/src/transports/http/http_transport.d.ts.map +1 -1
- package/script/src/transports/http/http_transport.js +16 -63
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +36 -39
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/script/src/transports/websocket/_reconnecting_websocket.d.ts +21 -27
- package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
- package/script/src/transports/websocket/_reconnecting_websocket.js +90 -183
- package/{esm/src/transports/websocket/_websocket_request_dispatcher.d.ts → script/src/transports/websocket/_websocket_async_request.d.ts} +17 -19
- package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -0
- package/script/src/transports/websocket/_websocket_async_request.js +192 -0
- package/script/src/transports/websocket/websocket_transport.d.ts +54 -41
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.js +103 -115
- package/script/src/types/info/accounts.d.ts +1 -0
- package/script/src/types/info/accounts.d.ts.map +1 -1
- package/script/src/types/info/assets.d.ts +0 -48
- package/script/src/types/info/assets.d.ts.map +1 -1
- package/script/src/types/info/markets.d.ts +52 -0
- package/script/src/types/info/markets.d.ts.map +1 -0
- package/script/{deps/jsr.io/@noble/hashes/1.8.0/src/crypto.js → src/types/info/markets.js} +0 -2
- package/script/src/types/info/requests.d.ts +9 -0
- package/script/src/types/info/requests.d.ts.map +1 -1
- package/script/src/types/mod.d.ts +3 -0
- package/script/src/types/mod.d.ts.map +1 -1
- package/script/src/types/mod.js +2 -0
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts +0 -55
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts.map +0 -1
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.js +0 -66
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.d.ts +0 -2
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.d.ts.map +0 -1
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.js +0 -1
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts +0 -53
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts.map +0 -1
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.js +0 -294
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts +0 -161
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts.map +0 -1
- package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/utils.js +0 -280
- package/esm/src/clients/event.d.ts.map +0 -1
- package/esm/src/clients/public.d.ts.map +0 -1
- package/esm/src/clients/wallet.d.ts.map +0 -1
- package/esm/src/transports/websocket/_websocket_request_dispatcher.d.ts.map +0 -1
- package/esm/src/transports/websocket/_websocket_request_dispatcher.js +0 -191
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts +0 -55
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts.map +0 -1
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.js +0 -99
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.d.ts +0 -2
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/crypto.d.ts.map +0 -1
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts +0 -53
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts.map +0 -1
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.js +0 -309
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts +0 -161
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts.map +0 -1
- package/script/deps/jsr.io/@noble/hashes/1.8.0/src/utils.js +0 -322
- package/script/src/clients/event.d.ts.map +0 -1
- package/script/src/clients/public.d.ts.map +0 -1
- package/script/src/clients/wallet.d.ts.map +0 -1
- package/script/src/transports/websocket/_websocket_request_dispatcher.d.ts.map +0 -1
- package/script/src/transports/websocket/_websocket_request_dispatcher.js +0 -206
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type Hex, HyperliquidError, type
|
|
2
|
-
import type {
|
|
1
|
+
import { type Hex, HyperliquidError, type MaybePromise } from "../base.js";
|
|
2
|
+
import type { IRequestTransport } from "../transports/base.js";
|
|
3
|
+
import type { ApproveAgentRequest, ApproveBuilderFeeRequest, BaseExchangeRequest, 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, 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";
|
|
3
4
|
import type { CancelResponse, CreateSubAccountResponse, CreateVaultResponse, ErrorResponse, OrderResponse, SuccessResponse, TwapCancelResponse, TwapOrderResponse } from "../types/exchange/responses.js";
|
|
4
5
|
import { type AbstractWallet } from "../signing.js";
|
|
5
|
-
/** Parameters for the {@linkcode
|
|
6
|
-
export interface
|
|
6
|
+
/** Parameters for the {@linkcode ExchangeClient} constructor. */
|
|
7
|
+
export interface ExchangeClientParameters<T extends IRequestTransport = IRequestTransport, W extends AbstractWallet = AbstractWallet> {
|
|
7
8
|
/** The transport used to connect to the Hyperliquid API. */
|
|
8
9
|
transport: T;
|
|
9
10
|
/** The `viem`, `ethers.js`, or `window.ethereum` wallet used for signing transactions. */
|
|
@@ -32,112 +33,112 @@ export interface WalletClientParameters<T extends IRequestTransport = IRequestTr
|
|
|
32
33
|
*/
|
|
33
34
|
nonceManager?: () => MaybePromise<number>;
|
|
34
35
|
}
|
|
35
|
-
/** Parameters for the {@linkcode
|
|
36
|
+
/** Parameters for the {@linkcode ExchangeClient.approveAgent} method. */
|
|
36
37
|
export type ApproveAgentParameters = Omit<ApproveAgentRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
|
|
37
|
-
/** Parameters for the {@linkcode
|
|
38
|
+
/** Parameters for the {@linkcode ExchangeClient.approveBuilderFee} method. */
|
|
38
39
|
export type ApproveBuilderFeeParameters = Omit<ApproveBuilderFeeRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
|
|
39
|
-
/** Parameters for the {@linkcode
|
|
40
|
+
/** Parameters for the {@linkcode ExchangeClient.batchModify} method. */
|
|
40
41
|
export type BatchModifyParameters = Omit<BatchModifyRequest["action"], "type"> & Partial<Pick<BatchModifyRequest, "vaultAddress">> & Partial<Pick<BatchModifyRequest, "expiresAfter">>;
|
|
41
|
-
/** Parameters for the {@linkcode
|
|
42
|
+
/** Parameters for the {@linkcode ExchangeClient.cancel} method. */
|
|
42
43
|
export type CancelParameters = Omit<CancelRequest["action"], "type"> & Partial<Pick<CancelRequest, "vaultAddress">> & Partial<Pick<CancelRequest, "expiresAfter">>;
|
|
43
|
-
/** Parameters for the {@linkcode
|
|
44
|
+
/** Parameters for the {@linkcode ExchangeClient.cancelByCloid} method. */
|
|
44
45
|
export type CancelByCloidParameters = Omit<CancelByCloidRequest["action"], "type"> & Partial<Pick<CancelByCloidRequest, "vaultAddress">> & Partial<Pick<CancelByCloidRequest, "expiresAfter">>;
|
|
45
|
-
/** Parameters for the {@linkcode
|
|
46
|
+
/** Parameters for the {@linkcode ExchangeClient.cDeposit} method. */
|
|
46
47
|
export type CDepositParameters = Omit<CDepositRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
|
|
47
|
-
/** Parameters for the {@linkcode
|
|
48
|
+
/** Parameters for the {@linkcode ExchangeClient.convertToMultiSigUser} method. */
|
|
48
49
|
export type ConvertToMultiSigUserParameters = NonNullable<ConvertToMultiSigUserRequest_Signers>;
|
|
49
|
-
/** Parameters for the {@linkcode
|
|
50
|
+
/** Parameters for the {@linkcode ExchangeClient.createSubAccount} method. */
|
|
50
51
|
export type CreateSubAccountParameters = Omit<CreateSubAccountRequest["action"], "type">;
|
|
51
|
-
/** Parameters for the {@linkcode
|
|
52
|
+
/** Parameters for the {@linkcode ExchangeClient.createVault} method. */
|
|
52
53
|
export type CreateVaultParameters = Omit<CreateVaultRequest["action"], "type" | "nonce">;
|
|
53
|
-
/** Parameters for the {@linkcode
|
|
54
|
+
/** Parameters for the {@linkcode ExchangeClient.cSignerAction} method. */
|
|
54
55
|
export type CSignerActionParameters = CSignerActionParameters_JailSelf | CSignerActionParameters_UnjailSelf;
|
|
55
|
-
/** One of the parameters for the {@linkcode
|
|
56
|
+
/** One of the parameters for the {@linkcode ExchangeClient.cSignerAction} method. */
|
|
56
57
|
export type CSignerActionParameters_JailSelf = Omit<CSignerActionRequest_JailSelf["action"], "type"> & Partial<Pick<CSignerActionRequest_JailSelf, "expiresAfter">>;
|
|
57
|
-
/** One of the parameters for the {@linkcode
|
|
58
|
+
/** One of the parameters for the {@linkcode ExchangeClient.cSignerAction} method. */
|
|
58
59
|
export type CSignerActionParameters_UnjailSelf = Omit<CSignerActionRequest_UnjailSelf["action"], "type"> & Partial<Pick<CSignerActionRequest_UnjailSelf, "expiresAfter">>;
|
|
59
|
-
/** Parameters for the {@linkcode
|
|
60
|
+
/** Parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
|
|
60
61
|
export type CValidatorActionParameters = CValidatorActionParameters_ChangeProfile | CValidatorActionParameters_Register | CValidatorActionParameters_Unregister;
|
|
61
|
-
/** One of the parameters for the {@linkcode
|
|
62
|
+
/** One of the parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
|
|
62
63
|
export type CValidatorActionParameters_ChangeProfile = Omit<CValidatorActionRequest_ChangeProfile["action"], "type"> & Partial<Pick<CValidatorActionRequest_ChangeProfile, "expiresAfter">>;
|
|
63
|
-
/** One of the parameters for the {@linkcode
|
|
64
|
+
/** One of the parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
|
|
64
65
|
export type CValidatorActionParameters_Register = Omit<CValidatorActionRequest_Register["action"], "type"> & Partial<Pick<CValidatorActionRequest_Register, "expiresAfter">>;
|
|
65
|
-
/** One of the parameters for the {@linkcode
|
|
66
|
+
/** One of the parameters for the {@linkcode ExchangeClient.cValidatorAction} method. */
|
|
66
67
|
export type CValidatorActionParameters_Unregister = Omit<CValidatorActionRequest_Unregister["action"], "type"> & Partial<Pick<CValidatorActionRequest_Unregister, "expiresAfter">>;
|
|
67
|
-
/** Parameters for the {@linkcode
|
|
68
|
+
/** Parameters for the {@linkcode ExchangeClient.cWithdraw} method. */
|
|
68
69
|
export type CWithdrawParameters = Omit<CWithdrawRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
|
|
69
|
-
/** Parameters for the {@linkcode
|
|
70
|
+
/** Parameters for the {@linkcode ExchangeClient.evmUserModify} method. */
|
|
70
71
|
export type EvmUserModifyParameters = Omit<EvmUserModifyRequest["action"], "type">;
|
|
71
|
-
/** Parameters for the {@linkcode
|
|
72
|
+
/** Parameters for the {@linkcode ExchangeClient.modify} method. */
|
|
72
73
|
export type ModifyParameters = Omit<ModifyRequest["action"], "type"> & Partial<Pick<ModifyRequest, "vaultAddress">> & Partial<Pick<ModifyRequest, "expiresAfter">>;
|
|
73
|
-
/** Parameters for the {@linkcode
|
|
74
|
+
/** Parameters for the {@linkcode ExchangeClient.multiSig} method. */
|
|
74
75
|
export type MultiSigParameters = Omit<MultiSigRequest["action"], "type" | "signatureChainId"> & Partial<Pick<MultiSigRequest, "vaultAddress">> & Partial<Pick<MultiSigRequest, "expiresAfter">> & {
|
|
75
76
|
/** Must be the same for all signers. */
|
|
76
77
|
nonce: number;
|
|
77
78
|
};
|
|
78
|
-
/** Parameters for the {@linkcode
|
|
79
|
+
/** Parameters for the {@linkcode ExchangeClient.order} method. */
|
|
79
80
|
export type OrderParameters = Omit<OrderRequest["action"], "type"> & Partial<Pick<OrderRequest, "vaultAddress">> & Partial<Pick<OrderRequest, "expiresAfter">>;
|
|
80
|
-
/** Parameters for the {@linkcode
|
|
81
|
+
/** Parameters for the {@linkcode ExchangeClient.perpDeploy} method. */
|
|
81
82
|
export type PerpDeployParameters = PerpDeployParameters_RegisterAsset | PerpDeployParameters_SetOracle;
|
|
82
|
-
/** One of the parameters for the {@linkcode
|
|
83
|
+
/** One of the parameters for the {@linkcode ExchangeClient.perpDeploy} method. */
|
|
83
84
|
export type PerpDeployParameters_RegisterAsset = Omit<PerpDeployRequest_RegisterAsset["action"], "type">;
|
|
84
|
-
/** One of the parameters for the {@linkcode
|
|
85
|
+
/** One of the parameters for the {@linkcode ExchangeClient.perpDeploy} method. */
|
|
85
86
|
export type PerpDeployParameters_SetOracle = Omit<PerpDeployRequest_SetOracle["action"], "type">;
|
|
86
|
-
/** Parameters for the {@linkcode
|
|
87
|
+
/** Parameters for the {@linkcode ExchangeClient.perpDexClassTransfer} method. */
|
|
87
88
|
export type PerpDexClassTransferParameters = Omit<PerpDexClassTransferRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
|
|
88
|
-
/** Parameters for the {@linkcode
|
|
89
|
+
/** Parameters for the {@linkcode ExchangeClient.registerReferrer} method. */
|
|
89
90
|
export type RegisterReferrerParameters = Omit<RegisterReferrerRequest["action"], "type">;
|
|
90
|
-
/** Parameters for the {@linkcode
|
|
91
|
+
/** Parameters for the {@linkcode ExchangeClient.reserveRequestWeight} method. */
|
|
91
92
|
export type ReserveRequestWeightParameters = Omit<ReserveRequestWeightRequest["action"], "type"> & Partial<Pick<ReserveRequestWeightRequest, "expiresAfter">>;
|
|
92
|
-
/** Parameters for the {@linkcode
|
|
93
|
+
/** Parameters for the {@linkcode ExchangeClient.scheduleCancel} method. */
|
|
93
94
|
export type ScheduleCancelParameters = Omit<ScheduleCancelRequest["action"], "type"> & Partial<Pick<ScheduleCancelRequest, "vaultAddress">> & Partial<Pick<ScheduleCancelRequest, "expiresAfter">>;
|
|
94
|
-
/** Parameters for the {@linkcode
|
|
95
|
+
/** Parameters for the {@linkcode ExchangeClient.setDisplayName} method. */
|
|
95
96
|
export type SetDisplayNameParameters = Omit<SetDisplayNameRequest["action"], "type">;
|
|
96
|
-
/** Parameters for the {@linkcode
|
|
97
|
+
/** Parameters for the {@linkcode ExchangeClient.setReferrer} method. */
|
|
97
98
|
export type SetReferrerParameters = Omit<SetReferrerRequest["action"], "type">;
|
|
98
|
-
/** Parameters for the {@linkcode
|
|
99
|
+
/** Parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
|
|
99
100
|
export type SpotDeployParameters = SpotDeployParameters_Genesis | SpotDeployParameters_RegisterHyperliquidity | SpotDeployParameters_RegisterSpot | SpotDeployParameters_RegisterToken2 | SpotDeployParameters_SetDeployerTradingFeeShare | SpotDeployParameters_UserGenesis;
|
|
100
|
-
/** One of the parameters for the {@linkcode
|
|
101
|
+
/** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
|
|
101
102
|
export type SpotDeployParameters_Genesis = Omit<SpotDeployRequest_Genesis["action"], "type">;
|
|
102
|
-
/** One of the parameters for the {@linkcode
|
|
103
|
+
/** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
|
|
103
104
|
export type SpotDeployParameters_RegisterHyperliquidity = Omit<SpotDeployRequest_RegisterHyperliquidity["action"], "type">;
|
|
104
|
-
/** One of the parameters for the {@linkcode
|
|
105
|
+
/** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
|
|
105
106
|
export type SpotDeployParameters_RegisterSpot = Omit<SpotDeployRequest_RegisterSpot["action"], "type">;
|
|
106
|
-
/** One of the parameters for the {@linkcode
|
|
107
|
+
/** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
|
|
107
108
|
export type SpotDeployParameters_RegisterToken2 = Omit<SpotDeployRequest_RegisterToken2["action"], "type">;
|
|
108
|
-
/** One of the parameters for the {@linkcode
|
|
109
|
+
/** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
|
|
109
110
|
export type SpotDeployParameters_SetDeployerTradingFeeShare = Omit<SpotDeployRequest_SetDeployerTradingFeeShare["action"], "type">;
|
|
110
|
-
/** One of the parameters for the {@linkcode
|
|
111
|
+
/** One of the parameters for the {@linkcode ExchangeClient.spotDeploy} method. */
|
|
111
112
|
export type SpotDeployParameters_UserGenesis = Omit<SpotDeployRequest_UserGenesis["action"], "type">;
|
|
112
|
-
/** Parameters for the {@linkcode
|
|
113
|
+
/** Parameters for the {@linkcode ExchangeClient.spotSend} method. */
|
|
113
114
|
export type SpotSendParameters = Omit<SpotSendRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time">;
|
|
114
|
-
/** Parameters for the {@linkcode
|
|
115
|
+
/** Parameters for the {@linkcode ExchangeClient.spotUser} method. */
|
|
115
116
|
export type SpotUserParameters = Omit<SpotUserRequest["action"], "type">;
|
|
116
|
-
/** Parameters for the {@linkcode
|
|
117
|
+
/** Parameters for the {@linkcode ExchangeClient.subAccountSpotTransfer} method. */
|
|
117
118
|
export type SubAccountSpotTransferParameters = Omit<SubAccountSpotTransferRequest["action"], "type">;
|
|
118
|
-
/** Parameters for the {@linkcode
|
|
119
|
+
/** Parameters for the {@linkcode ExchangeClient.subAccountTransfer} method. */
|
|
119
120
|
export type SubAccountTransferParameters = Omit<SubAccountTransferRequest["action"], "type">;
|
|
120
|
-
/** Parameters for the {@linkcode
|
|
121
|
+
/** Parameters for the {@linkcode ExchangeClient.tokenDelegate} method. */
|
|
121
122
|
export type TokenDelegateParameters = Omit<TokenDelegateRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
|
|
122
|
-
/** Parameters for the {@linkcode
|
|
123
|
+
/** Parameters for the {@linkcode ExchangeClient.twapCancel} method. */
|
|
123
124
|
export type TwapCancelParameters = Omit<TwapCancelRequest["action"], "type"> & Partial<Pick<TwapCancelRequest, "vaultAddress">> & Partial<Pick<TwapCancelRequest, "expiresAfter">>;
|
|
124
|
-
/** Parameters for the {@linkcode
|
|
125
|
+
/** Parameters for the {@linkcode ExchangeClient.twapOrder} method. */
|
|
125
126
|
export type TwapOrderParameters = TwapOrderRequest["action"]["twap"] & Partial<Pick<TwapOrderRequest, "vaultAddress">> & Partial<Pick<TwapOrderRequest, "expiresAfter">>;
|
|
126
|
-
/** Parameters for the {@linkcode
|
|
127
|
+
/** Parameters for the {@linkcode ExchangeClient.updateIsolatedMargin} method. */
|
|
127
128
|
export type UpdateIsolatedMarginParameters = Omit<UpdateIsolatedMarginRequest["action"], "type"> & Partial<Pick<UpdateIsolatedMarginRequest, "vaultAddress">> & Partial<Pick<UpdateIsolatedMarginRequest, "expiresAfter">>;
|
|
128
|
-
/** Parameters for the {@linkcode
|
|
129
|
+
/** Parameters for the {@linkcode ExchangeClient.updateLeverage} method. */
|
|
129
130
|
export type UpdateLeverageParameters = Omit<UpdateLeverageRequest["action"], "type"> & Partial<Pick<UpdateLeverageRequest, "vaultAddress">> & Partial<Pick<UpdateLeverageRequest, "expiresAfter">>;
|
|
130
|
-
/** Parameters for the {@linkcode
|
|
131
|
+
/** Parameters for the {@linkcode ExchangeClient.usdClassTransfer} method. */
|
|
131
132
|
export type UsdClassTransferParameters = Omit<UsdClassTransferRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "nonce">;
|
|
132
|
-
/** Parameters for the {@linkcode
|
|
133
|
+
/** Parameters for the {@linkcode ExchangeClient.usdSend} method. */
|
|
133
134
|
export type UsdSendParameters = Omit<UsdSendRequest["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time">;
|
|
134
|
-
/** Parameters for the {@linkcode
|
|
135
|
+
/** Parameters for the {@linkcode ExchangeClient.vaultDistribute} method. */
|
|
135
136
|
export type VaultDistributeParameters = Omit<VaultDistributeRequest["action"], "type">;
|
|
136
|
-
/** Parameters for the {@linkcode
|
|
137
|
+
/** Parameters for the {@linkcode ExchangeClient.vaultModify} method. */
|
|
137
138
|
export type VaultModifyParameters = Omit<VaultModifyRequest["action"], "type">;
|
|
138
|
-
/** Parameters for the {@linkcode
|
|
139
|
+
/** Parameters for the {@linkcode ExchangeClient.vaultTransfer} method. */
|
|
139
140
|
export type VaultTransferParameters = Omit<VaultTransferRequest["action"], "type"> & Partial<Pick<VaultTransferRequest, "expiresAfter">>;
|
|
140
|
-
/** Parameters for the {@linkcode
|
|
141
|
+
/** Parameters for the {@linkcode ExchangeClient.withdraw3} method. */
|
|
141
142
|
export type Withdraw3Parameters = Omit<Withdraw3Request["action"], "type" | "hyperliquidChain" | "signatureChainId" | "time">;
|
|
142
143
|
/** Successful variant of {@linkcode CancelResponse} without error statuses. */
|
|
143
144
|
export type CancelResponseSuccess = CancelResponse & {
|
|
@@ -185,27 +186,17 @@ export declare class ApiRequestError extends HyperliquidError {
|
|
|
185
186
|
constructor(response: ErrorResponse | OrderResponse | CancelResponse | TwapOrderResponse | TwapCancelResponse);
|
|
186
187
|
}
|
|
187
188
|
/**
|
|
188
|
-
*
|
|
189
|
+
* Exchange client for interacting with the Hyperliquid API.
|
|
189
190
|
* @typeParam T The transport used to connect to the Hyperliquid API.
|
|
190
191
|
* @typeParam W The WalletClient/Account ([viem](https://viem.sh/docs/clients/wallet)) or Signer ([ethers.js](https://docs.ethers.io/v6/api/providers/#Signer)) used for signing transactions.
|
|
191
192
|
*/
|
|
192
|
-
export declare class
|
|
193
|
-
/** The transport used to connect to the Hyperliquid API. */
|
|
193
|
+
export declare class ExchangeClient<T extends IRequestTransport = IRequestTransport, W extends AbstractWallet = AbstractWallet> implements ExchangeClientParameters, AsyncDisposable {
|
|
194
194
|
transport: T;
|
|
195
|
-
/** The `viem`, `ethers.js`, or `window.ethereum` wallet used for signing transactions. */
|
|
196
195
|
wallet: W;
|
|
197
|
-
/** Specifies whether the client uses testnet. */
|
|
198
196
|
isTestnet: boolean;
|
|
199
|
-
/** Sets a default vaultAddress to be used if no vaultAddress is explicitly passed to a method. */
|
|
200
197
|
defaultVaultAddress?: Hex;
|
|
201
|
-
/** Sets a default expiresAfter to be used if no expiresAfter is explicitly passed to a method. */
|
|
202
198
|
defaultExpiresAfter?: number | (() => MaybePromise<number>);
|
|
203
|
-
/**
|
|
204
|
-
* The network that will be used to sign transactions.
|
|
205
|
-
* Must match the network of the {@link wallet}.
|
|
206
|
-
*/
|
|
207
199
|
signatureChainId: Hex | (() => MaybePromise<Hex>);
|
|
208
|
-
/** Function to get the next nonce for signing transactions. */
|
|
209
200
|
nonceManager: () => MaybePromise<number>;
|
|
210
201
|
/**
|
|
211
202
|
* Initialises a new instance.
|
|
@@ -219,7 +210,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
219
210
|
* const wallet = privateKeyToAccount("0x...");
|
|
220
211
|
*
|
|
221
212
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
222
|
-
* const
|
|
213
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
223
214
|
* ```
|
|
224
215
|
*
|
|
225
216
|
* @example Private key via [ethers.js](https://docs.ethers.org/v6/api/wallet/#Wallet) or [ethers.js v5](https://docs.ethers.org/v5/api/signer/#Wallet)
|
|
@@ -230,7 +221,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
230
221
|
* const wallet = new ethers.Wallet("0x...");
|
|
231
222
|
*
|
|
232
223
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
233
|
-
* const
|
|
224
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
234
225
|
* ```
|
|
235
226
|
*
|
|
236
227
|
* @example External wallet (e.g. MetaMask) via [viem](https://viem.sh/docs/clients/wallet#optional-hoist-the-account)
|
|
@@ -242,7 +233,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
242
233
|
* const wallet = createWalletClient({ account, transport: custom(window.ethereum) });
|
|
243
234
|
*
|
|
244
235
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
245
|
-
* const
|
|
236
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
246
237
|
* ```
|
|
247
238
|
*
|
|
248
239
|
* @example External wallet (e.g. MetaMask) via `window.ethereum` directly
|
|
@@ -250,10 +241,10 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
250
241
|
* import * as hl from "@nktkas/hyperliquid";
|
|
251
242
|
*
|
|
252
243
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
253
|
-
* const
|
|
244
|
+
* const exchClient = new hl.ExchangeClient({ wallet: window.ethereum, transport });
|
|
254
245
|
* ```
|
|
255
246
|
*/
|
|
256
|
-
constructor(args:
|
|
247
|
+
constructor(args: ExchangeClientParameters<T, W>);
|
|
257
248
|
/**
|
|
258
249
|
* Approve an agent to sign on behalf of the master account.
|
|
259
250
|
* @param args - The parameters for the request.
|
|
@@ -269,7 +260,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
269
260
|
*
|
|
270
261
|
* const wallet = privateKeyToAccount("0x...");
|
|
271
262
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
272
|
-
* const
|
|
263
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
273
264
|
*
|
|
274
265
|
* const result = await client.approveAgent({ agentAddress: "0x...", agentName: "agentName" });
|
|
275
266
|
* ```
|
|
@@ -290,7 +281,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
290
281
|
*
|
|
291
282
|
* const wallet = privateKeyToAccount("0x...");
|
|
292
283
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
293
|
-
* const
|
|
284
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
294
285
|
*
|
|
295
286
|
* const result = await client.approveBuilderFee({ maxFeeRate: "0.01%", builder: "0x..." });
|
|
296
287
|
* ```
|
|
@@ -311,7 +302,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
311
302
|
*
|
|
312
303
|
* const wallet = privateKeyToAccount("0x...");
|
|
313
304
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
314
|
-
* const
|
|
305
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
315
306
|
*
|
|
316
307
|
* const result = await client.batchModify({
|
|
317
308
|
* modifies: [{
|
|
@@ -349,7 +340,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
349
340
|
*
|
|
350
341
|
* const wallet = privateKeyToAccount("0x...");
|
|
351
342
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
352
|
-
* const
|
|
343
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
353
344
|
*
|
|
354
345
|
* const result = await client.cancel({
|
|
355
346
|
* cancels: [{
|
|
@@ -375,7 +366,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
375
366
|
*
|
|
376
367
|
* const wallet = privateKeyToAccount("0x...");
|
|
377
368
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
378
|
-
* const
|
|
369
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
379
370
|
*
|
|
380
371
|
* const result = await client.cancelByCloid({
|
|
381
372
|
* cancels: [
|
|
@@ -400,7 +391,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
400
391
|
*
|
|
401
392
|
* const wallet = privateKeyToAccount("0x...");
|
|
402
393
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
403
|
-
* const
|
|
394
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
404
395
|
*
|
|
405
396
|
* const result = await client.cDeposit({ wei: 1 * 1e8 });
|
|
406
397
|
* ```
|
|
@@ -421,7 +412,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
421
412
|
*
|
|
422
413
|
* const wallet = privateKeyToAccount("0x...");
|
|
423
414
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
424
|
-
* const
|
|
415
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
425
416
|
*
|
|
426
417
|
* const result = await client.claimRewards();
|
|
427
418
|
* ```
|
|
@@ -442,7 +433,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
442
433
|
*
|
|
443
434
|
* const wallet = privateKeyToAccount("0x...");
|
|
444
435
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
445
|
-
* const
|
|
436
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
446
437
|
*
|
|
447
438
|
* const result = await client.convertToMultiSigUser({
|
|
448
439
|
* authorizedUsers: ["0x...", "0x..."],
|
|
@@ -466,7 +457,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
466
457
|
*
|
|
467
458
|
* const wallet = privateKeyToAccount("0x...");
|
|
468
459
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
469
|
-
* const
|
|
460
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
470
461
|
*
|
|
471
462
|
* const result = await client.createSubAccount({ name: "subAccountName" });
|
|
472
463
|
* ```
|
|
@@ -487,7 +478,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
487
478
|
*
|
|
488
479
|
* const wallet = privateKeyToAccount("0x...");
|
|
489
480
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
490
|
-
* const
|
|
481
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
491
482
|
*
|
|
492
483
|
* const result = await client.createVault({
|
|
493
484
|
* name: "VaultName",
|
|
@@ -512,7 +503,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
512
503
|
*
|
|
513
504
|
* const wallet = privateKeyToAccount("0x...");
|
|
514
505
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
515
|
-
* const
|
|
506
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
516
507
|
*
|
|
517
508
|
* // Jail self
|
|
518
509
|
* const result = await client.cSignerAction({ jailSelf: null });
|
|
@@ -537,7 +528,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
537
528
|
*
|
|
538
529
|
* const wallet = privateKeyToAccount("0x...");
|
|
539
530
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
540
|
-
* const
|
|
531
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
541
532
|
*
|
|
542
533
|
* // Change validator profile
|
|
543
534
|
* const result = await client.cValidatorAction({
|
|
@@ -567,7 +558,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
567
558
|
*
|
|
568
559
|
* const wallet = privateKeyToAccount("0x...");
|
|
569
560
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
570
|
-
* const
|
|
561
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
571
562
|
*
|
|
572
563
|
* const result = await client.cWithdraw({ wei: 1 * 1e8 });
|
|
573
564
|
* ```
|
|
@@ -588,7 +579,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
588
579
|
*
|
|
589
580
|
* const wallet = privateKeyToAccount("0x...");
|
|
590
581
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
591
|
-
* const
|
|
582
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
592
583
|
*
|
|
593
584
|
* const result = await client.evmUserModify({ usingBigBlocks: true });
|
|
594
585
|
* ```
|
|
@@ -609,7 +600,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
609
600
|
*
|
|
610
601
|
* const wallet = privateKeyToAccount("0x...");
|
|
611
602
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
612
|
-
* const
|
|
603
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
613
604
|
*
|
|
614
605
|
* const result = await client.modify({
|
|
615
606
|
* oid: 123,
|
|
@@ -645,7 +636,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
645
636
|
*
|
|
646
637
|
* const wallet = privateKeyToAccount("0x...");
|
|
647
638
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
648
|
-
* const
|
|
639
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
649
640
|
*
|
|
650
641
|
* const multiSigUser = "0x..."; // Multi-sig user address
|
|
651
642
|
*
|
|
@@ -687,7 +678,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
687
678
|
*
|
|
688
679
|
* const wallet = privateKeyToAccount("0x...");
|
|
689
680
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
690
|
-
* const
|
|
681
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
691
682
|
*
|
|
692
683
|
* const result = await client.order({
|
|
693
684
|
* orders: [{
|
|
@@ -734,7 +725,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
734
725
|
*
|
|
735
726
|
* const wallet = privateKeyToAccount("0x...");
|
|
736
727
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
737
|
-
* const
|
|
728
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
738
729
|
*
|
|
739
730
|
* const result = await client.perpDexClassTransfer({
|
|
740
731
|
* dex: "test",
|
|
@@ -760,7 +751,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
760
751
|
*
|
|
761
752
|
* const wallet = privateKeyToAccount("0x...");
|
|
762
753
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
763
|
-
* const
|
|
754
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
764
755
|
*
|
|
765
756
|
* const result = await client.registerReferrer({ code: "TEST" });
|
|
766
757
|
* ```
|
|
@@ -781,7 +772,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
781
772
|
*
|
|
782
773
|
* const wallet = privateKeyToAccount("0x...");
|
|
783
774
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
784
|
-
* const
|
|
775
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
785
776
|
*
|
|
786
777
|
* const result = await client.reserveRequestWeight({ weight: 10 });
|
|
787
778
|
* ```
|
|
@@ -802,7 +793,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
802
793
|
*
|
|
803
794
|
* const wallet = privateKeyToAccount("0x...");
|
|
804
795
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
805
|
-
* const
|
|
796
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
806
797
|
*
|
|
807
798
|
* const result = await client.scheduleCancel({ time: Date.now() + 3600000 });
|
|
808
799
|
* ```
|
|
@@ -824,7 +815,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
824
815
|
*
|
|
825
816
|
* const wallet = privateKeyToAccount("0x...");
|
|
826
817
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
827
|
-
* const
|
|
818
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
828
819
|
*
|
|
829
820
|
* const result = await client.setDisplayName({ displayName: "My Name" });
|
|
830
821
|
* ```
|
|
@@ -845,7 +836,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
845
836
|
*
|
|
846
837
|
* const wallet = privateKeyToAccount("0x...");
|
|
847
838
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
848
|
-
* const
|
|
839
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
849
840
|
*
|
|
850
841
|
* const result = await client.setReferrer({ code: "TEST" });
|
|
851
842
|
* ```
|
|
@@ -881,7 +872,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
881
872
|
*
|
|
882
873
|
* const wallet = privateKeyToAccount("0x...");
|
|
883
874
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
884
|
-
* const
|
|
875
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
885
876
|
*
|
|
886
877
|
* const result = await client.spotSend({
|
|
887
878
|
* destination: "0x...",
|
|
@@ -906,7 +897,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
906
897
|
*
|
|
907
898
|
* const wallet = privateKeyToAccount("0x...");
|
|
908
899
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
909
|
-
* const
|
|
900
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
910
901
|
*
|
|
911
902
|
* const result = await client.spotUser({ toggleSpotDusting: { optOut: false } });
|
|
912
903
|
* ```
|
|
@@ -927,7 +918,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
927
918
|
*
|
|
928
919
|
* const wallet = privateKeyToAccount("0x...");
|
|
929
920
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
930
|
-
* const
|
|
921
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
931
922
|
*
|
|
932
923
|
* const result = await client.subAccountSpotTransfer({
|
|
933
924
|
* subAccountUser: "0x...",
|
|
@@ -953,7 +944,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
953
944
|
*
|
|
954
945
|
* const wallet = privateKeyToAccount("0x...");
|
|
955
946
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
956
|
-
* const
|
|
947
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
957
948
|
*
|
|
958
949
|
* const result = await client.subAccountTransfer({
|
|
959
950
|
* subAccountUser: "0x...",
|
|
@@ -978,7 +969,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
978
969
|
*
|
|
979
970
|
* const wallet = privateKeyToAccount("0x...");
|
|
980
971
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
981
|
-
* const
|
|
972
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
982
973
|
*
|
|
983
974
|
* const result = await client.tokenDelegate({
|
|
984
975
|
* validator: "0x...",
|
|
@@ -1003,7 +994,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1003
994
|
*
|
|
1004
995
|
* const wallet = privateKeyToAccount("0x...");
|
|
1005
996
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1006
|
-
* const
|
|
997
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1007
998
|
*
|
|
1008
999
|
* const result = await client.twapCancel({
|
|
1009
1000
|
* a: 0, // Asset index
|
|
@@ -1027,7 +1018,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1027
1018
|
*
|
|
1028
1019
|
* const wallet = privateKeyToAccount("0x...");
|
|
1029
1020
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1030
|
-
* const
|
|
1021
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1031
1022
|
*
|
|
1032
1023
|
* const result = await client.twapOrder({
|
|
1033
1024
|
* a: 0, // Asset index
|
|
@@ -1055,7 +1046,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1055
1046
|
*
|
|
1056
1047
|
* const wallet = privateKeyToAccount("0x...");
|
|
1057
1048
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1058
|
-
* const
|
|
1049
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1059
1050
|
*
|
|
1060
1051
|
* const result = await client.updateIsolatedMargin({ asset: 0, isBuy: true, ntli: 1 * 1e6 });
|
|
1061
1052
|
* ```
|
|
@@ -1076,7 +1067,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1076
1067
|
*
|
|
1077
1068
|
* const wallet = privateKeyToAccount("0x...");
|
|
1078
1069
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1079
|
-
* const
|
|
1070
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1080
1071
|
*
|
|
1081
1072
|
* const result = await client.updateLeverage({ asset: 0, isCross: true, leverage: 5 });
|
|
1082
1073
|
* ```
|
|
@@ -1097,7 +1088,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1097
1088
|
*
|
|
1098
1089
|
* const wallet = privateKeyToAccount("0x...");
|
|
1099
1090
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1100
|
-
* const
|
|
1091
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1101
1092
|
*
|
|
1102
1093
|
* const result = await client.usdClassTransfer({ amount: "1", toPerp: true });
|
|
1103
1094
|
* ```
|
|
@@ -1118,7 +1109,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1118
1109
|
*
|
|
1119
1110
|
* const wallet = privateKeyToAccount("0x...");
|
|
1120
1111
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1121
|
-
* const
|
|
1112
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1122
1113
|
*
|
|
1123
1114
|
* const result = await client.usdSend({ destination: "0x...", amount: "1" });
|
|
1124
1115
|
* ```
|
|
@@ -1139,7 +1130,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1139
1130
|
*
|
|
1140
1131
|
* const wallet = privateKeyToAccount("0x...");
|
|
1141
1132
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1142
|
-
* const
|
|
1133
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1143
1134
|
*
|
|
1144
1135
|
* const result = await client.vaultDistribute({ vaultAddress: "0x...", usd: 10 * 1e6 });
|
|
1145
1136
|
* ```
|
|
@@ -1160,7 +1151,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1160
1151
|
*
|
|
1161
1152
|
* const wallet = privateKeyToAccount("0x...");
|
|
1162
1153
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1163
|
-
* const
|
|
1154
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1164
1155
|
*
|
|
1165
1156
|
* const result = await client.vaultModify({
|
|
1166
1157
|
* vaultAddress: "0x...",
|
|
@@ -1185,7 +1176,7 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1185
1176
|
*
|
|
1186
1177
|
* const wallet = privateKeyToAccount("0x...");
|
|
1187
1178
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1188
|
-
* const
|
|
1179
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1189
1180
|
*
|
|
1190
1181
|
* const result = await client.vaultTransfer({
|
|
1191
1182
|
* vaultAddress: "0x...",
|
|
@@ -1210,12 +1201,20 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1210
1201
|
*
|
|
1211
1202
|
* const wallet = privateKeyToAccount("0x...");
|
|
1212
1203
|
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1213
|
-
* const
|
|
1204
|
+
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1214
1205
|
*
|
|
1215
1206
|
* const result = await client.withdraw3({ destination: "0x...", amount: "1" });
|
|
1216
1207
|
* ```
|
|
1217
1208
|
*/
|
|
1218
1209
|
withdraw3(args: Withdraw3Parameters, signal?: AbortSignal): Promise<SuccessResponse>;
|
|
1210
|
+
/** Send an API request and validate the response. */
|
|
1211
|
+
protected _request(payload: {
|
|
1212
|
+
action: BaseExchangeRequest["action"];
|
|
1213
|
+
signature: BaseExchangeRequest["signature"];
|
|
1214
|
+
nonce: BaseExchangeRequest["nonce"];
|
|
1215
|
+
vaultAddress?: Hex;
|
|
1216
|
+
expiresAfter?: number;
|
|
1217
|
+
}, signal?: AbortSignal): Promise<SuccessResponse | CancelResponseSuccess | CreateSubAccountResponse | CreateVaultResponse | OrderResponseSuccess | TwapOrderResponseSuccess | TwapCancelResponseSuccess>;
|
|
1219
1218
|
/** Formats a decimal number as a string, removing trailing zeros. */
|
|
1220
1219
|
protected _formatDecimal(numStr: string): string;
|
|
1221
1220
|
/** Guesses the chain ID based on the wallet type or the isTestnet flag. */
|
|
@@ -1230,4 +1229,4 @@ export declare class WalletClient<T extends IRequestTransport = IRequestTranspor
|
|
|
1230
1229
|
protected _validateResponse(response: SuccessResponse | ErrorResponse | CancelResponse | CreateSubAccountResponse | CreateVaultResponse | OrderResponse | TwapOrderResponse | TwapCancelResponse): asserts response is SuccessResponse | CancelResponseSuccess | CreateSubAccountResponse | CreateVaultResponse | OrderResponseSuccess | TwapOrderResponseSuccess | TwapCancelResponseSuccess;
|
|
1231
1230
|
[Symbol.asyncDispose](): Promise<void>;
|
|
1232
1231
|
}
|
|
1233
|
-
//# sourceMappingURL=
|
|
1232
|
+
//# sourceMappingURL=exchange.d.ts.map
|