@nktkas/hyperliquid 0.25.3 → 0.25.4
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 +36 -27
- package/esm/bin/cli.js +87 -87
- package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts +74 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.js +58 -0
- package/esm/src/api/exchange/agentEnableDexAbstraction.js.map +1 -0
- package/esm/src/api/exchange/userDexAbstraction.d.ts +104 -0
- package/esm/src/api/exchange/userDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/exchange/userDexAbstraction.js +79 -0
- package/esm/src/api/exchange/userDexAbstraction.js.map +1 -0
- package/esm/src/api/exchange/~client.d.ts +100 -40
- package/esm/src/api/exchange/~client.d.ts.map +1 -1
- package/esm/src/api/exchange/~client.js +50 -0
- package/esm/src/api/exchange/~client.js.map +1 -1
- package/esm/src/api/exchange/~mod.d.ts +2 -0
- package/esm/src/api/exchange/~mod.d.ts.map +1 -1
- package/esm/src/api/exchange/~mod.js +2 -0
- package/esm/src/api/exchange/~mod.js.map +1 -1
- package/esm/src/api/info/userDexAbstraction.d.ts +49 -0
- package/esm/src/api/info/userDexAbstraction.d.ts.map +1 -0
- package/esm/src/api/info/userDexAbstraction.js +52 -0
- package/esm/src/api/info/userDexAbstraction.js.map +1 -0
- package/esm/src/api/info/~client.d.ts +22 -0
- package/esm/src/api/info/~client.d.ts.map +1 -1
- package/esm/src/api/info/~client.js +23 -0
- package/esm/src/api/info/~client.js.map +1 -1
- package/esm/src/api/info/~mod.d.ts +1 -0
- package/esm/src/api/info/~mod.d.ts.map +1 -1
- package/esm/src/api/info/~mod.js +1 -0
- package/esm/src/api/info/~mod.js.map +1 -1
- package/package.json +1 -1
- package/script/bin/cli.js +87 -87
- package/script/src/api/exchange/agentEnableDexAbstraction.d.ts +74 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.d.ts.map +1 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.js +95 -0
- package/script/src/api/exchange/agentEnableDexAbstraction.js.map +1 -0
- package/script/src/api/exchange/userDexAbstraction.d.ts +104 -0
- package/script/src/api/exchange/userDexAbstraction.d.ts.map +1 -0
- package/script/src/api/exchange/userDexAbstraction.js +116 -0
- package/script/src/api/exchange/userDexAbstraction.js.map +1 -0
- package/script/src/api/exchange/~client.d.ts +100 -40
- package/script/src/api/exchange/~client.d.ts.map +1 -1
- package/script/src/api/exchange/~client.js +50 -0
- package/script/src/api/exchange/~client.js.map +1 -1
- package/script/src/api/exchange/~mod.d.ts +2 -0
- package/script/src/api/exchange/~mod.d.ts.map +1 -1
- package/script/src/api/exchange/~mod.js +2 -0
- package/script/src/api/exchange/~mod.js.map +1 -1
- package/script/src/api/info/userDexAbstraction.d.ts +49 -0
- package/script/src/api/info/userDexAbstraction.d.ts.map +1 -0
- package/script/src/api/info/userDexAbstraction.js +89 -0
- package/script/src/api/info/userDexAbstraction.js.map +1 -0
- package/script/src/api/info/~client.d.ts +22 -0
- package/script/src/api/info/~client.d.ts.map +1 -1
- package/script/src/api/info/~client.js +23 -0
- package/script/src/api/info/~client.js.map +1 -1
- package/script/src/api/info/~mod.d.ts +1 -0
- package/script/src/api/info/~mod.d.ts.map +1 -1
- package/script/src/api/info/~mod.js +1 -0
- package/script/src/api/info/~mod.js.map +1 -1
- package/src/bin/cli.ts +87 -87
- package/src/src/api/exchange/agentEnableDexAbstraction.ts +96 -0
- package/src/src/api/exchange/userDexAbstraction.ts +142 -0
- package/src/src/api/exchange/~client.ts +96 -40
- package/src/src/api/exchange/~mod.ts +2 -0
- package/src/src/api/info/userDexAbstraction.ts +79 -0
- package/src/src/api/info/~client.ts +25 -0
- package/src/src/api/info/~mod.ts +1 -0
package/src/bin/cli.ts
CHANGED
|
@@ -108,156 +108,156 @@ INFO ENDPOINT METHODS
|
|
|
108
108
|
Market Data:
|
|
109
109
|
alignedQuoteTokenInfo --token <number>
|
|
110
110
|
allMids [--dex <string>]
|
|
111
|
-
|
|
112
|
-
candleSnapshot --coin <string> --interval <1m|3m|5m|15m|30m|1h|2h|4h|8h|12h|1d|3d|1w|1M>
|
|
111
|
+
candleSnapshot --coin <string> --interval <1m|3m|5m|15m|30m|1h|2h|4h|8h|12h|1d|3d|1w|1M>
|
|
113
112
|
--startTime <number> [--endTime <number>]
|
|
114
113
|
fundingHistory --coin <string> --startTime <number> [--endTime <number>]
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
l2Book --coin <string> [--nSigFigs <2|3|4|5>] [--mantissa <2|5>]
|
|
115
|
+
liquidatable (no params)
|
|
116
|
+
marginTable --id <number>
|
|
117
|
+
maxMarketOrderNtls (no params)
|
|
119
118
|
meta [--dex <string>]
|
|
120
119
|
metaAndAssetCtxs [--dex <string>]
|
|
120
|
+
perpDexLimits --dex <string>
|
|
121
|
+
perpDexs (no params)
|
|
122
|
+
perpsAtOpenInterestCap [--dex <string>]
|
|
123
|
+
predictedFundings (no params)
|
|
124
|
+
recentTrades --coin <string>
|
|
121
125
|
spotMeta (no params)
|
|
122
126
|
spotMetaAndAssetCtxs (no params)
|
|
123
|
-
exchangeStatus (no params)
|
|
124
|
-
perpDexs (no params)
|
|
125
|
-
perpDexLimits --dex <string>
|
|
126
|
-
spotPairDeployAuctionStatus (no params)
|
|
127
|
-
perpDeployAuctionStatus (no params)
|
|
128
|
-
perpsAtOpenInterestCap [--dex <string>]
|
|
129
|
-
maxMarketOrderNtls (no params)
|
|
130
|
-
liquidatable (no params)
|
|
131
|
-
marginTable --id <number>
|
|
132
127
|
|
|
133
|
-
User Account
|
|
134
|
-
clearinghouseState --user <address> [--dex <string>]
|
|
135
|
-
spotClearinghouseState --user <address> [--dex <string>]
|
|
136
|
-
portfolio --user <address>
|
|
137
|
-
openOrders --user <address> [--dex <string>]
|
|
138
|
-
frontendOpenOrders --user <address> [--dex <string>]
|
|
139
|
-
historicalOrders --user <address>
|
|
140
|
-
orderStatus --user <address> --oid <number|hex>
|
|
141
|
-
userDetails --user <address>
|
|
142
|
-
userFees --user <address>
|
|
143
|
-
userRateLimit --user <address>
|
|
144
|
-
userRole --user <address>
|
|
128
|
+
User Account:
|
|
145
129
|
activeAssetData --user <address> --coin <string>
|
|
130
|
+
clearinghouseState --user <address> [--dex <string>]
|
|
131
|
+
extraAgents --user <address>
|
|
146
132
|
isVip --user <address>
|
|
147
133
|
legalCheck --user <address>
|
|
148
|
-
referral --user <address>
|
|
149
|
-
spotDeployState --user <address>
|
|
150
|
-
preTransferCheck --user <address> --source <address>
|
|
151
134
|
maxBuilderFee --user <address> --builder <address>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
portfolio --user <address>
|
|
136
|
+
preTransferCheck --user <address> --source <address>
|
|
137
|
+
referral --user <address>
|
|
138
|
+
spotClearinghouseState --user <address> [--dex <string>]
|
|
139
|
+
subAccounts --user <address>
|
|
140
|
+
userDexAbstraction --user <address>
|
|
141
|
+
userFees --user <address>
|
|
158
142
|
userFunding --user <address> --startTime <number> [--endTime <number>]
|
|
159
143
|
userNonFundingLedgerUpdates --user <address> --startTime <number> [--endTime <number>]
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
userTwapSliceFillsByTime --user <address> --startTime <number> [--endTime <number>]
|
|
163
|
-
[--aggregateByTime <bool>]
|
|
164
|
-
|
|
165
|
-
Sub-Account & Multi-Sig:
|
|
166
|
-
subAccounts --user <address>
|
|
167
|
-
extraAgents --user <address>
|
|
144
|
+
userRateLimit --user <address>
|
|
145
|
+
userRole --user <address>
|
|
168
146
|
userToMultiSigSigners --user <address>
|
|
147
|
+
webData2 --user <address>
|
|
169
148
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
149
|
+
Orders & TWAP & Position:
|
|
150
|
+
frontendOpenOrders --user <address> [--dex <string>]
|
|
151
|
+
historicalOrders --user <address>
|
|
152
|
+
openOrders --user <address> [--dex <string>]
|
|
153
|
+
orderStatus --user <address> --oid <number|hex>
|
|
154
|
+
twapHistory --user <address>
|
|
155
|
+
userFills --user <address> [--aggregateByTime <bool>]
|
|
156
|
+
userFillsByTime --user <address> --startTime <number>
|
|
157
|
+
[--endTime <number>] [--aggregateByTime <bool>]
|
|
158
|
+
userTwapSliceFills --user <address>
|
|
159
|
+
userTwapSliceFillsByTime --user <address> --startTime <number>
|
|
160
|
+
[--endTime <number>] [--aggregateByTime <bool>]
|
|
175
161
|
|
|
176
162
|
Delegation & Validators:
|
|
177
163
|
delegations --user <address>
|
|
178
164
|
delegatorHistory --user <address>
|
|
179
165
|
delegatorRewards --user <address>
|
|
180
166
|
delegatorSummary --user <address>
|
|
167
|
+
gossipRootIps (no params)
|
|
181
168
|
validatorL1Votes (no params)
|
|
182
169
|
validatorSummaries (no params)
|
|
183
|
-
|
|
170
|
+
|
|
171
|
+
Vault:
|
|
172
|
+
leadingVaults --user <address>
|
|
173
|
+
userVaultEquities --user <address>
|
|
174
|
+
vaultDetails --vaultAddress <address> [--user <address>]
|
|
175
|
+
vaultSummaries (no params)
|
|
176
|
+
|
|
177
|
+
Deploy Market:
|
|
178
|
+
perpDeployAuctionStatus (no params)
|
|
179
|
+
spotDeployState --user <address>
|
|
180
|
+
spotPairDeployAuctionStatus (no params)
|
|
181
|
+
|
|
182
|
+
Other:
|
|
183
|
+
exchangeStatus (no params)
|
|
184
184
|
|
|
185
185
|
Transaction & Block Details:
|
|
186
|
-
txDetails --hash <hex>
|
|
187
186
|
blockDetails --height <number>
|
|
188
187
|
tokenDetails --tokenId <hex>
|
|
188
|
+
txDetails --hash <hex>
|
|
189
|
+
userDetails --user <address>
|
|
189
190
|
|
|
190
191
|
=============================================================================
|
|
191
192
|
EXCHANGE ENDPOINT METHODS
|
|
192
193
|
=============================================================================
|
|
193
194
|
|
|
194
|
-
|
|
195
|
-
order --orders <json> [--grouping <na|normalTpsl|positionTpsl>]
|
|
196
|
-
[--builder <json>]
|
|
197
|
-
modify --oid <number|hex> --order <json>
|
|
195
|
+
Order & TWAP & Position:
|
|
198
196
|
batchModify --modifies <json>
|
|
199
197
|
cancel --cancels <json>
|
|
200
198
|
cancelByCloid --cancels <json>
|
|
199
|
+
modify --oid <number|hex> --order <json>
|
|
200
|
+
order --orders <json> [--grouping <na|normalTpsl|positionTpsl>] [--builder <json>]
|
|
201
201
|
scheduleCancel [--time <number>]
|
|
202
|
-
|
|
203
|
-
TWAP Operations:
|
|
204
|
-
twapOrder --a <number> --b <bool> --s <number> --r <bool> --m <number> --t <bool>
|
|
205
202
|
twapCancel --a <number> --t <number>
|
|
206
|
-
|
|
207
|
-
Position Management:
|
|
208
|
-
updateLeverage --asset <number> --isCross <bool> --leverage <number>
|
|
203
|
+
twapOrder --a <number> --b <bool> --s <number> --r <bool> --m <number> --t <bool>
|
|
209
204
|
updateIsolatedMargin --asset <number> --isBuy <bool> --ntli <number>
|
|
205
|
+
updateLeverage --asset <number> --isCross <bool> --leverage <number>
|
|
206
|
+
|
|
207
|
+
Account:
|
|
208
|
+
agentEnableDexAbstraction (no params)
|
|
209
|
+
approveAgent --agentAddress <address> [--agentName <string>]
|
|
210
|
+
approveBuilderFee --maxFeeRate <number> --builder <address>
|
|
211
|
+
evmUserModify --usingBigBlocks <bool>
|
|
212
|
+
noop (no params)
|
|
213
|
+
reserveRequestWeight --weight <number>
|
|
214
|
+
setDisplayName --displayName <string>
|
|
215
|
+
spotUser --optOut <bool>
|
|
216
|
+
userDexAbstraction --user <address> --enabled <bool>
|
|
210
217
|
|
|
211
218
|
Fund Transfers:
|
|
212
|
-
withdraw3 --destination <address> --amount <number>
|
|
213
|
-
usdSend --destination <address> --amount <number>
|
|
214
|
-
spotSend --destination <address> --token <name:address> --amount <number>
|
|
215
219
|
sendAsset --destination <address> --token <name:address> --amount <number>
|
|
216
220
|
--sourceDex <string> --destinationDex <string> [--fromSubAccount <address>]
|
|
221
|
+
spotSend --destination <address> --token <name:address> --amount <number>
|
|
217
222
|
usdClassTransfer --amount <number> --toPerp <bool>
|
|
223
|
+
usdSend --destination <address> --amount <number>
|
|
224
|
+
withdraw3 --destination <address> --amount <number>
|
|
218
225
|
|
|
219
|
-
Sub-Account
|
|
226
|
+
Sub-Account:
|
|
220
227
|
createSubAccount --name <string>
|
|
221
228
|
subAccountModify --subAccountUser <address> --name <string>
|
|
222
|
-
|
|
223
|
-
subAccountSpotTransfer --subAccountUser <address> --isDeposit <bool>
|
|
229
|
+
subAccountSpotTransfer --subAccountUser <address> --isDeposit <bool>
|
|
224
230
|
--token <name:address> --amount <number>
|
|
231
|
+
subAccountTransfer --subAccountUser <address> --isDeposit <bool> --usd <number>
|
|
225
232
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
vaultModify --vaultAddress <address> [--allowDeposits <bool>]
|
|
229
|
-
[--alwaysCloseOnWithdraw <bool>]
|
|
230
|
-
vaultTransfer --vaultAddress <address> --isDeposit <bool> --usd <number>
|
|
231
|
-
vaultDistribute --vaultAddress <address> --usd <number>
|
|
232
|
-
|
|
233
|
-
Agent & Referrer:
|
|
234
|
-
approveAgent --agentAddress <address> [--agentName <string>]
|
|
235
|
-
approveBuilderFee --maxFeeRate <number> --builder <address>
|
|
233
|
+
Referrer:
|
|
234
|
+
claimRewards (no params)
|
|
236
235
|
registerReferrer --code <string>
|
|
237
236
|
setReferrer --code <string>
|
|
238
|
-
setDisplayName --displayName <string>
|
|
239
237
|
|
|
240
238
|
Staking & Delegation:
|
|
241
|
-
tokenDelegate --validator <address> --wei <number> --isUndelegate <bool>
|
|
242
239
|
cDeposit --wei <number>
|
|
243
240
|
cWithdraw --wei <number>
|
|
244
|
-
|
|
241
|
+
tokenDelegate --validator <address> --wei <number> --isUndelegate <bool>
|
|
245
242
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
Vault:
|
|
244
|
+
createVault --name <string> --description <string> --initialUsd <number>
|
|
245
|
+
vaultDistribute --vaultAddress <address> --usd <number>
|
|
246
|
+
vaultModify --vaultAddress <address> [--allowDeposits <bool>]
|
|
247
|
+
[--alwaysCloseOnWithdraw <bool>]
|
|
248
|
+
vaultTransfer --vaultAddress <address> --isDeposit <bool> --usd <number>
|
|
250
249
|
|
|
251
250
|
Deploy Market:
|
|
252
251
|
perpDeploy --registerAsset <json> | --setOracle <json>
|
|
253
252
|
spotDeploy --genesis <json> | --registerHyperliquidity <json> | --registerSpot <json> |
|
|
254
253
|
--registerToken2 <json> | --setDeployerTradingFeeShare <json> | --userGenesis <json>
|
|
255
254
|
|
|
256
|
-
|
|
257
|
-
convertToMultiSigUser --authorizedUsers <json> --threshold <number>
|
|
255
|
+
Validator Actions:
|
|
258
256
|
cSignerAction --jailSelf null | --unjailSelf null
|
|
259
257
|
cValidatorAction --changeProfile <json> | --register <json> | --unregister null
|
|
260
|
-
|
|
258
|
+
|
|
259
|
+
Other:
|
|
260
|
+
convertToMultiSigUser --authorizedUsers <json> --threshold <number>
|
|
261
261
|
|
|
262
262
|
=============================================================================
|
|
263
263
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { parser, UnsignedInteger } from "../_base.js";
|
|
2
|
+
import {
|
|
3
|
+
type ExchangeRequestConfig,
|
|
4
|
+
executeL1Action,
|
|
5
|
+
type ExtractRequestOptions,
|
|
6
|
+
type MultiSignRequestConfig,
|
|
7
|
+
Signature,
|
|
8
|
+
} from "./_base.js";
|
|
9
|
+
import * as v from "valibot";
|
|
10
|
+
|
|
11
|
+
// -------------------- Schemas --------------------
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Enable HIP-3 DEX abstraction.
|
|
15
|
+
* @see null
|
|
16
|
+
*/
|
|
17
|
+
export const AgentEnableDexAbstractionRequest = /* @__PURE__ */ (() => {
|
|
18
|
+
return v.pipe(
|
|
19
|
+
v.object({
|
|
20
|
+
/** Action to perform. */
|
|
21
|
+
action: v.pipe(
|
|
22
|
+
v.object({
|
|
23
|
+
/** Type of action. */
|
|
24
|
+
type: v.pipe(
|
|
25
|
+
v.literal("agentEnableDexAbstraction"),
|
|
26
|
+
v.description("Type of action."),
|
|
27
|
+
),
|
|
28
|
+
}),
|
|
29
|
+
v.description("Action to perform."),
|
|
30
|
+
),
|
|
31
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
32
|
+
nonce: v.pipe(
|
|
33
|
+
UnsignedInteger,
|
|
34
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
35
|
+
),
|
|
36
|
+
/** Cryptographic signature. */
|
|
37
|
+
signature: v.pipe(
|
|
38
|
+
Signature,
|
|
39
|
+
v.description("Cryptographic signature."),
|
|
40
|
+
),
|
|
41
|
+
/** Expiration time of the action. */
|
|
42
|
+
expiresAfter: v.pipe(
|
|
43
|
+
v.optional(UnsignedInteger),
|
|
44
|
+
v.description("Expiration time of the action."),
|
|
45
|
+
),
|
|
46
|
+
}),
|
|
47
|
+
v.description("Enable HIP-3 DEX abstraction request."),
|
|
48
|
+
);
|
|
49
|
+
})();
|
|
50
|
+
export type AgentEnableDexAbstractionRequest = v.InferOutput<typeof AgentEnableDexAbstractionRequest>;
|
|
51
|
+
|
|
52
|
+
import { SuccessResponse } from "./_base.js";
|
|
53
|
+
export { SuccessResponse };
|
|
54
|
+
|
|
55
|
+
// -------------------- Function --------------------
|
|
56
|
+
|
|
57
|
+
/** Request options for the {@linkcode agentEnableDexAbstraction} function. */
|
|
58
|
+
export type AgentEnableDexAbstractionOptions = ExtractRequestOptions<
|
|
59
|
+
v.InferInput<typeof AgentEnableDexAbstractionRequest>
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Enable HIP-3 DEX abstraction.
|
|
64
|
+
* @param config - General configuration for Exchange API requests.
|
|
65
|
+
* @param params - Parameters specific to the API request.
|
|
66
|
+
* @param opts - Request execution options.
|
|
67
|
+
* @returns Successful response without specific data.
|
|
68
|
+
*
|
|
69
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
70
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
71
|
+
*
|
|
72
|
+
* @see null
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
76
|
+
* import { agentEnableDexAbstraction } from "@nktkas/hyperliquid/api/exchange";
|
|
77
|
+
* import { privateKeyToAccount } from "npm:viem/accounts";
|
|
78
|
+
*
|
|
79
|
+
* const wallet = privateKeyToAccount("0x..."); // viem or ethers
|
|
80
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
81
|
+
*
|
|
82
|
+
* await agentEnableDexAbstraction({ transport, wallet });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export async function agentEnableDexAbstraction(
|
|
86
|
+
config: ExchangeRequestConfig | MultiSignRequestConfig,
|
|
87
|
+
opts?: AgentEnableDexAbstractionOptions,
|
|
88
|
+
): Promise<SuccessResponse> {
|
|
89
|
+
const action = parser(AgentEnableDexAbstractionRequest.entries.action)({
|
|
90
|
+
type: "agentEnableDexAbstraction",
|
|
91
|
+
});
|
|
92
|
+
const expiresAfter = typeof config.defaultExpiresAfter === "number"
|
|
93
|
+
? config.defaultExpiresAfter
|
|
94
|
+
: await config.defaultExpiresAfter?.();
|
|
95
|
+
return await executeL1Action(config, { action, expiresAfter }, opts?.signal);
|
|
96
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Address, type DeepImmutable, Hex, parser, UnsignedInteger } from "../_base.js";
|
|
2
|
+
import {
|
|
3
|
+
type ExchangeRequestConfig,
|
|
4
|
+
executeUserSignedAction,
|
|
5
|
+
type ExtractRequestAction,
|
|
6
|
+
type ExtractRequestOptions,
|
|
7
|
+
getNonce,
|
|
8
|
+
getSignatureChainId,
|
|
9
|
+
type MultiSignRequestConfig,
|
|
10
|
+
Signature,
|
|
11
|
+
} from "./_base.js";
|
|
12
|
+
import * as v from "valibot";
|
|
13
|
+
|
|
14
|
+
// -------------------- Schemas --------------------
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Enable/disable HIP-3 DEX abstraction.
|
|
18
|
+
* @see null
|
|
19
|
+
*/
|
|
20
|
+
export const UserDexAbstractionExchangeRequest = /* @__PURE__ */ (() => {
|
|
21
|
+
return v.pipe(
|
|
22
|
+
v.object({
|
|
23
|
+
/** Action to perform. */
|
|
24
|
+
action: v.pipe(
|
|
25
|
+
v.object({
|
|
26
|
+
/** Type of action. */
|
|
27
|
+
type: v.pipe(
|
|
28
|
+
v.literal("userDexAbstraction"),
|
|
29
|
+
v.description("Type of action."),
|
|
30
|
+
),
|
|
31
|
+
/** Chain ID used for signing. */
|
|
32
|
+
signatureChainId: v.pipe(
|
|
33
|
+
Hex,
|
|
34
|
+
v.description("Chain ID used for signing."),
|
|
35
|
+
),
|
|
36
|
+
/** HyperLiquid network. */
|
|
37
|
+
hyperliquidChain: v.pipe(
|
|
38
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
39
|
+
v.description("HyperLiquid network."),
|
|
40
|
+
),
|
|
41
|
+
/** User address. */
|
|
42
|
+
user: v.pipe(
|
|
43
|
+
Address,
|
|
44
|
+
v.description("User address."),
|
|
45
|
+
),
|
|
46
|
+
/** Whether to enable or disable HIP-3 DEX abstraction. */
|
|
47
|
+
enabled: v.pipe(
|
|
48
|
+
v.boolean(),
|
|
49
|
+
v.description("Whether to enable or disable HIP-3 DEX abstraction."),
|
|
50
|
+
),
|
|
51
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
52
|
+
nonce: v.pipe(
|
|
53
|
+
UnsignedInteger,
|
|
54
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
55
|
+
),
|
|
56
|
+
}),
|
|
57
|
+
v.description("Action to perform."),
|
|
58
|
+
),
|
|
59
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
60
|
+
nonce: v.pipe(
|
|
61
|
+
UnsignedInteger,
|
|
62
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
63
|
+
),
|
|
64
|
+
/** Cryptographic signature. */
|
|
65
|
+
signature: v.pipe(
|
|
66
|
+
Signature,
|
|
67
|
+
v.description("Cryptographic signature."),
|
|
68
|
+
),
|
|
69
|
+
}),
|
|
70
|
+
v.description("Enable/disable HIP-3 DEX abstraction."),
|
|
71
|
+
);
|
|
72
|
+
})();
|
|
73
|
+
export type UserDexAbstractionExchangeRequest = v.InferOutput<typeof UserDexAbstractionExchangeRequest>;
|
|
74
|
+
|
|
75
|
+
import { SuccessResponse } from "./_base.js";
|
|
76
|
+
export { SuccessResponse };
|
|
77
|
+
|
|
78
|
+
// -------------------- Function --------------------
|
|
79
|
+
|
|
80
|
+
/** Action parameters for the {@linkcode userDexAbstraction} function. */
|
|
81
|
+
export type UserDexAbstractionExchangeParameters = ExtractRequestAction<
|
|
82
|
+
v.InferInput<typeof UserDexAbstractionExchangeRequest>
|
|
83
|
+
>;
|
|
84
|
+
/** Request options for the {@linkcode userDexAbstraction} function. */
|
|
85
|
+
export type UserDexAbstractionExchangeOptions = ExtractRequestOptions<
|
|
86
|
+
v.InferInput<typeof UserDexAbstractionExchangeRequest>
|
|
87
|
+
>;
|
|
88
|
+
|
|
89
|
+
/** EIP-712 types for the {@linkcode userDexAbstraction} function. */
|
|
90
|
+
export const UserDexAbstractionTypes = {
|
|
91
|
+
"HyperliquidTransaction:UserDexAbstraction": [
|
|
92
|
+
{ name: "hyperliquidChain", type: "string" },
|
|
93
|
+
{ name: "user", type: "address" },
|
|
94
|
+
{ name: "enabled", type: "bool" },
|
|
95
|
+
{ name: "nonce", type: "uint64" },
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Enable/disable HIP-3 DEX abstraction.
|
|
101
|
+
* @param config - General configuration for Exchange API requests.
|
|
102
|
+
* @param params - Parameters specific to the API request.
|
|
103
|
+
* @param opts - Request execution options.
|
|
104
|
+
* @returns Successful response without specific data.
|
|
105
|
+
*
|
|
106
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
107
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
108
|
+
*
|
|
109
|
+
* @see null
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* import { HttpTransport } from "@nktkas/hyperliquid";
|
|
113
|
+
* import { userDexAbstraction } from "@nktkas/hyperliquid/api/exchange";
|
|
114
|
+
* import { privateKeyToAccount } from "npm:viem/accounts";
|
|
115
|
+
*
|
|
116
|
+
* const wallet = privateKeyToAccount("0x..."); // viem or ethers
|
|
117
|
+
* const transport = new HttpTransport(); // or `WebSocketTransport`
|
|
118
|
+
*
|
|
119
|
+
* await userDexAbstraction(
|
|
120
|
+
* { transport, wallet },
|
|
121
|
+
* { user: "0x...", enabled: true },
|
|
122
|
+
* );
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export async function userDexAbstraction(
|
|
126
|
+
config: ExchangeRequestConfig | MultiSignRequestConfig,
|
|
127
|
+
params: DeepImmutable<UserDexAbstractionExchangeParameters>,
|
|
128
|
+
opts?: UserDexAbstractionExchangeOptions,
|
|
129
|
+
): Promise<SuccessResponse> {
|
|
130
|
+
const action = parser(UserDexAbstractionExchangeRequest.entries.action)({
|
|
131
|
+
type: "userDexAbstraction",
|
|
132
|
+
hyperliquidChain: config.transport.isTestnet ? "Testnet" : "Mainnet",
|
|
133
|
+
signatureChainId: await getSignatureChainId(config),
|
|
134
|
+
nonce: await getNonce(config),
|
|
135
|
+
...params,
|
|
136
|
+
});
|
|
137
|
+
return await executeUserSignedAction(
|
|
138
|
+
config,
|
|
139
|
+
{ action, types: UserDexAbstractionTypes },
|
|
140
|
+
opts?.signal,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -4,6 +4,7 @@ import type { IRequestTransport } from "../../transport/base.js";
|
|
|
4
4
|
import type { AbstractWallet } from "../../signing/mod.js";
|
|
5
5
|
import { PrivateKeyEIP712Signer } from "../../utils/minimalEIP712Signer.js";
|
|
6
6
|
|
|
7
|
+
import { agentEnableDexAbstraction } from "./agentEnableDexAbstraction.js";
|
|
7
8
|
import { approveAgent } from "./approveAgent.js";
|
|
8
9
|
import { approveBuilderFee } from "./approveBuilderFee.js";
|
|
9
10
|
import { batchModify } from "./batchModify.js";
|
|
@@ -42,51 +43,56 @@ import { updateIsolatedMargin } from "./updateIsolatedMargin.js";
|
|
|
42
43
|
import { updateLeverage } from "./updateLeverage.js";
|
|
43
44
|
import { usdClassTransfer } from "./usdClassTransfer.js";
|
|
44
45
|
import { usdSend } from "./usdSend.js";
|
|
46
|
+
import { userDexAbstraction } from "./userDexAbstraction.js";
|
|
45
47
|
import { vaultDistribute } from "./vaultDistribute.js";
|
|
46
48
|
import { vaultModify } from "./vaultModify.js";
|
|
47
49
|
import { vaultTransfer } from "./vaultTransfer.js";
|
|
48
50
|
import { withdraw3 } from "./withdraw3.js";
|
|
49
51
|
|
|
50
|
-
export type {
|
|
51
|
-
export type {
|
|
52
|
-
export type {
|
|
53
|
-
export type {
|
|
54
|
-
export type {
|
|
55
|
-
export type {
|
|
56
|
-
export type {
|
|
57
|
-
export type {
|
|
58
|
-
export type {
|
|
59
|
-
export type {
|
|
60
|
-
export type {
|
|
61
|
-
export type {
|
|
62
|
-
export type {
|
|
63
|
-
export type {
|
|
64
|
-
export type {
|
|
65
|
-
export type {
|
|
66
|
-
export type {
|
|
67
|
-
export type {
|
|
68
|
-
export type {
|
|
69
|
-
export type {
|
|
70
|
-
export type {
|
|
71
|
-
export type {
|
|
72
|
-
export type {
|
|
73
|
-
export type {
|
|
74
|
-
export type {
|
|
75
|
-
export type {
|
|
76
|
-
export type {
|
|
77
|
-
export type {
|
|
78
|
-
export type {
|
|
79
|
-
export type {
|
|
80
|
-
export type {
|
|
81
|
-
export type {
|
|
82
|
-
export type {
|
|
83
|
-
export type {
|
|
84
|
-
export type {
|
|
85
|
-
export type {
|
|
86
|
-
export type {
|
|
87
|
-
export type {
|
|
88
|
-
export type {
|
|
89
|
-
export type {
|
|
52
|
+
export type { AgentEnableDexAbstractionOptions } from "./agentEnableDexAbstraction.js";
|
|
53
|
+
export type { ApproveAgentOptions, ApproveAgentParameters } from "./approveAgent.js";
|
|
54
|
+
export type { ApproveBuilderFeeOptions, ApproveBuilderFeeParameters } from "./approveBuilderFee.js";
|
|
55
|
+
export type { BatchModifyOptions, BatchModifyParameters } from "./batchModify.js";
|
|
56
|
+
export type { CancelOptions, CancelParameters } from "./cancel.js";
|
|
57
|
+
export type { CancelByCloidOptions, CancelByCloidParameters } from "./cancelByCloid.js";
|
|
58
|
+
export type { CDepositOptions, CDepositParameters } from "./cDeposit.js";
|
|
59
|
+
export type { ClaimRewardsOptions } from "./claimRewards.js";
|
|
60
|
+
export type { ConvertToMultiSigUserOptions, ConvertToMultiSigUserParameters } from "./convertToMultiSigUser.js";
|
|
61
|
+
export type { CreateSubAccountOptions, CreateSubAccountParameters } from "./createSubAccount.js";
|
|
62
|
+
export type { CreateVaultOptions, CreateVaultParameters } from "./createVault.js";
|
|
63
|
+
export type { CSignerActionOptions, CSignerActionParameters } from "./cSignerAction.js";
|
|
64
|
+
export type { CValidatorActionOptions, CValidatorActionParameters } from "./cValidatorAction.js";
|
|
65
|
+
export type { CWithdrawOptions, CWithdrawParameters } from "./cWithdraw.js";
|
|
66
|
+
export type { EvmUserModifyOptions, EvmUserModifyParameters } from "./evmUserModify.js";
|
|
67
|
+
export type { ModifyOptions, ModifyParameters } from "./modify.js";
|
|
68
|
+
export type { MultiSigOptions, MultiSigParameters } from "./multiSig.js";
|
|
69
|
+
export type { OrderOptions, OrderParameters } from "./order.js";
|
|
70
|
+
export type { NoopOptions } from "./noop.js";
|
|
71
|
+
export type { PerpDeployOptions, PerpDeployParameters } from "./perpDeploy.js";
|
|
72
|
+
export type { RegisterReferrerOptions, RegisterReferrerParameters } from "./registerReferrer.js";
|
|
73
|
+
export type { ReserveRequestWeightOptions, ReserveRequestWeightParameters } from "./reserveRequestWeight.js";
|
|
74
|
+
export type { ScheduleCancelOptions, ScheduleCancelParameters } from "./scheduleCancel.js";
|
|
75
|
+
export type { SendAssetOptions, SendAssetParameters } from "./sendAsset.js";
|
|
76
|
+
export type { SetDisplayNameOptions, SetDisplayNameParameters } from "./setDisplayName.js";
|
|
77
|
+
export type { SetReferrerOptions, SetReferrerParameters } from "./setReferrer.js";
|
|
78
|
+
export type { SpotDeployOptions, SpotDeployParameters } from "./spotDeploy.js";
|
|
79
|
+
export type { SpotSendOptions, SpotSendParameters } from "./spotSend.js";
|
|
80
|
+
export type { SpotUserOptions, SpotUserParameters } from "./spotUser.js";
|
|
81
|
+
export type { SubAccountModifyOptions, SubAccountModifyParameters } from "./subAccountModify.js";
|
|
82
|
+
export type { SubAccountSpotTransferOptions, SubAccountSpotTransferParameters } from "./subAccountSpotTransfer.js";
|
|
83
|
+
export type { SubAccountTransferOptions, SubAccountTransferParameters } from "./subAccountTransfer.js";
|
|
84
|
+
export type { TokenDelegateOptions, TokenDelegateParameters } from "./tokenDelegate.js";
|
|
85
|
+
export type { TwapCancelOptions, TwapCancelParameters } from "./twapCancel.js";
|
|
86
|
+
export type { TwapOrderOptions, TwapOrderParameters } from "./twapOrder.js";
|
|
87
|
+
export type { UpdateIsolatedMarginOptions, UpdateIsolatedMarginParameters } from "./updateIsolatedMargin.js";
|
|
88
|
+
export type { UpdateLeverageOptions, UpdateLeverageParameters } from "./updateLeverage.js";
|
|
89
|
+
export type { UsdClassTransferOptions, UsdClassTransferParameters } from "./usdClassTransfer.js";
|
|
90
|
+
export type { UsdSendOptions, UsdSendParameters } from "./usdSend.js";
|
|
91
|
+
export type { UserDexAbstractionExchangeOptions, UserDexAbstractionExchangeParameters } from "./userDexAbstraction.js";
|
|
92
|
+
export type { VaultDistributeOptions, VaultDistributeParameters } from "./vaultDistribute.js";
|
|
93
|
+
export type { VaultModifyOptions, VaultModifyParameters } from "./vaultModify.js";
|
|
94
|
+
export type { VaultTransferOptions, VaultTransferParameters } from "./vaultTransfer.js";
|
|
95
|
+
export type { Withdraw3Options, Withdraw3Parameters } from "./withdraw3.js";
|
|
90
96
|
|
|
91
97
|
export type { CancelSuccessResponse } from "./cancel.js";
|
|
92
98
|
export type { CreateSubAccountResponse } from "./createSubAccount.js";
|
|
@@ -178,6 +184,31 @@ export class ExchangeClient<
|
|
|
178
184
|
this.nonceManager = args.nonceManager;
|
|
179
185
|
}
|
|
180
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Enable HIP-3 DEX abstraction.
|
|
189
|
+
* @param params - Parameters specific to the API request.
|
|
190
|
+
* @param opts - Request execution options.
|
|
191
|
+
* @returns Successful response without specific data.
|
|
192
|
+
*
|
|
193
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
194
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
195
|
+
*
|
|
196
|
+
* @see null
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
200
|
+
*
|
|
201
|
+
* const pk = "0x..."; // viem, ethers or private key
|
|
202
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
203
|
+
*
|
|
204
|
+
* const client = new hl.ExchangeClient({ transport, wallet: pk });
|
|
205
|
+
* await client.agentEnableDexAbstraction();
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
agentEnableDexAbstraction(...args: OmitFirst<OverloadedParameters<typeof agentEnableDexAbstraction>>) {
|
|
209
|
+
return agentEnableDexAbstraction(this, ...args);
|
|
210
|
+
}
|
|
211
|
+
|
|
181
212
|
/**
|
|
182
213
|
* Approve an agent to sign on behalf of the master account.
|
|
183
214
|
* @param params - Parameters specific to the API request.
|
|
@@ -1315,6 +1346,31 @@ export class ExchangeClient<
|
|
|
1315
1346
|
return usdSend(this, ...args);
|
|
1316
1347
|
}
|
|
1317
1348
|
|
|
1349
|
+
/**
|
|
1350
|
+
* Enable/disable HIP-3 DEX abstraction.
|
|
1351
|
+
* @param params - Parameters specific to the API request.
|
|
1352
|
+
* @param opts - Request execution options.
|
|
1353
|
+
* @returns Successful response without specific data.
|
|
1354
|
+
*
|
|
1355
|
+
* @throws {ApiRequestError} When the API returns an unsuccessful response.
|
|
1356
|
+
* @throws {TransportError} When the transport layer throws an error.
|
|
1357
|
+
*
|
|
1358
|
+
* @see null
|
|
1359
|
+
* @example
|
|
1360
|
+
* ```ts
|
|
1361
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
1362
|
+
*
|
|
1363
|
+
* const pk = "0x..."; // viem, ethers or private key
|
|
1364
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1365
|
+
*
|
|
1366
|
+
* const client = new hl.ExchangeClient({ transport, wallet: pk });
|
|
1367
|
+
* await client.userDexAbstraction({ user: "0x...", enabled: true });
|
|
1368
|
+
* ```
|
|
1369
|
+
*/
|
|
1370
|
+
userDexAbstraction(...args: OmitFirst<OverloadedParameters<typeof userDexAbstraction>>) {
|
|
1371
|
+
return userDexAbstraction(this, ...args);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1318
1374
|
/**
|
|
1319
1375
|
* Distribute funds from a vault between followers.
|
|
1320
1376
|
* @param params - Parameters specific to the API request.
|