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