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