@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.
Files changed (58) hide show
  1. package/README.md +84 -27
  2. package/esm/mod.d.ts +1 -1
  3. package/esm/mod.d.ts.map +1 -1
  4. package/esm/src/clients/exchange.d.ts +136 -166
  5. package/esm/src/clients/exchange.d.ts.map +1 -1
  6. package/esm/src/clients/exchange.js +121 -146
  7. package/esm/src/clients/multiSign.d.ts +121 -280
  8. package/esm/src/clients/multiSign.d.ts.map +1 -1
  9. package/esm/src/clients/multiSign.js +123 -246
  10. package/esm/src/signing/_ethers.d.ts +33 -0
  11. package/esm/src/signing/_ethers.d.ts.map +1 -0
  12. package/esm/src/signing/_ethers.js +12 -0
  13. package/esm/src/signing/_private_key.d.ts +22 -0
  14. package/esm/src/signing/_private_key.d.ts.map +1 -0
  15. package/esm/src/signing/_private_key.js +124 -0
  16. package/esm/src/signing/_sorter.d.ts +154 -0
  17. package/esm/src/signing/_sorter.d.ts.map +1 -0
  18. package/esm/src/{signing.js → signing/_sorter.js} +0 -400
  19. package/esm/src/signing/_viem.d.ts +23 -0
  20. package/esm/src/signing/_viem.d.ts.map +1 -0
  21. package/esm/src/signing/_viem.js +6 -0
  22. package/esm/src/signing/_window.d.ts +23 -0
  23. package/esm/src/signing/_window.d.ts.map +1 -0
  24. package/esm/src/signing/_window.js +29 -0
  25. package/esm/src/signing/mod.d.ts +251 -0
  26. package/esm/src/signing/mod.d.ts.map +1 -0
  27. package/esm/src/signing/mod.js +352 -0
  28. package/package.json +6 -5
  29. package/script/mod.d.ts +1 -1
  30. package/script/mod.d.ts.map +1 -1
  31. package/script/src/clients/exchange.d.ts +136 -166
  32. package/script/src/clients/exchange.d.ts.map +1 -1
  33. package/script/src/clients/exchange.js +205 -230
  34. package/script/src/clients/multiSign.d.ts +121 -280
  35. package/script/src/clients/multiSign.d.ts.map +1 -1
  36. package/script/src/clients/multiSign.js +168 -291
  37. package/script/src/signing/_ethers.d.ts +33 -0
  38. package/script/src/signing/_ethers.d.ts.map +1 -0
  39. package/script/src/signing/_ethers.js +26 -0
  40. package/script/src/signing/_private_key.d.ts +22 -0
  41. package/script/src/signing/_private_key.d.ts.map +1 -0
  42. package/script/src/signing/_private_key.js +138 -0
  43. package/script/src/signing/_sorter.d.ts +154 -0
  44. package/script/src/signing/_sorter.d.ts.map +1 -0
  45. package/script/src/{signing.js → signing/_sorter.js} +1 -409
  46. package/script/src/signing/_viem.d.ts +23 -0
  47. package/script/src/signing/_viem.d.ts.map +1 -0
  48. package/script/src/signing/_viem.js +19 -0
  49. package/script/src/signing/_window.d.ts +23 -0
  50. package/script/src/signing/_window.d.ts.map +1 -0
  51. package/script/src/signing/_window.js +43 -0
  52. package/script/src/signing/mod.d.ts +251 -0
  53. package/script/src/signing/mod.d.ts.map +1 -0
  54. package/script/src/signing/mod.js +387 -0
  55. package/esm/src/signing.d.ts +0 -463
  56. package/esm/src/signing.d.ts.map +0 -1
  57. package/script/src/signing.d.ts +0 -463
  58. package/script/src/signing.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { HyperliquidError } from "../base.js";
2
- import { actionSorter, isAbstractEthersSigner, isAbstractEthersV5Signer, isAbstractViemWalletClient, isAbstractWindowEthereum, signL1Action, signMultiSigAction, signUserSignedAction, userSignedActionEip712Types, } from "../signing.js";
2
+ import { actionSorter, isAbstractEthersSigner, isAbstractEthersV5Signer, isAbstractViemWalletClient, isAbstractWindowEthereum, signL1Action, signMultiSigAction, signUserSignedAction, userSignedActionEip712Types, } from "../signing/mod.js";
3
3
  /** Error thrown when the API returns an error response. */
4
4
  export class ApiRequestError extends HyperliquidError {
5
5
  response;
@@ -70,6 +70,16 @@ export class ExchangeClient {
70
70
  * Initialises a new instance.
71
71
  * @param args - The parameters for the client.
72
72
  *
73
+ * @example Private key
74
+ * ```ts
75
+ * import * as hl from "@nktkas/hyperliquid";
76
+ *
77
+ * const privateKey = "0x...";
78
+ *
79
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
80
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
81
+ * ```
82
+ *
73
83
  * @example Private key via [viem](https://viem.sh/docs/clients/wallet#local-accounts-private-key-mnemonic-etc)
74
84
  * ```ts
75
85
  * import * as hl from "@nktkas/hyperliquid";
@@ -77,7 +87,7 @@ export class ExchangeClient {
77
87
  *
78
88
  * const wallet = privateKeyToAccount("0x...");
79
89
  *
80
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
90
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
81
91
  * const exchClient = new hl.ExchangeClient({ wallet, transport });
82
92
  * ```
83
93
  *
@@ -88,7 +98,7 @@ export class ExchangeClient {
88
98
  *
89
99
  * const wallet = new ethers.Wallet("0x...");
90
100
  *
91
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
101
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
92
102
  * const exchClient = new hl.ExchangeClient({ wallet, transport });
93
103
  * ```
94
104
  *
@@ -100,7 +110,7 @@ export class ExchangeClient {
100
110
  * const [account] = await window.ethereum.request({ method: "eth_requestAccounts" });
101
111
  * const wallet = createWalletClient({ account, transport: custom(window.ethereum) });
102
112
  *
103
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
113
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
104
114
  * const exchClient = new hl.ExchangeClient({ wallet, transport });
105
115
  * ```
106
116
  *
@@ -108,7 +118,7 @@ export class ExchangeClient {
108
118
  * ```ts
109
119
  * import * as hl from "@nktkas/hyperliquid";
110
120
  *
111
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
121
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
112
122
  * const exchClient = new hl.ExchangeClient({ wallet: window.ethereum, transport });
113
123
  * ```
114
124
  */
@@ -132,11 +142,10 @@ export class ExchangeClient {
132
142
  * @example
133
143
  * ```ts
134
144
  * import * as hl from "@nktkas/hyperliquid";
135
- * import { privateKeyToAccount } from "viem/accounts";
136
145
  *
137
- * const wallet = privateKeyToAccount("0x...");
138
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
139
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
146
+ * const privateKey = "0x..."; // or `viem`, `ethers`
147
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
148
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
140
149
  *
141
150
  * const data = await exchClient.approveAgent({ agentAddress: "0x...", agentName: "agentName" });
142
151
  * ```
@@ -177,11 +186,10 @@ export class ExchangeClient {
177
186
  * @example
178
187
  * ```ts
179
188
  * import * as hl from "@nktkas/hyperliquid";
180
- * import { privateKeyToAccount } from "viem/accounts";
181
189
  *
182
- * const wallet = privateKeyToAccount("0x...");
183
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
184
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
190
+ * const privateKey = "0x..."; // or `viem`, `ethers`
191
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
192
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
185
193
  *
186
194
  * const data = await exchClient.approveBuilderFee({ maxFeeRate: "0.01%", builder: "0x..." });
187
195
  * ```
@@ -219,11 +227,10 @@ export class ExchangeClient {
219
227
  * @example
220
228
  * ```ts
221
229
  * import * as hl from "@nktkas/hyperliquid";
222
- * import { privateKeyToAccount } from "viem/accounts";
223
230
  *
224
- * const wallet = privateKeyToAccount("0x...");
225
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
226
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
231
+ * const privateKey = "0x..."; // or `viem`, `ethers`
232
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
233
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
227
234
  *
228
235
  * const data = await exchClient.batchModify({
229
236
  * modifies: [{
@@ -277,11 +284,10 @@ export class ExchangeClient {
277
284
  * @example
278
285
  * ```ts
279
286
  * import * as hl from "@nktkas/hyperliquid";
280
- * import { privateKeyToAccount } from "viem/accounts";
281
287
  *
282
- * const wallet = privateKeyToAccount("0x...");
283
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
284
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
288
+ * const privateKey = "0x..."; // or `viem`, `ethers`
289
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
290
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
285
291
  *
286
292
  * const data = await exchClient.cancel({
287
293
  * cancels: [{
@@ -323,11 +329,10 @@ export class ExchangeClient {
323
329
  * @example
324
330
  * ```ts
325
331
  * import * as hl from "@nktkas/hyperliquid";
326
- * import { privateKeyToAccount } from "viem/accounts";
327
332
  *
328
- * const wallet = privateKeyToAccount("0x...");
329
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
330
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
333
+ * const privateKey = "0x..."; // or `viem`, `ethers`
334
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
335
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
331
336
  *
332
337
  * const data = await exchClient.cancelByCloid({
333
338
  * cancels: [
@@ -368,11 +373,10 @@ export class ExchangeClient {
368
373
  * @example
369
374
  * ```ts
370
375
  * import * as hl from "@nktkas/hyperliquid";
371
- * import { privateKeyToAccount } from "viem/accounts";
372
376
  *
373
- * const wallet = privateKeyToAccount("0x...");
374
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
375
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
377
+ * const privateKey = "0x..."; // or `viem`, `ethers`
378
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
379
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
376
380
  *
377
381
  * const data = await exchClient.cDeposit({ wei: 1 * 1e8 });
378
382
  * ```
@@ -410,11 +414,10 @@ export class ExchangeClient {
410
414
  * @example
411
415
  * ```ts
412
416
  * import * as hl from "@nktkas/hyperliquid";
413
- * import { privateKeyToAccount } from "viem/accounts";
414
417
  *
415
- * const wallet = privateKeyToAccount("0x...");
416
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
417
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
418
+ * const privateKey = "0x..."; // or `viem`, `ethers`
419
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
420
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
418
421
  *
419
422
  * const data = await exchClient.claimRewards();
420
423
  * ```
@@ -446,11 +449,10 @@ export class ExchangeClient {
446
449
  * @example
447
450
  * ```ts
448
451
  * import * as hl from "@nktkas/hyperliquid";
449
- * import { privateKeyToAccount } from "viem/accounts";
450
452
  *
451
- * const wallet = privateKeyToAccount("0x...");
452
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
453
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
453
+ * const privateKey = "0x..."; // or `viem`, `ethers`
454
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
455
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
454
456
  *
455
457
  * const data = await exchClient.convertToMultiSigUser({ // convert to multi-sig user
456
458
  * authorizedUsers: ["0x...", "0x...", "0x..."],
@@ -460,7 +462,7 @@ export class ExchangeClient {
460
462
  */
461
463
  async convertToMultiSigUser(args, signal) {
462
464
  // Destructure the parameters
463
- const { ...actionArgs } = args;
465
+ const actionArgs = args;
464
466
  // Construct an action
465
467
  const nonce = await this.nonceManager();
466
468
  const action = {
@@ -491,11 +493,10 @@ export class ExchangeClient {
491
493
  * @example
492
494
  * ```ts
493
495
  * import * as hl from "@nktkas/hyperliquid";
494
- * import { privateKeyToAccount } from "viem/accounts";
495
496
  *
496
- * const wallet = privateKeyToAccount("0x...");
497
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
498
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
497
+ * const privateKey = "0x..."; // or `viem`, `ethers`
498
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
499
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
499
500
  *
500
501
  * const data = await exchClient.createSubAccount({ name: "subAccountName" });
501
502
  * ```
@@ -530,11 +531,10 @@ export class ExchangeClient {
530
531
  * @example
531
532
  * ```ts
532
533
  * import * as hl from "@nktkas/hyperliquid";
533
- * import { privateKeyToAccount } from "viem/accounts";
534
534
  *
535
- * const wallet = privateKeyToAccount("0x...");
536
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
537
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
535
+ * const privateKey = "0x..."; // or `viem`, `ethers`
536
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
537
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
538
538
  *
539
539
  * const data = await exchClient.createVault({
540
540
  * name: "VaultName",
@@ -614,11 +614,10 @@ export class ExchangeClient {
614
614
  * @example
615
615
  * ```ts
616
616
  * import * as hl from "@nktkas/hyperliquid";
617
- * import { privateKeyToAccount } from "viem/accounts";
618
617
  *
619
- * const wallet = privateKeyToAccount("0x...");
620
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
621
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
618
+ * const privateKey = "0x..."; // or `viem`, `ethers`
619
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
620
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
622
621
  *
623
622
  * const data = await exchClient.cWithdraw({ wei: 1 * 1e8 });
624
623
  * ```
@@ -656,11 +655,10 @@ export class ExchangeClient {
656
655
  * @example
657
656
  * ```ts
658
657
  * import * as hl from "@nktkas/hyperliquid";
659
- * import { privateKeyToAccount } from "viem/accounts";
660
658
  *
661
- * const wallet = privateKeyToAccount("0x...");
662
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
663
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
659
+ * const privateKey = "0x..."; // or `viem`, `ethers`
660
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
661
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
664
662
  *
665
663
  * const data = await exchClient.evmUserModify({ usingBigBlocks: true });
666
664
  * ```
@@ -695,11 +693,10 @@ export class ExchangeClient {
695
693
  * @example
696
694
  * ```ts
697
695
  * import * as hl from "@nktkas/hyperliquid";
698
- * import { privateKeyToAccount } from "viem/accounts";
699
696
  *
700
- * const wallet = privateKeyToAccount("0x...");
701
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
702
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
697
+ * const privateKey = "0x..."; // or `viem`, `ethers`
698
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
699
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
703
700
  *
704
701
  * const data = await exchClient.modify({
705
702
  * oid: 123,
@@ -751,11 +748,10 @@ export class ExchangeClient {
751
748
  * @example
752
749
  * ```ts
753
750
  * import * as hl from "@nktkas/hyperliquid";
754
- * import { privateKeyToAccount } from "viem/accounts";
755
751
  *
756
- * const wallet = privateKeyToAccount("0x...");
757
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
758
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
752
+ * const privateKey = "0x..."; // or `viem`, `ethers`
753
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
754
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
759
755
  *
760
756
  * const multiSigUser = "0x..."; // Multi-sig user address
761
757
  *
@@ -815,11 +811,10 @@ export class ExchangeClient {
815
811
  * @example
816
812
  * ```ts
817
813
  * import * as hl from "@nktkas/hyperliquid";
818
- * import { privateKeyToAccount } from "viem/accounts";
819
814
  *
820
- * const wallet = privateKeyToAccount("0x...");
821
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
822
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
815
+ * const privateKey = "0x..."; // or `viem`, `ethers`
816
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
817
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
823
818
  *
824
819
  * const data = await exchClient.order({
825
820
  * orders: [{
@@ -890,11 +885,10 @@ export class ExchangeClient {
890
885
  * @example
891
886
  * ```ts
892
887
  * import * as hl from "@nktkas/hyperliquid";
893
- * import { privateKeyToAccount } from "viem/accounts";
894
888
  *
895
- * const wallet = privateKeyToAccount("0x...");
896
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
897
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
889
+ * const privateKey = "0x..."; // or `viem`, `ethers`
890
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
891
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
898
892
  *
899
893
  * const data = await exchClient.perpDexClassTransfer({
900
894
  * dex: "test",
@@ -937,11 +931,10 @@ export class ExchangeClient {
937
931
  * @example
938
932
  * ```ts
939
933
  * import * as hl from "@nktkas/hyperliquid";
940
- * import { privateKeyToAccount } from "viem/accounts";
941
934
  *
942
- * const wallet = privateKeyToAccount("0x...");
943
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
944
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
935
+ * const privateKey = "0x..."; // or `viem`, `ethers`
936
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
937
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
945
938
  *
946
939
  * const data = await exchClient.registerReferrer({ code: "TEST" });
947
940
  * ```
@@ -976,11 +969,10 @@ export class ExchangeClient {
976
969
  * @example
977
970
  * ```ts
978
971
  * import * as hl from "@nktkas/hyperliquid";
979
- * import { privateKeyToAccount } from "viem/accounts";
980
972
  *
981
- * const wallet = privateKeyToAccount("0x...");
982
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
983
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
973
+ * const privateKey = "0x..."; // or `viem`, `ethers`
974
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
975
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
984
976
  *
985
977
  * const data = await exchClient.reserveRequestWeight({ weight: 10 });
986
978
  * ```
@@ -1039,11 +1031,10 @@ export class ExchangeClient {
1039
1031
  * @example
1040
1032
  * ```ts
1041
1033
  * import * as hl from "@nktkas/hyperliquid";
1042
- * import { privateKeyToAccount } from "viem/accounts";
1043
1034
  *
1044
- * const wallet = privateKeyToAccount("0x...");
1045
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1046
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1035
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1036
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1037
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1047
1038
  *
1048
1039
  * const data = await exchClient.setDisplayName({ displayName: "My Name" });
1049
1040
  * ```
@@ -1078,11 +1069,10 @@ export class ExchangeClient {
1078
1069
  * @example
1079
1070
  * ```ts
1080
1071
  * import * as hl from "@nktkas/hyperliquid";
1081
- * import { privateKeyToAccount } from "viem/accounts";
1082
1072
  *
1083
- * const wallet = privateKeyToAccount("0x...");
1084
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1085
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1073
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1074
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1075
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1086
1076
  *
1087
1077
  * const data = await exchClient.setReferrer({ code: "TEST" });
1088
1078
  * ```
@@ -1136,11 +1126,10 @@ export class ExchangeClient {
1136
1126
  * @example
1137
1127
  * ```ts
1138
1128
  * import * as hl from "@nktkas/hyperliquid";
1139
- * import { privateKeyToAccount } from "viem/accounts";
1140
1129
  *
1141
- * const wallet = privateKeyToAccount("0x...");
1142
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1143
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1130
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1131
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1132
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1144
1133
  *
1145
1134
  * const data = await exchClient.spotSend({
1146
1135
  * destination: "0x...",
@@ -1182,11 +1171,10 @@ export class ExchangeClient {
1182
1171
  * @example
1183
1172
  * ```ts
1184
1173
  * import * as hl from "@nktkas/hyperliquid";
1185
- * import { privateKeyToAccount } from "viem/accounts";
1186
1174
  *
1187
- * const wallet = privateKeyToAccount("0x...");
1188
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1189
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1175
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1176
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1177
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1190
1178
  *
1191
1179
  * const data = await exchClient.spotUser({ toggleSpotDusting: { optOut: false } });
1192
1180
  * ```
@@ -1221,11 +1209,10 @@ export class ExchangeClient {
1221
1209
  * @example
1222
1210
  * ```ts
1223
1211
  * import * as hl from "@nktkas/hyperliquid";
1224
- * import { privateKeyToAccount } from "viem/accounts";
1225
1212
  *
1226
- * const wallet = privateKeyToAccount("0x...");
1227
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1228
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1213
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1214
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1215
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1229
1216
  *
1230
1217
  * const data = await exchClient.subAccountSpotTransfer({
1231
1218
  * subAccountUser: "0x...",
@@ -1265,11 +1252,10 @@ export class ExchangeClient {
1265
1252
  * @example
1266
1253
  * ```ts
1267
1254
  * import * as hl from "@nktkas/hyperliquid";
1268
- * import { privateKeyToAccount } from "viem/accounts";
1269
1255
  *
1270
- * const wallet = privateKeyToAccount("0x...");
1271
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1272
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1256
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1257
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1258
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1273
1259
  *
1274
1260
  * const data = await exchClient.subAccountTransfer({
1275
1261
  * subAccountUser: "0x...",
@@ -1308,11 +1294,10 @@ export class ExchangeClient {
1308
1294
  * @example
1309
1295
  * ```ts
1310
1296
  * import * as hl from "@nktkas/hyperliquid";
1311
- * import { privateKeyToAccount } from "viem/accounts";
1312
1297
  *
1313
- * const wallet = privateKeyToAccount("0x...");
1314
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1315
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1298
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1299
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1300
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1316
1301
  *
1317
1302
  * const data = await exchClient.tokenDelegate({
1318
1303
  * validator: "0x...",
@@ -1354,11 +1339,10 @@ export class ExchangeClient {
1354
1339
  * @example
1355
1340
  * ```ts
1356
1341
  * import * as hl from "@nktkas/hyperliquid";
1357
- * import { privateKeyToAccount } from "viem/accounts";
1358
1342
  *
1359
- * const wallet = privateKeyToAccount("0x...");
1360
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1361
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1343
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1344
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1345
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1362
1346
  *
1363
1347
  * const data = await exchClient.twapCancel({
1364
1348
  * a: 0, // Asset index
@@ -1398,11 +1382,10 @@ export class ExchangeClient {
1398
1382
  * @example
1399
1383
  * ```ts
1400
1384
  * import * as hl from "@nktkas/hyperliquid";
1401
- * import { privateKeyToAccount } from "viem/accounts";
1402
1385
  *
1403
- * const wallet = privateKeyToAccount("0x...");
1404
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1405
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1386
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1387
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1388
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1406
1389
  *
1407
1390
  * const data = await exchClient.twapOrder({
1408
1391
  * a: 0, // Asset index
@@ -1448,11 +1431,10 @@ export class ExchangeClient {
1448
1431
  * @example
1449
1432
  * ```ts
1450
1433
  * import * as hl from "@nktkas/hyperliquid";
1451
- * import { privateKeyToAccount } from "viem/accounts";
1452
1434
  *
1453
- * const wallet = privateKeyToAccount("0x...");
1454
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1455
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1435
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1436
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1437
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1456
1438
  *
1457
1439
  * const data = await exchClient.updateIsolatedMargin({
1458
1440
  * asset: 0,
@@ -1493,11 +1475,10 @@ export class ExchangeClient {
1493
1475
  * @example
1494
1476
  * ```ts
1495
1477
  * import * as hl from "@nktkas/hyperliquid";
1496
- * import { privateKeyToAccount } from "viem/accounts";
1497
1478
  *
1498
- * const wallet = privateKeyToAccount("0x...");
1499
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1500
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1479
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1480
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1481
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1501
1482
  *
1502
1483
  * const data = await exchClient.updateLeverage({
1503
1484
  * asset: 0,
@@ -1538,11 +1519,10 @@ export class ExchangeClient {
1538
1519
  * @example
1539
1520
  * ```ts
1540
1521
  * import * as hl from "@nktkas/hyperliquid";
1541
- * import { privateKeyToAccount } from "viem/accounts";
1542
1522
  *
1543
- * const wallet = privateKeyToAccount("0x...");
1544
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1545
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1523
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1524
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1525
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1546
1526
  *
1547
1527
  * const data = await exchClient.usdClassTransfer({ amount: "1", toPerp: true });
1548
1528
  * ```
@@ -1580,11 +1560,10 @@ export class ExchangeClient {
1580
1560
  * @example
1581
1561
  * ```ts
1582
1562
  * import * as hl from "@nktkas/hyperliquid";
1583
- * import { privateKeyToAccount } from "viem/accounts";
1584
1563
  *
1585
- * const wallet = privateKeyToAccount("0x...");
1586
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1587
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1564
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1565
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1566
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1588
1567
  *
1589
1568
  * const data = await exchClient.usdSend({ destination: "0x...", amount: "1" });
1590
1569
  * ```
@@ -1622,11 +1601,10 @@ export class ExchangeClient {
1622
1601
  * @example
1623
1602
  * ```ts
1624
1603
  * import * as hl from "@nktkas/hyperliquid";
1625
- * import { privateKeyToAccount } from "viem/accounts";
1626
1604
  *
1627
- * const wallet = privateKeyToAccount("0x...");
1628
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1629
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1605
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1606
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1607
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1630
1608
  *
1631
1609
  * const data = await exchClient.vaultDistribute({ vaultAddress: "0x...", usd: 10 * 1e6 });
1632
1610
  * ```
@@ -1661,11 +1639,10 @@ export class ExchangeClient {
1661
1639
  * @example
1662
1640
  * ```ts
1663
1641
  * import * as hl from "@nktkas/hyperliquid";
1664
- * import { privateKeyToAccount } from "viem/accounts";
1665
1642
  *
1666
- * const wallet = privateKeyToAccount("0x...");
1667
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1668
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1643
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1644
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1645
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1669
1646
  *
1670
1647
  * const data = await exchClient.vaultModify({
1671
1648
  * vaultAddress: "0x...",
@@ -1704,11 +1681,10 @@ export class ExchangeClient {
1704
1681
  * @example
1705
1682
  * ```ts
1706
1683
  * import * as hl from "@nktkas/hyperliquid";
1707
- * import { privateKeyToAccount } from "viem/accounts";
1708
1684
  *
1709
- * const wallet = privateKeyToAccount("0x...");
1710
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1711
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1685
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1686
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1687
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1712
1688
  *
1713
1689
  * const data = await exchClient.vaultTransfer({
1714
1690
  * vaultAddress: "0x...",
@@ -1748,11 +1724,10 @@ export class ExchangeClient {
1748
1724
  * @example
1749
1725
  * ```ts
1750
1726
  * import * as hl from "@nktkas/hyperliquid";
1751
- * import { privateKeyToAccount } from "viem/accounts";
1752
1727
  *
1753
- * const wallet = privateKeyToAccount("0x...");
1754
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
1755
- * const exchClient = new hl.ExchangeClient({ wallet, transport });
1728
+ * const privateKey = "0x..."; // or `viem`, `ethers`
1729
+ * const transport = new hl.HttpTransport(); // or `WebSocketTransport`
1730
+ * const exchClient = new hl.ExchangeClient({ wallet: privateKey, transport });
1756
1731
  *
1757
1732
  * const data = await exchClient.withdraw3({ destination: "0x...", amount: "1" });
1758
1733
  * ```