@nktkas/hyperliquid 0.22.1 → 0.22.2
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 +84 -27
- package/esm/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/src/clients/exchange.d.ts +136 -166
- package/esm/src/clients/exchange.d.ts.map +1 -1
- package/esm/src/clients/exchange.js +121 -146
- package/esm/src/clients/multiSign.d.ts +121 -280
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/multiSign.js +123 -246
- package/esm/src/signing/_ethers.d.ts +33 -0
- package/esm/src/signing/_ethers.d.ts.map +1 -0
- package/esm/src/signing/_ethers.js +12 -0
- package/esm/src/signing/_private_key.d.ts +22 -0
- package/esm/src/signing/_private_key.d.ts.map +1 -0
- package/esm/src/signing/_private_key.js +124 -0
- package/esm/src/signing/_sorter.d.ts +154 -0
- package/esm/src/signing/_sorter.d.ts.map +1 -0
- package/esm/src/{signing.js → signing/_sorter.js} +0 -400
- package/esm/src/signing/_viem.d.ts +23 -0
- package/esm/src/signing/_viem.d.ts.map +1 -0
- package/esm/src/signing/_viem.js +6 -0
- package/esm/src/signing/_window.d.ts +23 -0
- package/esm/src/signing/_window.d.ts.map +1 -0
- package/esm/src/signing/_window.js +29 -0
- package/esm/src/signing/mod.d.ts +251 -0
- package/esm/src/signing/mod.d.ts.map +1 -0
- package/esm/src/signing/mod.js +352 -0
- package/package.json +6 -5
- package/script/mod.d.ts +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/src/clients/exchange.d.ts +136 -166
- package/script/src/clients/exchange.d.ts.map +1 -1
- package/script/src/clients/exchange.js +205 -230
- package/script/src/clients/multiSign.d.ts +121 -280
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/multiSign.js +168 -291
- package/script/src/signing/_ethers.d.ts +33 -0
- package/script/src/signing/_ethers.d.ts.map +1 -0
- package/script/src/signing/_ethers.js +26 -0
- package/script/src/signing/_private_key.d.ts +22 -0
- package/script/src/signing/_private_key.d.ts.map +1 -0
- package/script/src/signing/_private_key.js +138 -0
- package/script/src/signing/_sorter.d.ts +154 -0
- package/script/src/signing/_sorter.d.ts.map +1 -0
- package/script/src/{signing.js → signing/_sorter.js} +1 -409
- package/script/src/signing/_viem.d.ts +23 -0
- package/script/src/signing/_viem.d.ts.map +1 -0
- package/script/src/signing/_viem.js +19 -0
- package/script/src/signing/_window.d.ts +23 -0
- package/script/src/signing/_window.d.ts.map +1 -0
- package/script/src/signing/_window.js +43 -0
- package/script/src/signing/mod.d.ts +251 -0
- package/script/src/signing/mod.d.ts.map +1 -0
- package/script/src/signing/mod.js +387 -0
- package/esm/src/signing.d.ts +0 -463
- package/esm/src/signing.d.ts.map +0 -1
- package/script/src/signing.d.ts +0 -463
- package/script/src/signing.d.ts.map +0 -1
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../base.js", "../signing.js"], factory);
|
|
7
|
+
define(["require", "exports", "../base.js", "../signing/mod.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ExchangeClient = exports.ApiRequestError = void 0;
|
|
13
13
|
const base_js_1 = require("../base.js");
|
|
14
|
-
const
|
|
14
|
+
const mod_js_1 = require("../signing/mod.js");
|
|
15
15
|
/** Error thrown when the API returns an error response. */
|
|
16
16
|
class ApiRequestError extends base_js_1.HyperliquidError {
|
|
17
17
|
response;
|
|
@@ -83,6 +83,16 @@
|
|
|
83
83
|
* Initialises a new instance.
|
|
84
84
|
* @param args - The parameters for the client.
|
|
85
85
|
*
|
|
86
|
+
* @example Private key
|
|
87
|
+
* ```ts
|
|
88
|
+
* import * as hl from "@nktkas/hyperliquid";
|
|
89
|
+
*
|
|
90
|
+
* const privateKey = "0x...";
|
|
91
|
+
*
|
|
92
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
93
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
86
96
|
* @example Private key via [viem](https://viem.sh/docs/clients/wallet#local-accounts-private-key-mnemonic-etc)
|
|
87
97
|
* ```ts
|
|
88
98
|
* import * as hl from "@nktkas/hyperliquid";
|
|
@@ -90,7 +100,7 @@
|
|
|
90
100
|
*
|
|
91
101
|
* const wallet = privateKeyToAccount("0x...");
|
|
92
102
|
*
|
|
93
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
103
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
94
104
|
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
95
105
|
* ```
|
|
96
106
|
*
|
|
@@ -101,7 +111,7 @@
|
|
|
101
111
|
*
|
|
102
112
|
* const wallet = new ethers.Wallet("0x...");
|
|
103
113
|
*
|
|
104
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
114
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
105
115
|
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
106
116
|
* ```
|
|
107
117
|
*
|
|
@@ -113,7 +123,7 @@
|
|
|
113
123
|
* const [account] = await window.ethereum.request({ method: "eth_requestAccounts" });
|
|
114
124
|
* const wallet = createWalletClient({ account, transport: custom(window.ethereum) });
|
|
115
125
|
*
|
|
116
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
126
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
117
127
|
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
118
128
|
* ```
|
|
119
129
|
*
|
|
@@ -121,7 +131,7 @@
|
|
|
121
131
|
* ```ts
|
|
122
132
|
* import * as hl from "@nktkas/hyperliquid";
|
|
123
133
|
*
|
|
124
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
134
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
125
135
|
* const exchClient = new hl.ExchangeClient({ wallet: window.ethereum, transport });
|
|
126
136
|
* ```
|
|
127
137
|
*/
|
|
@@ -145,11 +155,10 @@
|
|
|
145
155
|
* @example
|
|
146
156
|
* ```ts
|
|
147
157
|
* import * as hl from "@nktkas/hyperliquid";
|
|
148
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
149
158
|
*
|
|
150
|
-
* const
|
|
151
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
152
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
159
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
160
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
161
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
153
162
|
*
|
|
154
163
|
* const data = await exchClient.approveAgent({ agentAddress: "0x...", agentName: "agentName" });
|
|
155
164
|
* ```
|
|
@@ -168,10 +177,10 @@
|
|
|
168
177
|
nonce,
|
|
169
178
|
};
|
|
170
179
|
// Sign the action
|
|
171
|
-
const signature = await (0,
|
|
180
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
172
181
|
wallet: this.wallet,
|
|
173
182
|
action,
|
|
174
|
-
types:
|
|
183
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
175
184
|
chainId: parseInt(action.signatureChainId, 16),
|
|
176
185
|
});
|
|
177
186
|
if (action.agentName === "")
|
|
@@ -190,11 +199,10 @@
|
|
|
190
199
|
* @example
|
|
191
200
|
* ```ts
|
|
192
201
|
* import * as hl from "@nktkas/hyperliquid";
|
|
193
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
194
202
|
*
|
|
195
|
-
* const
|
|
196
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
197
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
203
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
204
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
205
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
198
206
|
*
|
|
199
207
|
* const data = await exchClient.approveBuilderFee({ maxFeeRate: "0.01%", builder: "0x..." });
|
|
200
208
|
* ```
|
|
@@ -212,10 +220,10 @@
|
|
|
212
220
|
nonce,
|
|
213
221
|
};
|
|
214
222
|
// Sign the action
|
|
215
|
-
const signature = await (0,
|
|
223
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
216
224
|
wallet: this.wallet,
|
|
217
225
|
action,
|
|
218
|
-
types:
|
|
226
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
219
227
|
chainId: parseInt(action.signatureChainId, 16),
|
|
220
228
|
});
|
|
221
229
|
// Send a request
|
|
@@ -232,11 +240,10 @@
|
|
|
232
240
|
* @example
|
|
233
241
|
* ```ts
|
|
234
242
|
* import * as hl from "@nktkas/hyperliquid";
|
|
235
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
236
243
|
*
|
|
237
|
-
* const
|
|
238
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
239
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
244
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
245
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
246
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
240
247
|
*
|
|
241
248
|
* const data = await exchClient.batchModify({
|
|
242
249
|
* modifies: [{
|
|
@@ -268,9 +275,9 @@
|
|
|
268
275
|
...actionArgs,
|
|
269
276
|
};
|
|
270
277
|
// Sign the action
|
|
271
|
-
const signature = await (0,
|
|
278
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
272
279
|
wallet: this.wallet,
|
|
273
|
-
action:
|
|
280
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
274
281
|
nonce,
|
|
275
282
|
isTestnet: this.isTestnet,
|
|
276
283
|
vaultAddress,
|
|
@@ -290,11 +297,10 @@
|
|
|
290
297
|
* @example
|
|
291
298
|
* ```ts
|
|
292
299
|
* import * as hl from "@nktkas/hyperliquid";
|
|
293
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
294
300
|
*
|
|
295
|
-
* const
|
|
296
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
297
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
301
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
302
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
303
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
298
304
|
*
|
|
299
305
|
* const data = await exchClient.cancel({
|
|
300
306
|
* cancels: [{
|
|
@@ -314,9 +320,9 @@
|
|
|
314
320
|
...actionArgs,
|
|
315
321
|
};
|
|
316
322
|
// Sign the action
|
|
317
|
-
const signature = await (0,
|
|
323
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
318
324
|
wallet: this.wallet,
|
|
319
|
-
action:
|
|
325
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
320
326
|
nonce,
|
|
321
327
|
isTestnet: this.isTestnet,
|
|
322
328
|
vaultAddress,
|
|
@@ -336,11 +342,10 @@
|
|
|
336
342
|
* @example
|
|
337
343
|
* ```ts
|
|
338
344
|
* import * as hl from "@nktkas/hyperliquid";
|
|
339
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
340
345
|
*
|
|
341
|
-
* const
|
|
342
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
343
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
346
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
347
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
348
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
344
349
|
*
|
|
345
350
|
* const data = await exchClient.cancelByCloid({
|
|
346
351
|
* cancels: [
|
|
@@ -359,9 +364,9 @@
|
|
|
359
364
|
...actionArgs,
|
|
360
365
|
};
|
|
361
366
|
// Sign the action
|
|
362
|
-
const signature = await (0,
|
|
367
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
363
368
|
wallet: this.wallet,
|
|
364
|
-
action:
|
|
369
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
365
370
|
nonce,
|
|
366
371
|
isTestnet: this.isTestnet,
|
|
367
372
|
vaultAddress,
|
|
@@ -381,11 +386,10 @@
|
|
|
381
386
|
* @example
|
|
382
387
|
* ```ts
|
|
383
388
|
* import * as hl from "@nktkas/hyperliquid";
|
|
384
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
385
389
|
*
|
|
386
|
-
* const
|
|
387
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
388
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
390
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
391
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
392
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
389
393
|
*
|
|
390
394
|
* const data = await exchClient.cDeposit({ wei: 1 * 1e8 });
|
|
391
395
|
* ```
|
|
@@ -403,10 +407,10 @@
|
|
|
403
407
|
nonce,
|
|
404
408
|
};
|
|
405
409
|
// Sign the action
|
|
406
|
-
const signature = await (0,
|
|
410
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
407
411
|
wallet: this.wallet,
|
|
408
412
|
action,
|
|
409
|
-
types:
|
|
413
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
410
414
|
chainId: parseInt(action.signatureChainId, 16),
|
|
411
415
|
});
|
|
412
416
|
// Send a request
|
|
@@ -423,11 +427,10 @@
|
|
|
423
427
|
* @example
|
|
424
428
|
* ```ts
|
|
425
429
|
* import * as hl from "@nktkas/hyperliquid";
|
|
426
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
427
430
|
*
|
|
428
|
-
* const
|
|
429
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
430
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
431
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
432
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
433
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
431
434
|
*
|
|
432
435
|
* const data = await exchClient.claimRewards();
|
|
433
436
|
* ```
|
|
@@ -439,9 +442,9 @@
|
|
|
439
442
|
type: "claimRewards",
|
|
440
443
|
};
|
|
441
444
|
// Sign the action
|
|
442
|
-
const signature = await (0,
|
|
445
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
443
446
|
wallet: this.wallet,
|
|
444
|
-
action:
|
|
447
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
445
448
|
nonce,
|
|
446
449
|
isTestnet: this.isTestnet,
|
|
447
450
|
});
|
|
@@ -459,11 +462,10 @@
|
|
|
459
462
|
* @example
|
|
460
463
|
* ```ts
|
|
461
464
|
* import * as hl from "@nktkas/hyperliquid";
|
|
462
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
463
465
|
*
|
|
464
|
-
* const
|
|
465
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
466
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
466
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
467
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
468
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
467
469
|
*
|
|
468
470
|
* const data = await exchClient.convertToMultiSigUser({ // convert to multi-sig user
|
|
469
471
|
* authorizedUsers: ["0x...", "0x...", "0x..."],
|
|
@@ -473,7 +475,7 @@
|
|
|
473
475
|
*/
|
|
474
476
|
async convertToMultiSigUser(args, signal) {
|
|
475
477
|
// Destructure the parameters
|
|
476
|
-
const
|
|
478
|
+
const actionArgs = args;
|
|
477
479
|
// Construct an action
|
|
478
480
|
const nonce = await this.nonceManager();
|
|
479
481
|
const action = {
|
|
@@ -484,10 +486,10 @@
|
|
|
484
486
|
nonce,
|
|
485
487
|
};
|
|
486
488
|
// Sign the action
|
|
487
|
-
const signature = await (0,
|
|
489
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
488
490
|
wallet: this.wallet,
|
|
489
491
|
action,
|
|
490
|
-
types:
|
|
492
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
491
493
|
chainId: parseInt(action.signatureChainId, 16),
|
|
492
494
|
});
|
|
493
495
|
// Send a request
|
|
@@ -504,11 +506,10 @@
|
|
|
504
506
|
* @example
|
|
505
507
|
* ```ts
|
|
506
508
|
* import * as hl from "@nktkas/hyperliquid";
|
|
507
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
508
509
|
*
|
|
509
|
-
* const
|
|
510
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
511
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
510
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
511
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
512
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
512
513
|
*
|
|
513
514
|
* const data = await exchClient.createSubAccount({ name: "subAccountName" });
|
|
514
515
|
* ```
|
|
@@ -523,9 +524,9 @@
|
|
|
523
524
|
...actionArgs,
|
|
524
525
|
};
|
|
525
526
|
// Sign the action
|
|
526
|
-
const signature = await (0,
|
|
527
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
527
528
|
wallet: this.wallet,
|
|
528
|
-
action:
|
|
529
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
529
530
|
nonce,
|
|
530
531
|
isTestnet: this.isTestnet,
|
|
531
532
|
});
|
|
@@ -543,11 +544,10 @@
|
|
|
543
544
|
* @example
|
|
544
545
|
* ```ts
|
|
545
546
|
* import * as hl from "@nktkas/hyperliquid";
|
|
546
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
547
547
|
*
|
|
548
|
-
* const
|
|
549
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
550
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
548
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
549
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
550
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
551
551
|
*
|
|
552
552
|
* const data = await exchClient.createVault({
|
|
553
553
|
* name: "VaultName",
|
|
@@ -567,9 +567,9 @@
|
|
|
567
567
|
...actionArgs,
|
|
568
568
|
};
|
|
569
569
|
// Sign the action
|
|
570
|
-
const signature = await (0,
|
|
570
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
571
571
|
wallet: this.wallet,
|
|
572
|
-
action:
|
|
572
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
573
573
|
nonce,
|
|
574
574
|
isTestnet: this.isTestnet,
|
|
575
575
|
});
|
|
@@ -586,9 +586,9 @@
|
|
|
586
586
|
...actionArgs,
|
|
587
587
|
};
|
|
588
588
|
// Sign the action
|
|
589
|
-
const signature = await (0,
|
|
589
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
590
590
|
wallet: this.wallet,
|
|
591
|
-
action:
|
|
591
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
592
592
|
nonce,
|
|
593
593
|
isTestnet: this.isTestnet,
|
|
594
594
|
expiresAfter,
|
|
@@ -606,9 +606,9 @@
|
|
|
606
606
|
...actionArgs,
|
|
607
607
|
};
|
|
608
608
|
// Sign the action
|
|
609
|
-
const signature = await (0,
|
|
609
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
610
610
|
wallet: this.wallet,
|
|
611
|
-
action:
|
|
611
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
612
612
|
nonce,
|
|
613
613
|
isTestnet: this.isTestnet,
|
|
614
614
|
expiresAfter,
|
|
@@ -627,11 +627,10 @@
|
|
|
627
627
|
* @example
|
|
628
628
|
* ```ts
|
|
629
629
|
* import * as hl from "@nktkas/hyperliquid";
|
|
630
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
631
630
|
*
|
|
632
|
-
* const
|
|
633
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
634
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
631
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
632
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
633
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
635
634
|
*
|
|
636
635
|
* const data = await exchClient.cWithdraw({ wei: 1 * 1e8 });
|
|
637
636
|
* ```
|
|
@@ -649,10 +648,10 @@
|
|
|
649
648
|
nonce,
|
|
650
649
|
};
|
|
651
650
|
// Sign the action
|
|
652
|
-
const signature = await (0,
|
|
651
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
653
652
|
wallet: this.wallet,
|
|
654
653
|
action,
|
|
655
|
-
types:
|
|
654
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
656
655
|
chainId: parseInt(action.signatureChainId, 16),
|
|
657
656
|
});
|
|
658
657
|
// Send a request
|
|
@@ -669,11 +668,10 @@
|
|
|
669
668
|
* @example
|
|
670
669
|
* ```ts
|
|
671
670
|
* import * as hl from "@nktkas/hyperliquid";
|
|
672
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
673
671
|
*
|
|
674
|
-
* const
|
|
675
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
676
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
672
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
673
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
674
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
677
675
|
*
|
|
678
676
|
* const data = await exchClient.evmUserModify({ usingBigBlocks: true });
|
|
679
677
|
* ```
|
|
@@ -688,9 +686,9 @@
|
|
|
688
686
|
...actionArgs,
|
|
689
687
|
};
|
|
690
688
|
// Sign the action
|
|
691
|
-
const signature = await (0,
|
|
689
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
692
690
|
wallet: this.wallet,
|
|
693
|
-
action:
|
|
691
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
694
692
|
nonce,
|
|
695
693
|
isTestnet: this.isTestnet,
|
|
696
694
|
});
|
|
@@ -708,11 +706,10 @@
|
|
|
708
706
|
* @example
|
|
709
707
|
* ```ts
|
|
710
708
|
* import * as hl from "@nktkas/hyperliquid";
|
|
711
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
712
709
|
*
|
|
713
|
-
* const
|
|
714
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
715
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
710
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
711
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
712
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
716
713
|
*
|
|
717
714
|
* const data = await exchClient.modify({
|
|
718
715
|
* oid: 123,
|
|
@@ -742,9 +739,9 @@
|
|
|
742
739
|
...actionArgs,
|
|
743
740
|
};
|
|
744
741
|
// Sign the action
|
|
745
|
-
const signature = await (0,
|
|
742
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
746
743
|
wallet: this.wallet,
|
|
747
|
-
action:
|
|
744
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
748
745
|
nonce,
|
|
749
746
|
isTestnet: this.isTestnet,
|
|
750
747
|
vaultAddress,
|
|
@@ -764,11 +761,10 @@
|
|
|
764
761
|
* @example
|
|
765
762
|
* ```ts
|
|
766
763
|
* import * as hl from "@nktkas/hyperliquid";
|
|
767
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
768
764
|
*
|
|
769
|
-
* const
|
|
770
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
771
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
765
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
766
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
767
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
772
768
|
*
|
|
773
769
|
* const multiSigUser = "0x..."; // Multi-sig user address
|
|
774
770
|
*
|
|
@@ -803,9 +799,9 @@
|
|
|
803
799
|
...actionArgs,
|
|
804
800
|
};
|
|
805
801
|
// Sign the action
|
|
806
|
-
const actionForMultiSig =
|
|
802
|
+
const actionForMultiSig = mod_js_1.actionSorter[action.type](action);
|
|
807
803
|
delete actionForMultiSig.type;
|
|
808
|
-
const signature = await (0,
|
|
804
|
+
const signature = await (0, mod_js_1.signMultiSigAction)({
|
|
809
805
|
wallet: this.wallet,
|
|
810
806
|
action: actionForMultiSig,
|
|
811
807
|
nonce,
|
|
@@ -828,11 +824,10 @@
|
|
|
828
824
|
* @example
|
|
829
825
|
* ```ts
|
|
830
826
|
* import * as hl from "@nktkas/hyperliquid";
|
|
831
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
832
827
|
*
|
|
833
|
-
* const
|
|
834
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
835
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
828
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
829
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
830
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
836
831
|
*
|
|
837
832
|
* const data = await exchClient.order({
|
|
838
833
|
* orders: [{
|
|
@@ -862,9 +857,9 @@
|
|
|
862
857
|
...actionArgs,
|
|
863
858
|
};
|
|
864
859
|
// Sign the action
|
|
865
|
-
const signature = await (0,
|
|
860
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
866
861
|
wallet: this.wallet,
|
|
867
|
-
action:
|
|
862
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
868
863
|
nonce,
|
|
869
864
|
isTestnet: this.isTestnet,
|
|
870
865
|
vaultAddress,
|
|
@@ -883,9 +878,9 @@
|
|
|
883
878
|
...actionArgs,
|
|
884
879
|
};
|
|
885
880
|
// Sign the action
|
|
886
|
-
const signature = await (0,
|
|
881
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
887
882
|
wallet: this.wallet,
|
|
888
|
-
action:
|
|
883
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
889
884
|
nonce,
|
|
890
885
|
isTestnet: this.isTestnet,
|
|
891
886
|
});
|
|
@@ -903,11 +898,10 @@
|
|
|
903
898
|
* @example
|
|
904
899
|
* ```ts
|
|
905
900
|
* import * as hl from "@nktkas/hyperliquid";
|
|
906
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
907
901
|
*
|
|
908
|
-
* const
|
|
909
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
910
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
902
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
903
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
904
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
911
905
|
*
|
|
912
906
|
* const data = await exchClient.perpDexClassTransfer({
|
|
913
907
|
* dex: "test",
|
|
@@ -930,10 +924,10 @@
|
|
|
930
924
|
nonce,
|
|
931
925
|
};
|
|
932
926
|
// Sign the action
|
|
933
|
-
const signature = await (0,
|
|
927
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
934
928
|
wallet: this.wallet,
|
|
935
929
|
action,
|
|
936
|
-
types:
|
|
930
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
937
931
|
chainId: parseInt(action.signatureChainId, 16),
|
|
938
932
|
});
|
|
939
933
|
// Send a request
|
|
@@ -950,11 +944,10 @@
|
|
|
950
944
|
* @example
|
|
951
945
|
* ```ts
|
|
952
946
|
* import * as hl from "@nktkas/hyperliquid";
|
|
953
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
954
947
|
*
|
|
955
|
-
* const
|
|
956
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
957
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
948
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
949
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
950
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
958
951
|
*
|
|
959
952
|
* const data = await exchClient.registerReferrer({ code: "TEST" });
|
|
960
953
|
* ```
|
|
@@ -969,9 +962,9 @@
|
|
|
969
962
|
...actionArgs,
|
|
970
963
|
};
|
|
971
964
|
// Sign the action
|
|
972
|
-
const signature = await (0,
|
|
965
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
973
966
|
wallet: this.wallet,
|
|
974
|
-
action:
|
|
967
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
975
968
|
nonce,
|
|
976
969
|
isTestnet: this.isTestnet,
|
|
977
970
|
});
|
|
@@ -989,11 +982,10 @@
|
|
|
989
982
|
* @example
|
|
990
983
|
* ```ts
|
|
991
984
|
* import * as hl from "@nktkas/hyperliquid";
|
|
992
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
993
985
|
*
|
|
994
|
-
* const
|
|
995
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
996
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
986
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
987
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
988
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
997
989
|
*
|
|
998
990
|
* const data = await exchClient.reserveRequestWeight({ weight: 10 });
|
|
999
991
|
* ```
|
|
@@ -1008,9 +1000,9 @@
|
|
|
1008
1000
|
...actionArgs,
|
|
1009
1001
|
};
|
|
1010
1002
|
// Sign the action
|
|
1011
|
-
const signature = await (0,
|
|
1003
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1012
1004
|
wallet: this.wallet,
|
|
1013
|
-
action:
|
|
1005
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1014
1006
|
nonce,
|
|
1015
1007
|
isTestnet: this.isTestnet,
|
|
1016
1008
|
expiresAfter,
|
|
@@ -1030,9 +1022,9 @@
|
|
|
1030
1022
|
...actionArgs,
|
|
1031
1023
|
};
|
|
1032
1024
|
// Sign the action
|
|
1033
|
-
const signature = await (0,
|
|
1025
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1034
1026
|
wallet: this.wallet,
|
|
1035
|
-
action:
|
|
1027
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1036
1028
|
nonce,
|
|
1037
1029
|
isTestnet: this.isTestnet,
|
|
1038
1030
|
vaultAddress,
|
|
@@ -1052,11 +1044,10 @@
|
|
|
1052
1044
|
* @example
|
|
1053
1045
|
* ```ts
|
|
1054
1046
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1055
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1056
1047
|
*
|
|
1057
|
-
* const
|
|
1058
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1059
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1048
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1049
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1050
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1060
1051
|
*
|
|
1061
1052
|
* const data = await exchClient.setDisplayName({ displayName: "My Name" });
|
|
1062
1053
|
* ```
|
|
@@ -1071,9 +1062,9 @@
|
|
|
1071
1062
|
...actionArgs,
|
|
1072
1063
|
};
|
|
1073
1064
|
// Sign the action
|
|
1074
|
-
const signature = await (0,
|
|
1065
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1075
1066
|
wallet: this.wallet,
|
|
1076
|
-
action:
|
|
1067
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1077
1068
|
nonce,
|
|
1078
1069
|
isTestnet: this.isTestnet,
|
|
1079
1070
|
});
|
|
@@ -1091,11 +1082,10 @@
|
|
|
1091
1082
|
* @example
|
|
1092
1083
|
* ```ts
|
|
1093
1084
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1094
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1095
1085
|
*
|
|
1096
|
-
* const
|
|
1097
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1098
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1086
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1087
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1088
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1099
1089
|
*
|
|
1100
1090
|
* const data = await exchClient.setReferrer({ code: "TEST" });
|
|
1101
1091
|
* ```
|
|
@@ -1110,9 +1100,9 @@
|
|
|
1110
1100
|
...actionArgs,
|
|
1111
1101
|
};
|
|
1112
1102
|
// Sign the action
|
|
1113
|
-
const signature = await (0,
|
|
1103
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1114
1104
|
wallet: this.wallet,
|
|
1115
|
-
action:
|
|
1105
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1116
1106
|
nonce,
|
|
1117
1107
|
isTestnet: this.isTestnet,
|
|
1118
1108
|
});
|
|
@@ -1129,9 +1119,9 @@
|
|
|
1129
1119
|
...actionArgs,
|
|
1130
1120
|
};
|
|
1131
1121
|
// Sign the action
|
|
1132
|
-
const signature = await (0,
|
|
1122
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1133
1123
|
wallet: this.wallet,
|
|
1134
|
-
action:
|
|
1124
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1135
1125
|
nonce,
|
|
1136
1126
|
isTestnet: this.isTestnet,
|
|
1137
1127
|
});
|
|
@@ -1149,11 +1139,10 @@
|
|
|
1149
1139
|
* @example
|
|
1150
1140
|
* ```ts
|
|
1151
1141
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1152
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1153
1142
|
*
|
|
1154
|
-
* const
|
|
1155
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1156
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1143
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1144
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1145
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1157
1146
|
*
|
|
1158
1147
|
* const data = await exchClient.spotSend({
|
|
1159
1148
|
* destination: "0x...",
|
|
@@ -1175,10 +1164,10 @@
|
|
|
1175
1164
|
time: nonce,
|
|
1176
1165
|
};
|
|
1177
1166
|
// Sign the action
|
|
1178
|
-
const signature = await (0,
|
|
1167
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
1179
1168
|
wallet: this.wallet,
|
|
1180
1169
|
action,
|
|
1181
|
-
types:
|
|
1170
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
1182
1171
|
chainId: parseInt(action.signatureChainId, 16),
|
|
1183
1172
|
});
|
|
1184
1173
|
// Send a request
|
|
@@ -1195,11 +1184,10 @@
|
|
|
1195
1184
|
* @example
|
|
1196
1185
|
* ```ts
|
|
1197
1186
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1198
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1199
1187
|
*
|
|
1200
|
-
* const
|
|
1201
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1202
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1188
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1189
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1190
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1203
1191
|
*
|
|
1204
1192
|
* const data = await exchClient.spotUser({ toggleSpotDusting: { optOut: false } });
|
|
1205
1193
|
* ```
|
|
@@ -1214,9 +1202,9 @@
|
|
|
1214
1202
|
...actionArgs,
|
|
1215
1203
|
};
|
|
1216
1204
|
// Sign the action
|
|
1217
|
-
const signature = await (0,
|
|
1205
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1218
1206
|
wallet: this.wallet,
|
|
1219
|
-
action:
|
|
1207
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1220
1208
|
nonce,
|
|
1221
1209
|
isTestnet: this.isTestnet,
|
|
1222
1210
|
});
|
|
@@ -1234,11 +1222,10 @@
|
|
|
1234
1222
|
* @example
|
|
1235
1223
|
* ```ts
|
|
1236
1224
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1237
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1238
1225
|
*
|
|
1239
|
-
* const
|
|
1240
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1241
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1226
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1227
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1228
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1242
1229
|
*
|
|
1243
1230
|
* const data = await exchClient.subAccountSpotTransfer({
|
|
1244
1231
|
* subAccountUser: "0x...",
|
|
@@ -1258,9 +1245,9 @@
|
|
|
1258
1245
|
...actionArgs,
|
|
1259
1246
|
};
|
|
1260
1247
|
// Sign the action
|
|
1261
|
-
const signature = await (0,
|
|
1248
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1262
1249
|
wallet: this.wallet,
|
|
1263
|
-
action:
|
|
1250
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1264
1251
|
nonce,
|
|
1265
1252
|
isTestnet: this.isTestnet,
|
|
1266
1253
|
});
|
|
@@ -1278,11 +1265,10 @@
|
|
|
1278
1265
|
* @example
|
|
1279
1266
|
* ```ts
|
|
1280
1267
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1281
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1282
1268
|
*
|
|
1283
|
-
* const
|
|
1284
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1285
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1269
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1270
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1271
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1286
1272
|
*
|
|
1287
1273
|
* const data = await exchClient.subAccountTransfer({
|
|
1288
1274
|
* subAccountUser: "0x...",
|
|
@@ -1301,9 +1287,9 @@
|
|
|
1301
1287
|
...actionArgs,
|
|
1302
1288
|
};
|
|
1303
1289
|
// Sign the action
|
|
1304
|
-
const signature = await (0,
|
|
1290
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1305
1291
|
wallet: this.wallet,
|
|
1306
|
-
action:
|
|
1292
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1307
1293
|
nonce,
|
|
1308
1294
|
isTestnet: this.isTestnet,
|
|
1309
1295
|
});
|
|
@@ -1321,11 +1307,10 @@
|
|
|
1321
1307
|
* @example
|
|
1322
1308
|
* ```ts
|
|
1323
1309
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1324
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1325
1310
|
*
|
|
1326
|
-
* const
|
|
1327
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1328
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1311
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1312
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1313
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1329
1314
|
*
|
|
1330
1315
|
* const data = await exchClient.tokenDelegate({
|
|
1331
1316
|
* validator: "0x...",
|
|
@@ -1347,10 +1332,10 @@
|
|
|
1347
1332
|
nonce,
|
|
1348
1333
|
};
|
|
1349
1334
|
// Sign the action
|
|
1350
|
-
const signature = await (0,
|
|
1335
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
1351
1336
|
wallet: this.wallet,
|
|
1352
1337
|
action,
|
|
1353
|
-
types:
|
|
1338
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
1354
1339
|
chainId: parseInt(action.signatureChainId, 16),
|
|
1355
1340
|
});
|
|
1356
1341
|
// Send a request
|
|
@@ -1367,11 +1352,10 @@
|
|
|
1367
1352
|
* @example
|
|
1368
1353
|
* ```ts
|
|
1369
1354
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1370
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1371
1355
|
*
|
|
1372
|
-
* const
|
|
1373
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1374
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1356
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1357
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1358
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1375
1359
|
*
|
|
1376
1360
|
* const data = await exchClient.twapCancel({
|
|
1377
1361
|
* a: 0, // Asset index
|
|
@@ -1389,9 +1373,9 @@
|
|
|
1389
1373
|
...actionArgs,
|
|
1390
1374
|
};
|
|
1391
1375
|
// Sign the action
|
|
1392
|
-
const signature = await (0,
|
|
1376
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1393
1377
|
wallet: this.wallet,
|
|
1394
|
-
action:
|
|
1378
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1395
1379
|
nonce,
|
|
1396
1380
|
isTestnet: this.isTestnet,
|
|
1397
1381
|
vaultAddress,
|
|
@@ -1411,11 +1395,10 @@
|
|
|
1411
1395
|
* @example
|
|
1412
1396
|
* ```ts
|
|
1413
1397
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1414
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1415
1398
|
*
|
|
1416
|
-
* const
|
|
1417
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1418
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1399
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1400
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1401
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1419
1402
|
*
|
|
1420
1403
|
* const data = await exchClient.twapOrder({
|
|
1421
1404
|
* a: 0, // Asset index
|
|
@@ -1439,9 +1422,9 @@
|
|
|
1439
1422
|
},
|
|
1440
1423
|
};
|
|
1441
1424
|
// Sign the action
|
|
1442
|
-
const signature = await (0,
|
|
1425
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1443
1426
|
wallet: this.wallet,
|
|
1444
|
-
action:
|
|
1427
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1445
1428
|
nonce,
|
|
1446
1429
|
isTestnet: this.isTestnet,
|
|
1447
1430
|
vaultAddress,
|
|
@@ -1461,11 +1444,10 @@
|
|
|
1461
1444
|
* @example
|
|
1462
1445
|
* ```ts
|
|
1463
1446
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1464
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1465
1447
|
*
|
|
1466
|
-
* const
|
|
1467
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1468
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1448
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1449
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1450
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1469
1451
|
*
|
|
1470
1452
|
* const data = await exchClient.updateIsolatedMargin({
|
|
1471
1453
|
* asset: 0,
|
|
@@ -1484,9 +1466,9 @@
|
|
|
1484
1466
|
...actionArgs,
|
|
1485
1467
|
};
|
|
1486
1468
|
// Sign the action
|
|
1487
|
-
const signature = await (0,
|
|
1469
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1488
1470
|
wallet: this.wallet,
|
|
1489
|
-
action:
|
|
1471
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1490
1472
|
nonce,
|
|
1491
1473
|
isTestnet: this.isTestnet,
|
|
1492
1474
|
vaultAddress,
|
|
@@ -1506,11 +1488,10 @@
|
|
|
1506
1488
|
* @example
|
|
1507
1489
|
* ```ts
|
|
1508
1490
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1509
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1510
1491
|
*
|
|
1511
|
-
* const
|
|
1512
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1513
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1492
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1493
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1494
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1514
1495
|
*
|
|
1515
1496
|
* const data = await exchClient.updateLeverage({
|
|
1516
1497
|
* asset: 0,
|
|
@@ -1529,9 +1510,9 @@
|
|
|
1529
1510
|
...actionArgs,
|
|
1530
1511
|
};
|
|
1531
1512
|
// Sign the action
|
|
1532
|
-
const signature = await (0,
|
|
1513
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1533
1514
|
wallet: this.wallet,
|
|
1534
|
-
action:
|
|
1515
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1535
1516
|
nonce,
|
|
1536
1517
|
isTestnet: this.isTestnet,
|
|
1537
1518
|
vaultAddress,
|
|
@@ -1551,11 +1532,10 @@
|
|
|
1551
1532
|
* @example
|
|
1552
1533
|
* ```ts
|
|
1553
1534
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1554
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1555
1535
|
*
|
|
1556
|
-
* const
|
|
1557
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1558
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1536
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1537
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1538
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1559
1539
|
*
|
|
1560
1540
|
* const data = await exchClient.usdClassTransfer({ amount: "1", toPerp: true });
|
|
1561
1541
|
* ```
|
|
@@ -1573,10 +1553,10 @@
|
|
|
1573
1553
|
nonce,
|
|
1574
1554
|
};
|
|
1575
1555
|
// Sign the action
|
|
1576
|
-
const signature = await (0,
|
|
1556
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
1577
1557
|
wallet: this.wallet,
|
|
1578
1558
|
action,
|
|
1579
|
-
types:
|
|
1559
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
1580
1560
|
chainId: parseInt(action.signatureChainId, 16),
|
|
1581
1561
|
});
|
|
1582
1562
|
// Send a request
|
|
@@ -1593,11 +1573,10 @@
|
|
|
1593
1573
|
* @example
|
|
1594
1574
|
* ```ts
|
|
1595
1575
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1596
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1597
1576
|
*
|
|
1598
|
-
* const
|
|
1599
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1600
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1577
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1578
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1579
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1601
1580
|
*
|
|
1602
1581
|
* const data = await exchClient.usdSend({ destination: "0x...", amount: "1" });
|
|
1603
1582
|
* ```
|
|
@@ -1615,10 +1594,10 @@
|
|
|
1615
1594
|
time: nonce,
|
|
1616
1595
|
};
|
|
1617
1596
|
// Sign the action
|
|
1618
|
-
const signature = await (0,
|
|
1597
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
1619
1598
|
wallet: this.wallet,
|
|
1620
1599
|
action,
|
|
1621
|
-
types:
|
|
1600
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
1622
1601
|
chainId: parseInt(action.signatureChainId, 16),
|
|
1623
1602
|
});
|
|
1624
1603
|
// Send a request
|
|
@@ -1635,11 +1614,10 @@
|
|
|
1635
1614
|
* @example
|
|
1636
1615
|
* ```ts
|
|
1637
1616
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1638
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1639
1617
|
*
|
|
1640
|
-
* const
|
|
1641
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1642
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1618
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1619
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1620
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1643
1621
|
*
|
|
1644
1622
|
* const data = await exchClient.vaultDistribute({ vaultAddress: "0x...", usd: 10 * 1e6 });
|
|
1645
1623
|
* ```
|
|
@@ -1654,9 +1632,9 @@
|
|
|
1654
1632
|
...actionArgs,
|
|
1655
1633
|
};
|
|
1656
1634
|
// Sign the action
|
|
1657
|
-
const signature = await (0,
|
|
1635
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1658
1636
|
wallet: this.wallet,
|
|
1659
|
-
action:
|
|
1637
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1660
1638
|
nonce,
|
|
1661
1639
|
isTestnet: this.isTestnet,
|
|
1662
1640
|
});
|
|
@@ -1674,11 +1652,10 @@
|
|
|
1674
1652
|
* @example
|
|
1675
1653
|
* ```ts
|
|
1676
1654
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1677
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1678
1655
|
*
|
|
1679
|
-
* const
|
|
1680
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1681
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1656
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1657
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1658
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1682
1659
|
*
|
|
1683
1660
|
* const data = await exchClient.vaultModify({
|
|
1684
1661
|
* vaultAddress: "0x...",
|
|
@@ -1697,9 +1674,9 @@
|
|
|
1697
1674
|
...actionArgs,
|
|
1698
1675
|
};
|
|
1699
1676
|
// Sign the action
|
|
1700
|
-
const signature = await (0,
|
|
1677
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1701
1678
|
wallet: this.wallet,
|
|
1702
|
-
action:
|
|
1679
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1703
1680
|
nonce,
|
|
1704
1681
|
isTestnet: this.isTestnet,
|
|
1705
1682
|
});
|
|
@@ -1717,11 +1694,10 @@
|
|
|
1717
1694
|
* @example
|
|
1718
1695
|
* ```ts
|
|
1719
1696
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1720
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1721
1697
|
*
|
|
1722
|
-
* const
|
|
1723
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1724
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1698
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1699
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1700
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1725
1701
|
*
|
|
1726
1702
|
* const data = await exchClient.vaultTransfer({
|
|
1727
1703
|
* vaultAddress: "0x...",
|
|
@@ -1740,9 +1716,9 @@
|
|
|
1740
1716
|
...actionArgs,
|
|
1741
1717
|
};
|
|
1742
1718
|
// Sign the action
|
|
1743
|
-
const signature = await (0,
|
|
1719
|
+
const signature = await (0, mod_js_1.signL1Action)({
|
|
1744
1720
|
wallet: this.wallet,
|
|
1745
|
-
action:
|
|
1721
|
+
action: mod_js_1.actionSorter[action.type](action),
|
|
1746
1722
|
nonce,
|
|
1747
1723
|
isTestnet: this.isTestnet,
|
|
1748
1724
|
expiresAfter,
|
|
@@ -1761,11 +1737,10 @@
|
|
|
1761
1737
|
* @example
|
|
1762
1738
|
* ```ts
|
|
1763
1739
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1764
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1765
1740
|
*
|
|
1766
|
-
* const
|
|
1767
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1768
|
-
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
1741
|
+
* const privateKey = "0x..."; // or `viem`, `ethers`
|
|
1742
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1743
|
+
* const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
|
|
1769
1744
|
*
|
|
1770
1745
|
* const data = await exchClient.withdraw3({ destination: "0x...", amount: "1" });
|
|
1771
1746
|
* ```
|
|
@@ -1783,10 +1758,10 @@
|
|
|
1783
1758
|
time: nonce,
|
|
1784
1759
|
};
|
|
1785
1760
|
// Sign the action
|
|
1786
|
-
const signature = await (0,
|
|
1761
|
+
const signature = await (0, mod_js_1.signUserSignedAction)({
|
|
1787
1762
|
wallet: this.wallet,
|
|
1788
1763
|
action,
|
|
1789
|
-
types:
|
|
1764
|
+
types: mod_js_1.userSignedActionEip712Types[action.type],
|
|
1790
1765
|
chainId: parseInt(action.signatureChainId, 16),
|
|
1791
1766
|
});
|
|
1792
1767
|
// Send a request
|
|
@@ -1801,13 +1776,13 @@
|
|
|
1801
1776
|
/** Guesses the chain ID based on the wallet type or the isTestnet flag. */
|
|
1802
1777
|
async _guessSignatureChainId() {
|
|
1803
1778
|
// Trying to get chain ID of the wallet
|
|
1804
|
-
if ((0,
|
|
1779
|
+
if ((0, mod_js_1.isAbstractViemWalletClient)(this.wallet)) {
|
|
1805
1780
|
if ("getChainId" in this.wallet && typeof this.wallet.getChainId === "function") {
|
|
1806
1781
|
const chainId = await this.wallet.getChainId();
|
|
1807
1782
|
return `0x${chainId.toString(16)}`;
|
|
1808
1783
|
}
|
|
1809
1784
|
}
|
|
1810
|
-
else if ((0,
|
|
1785
|
+
else if ((0, mod_js_1.isAbstractEthersSigner)(this.wallet) || (0, mod_js_1.isAbstractEthersV5Signer)(this.wallet)) {
|
|
1811
1786
|
if ("provider" in this.wallet &&
|
|
1812
1787
|
typeof this.wallet.provider === "object" && this.wallet.provider !== null &&
|
|
1813
1788
|
"getNetwork" in this.wallet.provider &&
|
|
@@ -1816,7 +1791,7 @@
|
|
|
1816
1791
|
return `0x${network.chainId.toString(16)}`;
|
|
1817
1792
|
}
|
|
1818
1793
|
}
|
|
1819
|
-
else if ((0,
|
|
1794
|
+
else if ((0, mod_js_1.isAbstractWindowEthereum)(this.wallet)) {
|
|
1820
1795
|
const [chainId] = await this.wallet.request({ method: "eth_chainId", params: [] });
|
|
1821
1796
|
return chainId;
|
|
1822
1797
|
}
|