@nktkas/hyperliquid 0.22.0 → 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 +122 -147
- package/esm/src/clients/multiSign.d.ts +129 -282
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/multiSign.js +125 -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} +1 -401
- 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/esm/src/types/exchange/requests.d.ts +1 -1
- package/esm/src/types/exchange/requests.d.ts.map +1 -1
- 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 +206 -231
- package/script/src/clients/multiSign.d.ts +129 -282
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/multiSign.js +170 -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} +2 -410
- 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/script/src/types/exchange/requests.d.ts +1 -1
- package/script/src/types/exchange/requests.d.ts.map +1 -1
- 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,13 +4,16 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../signing.js", "./exchange.js"], factory);
|
|
7
|
+
define(["require", "exports", "@noble/hashes/sha3", "@noble/secp256k1", "../../deps/jsr.io/@std/encoding/1.0.10/hex.js", "../signing/mod.js", "./exchange.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MultiSignClient = void 0;
|
|
13
|
-
const
|
|
13
|
+
const sha3_1 = require("@noble/hashes/sha3");
|
|
14
|
+
const secp256k1_1 = require("@noble/secp256k1");
|
|
15
|
+
const hex_js_1 = require("../../deps/jsr.io/@std/encoding/1.0.10/hex.js");
|
|
16
|
+
const mod_js_1 = require("../signing/mod.js");
|
|
14
17
|
const exchange_js_1 = require("./exchange.js");
|
|
15
18
|
/**
|
|
16
19
|
* Multi-signature exchange client for interacting with the Hyperliquid API.
|
|
@@ -27,14 +30,11 @@
|
|
|
27
30
|
* @example
|
|
28
31
|
* ```ts
|
|
29
32
|
* import * as hl from "@nktkas/hyperliquid";
|
|
30
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
31
33
|
*
|
|
32
34
|
* const multiSignAddress = "0x...";
|
|
33
35
|
* const signers = [
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* privateKeyToAccount("0x..."),
|
|
37
|
-
* ];
|
|
36
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
37
|
+
* ] as const;
|
|
38
38
|
*
|
|
39
39
|
* const transport = new hl.HttpTransport();
|
|
40
40
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
@@ -65,17 +65,13 @@
|
|
|
65
65
|
* @example
|
|
66
66
|
* ```ts
|
|
67
67
|
* import * as hl from "@nktkas/hyperliquid";
|
|
68
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
69
68
|
*
|
|
70
69
|
* const multiSignAddress = "0x...";
|
|
71
70
|
* const signers = [
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* // ...
|
|
75
|
-
* privateKeyToAccount("0x..."),
|
|
76
|
-
* ];
|
|
71
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
72
|
+
* ] as const;
|
|
77
73
|
*
|
|
78
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
74
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
79
75
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
80
76
|
*
|
|
81
77
|
* const data = await multiSignClient.approveAgent({ agentAddress: "0x...", agentName: "agentName" });
|
|
@@ -95,9 +91,11 @@
|
|
|
95
91
|
nonce,
|
|
96
92
|
};
|
|
97
93
|
// Sign the action
|
|
98
|
-
const sortedAction =
|
|
94
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
99
95
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
100
96
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
97
|
+
if (sortedAction.agentName === "")
|
|
98
|
+
sortedAction.agentName = null;
|
|
101
99
|
// Send a multi-sig action
|
|
102
100
|
return super.multiSig({
|
|
103
101
|
signatures,
|
|
@@ -119,17 +117,13 @@
|
|
|
119
117
|
* @example
|
|
120
118
|
* ```ts
|
|
121
119
|
* import * as hl from "@nktkas/hyperliquid";
|
|
122
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
123
120
|
*
|
|
124
121
|
* const multiSignAddress = "0x...";
|
|
125
122
|
* const signers = [
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* // ...
|
|
129
|
-
* privateKeyToAccount("0x..."),
|
|
130
|
-
* ];
|
|
123
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
124
|
+
* ] as const;
|
|
131
125
|
*
|
|
132
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
126
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
133
127
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
134
128
|
*
|
|
135
129
|
* const data = await multiSignClient.approveBuilderFee({ maxFeeRate: "0.01%", builder: "0x..." });
|
|
@@ -148,7 +142,7 @@
|
|
|
148
142
|
nonce,
|
|
149
143
|
};
|
|
150
144
|
// Sign the action
|
|
151
|
-
const sortedAction =
|
|
145
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
152
146
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
153
147
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
154
148
|
// Send a multi-sig action
|
|
@@ -172,17 +166,13 @@
|
|
|
172
166
|
* @example
|
|
173
167
|
* ```ts
|
|
174
168
|
* import * as hl from "@nktkas/hyperliquid";
|
|
175
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
176
169
|
*
|
|
177
170
|
* const multiSignAddress = "0x...";
|
|
178
171
|
* const signers = [
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* // ...
|
|
182
|
-
* privateKeyToAccount("0x..."),
|
|
183
|
-
* ];
|
|
172
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
173
|
+
* ] as const;
|
|
184
174
|
*
|
|
185
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
175
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
186
176
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
187
177
|
*
|
|
188
178
|
* const data = await multiSignClient.batchModify({
|
|
@@ -215,7 +205,7 @@
|
|
|
215
205
|
...actionArgs,
|
|
216
206
|
};
|
|
217
207
|
// Send a multi-sig action
|
|
218
|
-
const sortedAction =
|
|
208
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
219
209
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
220
210
|
const signatures = await this._multiSignL1Action({
|
|
221
211
|
action: sortedAction,
|
|
@@ -247,17 +237,13 @@
|
|
|
247
237
|
* @example
|
|
248
238
|
* ```ts
|
|
249
239
|
* import * as hl from "@nktkas/hyperliquid";
|
|
250
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
251
240
|
*
|
|
252
241
|
* const multiSignAddress = "0x...";
|
|
253
242
|
* const signers = [
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* // ...
|
|
257
|
-
* privateKeyToAccount("0x..."),
|
|
258
|
-
* ];
|
|
243
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
244
|
+
* ] as const;
|
|
259
245
|
*
|
|
260
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
246
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
261
247
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
262
248
|
*
|
|
263
249
|
* const data = await multiSignClient.cancel({
|
|
@@ -278,7 +264,7 @@
|
|
|
278
264
|
...actionArgs,
|
|
279
265
|
};
|
|
280
266
|
// Send a multi-sig action
|
|
281
|
-
const sortedAction =
|
|
267
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
282
268
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
283
269
|
const signatures = await this._multiSignL1Action({
|
|
284
270
|
action: sortedAction,
|
|
@@ -310,17 +296,13 @@
|
|
|
310
296
|
* @example
|
|
311
297
|
* ```ts
|
|
312
298
|
* import * as hl from "@nktkas/hyperliquid";
|
|
313
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
314
299
|
*
|
|
315
300
|
* const multiSignAddress = "0x...";
|
|
316
301
|
* const signers = [
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* // ...
|
|
320
|
-
* privateKeyToAccount("0x..."),
|
|
321
|
-
* ];
|
|
302
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
303
|
+
* ] as const;
|
|
322
304
|
*
|
|
323
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
305
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
324
306
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
325
307
|
*
|
|
326
308
|
* const data = await multiSignClient.cancelByCloid({
|
|
@@ -340,7 +322,7 @@
|
|
|
340
322
|
...actionArgs,
|
|
341
323
|
};
|
|
342
324
|
// Send a multi-sig action
|
|
343
|
-
const sortedAction =
|
|
325
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
344
326
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
345
327
|
const signatures = await this._multiSignL1Action({
|
|
346
328
|
action: sortedAction,
|
|
@@ -372,17 +354,13 @@
|
|
|
372
354
|
* @example
|
|
373
355
|
* ```ts
|
|
374
356
|
* import * as hl from "@nktkas/hyperliquid";
|
|
375
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
376
357
|
*
|
|
377
358
|
* const multiSignAddress = "0x...";
|
|
378
359
|
* const signers = [
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
* // ...
|
|
382
|
-
* privateKeyToAccount("0x..."),
|
|
383
|
-
* ];
|
|
360
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
361
|
+
* ] as const;
|
|
384
362
|
*
|
|
385
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
363
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
386
364
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
387
365
|
*
|
|
388
366
|
* const data = await multiSignClient.cDeposit({ wei: 1 * 1e8 });
|
|
@@ -401,7 +379,7 @@
|
|
|
401
379
|
nonce,
|
|
402
380
|
};
|
|
403
381
|
// Sign the action
|
|
404
|
-
const sortedAction =
|
|
382
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
405
383
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
406
384
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
407
385
|
// Send a multi-sig action
|
|
@@ -425,17 +403,13 @@
|
|
|
425
403
|
* @example
|
|
426
404
|
* ```ts
|
|
427
405
|
* import * as hl from "@nktkas/hyperliquid";
|
|
428
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
429
406
|
*
|
|
430
407
|
* const multiSignAddress = "0x...";
|
|
431
408
|
* const signers = [
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
* // ...
|
|
435
|
-
* privateKeyToAccount("0x..."),
|
|
436
|
-
* ];
|
|
409
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
410
|
+
* ] as const;
|
|
437
411
|
*
|
|
438
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
412
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
439
413
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
440
414
|
*
|
|
441
415
|
* const data = await multiSignClient.claimRewards();
|
|
@@ -448,7 +422,7 @@
|
|
|
448
422
|
type: "claimRewards",
|
|
449
423
|
};
|
|
450
424
|
// Send a multi-sig action
|
|
451
|
-
const sortedAction =
|
|
425
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
452
426
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
453
427
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
454
428
|
// Send a multi-sig action
|
|
@@ -472,17 +446,13 @@
|
|
|
472
446
|
* @example
|
|
473
447
|
* ```ts
|
|
474
448
|
* import * as hl from "@nktkas/hyperliquid";
|
|
475
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
476
449
|
*
|
|
477
450
|
* const multiSignAddress = "0x...";
|
|
478
451
|
* const signers = [
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
* // ...
|
|
482
|
-
* privateKeyToAccount("0x..."),
|
|
483
|
-
* ];
|
|
452
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
453
|
+
* ] as const;
|
|
484
454
|
*
|
|
485
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
455
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
486
456
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
487
457
|
*
|
|
488
458
|
* const data = await multiSignClient.convertToMultiSigUser({ // convert to normal user
|
|
@@ -493,7 +463,7 @@
|
|
|
493
463
|
*/
|
|
494
464
|
async convertToMultiSigUser(...[args, signal]) {
|
|
495
465
|
// Destructure the parameters
|
|
496
|
-
const
|
|
466
|
+
const actionArgs = args;
|
|
497
467
|
// Construct an action
|
|
498
468
|
const nonce = await this.nonceManager();
|
|
499
469
|
const action = {
|
|
@@ -504,7 +474,7 @@
|
|
|
504
474
|
nonce,
|
|
505
475
|
};
|
|
506
476
|
// Sign the action
|
|
507
|
-
const sortedAction =
|
|
477
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
508
478
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
509
479
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
510
480
|
// Send a multi-sig action
|
|
@@ -528,17 +498,13 @@
|
|
|
528
498
|
* @example
|
|
529
499
|
* ```ts
|
|
530
500
|
* import * as hl from "@nktkas/hyperliquid";
|
|
531
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
532
501
|
*
|
|
533
502
|
* const multiSignAddress = "0x...";
|
|
534
503
|
* const signers = [
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
* // ...
|
|
538
|
-
* privateKeyToAccount("0x..."),
|
|
539
|
-
* ];
|
|
504
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
505
|
+
* ] as const;
|
|
540
506
|
*
|
|
541
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
507
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
542
508
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
543
509
|
*
|
|
544
510
|
* const data = await multiSignClient.createSubAccount({ name: "subAccountName" });
|
|
@@ -554,7 +520,7 @@
|
|
|
554
520
|
...actionArgs,
|
|
555
521
|
};
|
|
556
522
|
// Send a multi-sig action
|
|
557
|
-
const sortedAction =
|
|
523
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
558
524
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
559
525
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
560
526
|
// Send a multi-sig action
|
|
@@ -578,17 +544,13 @@
|
|
|
578
544
|
* @example
|
|
579
545
|
* ```ts
|
|
580
546
|
* import * as hl from "@nktkas/hyperliquid";
|
|
581
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
582
547
|
*
|
|
583
548
|
* const multiSignAddress = "0x...";
|
|
584
549
|
* const signers = [
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
* // ...
|
|
588
|
-
* privateKeyToAccount("0x..."),
|
|
589
|
-
* ];
|
|
550
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
551
|
+
* ] as const;
|
|
590
552
|
*
|
|
591
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
553
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
592
554
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
593
555
|
*
|
|
594
556
|
* const data = await multiSignClient.createVault({
|
|
@@ -609,7 +571,7 @@
|
|
|
609
571
|
...actionArgs,
|
|
610
572
|
};
|
|
611
573
|
// Send a multi-sig action
|
|
612
|
-
const sortedAction =
|
|
574
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
613
575
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
614
576
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
615
577
|
// Send a multi-sig action
|
|
@@ -633,7 +595,7 @@
|
|
|
633
595
|
...actionArgs,
|
|
634
596
|
};
|
|
635
597
|
// Send a multi-sig action
|
|
636
|
-
const sortedAction =
|
|
598
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
637
599
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
638
600
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner, expiresAfter });
|
|
639
601
|
// Send a multi-sig action
|
|
@@ -658,7 +620,7 @@
|
|
|
658
620
|
...actionArgs,
|
|
659
621
|
};
|
|
660
622
|
// Send a multi-sig action
|
|
661
|
-
const sortedAction =
|
|
623
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
662
624
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
663
625
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner, expiresAfter });
|
|
664
626
|
// Send a multi-sig action
|
|
@@ -683,17 +645,13 @@
|
|
|
683
645
|
* @example
|
|
684
646
|
* ```ts
|
|
685
647
|
* import * as hl from "@nktkas/hyperliquid";
|
|
686
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
687
648
|
*
|
|
688
649
|
* const multiSignAddress = "0x...";
|
|
689
650
|
* const signers = [
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
* // ...
|
|
693
|
-
* privateKeyToAccount("0x..."),
|
|
694
|
-
* ];
|
|
651
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
652
|
+
* ] as const;
|
|
695
653
|
*
|
|
696
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
654
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
697
655
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
698
656
|
*
|
|
699
657
|
* const data = await multiSignClient.cWithdraw({ wei: 1 * 1e8 });
|
|
@@ -712,7 +670,7 @@
|
|
|
712
670
|
nonce,
|
|
713
671
|
};
|
|
714
672
|
// Sign the action
|
|
715
|
-
const sortedAction =
|
|
673
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
716
674
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
717
675
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
718
676
|
// Send a multi-sig action
|
|
@@ -736,17 +694,13 @@
|
|
|
736
694
|
* @example
|
|
737
695
|
* ```ts
|
|
738
696
|
* import * as hl from "@nktkas/hyperliquid";
|
|
739
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
740
697
|
*
|
|
741
698
|
* const multiSignAddress = "0x...";
|
|
742
699
|
* const signers = [
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
* // ...
|
|
746
|
-
* privateKeyToAccount("0x..."),
|
|
747
|
-
* ];
|
|
700
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
701
|
+
* ] as const;
|
|
748
702
|
*
|
|
749
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
703
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
750
704
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
751
705
|
*
|
|
752
706
|
* const data = await multiSignClient.evmUserModify({ usingBigBlocks: true });
|
|
@@ -762,7 +716,7 @@
|
|
|
762
716
|
...actionArgs,
|
|
763
717
|
};
|
|
764
718
|
// Send a multi-sig action
|
|
765
|
-
const sortedAction =
|
|
719
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
766
720
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
767
721
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
768
722
|
// Send a multi-sig action
|
|
@@ -786,17 +740,13 @@
|
|
|
786
740
|
* @example
|
|
787
741
|
* ```ts
|
|
788
742
|
* import * as hl from "@nktkas/hyperliquid";
|
|
789
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
790
743
|
*
|
|
791
744
|
* const multiSignAddress = "0x...";
|
|
792
745
|
* const signers = [
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
* // ...
|
|
796
|
-
* privateKeyToAccount("0x..."),
|
|
797
|
-
* ];
|
|
746
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
747
|
+
* ] as const;
|
|
798
748
|
*
|
|
799
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
749
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
800
750
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
801
751
|
*
|
|
802
752
|
* const data = await multiSignClient.modify({
|
|
@@ -827,7 +777,7 @@
|
|
|
827
777
|
...actionArgs,
|
|
828
778
|
};
|
|
829
779
|
// Send a multi-sig action
|
|
830
|
-
const sortedAction =
|
|
780
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
831
781
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
832
782
|
const signatures = await this._multiSignL1Action({
|
|
833
783
|
action: sortedAction,
|
|
@@ -865,17 +815,13 @@
|
|
|
865
815
|
* @example
|
|
866
816
|
* ```ts
|
|
867
817
|
* import * as hl from "@nktkas/hyperliquid";
|
|
868
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
869
818
|
*
|
|
870
819
|
* const multiSignAddress = "0x...";
|
|
871
820
|
* const signers = [
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
* // ...
|
|
875
|
-
* privateKeyToAccount("0x..."),
|
|
876
|
-
* ];
|
|
821
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
822
|
+
* ] as const;
|
|
877
823
|
*
|
|
878
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
824
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
879
825
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
880
826
|
*
|
|
881
827
|
* const data = await multiSignClient.order({
|
|
@@ -906,7 +852,7 @@
|
|
|
906
852
|
...actionArgs,
|
|
907
853
|
};
|
|
908
854
|
// Send a multi-sig action
|
|
909
|
-
const sortedAction =
|
|
855
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
910
856
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
911
857
|
const signatures = await this._multiSignL1Action({
|
|
912
858
|
action: sortedAction,
|
|
@@ -938,7 +884,7 @@
|
|
|
938
884
|
...actionArgs,
|
|
939
885
|
};
|
|
940
886
|
// Send a multi-sig action
|
|
941
|
-
const sortedAction =
|
|
887
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
942
888
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
943
889
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
944
890
|
// Send a multi-sig action
|
|
@@ -962,17 +908,13 @@
|
|
|
962
908
|
* @example
|
|
963
909
|
* ```ts
|
|
964
910
|
* import * as hl from "@nktkas/hyperliquid";
|
|
965
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
966
911
|
*
|
|
967
912
|
* const multiSignAddress = "0x...";
|
|
968
913
|
* const signers = [
|
|
969
|
-
*
|
|
970
|
-
*
|
|
971
|
-
* // ...
|
|
972
|
-
* privateKeyToAccount("0x..."),
|
|
973
|
-
* ];
|
|
914
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
915
|
+
* ] as const;
|
|
974
916
|
*
|
|
975
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
917
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
976
918
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
977
919
|
*
|
|
978
920
|
* const data = await multiSignClient.perpDexClassTransfer({
|
|
@@ -996,7 +938,7 @@
|
|
|
996
938
|
nonce,
|
|
997
939
|
};
|
|
998
940
|
// Sign the action
|
|
999
|
-
const sortedAction =
|
|
941
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1000
942
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1001
943
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
1002
944
|
// Send a multi-sig action
|
|
@@ -1020,17 +962,13 @@
|
|
|
1020
962
|
* @example
|
|
1021
963
|
* ```ts
|
|
1022
964
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1023
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1024
965
|
*
|
|
1025
966
|
* const multiSignAddress = "0x...";
|
|
1026
967
|
* const signers = [
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
* // ...
|
|
1030
|
-
* privateKeyToAccount("0x..."),
|
|
1031
|
-
* ];
|
|
968
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
969
|
+
* ] as const;
|
|
1032
970
|
*
|
|
1033
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
971
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1034
972
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1035
973
|
*
|
|
1036
974
|
* const data = await multiSignClient.registerReferrer({ code: "TEST" });
|
|
@@ -1046,7 +984,7 @@
|
|
|
1046
984
|
...actionArgs,
|
|
1047
985
|
};
|
|
1048
986
|
// Send a multi-sig action
|
|
1049
|
-
const sortedAction =
|
|
987
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1050
988
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1051
989
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1052
990
|
// Send a multi-sig action
|
|
@@ -1070,17 +1008,13 @@
|
|
|
1070
1008
|
* @example
|
|
1071
1009
|
* ```ts
|
|
1072
1010
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1073
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1074
1011
|
*
|
|
1075
1012
|
* const multiSignAddress = "0x...";
|
|
1076
1013
|
* const signers = [
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1079
|
-
* // ...
|
|
1080
|
-
* privateKeyToAccount("0x..."),
|
|
1081
|
-
* ];
|
|
1014
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1015
|
+
* ] as const;
|
|
1082
1016
|
*
|
|
1083
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1017
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1084
1018
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1085
1019
|
*
|
|
1086
1020
|
* const data = await multiSignClient.reserveRequestWeight({ weight: 10 });
|
|
@@ -1096,7 +1030,7 @@
|
|
|
1096
1030
|
...actionArgs,
|
|
1097
1031
|
};
|
|
1098
1032
|
// Send a multi-sig action
|
|
1099
|
-
const sortedAction =
|
|
1033
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1100
1034
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1101
1035
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner, expiresAfter });
|
|
1102
1036
|
// Send a multi-sig action
|
|
@@ -1123,7 +1057,7 @@
|
|
|
1123
1057
|
...actionArgs,
|
|
1124
1058
|
};
|
|
1125
1059
|
// Send a multi-sig action
|
|
1126
|
-
const sortedAction =
|
|
1060
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1127
1061
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1128
1062
|
const signatures = await this._multiSignL1Action({
|
|
1129
1063
|
action: sortedAction,
|
|
@@ -1155,17 +1089,13 @@
|
|
|
1155
1089
|
* @example
|
|
1156
1090
|
* ```ts
|
|
1157
1091
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1158
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1159
1092
|
*
|
|
1160
1093
|
* const multiSignAddress = "0x...";
|
|
1161
1094
|
* const signers = [
|
|
1162
|
-
*
|
|
1163
|
-
*
|
|
1164
|
-
* // ...
|
|
1165
|
-
* privateKeyToAccount("0x..."),
|
|
1166
|
-
* ];
|
|
1095
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1096
|
+
* ] as const;
|
|
1167
1097
|
*
|
|
1168
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1098
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1169
1099
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1170
1100
|
*
|
|
1171
1101
|
* const data = await multiSignClient.setDisplayName({ displayName: "My Name" });
|
|
@@ -1181,7 +1111,7 @@
|
|
|
1181
1111
|
...actionArgs,
|
|
1182
1112
|
};
|
|
1183
1113
|
// Send a multi-sig action
|
|
1184
|
-
const sortedAction =
|
|
1114
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1185
1115
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1186
1116
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1187
1117
|
// Send a multi-sig action
|
|
@@ -1205,17 +1135,13 @@
|
|
|
1205
1135
|
* @example
|
|
1206
1136
|
* ```ts
|
|
1207
1137
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1208
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1209
1138
|
*
|
|
1210
1139
|
* const multiSignAddress = "0x...";
|
|
1211
1140
|
* const signers = [
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
* // ...
|
|
1215
|
-
* privateKeyToAccount("0x..."),
|
|
1216
|
-
* ];
|
|
1141
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1142
|
+
* ] as const;
|
|
1217
1143
|
*
|
|
1218
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1144
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1219
1145
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1220
1146
|
*
|
|
1221
1147
|
* const data = await multiSignClient.setReferrer({ code: "TEST" });
|
|
@@ -1231,7 +1157,7 @@
|
|
|
1231
1157
|
...actionArgs,
|
|
1232
1158
|
};
|
|
1233
1159
|
// Send a multi-sig action
|
|
1234
|
-
const sortedAction =
|
|
1160
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1235
1161
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1236
1162
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1237
1163
|
// Send a multi-sig action
|
|
@@ -1255,7 +1181,7 @@
|
|
|
1255
1181
|
...actionArgs,
|
|
1256
1182
|
};
|
|
1257
1183
|
// Send a multi-sig action
|
|
1258
|
-
const sortedAction =
|
|
1184
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1259
1185
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1260
1186
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1261
1187
|
// Send a multi-sig action
|
|
@@ -1279,17 +1205,13 @@
|
|
|
1279
1205
|
* @example
|
|
1280
1206
|
* ```ts
|
|
1281
1207
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1282
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1283
1208
|
*
|
|
1284
1209
|
* const multiSignAddress = "0x...";
|
|
1285
1210
|
* const signers = [
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1288
|
-
* // ...
|
|
1289
|
-
* privateKeyToAccount("0x..."),
|
|
1290
|
-
* ];
|
|
1211
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1212
|
+
* ] as const;
|
|
1291
1213
|
*
|
|
1292
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1214
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1293
1215
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1294
1216
|
*
|
|
1295
1217
|
* const data = await multiSignClient.spotSend({
|
|
@@ -1312,7 +1234,7 @@
|
|
|
1312
1234
|
time: nonce,
|
|
1313
1235
|
};
|
|
1314
1236
|
// Sign the action
|
|
1315
|
-
const sortedAction =
|
|
1237
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1316
1238
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1317
1239
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
1318
1240
|
// Send a multi-sig action
|
|
@@ -1336,17 +1258,13 @@
|
|
|
1336
1258
|
* @example
|
|
1337
1259
|
* ```ts
|
|
1338
1260
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1339
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1340
1261
|
*
|
|
1341
1262
|
* const multiSignAddress = "0x...";
|
|
1342
1263
|
* const signers = [
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1345
|
-
* // ...
|
|
1346
|
-
* privateKeyToAccount("0x..."),
|
|
1347
|
-
* ];
|
|
1264
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1265
|
+
* ] as const;
|
|
1348
1266
|
*
|
|
1349
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1267
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1350
1268
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1351
1269
|
*
|
|
1352
1270
|
* const data = await multiSignClient.spotUser({ toggleSpotDusting: { optOut: false } });
|
|
@@ -1362,7 +1280,7 @@
|
|
|
1362
1280
|
...actionArgs,
|
|
1363
1281
|
};
|
|
1364
1282
|
// Send a multi-sig action
|
|
1365
|
-
const sortedAction =
|
|
1283
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1366
1284
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1367
1285
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1368
1286
|
// Send a multi-sig action
|
|
@@ -1386,17 +1304,13 @@
|
|
|
1386
1304
|
* @example
|
|
1387
1305
|
* ```ts
|
|
1388
1306
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1389
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1390
1307
|
*
|
|
1391
1308
|
* const multiSignAddress = "0x...";
|
|
1392
1309
|
* const signers = [
|
|
1393
|
-
*
|
|
1394
|
-
*
|
|
1395
|
-
* // ...
|
|
1396
|
-
* privateKeyToAccount("0x..."),
|
|
1397
|
-
* ];
|
|
1310
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1311
|
+
* ] as const;
|
|
1398
1312
|
*
|
|
1399
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1313
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1400
1314
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1401
1315
|
*
|
|
1402
1316
|
* const data = await multiSignClient.subAccountSpotTransfer({
|
|
@@ -1417,7 +1331,7 @@
|
|
|
1417
1331
|
...actionArgs,
|
|
1418
1332
|
};
|
|
1419
1333
|
// Send a multi-sig action
|
|
1420
|
-
const sortedAction =
|
|
1334
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1421
1335
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1422
1336
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1423
1337
|
// Send a multi-sig action
|
|
@@ -1441,17 +1355,13 @@
|
|
|
1441
1355
|
* @example
|
|
1442
1356
|
* ```ts
|
|
1443
1357
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1444
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1445
1358
|
*
|
|
1446
1359
|
* const multiSignAddress = "0x...";
|
|
1447
1360
|
* const signers = [
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
1450
|
-
* // ...
|
|
1451
|
-
* privateKeyToAccount("0x..."),
|
|
1452
|
-
* ];
|
|
1361
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1362
|
+
* ] as const;
|
|
1453
1363
|
*
|
|
1454
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1364
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1455
1365
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1456
1366
|
*
|
|
1457
1367
|
* const data = await multiSignClient.subAccountTransfer({
|
|
@@ -1471,7 +1381,7 @@
|
|
|
1471
1381
|
...actionArgs,
|
|
1472
1382
|
};
|
|
1473
1383
|
// Send a multi-sig action
|
|
1474
|
-
const sortedAction =
|
|
1384
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1475
1385
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1476
1386
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1477
1387
|
// Send a multi-sig action
|
|
@@ -1495,17 +1405,13 @@
|
|
|
1495
1405
|
* @example
|
|
1496
1406
|
* ```ts
|
|
1497
1407
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1498
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1499
1408
|
*
|
|
1500
1409
|
* const multiSignAddress = "0x...";
|
|
1501
1410
|
* const signers = [
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
* // ...
|
|
1505
|
-
* privateKeyToAccount("0x..."),
|
|
1506
|
-
* ];
|
|
1411
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1412
|
+
* ] as const;
|
|
1507
1413
|
*
|
|
1508
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1414
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1509
1415
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1510
1416
|
*
|
|
1511
1417
|
* const data = await multiSignClient.tokenDelegate({
|
|
@@ -1528,7 +1434,7 @@
|
|
|
1528
1434
|
nonce,
|
|
1529
1435
|
};
|
|
1530
1436
|
// Sign the action
|
|
1531
|
-
const sortedAction =
|
|
1437
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1532
1438
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1533
1439
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
1534
1440
|
// Send a multi-sig action
|
|
@@ -1552,17 +1458,13 @@
|
|
|
1552
1458
|
* @example
|
|
1553
1459
|
* ```ts
|
|
1554
1460
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1555
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1556
1461
|
*
|
|
1557
1462
|
* const multiSignAddress = "0x...";
|
|
1558
1463
|
* const signers = [
|
|
1559
|
-
*
|
|
1560
|
-
*
|
|
1561
|
-
* // ...
|
|
1562
|
-
* privateKeyToAccount("0x..."),
|
|
1563
|
-
* ];
|
|
1464
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1465
|
+
* ] as const;
|
|
1564
1466
|
*
|
|
1565
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1467
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1566
1468
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1567
1469
|
*
|
|
1568
1470
|
* const data = await multiSignClient.twapCancel({
|
|
@@ -1581,7 +1483,7 @@
|
|
|
1581
1483
|
...actionArgs,
|
|
1582
1484
|
};
|
|
1583
1485
|
// Send a multi-sig action
|
|
1584
|
-
const sortedAction =
|
|
1486
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1585
1487
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1586
1488
|
const signatures = await this._multiSignL1Action({
|
|
1587
1489
|
action: sortedAction,
|
|
@@ -1613,17 +1515,13 @@
|
|
|
1613
1515
|
* @example
|
|
1614
1516
|
* ```ts
|
|
1615
1517
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1616
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1617
1518
|
*
|
|
1618
1519
|
* const multiSignAddress = "0x...";
|
|
1619
1520
|
* const signers = [
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1622
|
-
* // ...
|
|
1623
|
-
* privateKeyToAccount("0x..."),
|
|
1624
|
-
* ];
|
|
1521
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1522
|
+
* ] as const;
|
|
1625
1523
|
*
|
|
1626
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1524
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1627
1525
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1628
1526
|
*
|
|
1629
1527
|
* const data = await multiSignClient.twapOrder({
|
|
@@ -1648,7 +1546,7 @@
|
|
|
1648
1546
|
},
|
|
1649
1547
|
};
|
|
1650
1548
|
// Send a multi-sig action
|
|
1651
|
-
const sortedAction =
|
|
1549
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1652
1550
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1653
1551
|
const signatures = await this._multiSignL1Action({
|
|
1654
1552
|
action: sortedAction,
|
|
@@ -1680,17 +1578,13 @@
|
|
|
1680
1578
|
* @example
|
|
1681
1579
|
* ```ts
|
|
1682
1580
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1683
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1684
1581
|
*
|
|
1685
1582
|
* const multiSignAddress = "0x...";
|
|
1686
1583
|
* const signers = [
|
|
1687
|
-
*
|
|
1688
|
-
*
|
|
1689
|
-
* // ...
|
|
1690
|
-
* privateKeyToAccount("0x..."),
|
|
1691
|
-
* ];
|
|
1584
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1585
|
+
* ] as const;
|
|
1692
1586
|
*
|
|
1693
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1587
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1694
1588
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1695
1589
|
*
|
|
1696
1590
|
* const data = await multiSignClient.updateIsolatedMargin({
|
|
@@ -1710,7 +1604,7 @@
|
|
|
1710
1604
|
...actionArgs,
|
|
1711
1605
|
};
|
|
1712
1606
|
// Send a multi-sig action
|
|
1713
|
-
const sortedAction =
|
|
1607
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1714
1608
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1715
1609
|
const signatures = await this._multiSignL1Action({
|
|
1716
1610
|
action: sortedAction,
|
|
@@ -1742,17 +1636,13 @@
|
|
|
1742
1636
|
* @example
|
|
1743
1637
|
* ```ts
|
|
1744
1638
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1745
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1746
1639
|
*
|
|
1747
1640
|
* const multiSignAddress = "0x...";
|
|
1748
1641
|
* const signers = [
|
|
1749
|
-
*
|
|
1750
|
-
*
|
|
1751
|
-
* // ...
|
|
1752
|
-
* privateKeyToAccount("0x..."),
|
|
1753
|
-
* ];
|
|
1642
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1643
|
+
* ] as const;
|
|
1754
1644
|
*
|
|
1755
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1645
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1756
1646
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1757
1647
|
*
|
|
1758
1648
|
* const data = await multiSignClient.updateLeverage({
|
|
@@ -1772,7 +1662,7 @@
|
|
|
1772
1662
|
...actionArgs,
|
|
1773
1663
|
};
|
|
1774
1664
|
// Send a multi-sig action
|
|
1775
|
-
const sortedAction =
|
|
1665
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1776
1666
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1777
1667
|
const signatures = await this._multiSignL1Action({
|
|
1778
1668
|
action: sortedAction,
|
|
@@ -1804,17 +1694,13 @@
|
|
|
1804
1694
|
* @example
|
|
1805
1695
|
* ```ts
|
|
1806
1696
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1807
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1808
1697
|
*
|
|
1809
1698
|
* const multiSignAddress = "0x...";
|
|
1810
1699
|
* const signers = [
|
|
1811
|
-
*
|
|
1812
|
-
*
|
|
1813
|
-
* // ...
|
|
1814
|
-
* privateKeyToAccount("0x..."),
|
|
1815
|
-
* ];
|
|
1700
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1701
|
+
* ] as const;
|
|
1816
1702
|
*
|
|
1817
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1703
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1818
1704
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1819
1705
|
*
|
|
1820
1706
|
* const data = await multiSignClient.usdClassTransfer({ amount: "1", toPerp: true });
|
|
@@ -1833,7 +1719,7 @@
|
|
|
1833
1719
|
nonce,
|
|
1834
1720
|
};
|
|
1835
1721
|
// Sign the action
|
|
1836
|
-
const sortedAction =
|
|
1722
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1837
1723
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1838
1724
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
1839
1725
|
// Send a multi-sig action
|
|
@@ -1857,17 +1743,13 @@
|
|
|
1857
1743
|
* @example
|
|
1858
1744
|
* ```ts
|
|
1859
1745
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1860
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1861
1746
|
*
|
|
1862
1747
|
* const multiSignAddress = "0x...";
|
|
1863
1748
|
* const signers = [
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
* // ...
|
|
1867
|
-
* privateKeyToAccount("0x..."),
|
|
1868
|
-
* ];
|
|
1749
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1750
|
+
* ] as const;
|
|
1869
1751
|
*
|
|
1870
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1752
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1871
1753
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1872
1754
|
*
|
|
1873
1755
|
* const data = await multiSignClient.usdSend({ destination: "0x...", amount: "1" });
|
|
@@ -1886,7 +1768,7 @@
|
|
|
1886
1768
|
time: nonce,
|
|
1887
1769
|
};
|
|
1888
1770
|
// Sign the action
|
|
1889
|
-
const sortedAction =
|
|
1771
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1890
1772
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1891
1773
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
1892
1774
|
// Send a multi-sig action
|
|
@@ -1910,17 +1792,13 @@
|
|
|
1910
1792
|
* @example
|
|
1911
1793
|
* ```ts
|
|
1912
1794
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1913
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1914
1795
|
*
|
|
1915
1796
|
* const multiSignAddress = "0x...";
|
|
1916
1797
|
* const signers = [
|
|
1917
|
-
*
|
|
1918
|
-
*
|
|
1919
|
-
* // ...
|
|
1920
|
-
* privateKeyToAccount("0x..."),
|
|
1921
|
-
* ];
|
|
1798
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1799
|
+
* ] as const;
|
|
1922
1800
|
*
|
|
1923
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1801
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1924
1802
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1925
1803
|
*
|
|
1926
1804
|
* const data = await multiSignClient.vaultDistribute({ vaultAddress: "0x...", usd: 10 * 1e6 });
|
|
@@ -1936,7 +1814,7 @@
|
|
|
1936
1814
|
...actionArgs,
|
|
1937
1815
|
};
|
|
1938
1816
|
// Send a multi-sig action
|
|
1939
|
-
const sortedAction =
|
|
1817
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1940
1818
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1941
1819
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1942
1820
|
// Send a multi-sig action
|
|
@@ -1960,17 +1838,13 @@
|
|
|
1960
1838
|
* @example
|
|
1961
1839
|
* ```ts
|
|
1962
1840
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1963
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1964
1841
|
*
|
|
1965
1842
|
* const multiSignAddress = "0x...";
|
|
1966
1843
|
* const signers = [
|
|
1967
|
-
*
|
|
1968
|
-
*
|
|
1969
|
-
* // ...
|
|
1970
|
-
* privateKeyToAccount("0x..."),
|
|
1971
|
-
* ];
|
|
1844
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1845
|
+
* ] as const;
|
|
1972
1846
|
*
|
|
1973
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1847
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1974
1848
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1975
1849
|
*
|
|
1976
1850
|
* const data = await multiSignClient.vaultModify({
|
|
@@ -1990,7 +1864,7 @@
|
|
|
1990
1864
|
...actionArgs,
|
|
1991
1865
|
};
|
|
1992
1866
|
// Send a multi-sig action
|
|
1993
|
-
const sortedAction =
|
|
1867
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
1994
1868
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
1995
1869
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner });
|
|
1996
1870
|
// Send a multi-sig action
|
|
@@ -2014,17 +1888,13 @@
|
|
|
2014
1888
|
* @example
|
|
2015
1889
|
* ```ts
|
|
2016
1890
|
* import * as hl from "@nktkas/hyperliquid";
|
|
2017
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
2018
1891
|
*
|
|
2019
1892
|
* const multiSignAddress = "0x...";
|
|
2020
1893
|
* const signers = [
|
|
2021
|
-
*
|
|
2022
|
-
*
|
|
2023
|
-
* // ...
|
|
2024
|
-
* privateKeyToAccount("0x..."),
|
|
2025
|
-
* ];
|
|
1894
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1895
|
+
* ] as const;
|
|
2026
1896
|
*
|
|
2027
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1897
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
2028
1898
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
2029
1899
|
*
|
|
2030
1900
|
* const data = await multiSignClient.vaultTransfer({
|
|
@@ -2044,7 +1914,7 @@
|
|
|
2044
1914
|
...actionArgs,
|
|
2045
1915
|
};
|
|
2046
1916
|
// Send a multi-sig action
|
|
2047
|
-
const sortedAction =
|
|
1917
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
2048
1918
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
2049
1919
|
const signatures = await this._multiSignL1Action({ action: sortedAction, nonce, outerSigner, expiresAfter });
|
|
2050
1920
|
// Send a multi-sig action
|
|
@@ -2069,17 +1939,13 @@
|
|
|
2069
1939
|
* @example
|
|
2070
1940
|
* ```ts
|
|
2071
1941
|
* import * as hl from "@nktkas/hyperliquid";
|
|
2072
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
2073
1942
|
*
|
|
2074
1943
|
* const multiSignAddress = "0x...";
|
|
2075
1944
|
* const signers = [
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2078
|
-
* // ...
|
|
2079
|
-
* privateKeyToAccount("0x..."),
|
|
2080
|
-
* ];
|
|
1945
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1946
|
+
* ] as const;
|
|
2081
1947
|
*
|
|
2082
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1948
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
2083
1949
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
2084
1950
|
*
|
|
2085
1951
|
* const data = await multiSignClient.withdraw3({ destination: "0x...", amount: "1" });
|
|
@@ -2098,7 +1964,7 @@
|
|
|
2098
1964
|
time: nonce,
|
|
2099
1965
|
};
|
|
2100
1966
|
// Sign the action
|
|
2101
|
-
const sortedAction =
|
|
1967
|
+
const sortedAction = mod_js_1.actionSorter[action.type](action);
|
|
2102
1968
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
2103
1969
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
2104
1970
|
// Send a multi-sig action
|
|
@@ -2114,13 +1980,16 @@
|
|
|
2114
1980
|
}
|
|
2115
1981
|
/** Extracts the wallet address from different wallet types. */
|
|
2116
1982
|
async _getWalletAddress(wallet) {
|
|
2117
|
-
if ((0,
|
|
1983
|
+
if ((0, mod_js_1.isValidPrivateKey)(wallet)) {
|
|
1984
|
+
return privateKeyToAddress(wallet);
|
|
1985
|
+
}
|
|
1986
|
+
else if ((0, mod_js_1.isAbstractViemWalletClient)(wallet)) {
|
|
2118
1987
|
return wallet.address;
|
|
2119
1988
|
}
|
|
2120
|
-
else if ((0,
|
|
1989
|
+
else if ((0, mod_js_1.isAbstractEthersSigner)(wallet) || (0, mod_js_1.isAbstractEthersV5Signer)(wallet)) {
|
|
2121
1990
|
return await wallet.getAddress();
|
|
2122
1991
|
}
|
|
2123
|
-
else if ((0,
|
|
1992
|
+
else if ((0, mod_js_1.isAbstractWindowEthereum)(wallet)) {
|
|
2124
1993
|
const accounts = await wallet.request({ method: "eth_requestAccounts", params: [] });
|
|
2125
1994
|
if (!Array.isArray(accounts) || accounts.length === 0) {
|
|
2126
1995
|
throw new Error("No Ethereum accounts available");
|
|
@@ -2135,7 +2004,7 @@
|
|
|
2135
2004
|
_multiSignL1Action(args) {
|
|
2136
2005
|
const { action, nonce, outerSigner, vaultAddress, expiresAfter } = args;
|
|
2137
2006
|
return Promise.all(this.signers.map((signer) => {
|
|
2138
|
-
return (0,
|
|
2007
|
+
return (0, mod_js_1.signL1Action)({
|
|
2139
2008
|
wallet: signer,
|
|
2140
2009
|
action: [this.multiSignAddress.toLowerCase(), outerSigner.toLowerCase(), action],
|
|
2141
2010
|
nonce,
|
|
@@ -2148,12 +2017,12 @@
|
|
|
2148
2017
|
/** Signs user-signed action with all signers for multi-signature operations. */
|
|
2149
2018
|
_multiSignUserSignedAction(action, outerSigner) {
|
|
2150
2019
|
return Promise.all(this.signers.map((signer) => {
|
|
2151
|
-
const types = structuredClone(
|
|
2020
|
+
const types = structuredClone(mod_js_1.userSignedActionEip712Types[action.type]); // for safe mutation
|
|
2152
2021
|
Object.values(types)[0].splice(// array mutation
|
|
2153
2022
|
1, // after `hyperliquidChain`
|
|
2154
2023
|
0, // do not remove any elements
|
|
2155
2024
|
{ name: "payloadMultiSigUser", type: "address" }, { name: "outerSigner", type: "address" });
|
|
2156
|
-
return (0,
|
|
2025
|
+
return (0, mod_js_1.signUserSignedAction)({
|
|
2157
2026
|
wallet: signer,
|
|
2158
2027
|
action: {
|
|
2159
2028
|
...action,
|
|
@@ -2167,4 +2036,14 @@
|
|
|
2167
2036
|
}
|
|
2168
2037
|
}
|
|
2169
2038
|
exports.MultiSignClient = MultiSignClient;
|
|
2039
|
+
/** Converts a private key to an Ethereum address. */
|
|
2040
|
+
function privateKeyToAddress(privateKey) {
|
|
2041
|
+
const cleanKey = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
|
|
2042
|
+
const publicKey = (0, secp256k1_1.getPublicKey)(cleanKey, false);
|
|
2043
|
+
const publicKeyWithoutPrefix = publicKey.slice(1);
|
|
2044
|
+
const hash = (0, sha3_1.keccak_256)(publicKeyWithoutPrefix);
|
|
2045
|
+
const addressBytes = hash.slice(-20);
|
|
2046
|
+
const address = (0, hex_js_1.encodeHex)(addressBytes);
|
|
2047
|
+
return `0x${address}`;
|
|
2048
|
+
}
|
|
2170
2049
|
});
|