@swapkit/helpers 1.0.0-rc.9 → 1.0.0-rc.90

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 (38) hide show
  1. package/dist/index.js +2065 -0
  2. package/dist/index.js.map +28 -0
  3. package/package.json +24 -37
  4. package/src/helpers/__tests__/asset.test.ts +126 -108
  5. package/src/helpers/__tests__/memo.test.ts +52 -40
  6. package/src/helpers/__tests__/others.test.ts +42 -37
  7. package/src/helpers/__tests__/validators.test.ts +24 -0
  8. package/src/helpers/asset.ts +119 -87
  9. package/src/helpers/liquidity.ts +50 -43
  10. package/src/helpers/memo.ts +31 -28
  11. package/src/helpers/others.ts +29 -12
  12. package/src/helpers/validators.ts +15 -6
  13. package/src/helpers/web3wallets.ts +178 -0
  14. package/src/index.ts +13 -9
  15. package/src/modules/__tests__/assetValue.test.ts +325 -116
  16. package/src/modules/__tests__/bigIntArithmetics.test.ts +30 -0
  17. package/src/modules/__tests__/swapKitNumber.test.ts +306 -183
  18. package/src/modules/assetValue.ts +216 -152
  19. package/src/modules/bigIntArithmetics.ts +214 -147
  20. package/src/modules/requestClient.ts +29 -0
  21. package/src/modules/swapKitError.ts +32 -5
  22. package/src/modules/swapKitNumber.ts +8 -1
  23. package/src/types/abis/erc20.ts +99 -0
  24. package/src/types/abis/tcEthVault.ts +496 -0
  25. package/src/types/chains.ts +220 -0
  26. package/src/types/commonTypes.ts +119 -0
  27. package/src/types/derivationPath.ts +56 -0
  28. package/src/types/index.ts +10 -0
  29. package/src/types/network.ts +43 -0
  30. package/src/types/sdk.ts +11 -0
  31. package/src/types/tokens.ts +30 -0
  32. package/src/types/transactions.ts +45 -0
  33. package/src/types/wallet.ts +39 -0
  34. package/LICENSE +0 -201
  35. package/dist/index.cjs +0 -1
  36. package/dist/index.d.ts +0 -354
  37. package/dist/index.es.js +0 -1054
  38. package/src/helpers/request.ts +0 -16
package/dist/index.js ADDED
@@ -0,0 +1,2065 @@
1
+ var __require = ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // src/types/abis/erc20.ts
10
+ var erc20ABI = [
11
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
12
+ {
13
+ anonymous: false,
14
+ inputs: [
15
+ { indexed: true, internalType: "address", name: "owner", type: "address" },
16
+ { indexed: true, internalType: "address", name: "spender", type: "address" },
17
+ { indexed: false, internalType: "uint256", name: "value", type: "uint256" }
18
+ ],
19
+ name: "Approval",
20
+ type: "event"
21
+ },
22
+ {
23
+ anonymous: false,
24
+ inputs: [
25
+ { indexed: true, internalType: "address", name: "from", type: "address" },
26
+ { indexed: true, internalType: "address", name: "to", type: "address" },
27
+ { indexed: false, internalType: "uint256", name: "value", type: "uint256" }
28
+ ],
29
+ name: "Transfer",
30
+ type: "event"
31
+ },
32
+ {
33
+ inputs: [
34
+ { internalType: "address", name: "", type: "address" },
35
+ { internalType: "address", name: "", type: "address" }
36
+ ],
37
+ name: "allowance",
38
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
39
+ stateMutability: "view",
40
+ type: "function"
41
+ },
42
+ {
43
+ inputs: [
44
+ { internalType: "address", name: "spender", type: "address" },
45
+ { internalType: "uint256", name: "value", type: "uint256" }
46
+ ],
47
+ name: "approve",
48
+ outputs: [{ internalType: "bool", name: "success", type: "bool" }],
49
+ stateMutability: "nonpayable",
50
+ type: "function"
51
+ },
52
+ {
53
+ inputs: [{ internalType: "address", name: "", type: "address" }],
54
+ name: "balanceOf",
55
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
56
+ stateMutability: "view",
57
+ type: "function"
58
+ },
59
+ {
60
+ inputs: [],
61
+ name: "decimals",
62
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
63
+ stateMutability: "view",
64
+ type: "function"
65
+ },
66
+ {
67
+ inputs: [],
68
+ name: "name",
69
+ outputs: [{ internalType: "string", name: "", type: "string" }],
70
+ stateMutability: "view",
71
+ type: "function"
72
+ },
73
+ {
74
+ inputs: [],
75
+ name: "symbol",
76
+ outputs: [{ internalType: "string", name: "", type: "string" }],
77
+ stateMutability: "view",
78
+ type: "function"
79
+ },
80
+ {
81
+ inputs: [],
82
+ name: "totalSupply",
83
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
84
+ stateMutability: "view",
85
+ type: "function"
86
+ },
87
+ {
88
+ inputs: [
89
+ { internalType: "address", name: "to", type: "address" },
90
+ { internalType: "uint256", name: "value", type: "uint256" }
91
+ ],
92
+ name: "transfer",
93
+ outputs: [{ internalType: "bool", name: "success", type: "bool" }],
94
+ stateMutability: "nonpayable",
95
+ type: "function"
96
+ },
97
+ {
98
+ inputs: [
99
+ { internalType: "address", name: "from", type: "address" },
100
+ { internalType: "address", name: "to", type: "address" },
101
+ { internalType: "uint256", name: "value", type: "uint256" }
102
+ ],
103
+ name: "transferFrom",
104
+ outputs: [{ internalType: "bool", name: "success", type: "bool" }],
105
+ stateMutability: "nonpayable",
106
+ type: "function"
107
+ }
108
+ ];
109
+ // src/types/abis/tcEthVault.ts
110
+ var TCEthereumVaultAbi = [
111
+ {
112
+ inputs: [{ internalType: "address", name: "rune", type: "address" }],
113
+ stateMutability: "nonpayable",
114
+ type: "constructor"
115
+ },
116
+ {
117
+ anonymous: false,
118
+ inputs: [
119
+ { indexed: true, internalType: "address", name: "to", type: "address" },
120
+ { indexed: true, internalType: "address", name: "asset", type: "address" },
121
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
122
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
123
+ ],
124
+ name: "Deposit",
125
+ type: "event"
126
+ },
127
+ {
128
+ anonymous: false,
129
+ inputs: [
130
+ { indexed: true, internalType: "address", name: "oldVault", type: "address" },
131
+ { indexed: true, internalType: "address", name: "newVault", type: "address" },
132
+ { indexed: false, internalType: "address", name: "asset", type: "address" },
133
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
134
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
135
+ ],
136
+ name: "TransferAllowance",
137
+ type: "event"
138
+ },
139
+ {
140
+ anonymous: false,
141
+ inputs: [
142
+ { indexed: true, internalType: "address", name: "vault", type: "address" },
143
+ { indexed: true, internalType: "address", name: "to", type: "address" },
144
+ { indexed: false, internalType: "address", name: "asset", type: "address" },
145
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
146
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
147
+ ],
148
+ name: "TransferOut",
149
+ type: "event"
150
+ },
151
+ {
152
+ anonymous: false,
153
+ inputs: [
154
+ { indexed: true, internalType: "address", name: "vault", type: "address" },
155
+ { indexed: false, internalType: "address", name: "target", type: "address" },
156
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
157
+ { indexed: false, internalType: "address", name: "finalAsset", type: "address" },
158
+ { indexed: false, internalType: "address", name: "to", type: "address" },
159
+ { indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
160
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
161
+ ],
162
+ name: "TransferOutAndCall",
163
+ type: "event"
164
+ },
165
+ {
166
+ anonymous: false,
167
+ inputs: [
168
+ { indexed: true, internalType: "address", name: "oldVault", type: "address" },
169
+ { indexed: true, internalType: "address", name: "newVault", type: "address" },
170
+ {
171
+ components: [
172
+ { internalType: "address", name: "asset", type: "address" },
173
+ { internalType: "uint256", name: "amount", type: "uint256" }
174
+ ],
175
+ indexed: false,
176
+ internalType: "struct THORChain_Router.Coin[]",
177
+ name: "coins",
178
+ type: "tuple[]"
179
+ },
180
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
181
+ ],
182
+ name: "VaultTransfer",
183
+ type: "event"
184
+ },
185
+ {
186
+ inputs: [],
187
+ name: "RUNE",
188
+ outputs: [{ internalType: "address", name: "", type: "address" }],
189
+ stateMutability: "view",
190
+ type: "function"
191
+ },
192
+ {
193
+ inputs: [
194
+ { internalType: "address payable", name: "vault", type: "address" },
195
+ { internalType: "address", name: "asset", type: "address" },
196
+ { internalType: "uint256", name: "amount", type: "uint256" },
197
+ { internalType: "string", name: "memo", type: "string" }
198
+ ],
199
+ name: "deposit",
200
+ outputs: [],
201
+ stateMutability: "payable",
202
+ type: "function"
203
+ },
204
+ {
205
+ inputs: [
206
+ { internalType: "address payable", name: "vault", type: "address" },
207
+ { internalType: "address", name: "asset", type: "address" },
208
+ { internalType: "uint256", name: "amount", type: "uint256" },
209
+ { internalType: "string", name: "memo", type: "string" },
210
+ { internalType: "uint256", name: "expiration", type: "uint256" }
211
+ ],
212
+ name: "depositWithExpiry",
213
+ outputs: [],
214
+ stateMutability: "payable",
215
+ type: "function"
216
+ },
217
+ {
218
+ inputs: [
219
+ { internalType: "address", name: "router", type: "address" },
220
+ { internalType: "address payable", name: "asgard", type: "address" },
221
+ {
222
+ components: [
223
+ { internalType: "address", name: "asset", type: "address" },
224
+ { internalType: "uint256", name: "amount", type: "uint256" }
225
+ ],
226
+ internalType: "struct THORChain_Router.Coin[]",
227
+ name: "coins",
228
+ type: "tuple[]"
229
+ },
230
+ { internalType: "string", name: "memo", type: "string" }
231
+ ],
232
+ name: "returnVaultAssets",
233
+ outputs: [],
234
+ stateMutability: "payable",
235
+ type: "function"
236
+ },
237
+ {
238
+ inputs: [
239
+ { internalType: "address", name: "router", type: "address" },
240
+ { internalType: "address", name: "newVault", type: "address" },
241
+ { internalType: "address", name: "asset", type: "address" },
242
+ { internalType: "uint256", name: "amount", type: "uint256" },
243
+ { internalType: "string", name: "memo", type: "string" }
244
+ ],
245
+ name: "transferAllowance",
246
+ outputs: [],
247
+ stateMutability: "nonpayable",
248
+ type: "function"
249
+ },
250
+ {
251
+ inputs: [
252
+ { internalType: "address payable", name: "to", type: "address" },
253
+ { internalType: "address", name: "asset", type: "address" },
254
+ { internalType: "uint256", name: "amount", type: "uint256" },
255
+ { internalType: "string", name: "memo", type: "string" }
256
+ ],
257
+ name: "transferOut",
258
+ outputs: [],
259
+ stateMutability: "payable",
260
+ type: "function"
261
+ },
262
+ {
263
+ inputs: [
264
+ { internalType: "address payable", name: "aggregator", type: "address" },
265
+ { internalType: "address", name: "finalToken", type: "address" },
266
+ { internalType: "address", name: "to", type: "address" },
267
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
268
+ { internalType: "string", name: "memo", type: "string" }
269
+ ],
270
+ name: "transferOutAndCall",
271
+ outputs: [],
272
+ stateMutability: "payable",
273
+ type: "function"
274
+ },
275
+ {
276
+ inputs: [
277
+ { internalType: "address", name: "vault", type: "address" },
278
+ { internalType: "address", name: "token", type: "address" }
279
+ ],
280
+ name: "vaultAllowance",
281
+ outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
282
+ stateMutability: "view",
283
+ type: "function"
284
+ }
285
+ ];
286
+ var TCAvalancheDepositABI = [
287
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
288
+ {
289
+ anonymous: false,
290
+ inputs: [
291
+ { indexed: true, internalType: "address", name: "to", type: "address" },
292
+ { indexed: true, internalType: "address", name: "asset", type: "address" },
293
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
294
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
295
+ ],
296
+ name: "Deposit",
297
+ type: "event"
298
+ },
299
+ {
300
+ anonymous: false,
301
+ inputs: [
302
+ { indexed: true, internalType: "address", name: "oldVault", type: "address" },
303
+ { indexed: true, internalType: "address", name: "newVault", type: "address" },
304
+ { indexed: false, internalType: "address", name: "asset", type: "address" },
305
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
306
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
307
+ ],
308
+ name: "TransferAllowance",
309
+ type: "event"
310
+ },
311
+ {
312
+ anonymous: false,
313
+ inputs: [
314
+ { indexed: true, internalType: "address", name: "vault", type: "address" },
315
+ { indexed: true, internalType: "address", name: "to", type: "address" },
316
+ { indexed: false, internalType: "address", name: "asset", type: "address" },
317
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
318
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
319
+ ],
320
+ name: "TransferOut",
321
+ type: "event"
322
+ },
323
+ {
324
+ anonymous: false,
325
+ inputs: [
326
+ { indexed: true, internalType: "address", name: "vault", type: "address" },
327
+ { indexed: false, internalType: "address", name: "target", type: "address" },
328
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
329
+ { indexed: false, internalType: "address", name: "finalAsset", type: "address" },
330
+ { indexed: false, internalType: "address", name: "to", type: "address" },
331
+ { indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
332
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
333
+ ],
334
+ name: "TransferOutAndCall",
335
+ type: "event"
336
+ },
337
+ {
338
+ anonymous: false,
339
+ inputs: [
340
+ { indexed: true, internalType: "address", name: "oldVault", type: "address" },
341
+ { indexed: true, internalType: "address", name: "newVault", type: "address" },
342
+ {
343
+ components: [
344
+ { internalType: "address", name: "asset", type: "address" },
345
+ { internalType: "uint256", name: "amount", type: "uint256" }
346
+ ],
347
+ indexed: false,
348
+ internalType: "struct AvaxRouter.Coin[]",
349
+ name: "coins",
350
+ type: "tuple[]"
351
+ },
352
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
353
+ ],
354
+ name: "VaultTransfer",
355
+ type: "event"
356
+ },
357
+ {
358
+ inputs: [
359
+ { internalType: "address payable", name: "vault", type: "address" },
360
+ { internalType: "address", name: "asset", type: "address" },
361
+ { internalType: "uint256", name: "amount", type: "uint256" },
362
+ { internalType: "string", name: "memo", type: "string" }
363
+ ],
364
+ name: "deposit",
365
+ outputs: [],
366
+ stateMutability: "payable",
367
+ type: "function"
368
+ },
369
+ {
370
+ inputs: [
371
+ { internalType: "address payable", name: "vault", type: "address" },
372
+ { internalType: "address", name: "asset", type: "address" },
373
+ { internalType: "uint256", name: "amount", type: "uint256" },
374
+ { internalType: "string", name: "memo", type: "string" },
375
+ { internalType: "uint256", name: "expiration", type: "uint256" }
376
+ ],
377
+ name: "depositWithExpiry",
378
+ outputs: [],
379
+ stateMutability: "payable",
380
+ type: "function"
381
+ },
382
+ {
383
+ inputs: [
384
+ { internalType: "address", name: "router", type: "address" },
385
+ { internalType: "address payable", name: "asgard", type: "address" },
386
+ {
387
+ components: [
388
+ { internalType: "address", name: "asset", type: "address" },
389
+ { internalType: "uint256", name: "amount", type: "uint256" }
390
+ ],
391
+ internalType: "struct AvaxRouter.Coin[]",
392
+ name: "coins",
393
+ type: "tuple[]"
394
+ },
395
+ { internalType: "string", name: "memo", type: "string" }
396
+ ],
397
+ name: "returnVaultAssets",
398
+ outputs: [],
399
+ stateMutability: "payable",
400
+ type: "function"
401
+ },
402
+ {
403
+ inputs: [
404
+ { internalType: "address", name: "router", type: "address" },
405
+ { internalType: "address", name: "newVault", type: "address" },
406
+ { internalType: "address", name: "asset", type: "address" },
407
+ { internalType: "uint256", name: "amount", type: "uint256" },
408
+ { internalType: "string", name: "memo", type: "string" }
409
+ ],
410
+ name: "transferAllowance",
411
+ outputs: [],
412
+ stateMutability: "nonpayable",
413
+ type: "function"
414
+ },
415
+ {
416
+ inputs: [
417
+ { internalType: "address payable", name: "to", type: "address" },
418
+ { internalType: "address", name: "asset", type: "address" },
419
+ { internalType: "uint256", name: "amount", type: "uint256" },
420
+ { internalType: "string", name: "memo", type: "string" }
421
+ ],
422
+ name: "transferOut",
423
+ outputs: [],
424
+ stateMutability: "payable",
425
+ type: "function"
426
+ },
427
+ {
428
+ inputs: [
429
+ { internalType: "address payable", name: "target", type: "address" },
430
+ { internalType: "address", name: "finalToken", type: "address" },
431
+ { internalType: "address", name: "to", type: "address" },
432
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
433
+ { internalType: "string", name: "memo", type: "string" }
434
+ ],
435
+ name: "transferOutAndCall",
436
+ outputs: [],
437
+ stateMutability: "payable",
438
+ type: "function"
439
+ },
440
+ {
441
+ inputs: [
442
+ { internalType: "address", name: "vault", type: "address" },
443
+ { internalType: "address", name: "token", type: "address" }
444
+ ],
445
+ name: "vaultAllowance",
446
+ outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
447
+ stateMutability: "view",
448
+ type: "function"
449
+ }
450
+ ];
451
+ var TCBscDepositABI = [
452
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
453
+ {
454
+ anonymous: false,
455
+ inputs: [
456
+ { indexed: true, internalType: "address", name: "to", type: "address" },
457
+ { indexed: true, internalType: "address", name: "asset", type: "address" },
458
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
459
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
460
+ ],
461
+ name: "Deposit",
462
+ type: "event"
463
+ },
464
+ {
465
+ anonymous: false,
466
+ inputs: [
467
+ { indexed: true, internalType: "address", name: "oldVault", type: "address" },
468
+ { indexed: true, internalType: "address", name: "newVault", type: "address" },
469
+ { indexed: false, internalType: "address", name: "asset", type: "address" },
470
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
471
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
472
+ ],
473
+ name: "TransferAllowance",
474
+ type: "event"
475
+ },
476
+ {
477
+ anonymous: false,
478
+ inputs: [
479
+ { indexed: true, internalType: "address", name: "vault", type: "address" },
480
+ { indexed: true, internalType: "address", name: "to", type: "address" },
481
+ { indexed: false, internalType: "address", name: "asset", type: "address" },
482
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
483
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
484
+ ],
485
+ name: "TransferOut",
486
+ type: "event"
487
+ },
488
+ {
489
+ anonymous: false,
490
+ inputs: [
491
+ { indexed: true, internalType: "address", name: "vault", type: "address" },
492
+ { indexed: false, internalType: "address", name: "target", type: "address" },
493
+ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
494
+ { indexed: false, internalType: "address", name: "finalAsset", type: "address" },
495
+ { indexed: false, internalType: "address", name: "to", type: "address" },
496
+ { indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
497
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
498
+ ],
499
+ name: "TransferOutAndCall",
500
+ type: "event"
501
+ },
502
+ {
503
+ anonymous: false,
504
+ inputs: [
505
+ { indexed: true, internalType: "address", name: "oldVault", type: "address" },
506
+ { indexed: true, internalType: "address", name: "newVault", type: "address" },
507
+ {
508
+ components: [
509
+ { internalType: "address", name: "asset", type: "address" },
510
+ { internalType: "uint256", name: "amount", type: "uint256" }
511
+ ],
512
+ indexed: false,
513
+ internalType: "struct THORChain_Router.Coin[]",
514
+ name: "coins",
515
+ type: "tuple[]"
516
+ },
517
+ { indexed: false, internalType: "string", name: "memo", type: "string" }
518
+ ],
519
+ name: "VaultTransfer",
520
+ type: "event"
521
+ },
522
+ {
523
+ inputs: [
524
+ { internalType: "address payable", name: "vault", type: "address" },
525
+ { internalType: "address", name: "asset", type: "address" },
526
+ { internalType: "uint256", name: "amount", type: "uint256" },
527
+ { internalType: "string", name: "memo", type: "string" },
528
+ { internalType: "uint256", name: "expiration", type: "uint256" }
529
+ ],
530
+ name: "depositWithExpiry",
531
+ outputs: [],
532
+ stateMutability: "payable",
533
+ type: "function"
534
+ },
535
+ {
536
+ inputs: [
537
+ { internalType: "address", name: "router", type: "address" },
538
+ { internalType: "address payable", name: "asgard", type: "address" },
539
+ {
540
+ components: [
541
+ { internalType: "address", name: "asset", type: "address" },
542
+ { internalType: "uint256", name: "amount", type: "uint256" }
543
+ ],
544
+ internalType: "struct THORChain_Router.Coin[]",
545
+ name: "coins",
546
+ type: "tuple[]"
547
+ },
548
+ { internalType: "string", name: "memo", type: "string" }
549
+ ],
550
+ name: "returnVaultAssets",
551
+ outputs: [],
552
+ stateMutability: "payable",
553
+ type: "function"
554
+ },
555
+ {
556
+ inputs: [
557
+ { internalType: "address", name: "router", type: "address" },
558
+ { internalType: "address", name: "newVault", type: "address" },
559
+ { internalType: "address", name: "asset", type: "address" },
560
+ { internalType: "uint256", name: "amount", type: "uint256" },
561
+ { internalType: "string", name: "memo", type: "string" }
562
+ ],
563
+ name: "transferAllowance",
564
+ outputs: [],
565
+ stateMutability: "nonpayable",
566
+ type: "function"
567
+ },
568
+ {
569
+ inputs: [
570
+ { internalType: "address payable", name: "to", type: "address" },
571
+ { internalType: "address", name: "asset", type: "address" },
572
+ { internalType: "uint256", name: "amount", type: "uint256" },
573
+ { internalType: "string", name: "memo", type: "string" }
574
+ ],
575
+ name: "transferOut",
576
+ outputs: [],
577
+ stateMutability: "payable",
578
+ type: "function"
579
+ },
580
+ {
581
+ inputs: [
582
+ { internalType: "address payable", name: "target", type: "address" },
583
+ { internalType: "address", name: "finalToken", type: "address" },
584
+ { internalType: "address", name: "to", type: "address" },
585
+ { internalType: "uint256", name: "amountOutMin", type: "uint256" },
586
+ { internalType: "string", name: "memo", type: "string" }
587
+ ],
588
+ name: "transferOutAndCall",
589
+ outputs: [],
590
+ stateMutability: "payable",
591
+ type: "function"
592
+ },
593
+ {
594
+ inputs: [
595
+ { internalType: "address", name: "vault", type: "address" },
596
+ { internalType: "address", name: "token", type: "address" }
597
+ ],
598
+ name: "vaultAllowance",
599
+ outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
600
+ stateMutability: "view",
601
+ type: "function"
602
+ }
603
+ ];
604
+ // src/types/network.ts
605
+ var RPCUrl;
606
+ (function(RPCUrl2) {
607
+ RPCUrl2["Arbitrum"] = "https://arb1.arbitrum.io/rpc";
608
+ RPCUrl2["Avalanche"] = "https://node-router.thorswap.net/avalanche-c";
609
+ RPCUrl2["Binance"] = "";
610
+ RPCUrl2["BinanceSmartChain"] = "https://bsc-dataseed.binance.org";
611
+ RPCUrl2["Bitcoin"] = "https://node-router.thorswap.net/bitcoin";
612
+ RPCUrl2["BitcoinCash"] = "https://node-router.thorswap.net/bitcoin-cash";
613
+ RPCUrl2["Chainflip"] = "wss://mainnet-archive.chainflip.io";
614
+ RPCUrl2["Cosmos"] = "https://node-router.thorswap.net/cosmos/rpc";
615
+ RPCUrl2["Dash"] = "https://node-router.thorswap.net/dash";
616
+ RPCUrl2["Dogecoin"] = "https://node-router.thorswap.net/dogecoin";
617
+ RPCUrl2["Ethereum"] = "https://node-router.thorswap.net/ethereum";
618
+ RPCUrl2["Kujira"] = "https://rpc-kujira.synergynodes.com/";
619
+ RPCUrl2["Litecoin"] = "https://node-router.thorswap.net/litecoin";
620
+ RPCUrl2["Maya"] = "https://tendermint.mayachain.info";
621
+ RPCUrl2["MayaStagenet"] = "https://stagenet.tendermint.mayachain.info";
622
+ RPCUrl2["Optimism"] = "https://mainnet.optimism.io";
623
+ RPCUrl2["Polkadot"] = "wss://rpc.polkadot.io";
624
+ RPCUrl2["Polygon"] = "https://polygon-rpc.com";
625
+ RPCUrl2["THORChain"] = "https://rpc.thorswap.net";
626
+ RPCUrl2["THORChainStagenet"] = "https://stagenet-rpc.ninerealms.com";
627
+ })(RPCUrl || (RPCUrl = {}));
628
+ var ExplorerUrl;
629
+ (function(ExplorerUrl2) {
630
+ ExplorerUrl2["Arbitrum"] = "https://arbiscan.io";
631
+ ExplorerUrl2["Avalanche"] = "https://snowtrace.io";
632
+ ExplorerUrl2["Binance"] = "https://explorer.binance.org";
633
+ ExplorerUrl2["BinanceSmartChain"] = "https://bscscan.com";
634
+ ExplorerUrl2["Bitcoin"] = "https://blockchair.com/bitcoin";
635
+ ExplorerUrl2["BitcoinCash"] = "https://www.blockchair.com/bitcoin-cash";
636
+ ExplorerUrl2["Chainflip"] = "https://explorer.polkascan.io/polkadot";
637
+ ExplorerUrl2["Cosmos"] = "https://www.mintscan.io/cosmos";
638
+ ExplorerUrl2["Dash"] = "https://blockchair.com/dash";
639
+ ExplorerUrl2["Dogecoin"] = "https://blockchair.com/dogecoin";
640
+ ExplorerUrl2["Ethereum"] = "https://etherscan.io";
641
+ ExplorerUrl2["Kujira"] = "https://finder.kujira.network/kaiyo-1";
642
+ ExplorerUrl2["Litecoin"] = "https://blockchair.com/litecoin";
643
+ ExplorerUrl2["Maya"] = "https://www.mayascan.org";
644
+ ExplorerUrl2["Optimism"] = "https://optimistic.etherscan.io";
645
+ ExplorerUrl2["Polkadot"] = "https://polkadot.subscan.io/";
646
+ ExplorerUrl2["Polygon"] = "https://polygonscan.com";
647
+ ExplorerUrl2["THORChain"] = "https://runescan.io";
648
+ })(ExplorerUrl || (ExplorerUrl = {}));
649
+
650
+ // src/types/chains.ts
651
+ var Chain;
652
+ (function(Chain2) {
653
+ Chain2["Arbitrum"] = "ARB";
654
+ Chain2["Avalanche"] = "AVAX";
655
+ Chain2["Binance"] = "BNB";
656
+ Chain2["BinanceSmartChain"] = "BSC";
657
+ Chain2["Bitcoin"] = "BTC";
658
+ Chain2["BitcoinCash"] = "BCH";
659
+ Chain2["Cosmos"] = "GAIA";
660
+ Chain2["Dash"] = "DASH";
661
+ Chain2["Dogecoin"] = "DOGE";
662
+ Chain2["Ethereum"] = "ETH";
663
+ Chain2["Kujira"] = "KUJI";
664
+ Chain2["Litecoin"] = "LTC";
665
+ Chain2["Maya"] = "MAYA";
666
+ Chain2["Optimism"] = "OP";
667
+ Chain2["Polkadot"] = "DOT";
668
+ Chain2["Chainflip"] = "FLIP";
669
+ Chain2["Polygon"] = "MATIC";
670
+ Chain2["THORChain"] = "THOR";
671
+ })(Chain || (Chain = {}));
672
+ var ChainId;
673
+ (function(ChainId2) {
674
+ ChainId2["Arbitrum"] = "42161";
675
+ ChainId2["ArbitrumHex"] = "0xa4b1";
676
+ ChainId2["Avalanche"] = "43114";
677
+ ChainId2["AvalancheHex"] = "0xa86a";
678
+ ChainId2["Binance"] = "Binance-Chain-Tigris";
679
+ ChainId2["BinanceSmartChain"] = "56";
680
+ ChainId2["BinanceSmartChainHex"] = "0x38";
681
+ ChainId2["Bitcoin"] = "bitcoin";
682
+ ChainId2["BitcoinCash"] = "bitcoincash";
683
+ ChainId2["Chainflip"] = "chainflip";
684
+ ChainId2["Cosmos"] = "cosmoshub-4";
685
+ ChainId2["Dash"] = "dash";
686
+ ChainId2["Dogecoin"] = "dogecoin";
687
+ ChainId2["Kujira"] = "kaiyo-1";
688
+ ChainId2["Ethereum"] = "1";
689
+ ChainId2["EthereumHex"] = "0x1";
690
+ ChainId2["Litecoin"] = "litecoin";
691
+ ChainId2["Maya"] = "mayachain-mainnet-v1";
692
+ ChainId2["MayaStagenet"] = "mayachain-stagenet-v1";
693
+ ChainId2["Optimism"] = "10";
694
+ ChainId2["OptimismHex"] = "0xa";
695
+ ChainId2["Polkadot"] = "polkadot";
696
+ ChainId2["Polygon"] = "137";
697
+ ChainId2["PolygonHex"] = "0x89";
698
+ ChainId2["THORChain"] = "thorchain-mainnet-v1";
699
+ ChainId2["THORChainStagenet"] = "thorchain-stagenet-v2";
700
+ })(ChainId || (ChainId = {}));
701
+ var ChainIdToChain = {
702
+ [ChainId.ArbitrumHex]: Chain.Arbitrum,
703
+ [ChainId.Arbitrum]: Chain.Arbitrum,
704
+ [ChainId.AvalancheHex]: Chain.Avalanche,
705
+ [ChainId.Avalanche]: Chain.Avalanche,
706
+ [ChainId.BinanceSmartChainHex]: Chain.BinanceSmartChain,
707
+ [ChainId.BinanceSmartChain]: Chain.BinanceSmartChain,
708
+ [ChainId.Binance]: Chain.Binance,
709
+ [ChainId.BitcoinCash]: Chain.BitcoinCash,
710
+ [ChainId.Bitcoin]: Chain.Bitcoin,
711
+ [ChainId.Chainflip]: Chain.Chainflip,
712
+ [ChainId.Cosmos]: Chain.Cosmos,
713
+ [ChainId.Dash]: Chain.Dash,
714
+ [ChainId.Dogecoin]: Chain.Dogecoin,
715
+ [ChainId.EthereumHex]: Chain.Ethereum,
716
+ [ChainId.Kujira]: Chain.Kujira,
717
+ [ChainId.Ethereum]: Chain.Ethereum,
718
+ [ChainId.Litecoin]: Chain.Litecoin,
719
+ [ChainId.MayaStagenet]: Chain.Maya,
720
+ [ChainId.Maya]: Chain.Maya,
721
+ [ChainId.OptimismHex]: Chain.Optimism,
722
+ [ChainId.Optimism]: Chain.Optimism,
723
+ [ChainId.Polkadot]: Chain.Polkadot,
724
+ [ChainId.PolygonHex]: Chain.Polygon,
725
+ [ChainId.Polygon]: Chain.Polygon,
726
+ [ChainId.THORChainStagenet]: Chain.THORChain,
727
+ [ChainId.THORChain]: Chain.THORChain
728
+ };
729
+ var chainNames = Object.keys(Chain);
730
+ var chains = Object.values(Chain);
731
+ var BaseDecimal;
732
+ (function(BaseDecimal2) {
733
+ BaseDecimal2[BaseDecimal2["ARB"] = 18] = "ARB";
734
+ BaseDecimal2[BaseDecimal2["AVAX"] = 18] = "AVAX";
735
+ BaseDecimal2[BaseDecimal2["BCH"] = 8] = "BCH";
736
+ BaseDecimal2[BaseDecimal2["BNB"] = 8] = "BNB";
737
+ BaseDecimal2[BaseDecimal2["BSC"] = 18] = "BSC";
738
+ BaseDecimal2[BaseDecimal2["BTC"] = 8] = "BTC";
739
+ BaseDecimal2[BaseDecimal2["DASH"] = 8] = "DASH";
740
+ BaseDecimal2[BaseDecimal2["DOGE"] = 8] = "DOGE";
741
+ BaseDecimal2[BaseDecimal2["DOT"] = 10] = "DOT";
742
+ BaseDecimal2[BaseDecimal2["ETH"] = 18] = "ETH";
743
+ BaseDecimal2[BaseDecimal2["FLIP"] = 18] = "FLIP";
744
+ BaseDecimal2[BaseDecimal2["GAIA"] = 6] = "GAIA";
745
+ BaseDecimal2[BaseDecimal2["KUJI"] = 6] = "KUJI";
746
+ BaseDecimal2[BaseDecimal2["LTC"] = 8] = "LTC";
747
+ BaseDecimal2[BaseDecimal2["MATIC"] = 18] = "MATIC";
748
+ BaseDecimal2[BaseDecimal2["MAYA"] = 10] = "MAYA";
749
+ BaseDecimal2[BaseDecimal2["OP"] = 18] = "OP";
750
+ BaseDecimal2[BaseDecimal2["THOR"] = 8] = "THOR";
751
+ BaseDecimal2[BaseDecimal2["ZEC"] = 8] = "ZEC";
752
+ })(BaseDecimal || (BaseDecimal = {}));
753
+ var SubstrateChains = [Chain.Polkadot, Chain.Chainflip];
754
+ var EVMChains = [
755
+ Chain.Ethereum,
756
+ Chain.Avalanche,
757
+ Chain.BinanceSmartChain,
758
+ Chain.Arbitrum,
759
+ Chain.Optimism,
760
+ Chain.Polygon
761
+ ];
762
+ var UTXOChains = [
763
+ Chain.Bitcoin,
764
+ Chain.BitcoinCash,
765
+ Chain.Dash,
766
+ Chain.Dogecoin,
767
+ Chain.Litecoin
768
+ ];
769
+ var CosmosChains = [
770
+ Chain.Cosmos,
771
+ Chain.THORChain,
772
+ Chain.Binance,
773
+ Chain.Maya,
774
+ Chain.Kujira
775
+ ];
776
+ var TCSupportedChains = [
777
+ Chain.Avalanche,
778
+ Chain.Binance,
779
+ Chain.BinanceSmartChain,
780
+ Chain.Bitcoin,
781
+ Chain.BitcoinCash,
782
+ Chain.Cosmos,
783
+ Chain.Dogecoin,
784
+ Chain.Ethereum,
785
+ Chain.Litecoin,
786
+ Chain.THORChain
787
+ ];
788
+ var MAYASupportedChains = [
789
+ Chain.Arbitrum,
790
+ Chain.Dash,
791
+ Chain.Ethereum,
792
+ Chain.Kujira,
793
+ Chain.Maya,
794
+ Chain.THORChain
795
+ ];
796
+ var ChainToChainName = chains.reduce((acc, chain) => {
797
+ const chainName = chainNames.find((key) => Chain[key] === chain);
798
+ if (chainName)
799
+ acc[chain] = chainName;
800
+ return acc;
801
+ }, {});
802
+ var ChainToChainId = chains.reduce((acc, chain) => {
803
+ acc[chain] = ChainId[ChainToChainName[chain]];
804
+ return acc;
805
+ }, {});
806
+ var ChainToRPC = chains.reduce((acc, chain) => {
807
+ acc[chain] = RPCUrl[ChainToChainName[chain]];
808
+ return acc;
809
+ }, {});
810
+ var ChainToHexChainId = chains.reduce((acc, chain) => {
811
+ const chainString = `${ChainToChainName[chain]}Hex`;
812
+ acc[chain] = ChainId[chainString];
813
+ return acc;
814
+ }, {});
815
+ var ChainToExplorerUrl = chains.reduce((acc, chain) => {
816
+ acc[chain] = ExplorerUrl[ChainToChainName[chain]];
817
+ return acc;
818
+ }, {});
819
+ // src/types/commonTypes.ts
820
+ var QuoteMode;
821
+ (function(QuoteMode2) {
822
+ QuoteMode2["TC_SUPPORTED_TO_TC_SUPPORTED"] = "TC-TC";
823
+ QuoteMode2["TC_SUPPORTED_TO_ETH"] = "TC-ERC20";
824
+ QuoteMode2["TC_SUPPORTED_TO_AVAX"] = "TC-ARC20";
825
+ QuoteMode2["TC_SUPPORTED_TO_BSC"] = "TC-BEP20";
826
+ QuoteMode2["ETH_TO_TC_SUPPORTED"] = "ERC20-TC";
827
+ QuoteMode2["ETH_TO_ETH"] = "ERC20-ERC20";
828
+ QuoteMode2["ETH_TO_AVAX"] = "ERC20-ARC20";
829
+ QuoteMode2["ETH_TO_BSC"] = "ERC20-BEP20";
830
+ QuoteMode2["AVAX_TO_TC_SUPPORTED"] = "ARC20-TC";
831
+ QuoteMode2["AVAX_TO_ETH"] = "ARC20-ERC20";
832
+ QuoteMode2["AVAX_TO_AVAX"] = "ARC20-ARC20";
833
+ QuoteMode2["AVAX_TO_BSC"] = "ARC20-BEP20";
834
+ QuoteMode2["BSC_TO_TC_SUPPORTED"] = "BEP20-TC";
835
+ QuoteMode2["BSC_TO_ETH"] = "BEP20-ERC20";
836
+ QuoteMode2["BSC_TO_AVAX"] = "BEP20-ARC20";
837
+ QuoteMode2["BSC_TO_BSC"] = "BEP20-BEP20";
838
+ })(QuoteMode || (QuoteMode = {}));
839
+ var AGG_SWAP = [QuoteMode.ETH_TO_ETH, QuoteMode.AVAX_TO_AVAX, QuoteMode.BSC_TO_BSC];
840
+ var SWAP_IN = [
841
+ QuoteMode.ETH_TO_TC_SUPPORTED,
842
+ QuoteMode.ETH_TO_AVAX,
843
+ QuoteMode.ETH_TO_BSC,
844
+ QuoteMode.AVAX_TO_TC_SUPPORTED,
845
+ QuoteMode.AVAX_TO_ETH,
846
+ QuoteMode.AVAX_TO_BSC,
847
+ QuoteMode.BSC_TO_TC_SUPPORTED,
848
+ QuoteMode.BSC_TO_ETH,
849
+ QuoteMode.BSC_TO_AVAX
850
+ ];
851
+ var SWAP_OUT = [
852
+ QuoteMode.TC_SUPPORTED_TO_TC_SUPPORTED,
853
+ QuoteMode.TC_SUPPORTED_TO_ETH,
854
+ QuoteMode.TC_SUPPORTED_TO_AVAX,
855
+ QuoteMode.TC_SUPPORTED_TO_BSC
856
+ ];
857
+ // src/types/derivationPath.ts
858
+ var ContractAddress;
859
+ (function(ContractAddress2) {
860
+ ContractAddress2["ARB"] = "0x0000000000000000000000000000000000000000";
861
+ ContractAddress2["AVAX"] = "0x0000000000000000000000000000000000000000";
862
+ ContractAddress2["ETH"] = "0x0000000000000000000000000000000000000000";
863
+ ContractAddress2["BSC"] = "0x0000000000000000000000000000000000000000";
864
+ ContractAddress2["MATIC"] = "0x0000000000000000000000000000000000001010";
865
+ ContractAddress2["OP"] = "0x4200000000000000000000000000000000000042";
866
+ })(ContractAddress || (ContractAddress = {}));
867
+ var DerivationPath;
868
+ (function(DerivationPath2) {
869
+ DerivationPath2["ARB"] = "m/44'/60'/0'/0";
870
+ DerivationPath2["AVAX"] = "m/44'/60'/0'/0";
871
+ DerivationPath2["BCH"] = "m/44'/145'/0'/0";
872
+ DerivationPath2["BNB"] = "m/44'/714'/0'/0";
873
+ DerivationPath2["BSC"] = "m/44'/60'/0'/0";
874
+ DerivationPath2["BTC"] = "m/84'/0'/0'/0";
875
+ DerivationPath2["DASH"] = "m/44'/5'/0'/0";
876
+ DerivationPath2["DOGE"] = "m/44'/3'/0'/0";
877
+ DerivationPath2["DOT"] = "////";
878
+ DerivationPath2["ETH"] = "m/44'/60'/0'/0";
879
+ DerivationPath2["FLIP"] = "////";
880
+ DerivationPath2["GAIA"] = "m/44'/118'/0'/0";
881
+ DerivationPath2["KUJI"] = "m/44'/118'/0'/0";
882
+ DerivationPath2["LTC"] = "m/84'/2'/0'/0";
883
+ DerivationPath2["MATIC"] = "m/44'/60'/0'/0";
884
+ DerivationPath2["MAYA"] = "m/44'/931'/0'/0";
885
+ DerivationPath2["OP"] = "m/44'/60'/0'/0";
886
+ DerivationPath2["THOR"] = "m/44'/931'/0'/0";
887
+ })(DerivationPath || (DerivationPath = {}));
888
+ var NetworkDerivationPath = {
889
+ ARB: [44, 60, 0, 0, 0],
890
+ AVAX: [44, 60, 0, 0, 0],
891
+ BCH: [44, 145, 0, 0, 0],
892
+ BNB: [44, 714, 0, 0, 0],
893
+ BSC: [44, 60, 0, 0, 0],
894
+ BTC: [84, 0, 0, 0, 0],
895
+ DASH: [44, 5, 0, 0, 0],
896
+ DOGE: [44, 3, 0, 0, 0],
897
+ ETH: [44, 60, 0, 0, 0],
898
+ GAIA: [44, 118, 0, 0, 0],
899
+ KUJI: [44, 118, 0, 0, 0],
900
+ LTC: [84, 2, 0, 0, 0],
901
+ MATIC: [44, 60, 0, 0, 0],
902
+ MAYA: [44, 931, 0, 0, 0],
903
+ OP: [44, 60, 0, 0, 0],
904
+ THOR: [44, 931, 0, 0, 0],
905
+ DOT: [0, 0, 0, 0, 0],
906
+ FLIP: [0, 0, 0, 0, 0]
907
+ };
908
+ // src/types/transactions.ts
909
+ var FeeOption;
910
+ (function(FeeOption2) {
911
+ FeeOption2["Average"] = "average";
912
+ FeeOption2["Fast"] = "fast";
913
+ FeeOption2["Fastest"] = "fastest";
914
+ })(FeeOption || (FeeOption = {}));
915
+ var ApproveMode;
916
+ (function(ApproveMode2) {
917
+ ApproveMode2["Approve"] = "approve";
918
+ ApproveMode2["CheckOnly"] = "checkOnly";
919
+ })(ApproveMode || (ApproveMode = {}));
920
+ var MemoType;
921
+ (function(MemoType2) {
922
+ MemoType2["BOND"] = "BOND";
923
+ MemoType2["DEPOSIT"] = "+";
924
+ MemoType2["LEAVE"] = "LEAVE";
925
+ MemoType2["THORNAME_REGISTER"] = "~";
926
+ MemoType2["UNBOND"] = "UNBOND";
927
+ MemoType2["WITHDRAW"] = "-";
928
+ MemoType2["OPEN_LOAN"] = "$+";
929
+ MemoType2["CLOSE_LOAN"] = "$-";
930
+ })(MemoType || (MemoType = {}));
931
+ // src/types/wallet.ts
932
+ var WalletOption;
933
+ (function(WalletOption2) {
934
+ WalletOption2["KEYSTORE"] = "KEYSTORE";
935
+ WalletOption2["KEEPKEY"] = "KEEPKEY";
936
+ WalletOption2["XDEFI"] = "XDEFI";
937
+ WalletOption2["METAMASK"] = "METAMASK";
938
+ WalletOption2["COINBASE_WEB"] = "COINBASE_WEB";
939
+ WalletOption2["COINBASE_MOBILE"] = "COINBASE_MOBILE";
940
+ WalletOption2["TREZOR"] = "TREZOR";
941
+ WalletOption2["TRUSTWALLET_WEB"] = "TRUSTWALLET_WEB";
942
+ WalletOption2["LEDGER"] = "LEDGER";
943
+ WalletOption2["KEPLR"] = "KEPLR";
944
+ WalletOption2["OKX"] = "OKX";
945
+ WalletOption2["OKX_MOBILE"] = "OKX_MOBILE";
946
+ WalletOption2["BRAVE"] = "BRAVE";
947
+ WalletOption2["WALLETCONNECT"] = "WALLETCONNECT";
948
+ })(WalletOption || (WalletOption = {}));
949
+ var LedgerErrorCode;
950
+ (function(LedgerErrorCode2) {
951
+ LedgerErrorCode2[LedgerErrorCode2["NoError"] = 36864] = "NoError";
952
+ LedgerErrorCode2[LedgerErrorCode2["LockedDevice"] = 21781] = "LockedDevice";
953
+ LedgerErrorCode2[LedgerErrorCode2["TC_NotFound"] = 65535] = "TC_NotFound";
954
+ })(LedgerErrorCode || (LedgerErrorCode = {}));
955
+ // src/modules/requestClient.ts
956
+ import ky from "ky";
957
+ function setRequestClientConfig({ apiKey, ...config }) {
958
+ kyClient = ky.create({
959
+ ...config,
960
+ headers: { ...defaultRequestHeaders, ...config.headers, "x-api-key": apiKey }
961
+ });
962
+ }
963
+ var getKyClient = function() {
964
+ if (kyClient)
965
+ return kyClient;
966
+ kyClient = ky.create({ headers: defaultRequestHeaders });
967
+ return kyClient;
968
+ };
969
+ var kyClient;
970
+ var defaultRequestHeaders = typeof window !== "undefined" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" };
971
+ var RequestClient = {
972
+ get: (url, options) => getKyClient().get(url, options).json(),
973
+ post: (url, options) => getKyClient().post(url, options).json()
974
+ };
975
+
976
+ // src/helpers/asset.ts
977
+ async function findAssetBy(params) {
978
+ const tokenPackages = await import("@swapkit/tokens");
979
+ for (const tokenList of Object.values(tokenPackages)) {
980
+ for (const { identifier, chain: tokenChain, ...rest } of tokenList.tokens) {
981
+ if ("identifier" in params && identifier === params.identifier) {
982
+ return identifier;
983
+ }
984
+ if ("address" in rest && "chain" in params && tokenChain === params.chain && rest.address.toLowerCase() === params.contract.toLowerCase())
985
+ return identifier;
986
+ }
987
+ }
988
+ return;
989
+ }
990
+ var getDecimalMethodHex = "0x313ce567";
991
+ var getContractDecimals = async ({ chain, to }) => {
992
+ try {
993
+ const { result } = await RequestClient.post(ChainToRPC[chain], {
994
+ headers: {
995
+ accept: "*/*",
996
+ "content-type": "application/json",
997
+ "cache-control": "no-cache"
998
+ },
999
+ body: JSON.stringify({
1000
+ id: 44,
1001
+ jsonrpc: "2.0",
1002
+ method: "eth_call",
1003
+ params: [{ to: to.toLowerCase(), data: getDecimalMethodHex }, "latest"]
1004
+ })
1005
+ });
1006
+ return Number.parseInt(BigInt(result || BaseDecimal[chain]).toString());
1007
+ } catch (error) {
1008
+ console.error(error);
1009
+ return BaseDecimal[chain];
1010
+ }
1011
+ };
1012
+ var getETHAssetDecimal = (symbol) => {
1013
+ if (symbol === Chain.Ethereum)
1014
+ return BaseDecimal.ETH;
1015
+ const [, address] = symbol.split("-");
1016
+ return address?.startsWith("0x") ? getContractDecimals({ chain: Chain.Ethereum, to: address }) : BaseDecimal.ETH;
1017
+ };
1018
+ var getAVAXAssetDecimal = (symbol) => {
1019
+ const [, address] = symbol.split("-");
1020
+ return address?.startsWith("0x") ? getContractDecimals({ chain: Chain.Avalanche, to: address.toLowerCase() }) : BaseDecimal.AVAX;
1021
+ };
1022
+ var getBSCAssetDecimal = (symbol) => {
1023
+ if (symbol === Chain.BinanceSmartChain)
1024
+ return BaseDecimal.BSC;
1025
+ return BaseDecimal.BSC;
1026
+ };
1027
+ var getDecimal = ({ chain, symbol }) => {
1028
+ switch (chain) {
1029
+ case Chain.Ethereum:
1030
+ return getETHAssetDecimal(symbol);
1031
+ case Chain.Avalanche:
1032
+ return getAVAXAssetDecimal(symbol);
1033
+ case Chain.BinanceSmartChain:
1034
+ return getBSCAssetDecimal(symbol);
1035
+ default:
1036
+ return BaseDecimal[chain];
1037
+ }
1038
+ };
1039
+ var gasFeeMultiplier = {
1040
+ [FeeOption.Average]: 1.2,
1041
+ [FeeOption.Fast]: 1.5,
1042
+ [FeeOption.Fastest]: 2
1043
+ };
1044
+ var isGasAsset = ({ chain, symbol }) => {
1045
+ switch (chain) {
1046
+ case Chain.Arbitrum:
1047
+ case Chain.Optimism:
1048
+ return symbol === "ETH";
1049
+ case Chain.Maya:
1050
+ return symbol === "CACAO";
1051
+ case Chain.Kujira:
1052
+ return symbol === "KUJI";
1053
+ case Chain.Cosmos:
1054
+ return symbol === "ATOM";
1055
+ case Chain.Polygon:
1056
+ return symbol === "MATIC";
1057
+ case Chain.BinanceSmartChain:
1058
+ return symbol === "BNB";
1059
+ case Chain.THORChain:
1060
+ return symbol === "RUNE";
1061
+ default:
1062
+ return symbol === chain;
1063
+ }
1064
+ };
1065
+ var getCommonAssetInfo = (assetString) => {
1066
+ switch (assetString) {
1067
+ case `${Chain.Ethereum}.THOR`:
1068
+ return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
1069
+ case `${Chain.Ethereum}.vTHOR`:
1070
+ return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
1071
+ case Chain.Cosmos:
1072
+ return { identifier: "GAIA.ATOM", decimal: BaseDecimal[assetString] };
1073
+ case Chain.THORChain:
1074
+ return { identifier: "THOR.RUNE", decimal: BaseDecimal[assetString] };
1075
+ case Chain.BinanceSmartChain:
1076
+ return { identifier: "BSC.BNB", decimal: BaseDecimal[assetString] };
1077
+ case Chain.Maya:
1078
+ return { identifier: "MAYA.CACAO", decimal: BaseDecimal.MAYA };
1079
+ case `${Chain.Maya}.MAYA`:
1080
+ return { identifier: "MAYA.MAYA", decimal: 4 };
1081
+ case `${Chain.Kujira}.USK`:
1082
+ return { identifier: `${Chain.Kujira}.USK`, decimal: 6 };
1083
+ default:
1084
+ return { identifier: `${assetString}.${assetString}`, decimal: BaseDecimal[assetString] };
1085
+ }
1086
+ };
1087
+ var getAssetType = ({ chain, symbol }) => {
1088
+ if (symbol.includes("/"))
1089
+ return "Synth";
1090
+ switch (chain) {
1091
+ case Chain.Cosmos:
1092
+ return symbol === "ATOM" ? "Native" : Chain.Cosmos;
1093
+ case Chain.Kujira:
1094
+ return symbol === Chain.Kujira ? "Native" : Chain.Kujira;
1095
+ case Chain.Binance:
1096
+ return symbol === Chain.Binance ? "Native" : "BEP2";
1097
+ case Chain.BinanceSmartChain:
1098
+ return symbol === Chain.Binance ? "Native" : "BEP20";
1099
+ case Chain.Ethereum:
1100
+ return symbol === Chain.Ethereum ? "Native" : "ERC20";
1101
+ case Chain.Avalanche:
1102
+ return symbol === Chain.Avalanche ? "Native" : Chain.Avalanche;
1103
+ case Chain.Polygon:
1104
+ return symbol === Chain.Polygon ? "Native" : "POLYGON";
1105
+ case Chain.Arbitrum:
1106
+ return [Chain.Ethereum, Chain.Arbitrum].includes(symbol) ? "Native" : "ARBITRUM";
1107
+ case Chain.Optimism:
1108
+ return [Chain.Ethereum, Chain.Optimism].includes(symbol) ? "Native" : "OPTIMISM";
1109
+ default:
1110
+ return "Native";
1111
+ }
1112
+ };
1113
+ var assetFromString = (assetString) => {
1114
+ const [chain, ...symbolArray] = assetString.split(".");
1115
+ const synth = assetString.includes("/");
1116
+ const symbol = symbolArray.join(".");
1117
+ const ticker = symbol?.split("-")?.[0];
1118
+ return { chain, symbol, ticker, synth };
1119
+ };
1120
+ var potentialScamRegex = new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/, "gmi");
1121
+ var evmAssetHasAddress = (assetString) => {
1122
+ const [chain, symbol] = assetString.split(".");
1123
+ if (!EVMChains.includes(chain))
1124
+ return true;
1125
+ const [, address] = symbol.split("-");
1126
+ return isGasAsset({ chain, symbol }) || !!address;
1127
+ };
1128
+ var filterAssets = (tokens2) => tokens2.filter(({ chain, value, symbol }) => {
1129
+ const assetString = `${chain}.${symbol}`;
1130
+ return !potentialScamRegex.test(assetString) && evmAssetHasAddress(assetString) && value !== "0";
1131
+ });
1132
+ // src/helpers/liquidity.ts
1133
+ function getAsymmetricRuneShare({
1134
+ liquidityUnits,
1135
+ poolUnits,
1136
+ runeDepth
1137
+ }) {
1138
+ const s = toTCSwapKitNumber(liquidityUnits);
1139
+ const T = toTCSwapKitNumber(poolUnits);
1140
+ const A = toTCSwapKitNumber(runeDepth);
1141
+ const part1 = s.mul(A);
1142
+ const part2 = T.mul(T).mul(2);
1143
+ const part3 = T.mul(s).mul(2);
1144
+ const part4 = s.mul(s);
1145
+ const part5 = T.mul(T).mul(T);
1146
+ const numerator = part1.mul(part2.sub(part3).add(part4));
1147
+ return numerator.div(part5);
1148
+ }
1149
+ function getAsymmetricAssetShare({
1150
+ liquidityUnits,
1151
+ poolUnits,
1152
+ assetDepth
1153
+ }) {
1154
+ const s = toTCSwapKitNumber(liquidityUnits);
1155
+ const T = toTCSwapKitNumber(poolUnits);
1156
+ const A = toTCSwapKitNumber(assetDepth);
1157
+ const part1 = s.mul(A);
1158
+ const part2 = T.mul(T).mul(2);
1159
+ const part3 = T.mul(s).mul(2);
1160
+ const part4 = s.mul(s);
1161
+ const numerator = part1.mul(part2.sub(part3).add(part4));
1162
+ const part5 = T.mul(T).mul(T);
1163
+ return numerator.div(part5);
1164
+ }
1165
+ function getAsymmetricRuneWithdrawAmount({
1166
+ percent,
1167
+ runeDepth,
1168
+ liquidityUnits,
1169
+ poolUnits
1170
+ }) {
1171
+ return getAsymmetricRuneShare({ runeDepth, liquidityUnits, poolUnits }).mul(percent);
1172
+ }
1173
+ function getAsymmetricAssetWithdrawAmount({
1174
+ percent,
1175
+ assetDepth,
1176
+ liquidityUnits,
1177
+ poolUnits
1178
+ }) {
1179
+ return getAsymmetricAssetShare({ assetDepth, liquidityUnits, poolUnits }).mul(percent);
1180
+ }
1181
+ var toTCSwapKitNumber = function(value) {
1182
+ return SwapKitNumber.fromBigInt(BigInt(value), BaseDecimal.THOR);
1183
+ };
1184
+ function getSymmetricPoolShare({
1185
+ liquidityUnits,
1186
+ poolUnits,
1187
+ runeDepth,
1188
+ assetDepth
1189
+ }) {
1190
+ return {
1191
+ assetAmount: toTCSwapKitNumber(assetDepth).mul(liquidityUnits).div(poolUnits),
1192
+ runeAmount: toTCSwapKitNumber(runeDepth).mul(liquidityUnits).div(poolUnits)
1193
+ };
1194
+ }
1195
+ function getSymmetricWithdraw({
1196
+ liquidityUnits,
1197
+ poolUnits,
1198
+ runeDepth,
1199
+ assetDepth,
1200
+ percent
1201
+ }) {
1202
+ return Object.fromEntries(Object.entries(getSymmetricPoolShare({ liquidityUnits, poolUnits, runeDepth, assetDepth })).map(([name, value]) => [name, value.mul(percent)]));
1203
+ }
1204
+ function getEstimatedPoolShare({
1205
+ runeDepth,
1206
+ poolUnits,
1207
+ assetDepth,
1208
+ liquidityUnits,
1209
+ runeAmount,
1210
+ assetAmount
1211
+ }) {
1212
+ const R = new SwapKitNumber({ value: runeDepth, decimal: 8 });
1213
+ const A = new SwapKitNumber({ value: assetDepth, decimal: 8 });
1214
+ const P = new SwapKitNumber({ value: poolUnits, decimal: 8 });
1215
+ const runeAddAmount = new SwapKitNumber({ value: runeAmount, decimal: 8 });
1216
+ const assetAddAmount = new SwapKitNumber({ value: assetAmount, decimal: 8 });
1217
+ const rA = runeAddAmount.mul(A);
1218
+ const aR = assetAddAmount.mul(R);
1219
+ const ra = runeAddAmount.mul(assetAddAmount);
1220
+ const RA = R.mul(A);
1221
+ const numerator = P.mul(rA.add(aR.add(ra.mul(2))));
1222
+ const denominator = rA.add(aR.add(RA.mul(2)));
1223
+ const liquidityUnitsAfterAdd = numerator.div(denominator);
1224
+ const estimatedLiquidityUnits = toTCSwapKitNumber(liquidityUnits).add(liquidityUnitsAfterAdd);
1225
+ if (liquidityUnitsAfterAdd.getBaseValue("number") === 0) {
1226
+ return estimatedLiquidityUnits.div(P).getBaseValue("number");
1227
+ }
1228
+ const newPoolUnits = P.add(estimatedLiquidityUnits);
1229
+ return estimatedLiquidityUnits.div(newPoolUnits).getBaseValue("number");
1230
+ }
1231
+ function getLiquiditySlippage({
1232
+ runeAmount,
1233
+ assetAmount,
1234
+ runeDepth,
1235
+ assetDepth
1236
+ }) {
1237
+ if (runeAmount === "0" || assetAmount === "0" || runeDepth === "0" || assetDepth === "0")
1238
+ return 0;
1239
+ const R = toTCSwapKitNumber(runeDepth);
1240
+ const T = toTCSwapKitNumber(assetDepth);
1241
+ const assetAddAmount = toTCSwapKitNumber(assetAmount);
1242
+ const runeAddAmount = toTCSwapKitNumber(runeAmount);
1243
+ const numerator = assetAddAmount.mul(R).sub(T.mul(runeAddAmount));
1244
+ const denominator = T.mul(runeAddAmount).add(R.mul(T));
1245
+ return Math.abs(numerator.div(denominator).getBaseValue("number"));
1246
+ }
1247
+ // src/helpers/memo.ts
1248
+ var getMemoFor = (memoType, options) => {
1249
+ switch (memoType) {
1250
+ case MemoType.LEAVE:
1251
+ case MemoType.BOND: {
1252
+ const { address } = options;
1253
+ return `${memoType}:${address}`;
1254
+ }
1255
+ case MemoType.UNBOND: {
1256
+ const { address, unbondAmount } = options;
1257
+ return `${memoType}:${address}:${unbondAmount}`;
1258
+ }
1259
+ case MemoType.THORNAME_REGISTER: {
1260
+ const { name, chain, address, owner } = options;
1261
+ return `${memoType}:${name}:${chain}:${address}${owner ? `:${owner}` : ""}`;
1262
+ }
1263
+ case MemoType.DEPOSIT: {
1264
+ const { chain, symbol, address, singleSide } = options;
1265
+ const getPoolIdentifier = (chain2, symbol2) => {
1266
+ switch (chain2) {
1267
+ case Chain.Litecoin:
1268
+ return "l";
1269
+ case Chain.Dogecoin:
1270
+ return "d";
1271
+ case Chain.BitcoinCash:
1272
+ return "c";
1273
+ default:
1274
+ return `${chain2}.${symbol2}`;
1275
+ }
1276
+ };
1277
+ return singleSide ? `${memoType}:${chain}/${symbol}` : `${memoType}:${getPoolIdentifier(chain, symbol)}:${address || ""}`;
1278
+ }
1279
+ case MemoType.WITHDRAW: {
1280
+ const { chain, ticker, symbol, basisPoints, targetAssetString, singleSide } = options;
1281
+ const shortenedSymbol = chain === "ETH" && ticker !== "ETH" ? `${ticker}-${symbol.slice(-3)}` : symbol;
1282
+ const target = !singleSide && targetAssetString ? `:${targetAssetString}` : "";
1283
+ const assetDivider = singleSide ? "/" : ".";
1284
+ return `${memoType}:${chain}${assetDivider}${shortenedSymbol}:${basisPoints}${target}`;
1285
+ }
1286
+ case MemoType.OPEN_LOAN:
1287
+ case MemoType.CLOSE_LOAN: {
1288
+ const { asset, address } = options;
1289
+ return `${memoType}:${asset}:${address}`;
1290
+ }
1291
+ default:
1292
+ return "";
1293
+ }
1294
+ };
1295
+ // src/modules/swapKitError.ts
1296
+ var errorMessages = {
1297
+ core_wallet_connection_not_found: 10001,
1298
+ core_estimated_max_spendable_chain_not_supported: 10002,
1299
+ core_extend_error: 10003,
1300
+ core_inbound_data_not_found: 10004,
1301
+ core_approve_asset_address_or_from_not_found: 10005,
1302
+ core_plugin_not_found: 10006,
1303
+ core_plugin_swap_not_found: 10007,
1304
+ core_chain_halted: 10099,
1305
+ core_wallet_xdefi_not_installed: 10101,
1306
+ core_wallet_evmwallet_not_installed: 10102,
1307
+ core_wallet_walletconnect_not_installed: 10103,
1308
+ core_wallet_keystore_not_installed: 10104,
1309
+ core_wallet_ledger_not_installed: 10105,
1310
+ core_wallet_trezor_not_installed: 10106,
1311
+ core_wallet_keplr_not_installed: 10107,
1312
+ core_wallet_okx_not_installed: 10108,
1313
+ core_wallet_keepkey_not_installed: 10109,
1314
+ core_swap_invalid_params: 10200,
1315
+ core_swap_route_not_complete: 10201,
1316
+ core_swap_asset_not_recognized: 10202,
1317
+ core_swap_contract_not_found: 10203,
1318
+ core_swap_route_transaction_not_found: 10204,
1319
+ core_swap_contract_not_supported: 10205,
1320
+ core_swap_transaction_error: 10206,
1321
+ core_swap_quote_mode_not_supported: 10207,
1322
+ core_transaction_deposit_error: 10301,
1323
+ core_transaction_create_liquidity_rune_error: 10302,
1324
+ core_transaction_create_liquidity_asset_error: 10303,
1325
+ core_transaction_create_liquidity_invalid_params: 10304,
1326
+ core_transaction_add_liquidity_invalid_params: 10305,
1327
+ core_transaction_add_liquidity_no_rune_address: 10306,
1328
+ core_transaction_add_liquidity_rune_error: 10307,
1329
+ core_transaction_add_liquidity_asset_error: 10308,
1330
+ core_transaction_withdraw_error: 10309,
1331
+ core_transaction_deposit_to_pool_error: 10310,
1332
+ core_transaction_deposit_insufficient_funds_error: 10311,
1333
+ core_transaction_deposit_gas_error: 10312,
1334
+ core_transaction_invalid_sender_address: 10313,
1335
+ core_transaction_deposit_server_error: 10314,
1336
+ core_transaction_user_rejected: 10315,
1337
+ wallet_ledger_connection_error: 20001,
1338
+ wallet_ledger_connection_claimed: 20002,
1339
+ wallet_ledger_get_address_error: 20003,
1340
+ wallet_ledger_device_not_found: 20004,
1341
+ wallet_ledger_device_locked: 20005,
1342
+ chainflip_channel_error: 30001,
1343
+ chainflip_broker_recipient_error: 30002,
1344
+ helpers_number_different_decimals: 99101
1345
+ };
1346
+
1347
+ class SwapKitError extends Error {
1348
+ constructor(errorKey, sourceError) {
1349
+ if (sourceError) {
1350
+ console.error(sourceError, {
1351
+ stack: sourceError?.stack,
1352
+ message: sourceError?.message
1353
+ });
1354
+ }
1355
+ super(errorKey, {
1356
+ cause: { code: errorMessages[errorKey], message: errorKey }
1357
+ });
1358
+ Object.setPrototypeOf(this, SwapKitError.prototype);
1359
+ }
1360
+ }
1361
+
1362
+ // src/helpers/others.ts
1363
+ function getTHORNameCost(year) {
1364
+ if (year < 0)
1365
+ throw new Error("Invalid number of year");
1366
+ return 10 + year;
1367
+ }
1368
+ function getMAYANameCost(year) {
1369
+ if (year < 0)
1370
+ throw new Error("Invalid number of year");
1371
+ return Math.round((10 + year * 1.0512) * 10000000000) / 10000000000;
1372
+ }
1373
+ function derivationPathToString([network3, chainId, account, change, index]) {
1374
+ const shortPath = typeof index !== "number";
1375
+ return `m/${network3}'/${chainId}'/${account}'/${change}${shortPath ? "" : `/${index}`}`;
1376
+ }
1377
+ function wrapWithThrow(fn, errorKey) {
1378
+ try {
1379
+ return fn();
1380
+ } catch (error) {
1381
+ if (errorKey) {
1382
+ throw new SwapKitError(errorKey, error);
1383
+ }
1384
+ return console.error(error);
1385
+ }
1386
+ }
1387
+ // src/helpers/validators.ts
1388
+ function validateIdentifier(identifier = "") {
1389
+ const uppercasedIdentifier = identifier.toUpperCase();
1390
+ const [chain] = uppercasedIdentifier.split(".");
1391
+ if (supportedChains.includes(chain))
1392
+ return true;
1393
+ const [synthChain] = uppercasedIdentifier.split("/");
1394
+ if (supportedChains.includes(synthChain))
1395
+ return true;
1396
+ throw new Error(`Invalid identifier: ${identifier}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`);
1397
+ }
1398
+ function validateTNS(name) {
1399
+ if (name.length > 30)
1400
+ return false;
1401
+ const regex = /^[a-zA-Z0-9+_-]+$/g;
1402
+ return !!name.match(regex);
1403
+ }
1404
+ var supportedChains = [...Object.values(Chain), "TERRA"];
1405
+ // src/helpers/web3wallets.ts
1406
+ var methodsToWrap = [
1407
+ "approve",
1408
+ "approvedAmount",
1409
+ "call",
1410
+ "sendTransaction",
1411
+ "transfer",
1412
+ "getBalance",
1413
+ "isApproved",
1414
+ "approvedAmount",
1415
+ "EIP1193SendTransaction",
1416
+ "getFeeData",
1417
+ "broadcastTransaction",
1418
+ "estimateCall",
1419
+ "estimateGasLimit",
1420
+ "estimateGasPrices",
1421
+ "createContractTxObject"
1422
+ ];
1423
+ var wrapMethodWithNetworkSwitch = (func, provider, chainId) => async (...args) => {
1424
+ try {
1425
+ await switchEVMWalletNetwork(provider, chainId);
1426
+ } catch (error) {
1427
+ throw new Error(`Failed to switch network: ${error}`);
1428
+ }
1429
+ return func(...args);
1430
+ };
1431
+ var providerRequest = ({ provider, params, method }) => {
1432
+ if (!provider?.send)
1433
+ throw new Error("Provider not found");
1434
+ const providerParams = params ? Array.isArray(params) ? params : [params] : [];
1435
+ return provider.send(method, providerParams);
1436
+ };
1437
+ var prepareNetworkSwitch = ({
1438
+ toolbox,
1439
+ chainId,
1440
+ provider = window.ethereum
1441
+ }) => {
1442
+ const wrappedMethods = methodsToWrap.reduce((object, methodName) => {
1443
+ if (!toolbox[methodName])
1444
+ return object;
1445
+ const method = toolbox[methodName];
1446
+ if (typeof method !== "function")
1447
+ return object;
1448
+ return {
1449
+ ...object,
1450
+ [methodName]: wrapMethodWithNetworkSwitch(method, provider, chainId)
1451
+ };
1452
+ }, {});
1453
+ return { ...toolbox, ...wrappedMethods };
1454
+ };
1455
+ var addEVMWalletNetwork = (provider, networkParams) => providerRequest({ provider, method: "wallet_addEthereumChain", params: [networkParams] });
1456
+ var switchEVMWalletNetwork = (provider, chainId = ChainId.EthereumHex) => providerRequest({ provider, method: "wallet_switchEthereumChain", params: [{ chainId }] });
1457
+ var addAccountsChangedCallback = (callback) => {
1458
+ window.ethereum?.on("accountsChanged", () => callback());
1459
+ window.xfi?.ethereum.on("accountsChanged", () => callback());
1460
+ };
1461
+ var getETHDefaultWallet = () => {
1462
+ const { isTrust, isBraveWallet, __XDEFI, overrideIsMetaMask, selectedProvider } = window?.ethereum || {};
1463
+ if (isTrust)
1464
+ return WalletOption.TRUSTWALLET_WEB;
1465
+ if (isBraveWallet)
1466
+ return WalletOption.BRAVE;
1467
+ if (overrideIsMetaMask && selectedProvider?.isCoinbaseWallet)
1468
+ return WalletOption.COINBASE_WEB;
1469
+ if (__XDEFI)
1470
+ WalletOption.XDEFI;
1471
+ return WalletOption.METAMASK;
1472
+ };
1473
+ var isDetected = (walletOption) => {
1474
+ return listWeb3EVMWallets().includes(walletOption);
1475
+ };
1476
+ var listWeb3EVMWallets = () => {
1477
+ const metamaskEnabled = window?.ethereum && !window.ethereum?.isBraveWallet;
1478
+ const xdefiEnabled = window?.xfi || window?.ethereum?.__XDEFI;
1479
+ const braveEnabled = window?.ethereum?.isBraveWallet;
1480
+ const trustEnabled = window?.ethereum?.isTrust || window?.trustwallet;
1481
+ const coinbaseEnabled = window?.ethereum?.overrideIsMetaMask && window?.ethereum?.selectedProvider?.isCoinbaseWallet || window?.coinbaseWalletExtension;
1482
+ const wallets = [];
1483
+ if (metamaskEnabled)
1484
+ wallets.push(WalletOption.METAMASK);
1485
+ if (xdefiEnabled)
1486
+ wallets.push(WalletOption.XDEFI);
1487
+ if (braveEnabled)
1488
+ wallets.push(WalletOption.BRAVE);
1489
+ if (trustEnabled)
1490
+ wallets.push(WalletOption.TRUSTWALLET_WEB);
1491
+ if (coinbaseEnabled)
1492
+ wallets.push(WalletOption.COINBASE_WEB);
1493
+ if (okxMobileEnabled())
1494
+ wallets.push(WalletOption.OKX_MOBILE);
1495
+ return wallets;
1496
+ };
1497
+ var okxMobileEnabled = () => {
1498
+ const ua = navigator.userAgent;
1499
+ const isIOS = /iphone|ipad|ipod|ios/i.test(ua);
1500
+ const isAndroid = /android|XiaoMi|MiuiBrowser/i.test(ua);
1501
+ const isMobile = isIOS || isAndroid;
1502
+ const isOKApp = /OKApp/i.test(ua);
1503
+ return isMobile && isOKApp;
1504
+ };
1505
+ var isWeb3Detected = () => typeof window.ethereum !== "undefined";
1506
+ // src/modules/bigIntArithmetics.ts
1507
+ function formatBigIntToSafeValue({
1508
+ value,
1509
+ bigIntDecimal = DEFAULT_DECIMAL,
1510
+ decimal = DEFAULT_DECIMAL
1511
+ }) {
1512
+ if (decimal === 0)
1513
+ return value.toString();
1514
+ const isNegative = value < 0n;
1515
+ let valueString = value.toString().substring(isNegative ? 1 : 0);
1516
+ const padLength = decimal - (valueString.length - 1);
1517
+ if (padLength > 0) {
1518
+ valueString = "0".repeat(padLength) + valueString;
1519
+ }
1520
+ const decimalIndex = valueString.length - decimal;
1521
+ let decimalString = valueString.slice(-decimal);
1522
+ if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
1523
+ decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
1524
+ } else {
1525
+ decimalString = decimalString.substring(0, bigIntDecimal);
1526
+ }
1527
+ return `${isNegative ? "-" : ""}${valueString.slice(0, decimalIndex)}.${decimalString}`.replace(/\.?0*$/, "");
1528
+ }
1529
+ var toSafeValue = function(value) {
1530
+ const parsedValue = typeof value === "number" ? numberFormatter.format(value) : getStringValue(value);
1531
+ const splitValue = `${parsedValue}`.replaceAll(",", ".").split(".");
1532
+ return splitValue.length > 1 ? `${splitValue.slice(0, -1).join("")}.${splitValue.at(-1)}` : splitValue[0] || "0";
1533
+ };
1534
+ var getFloatDecimals = function(value) {
1535
+ const decimals = value.split(".")[1]?.length || 0;
1536
+ return Math.max(decimals, DEFAULT_DECIMAL);
1537
+ };
1538
+ var getStringValue = function(param) {
1539
+ return typeof param === "object" ? "getValue" in param ? param.getValue("string") : param.value : param;
1540
+ };
1541
+ var DEFAULT_DECIMAL = 8;
1542
+ var toMultiplier = (decimal) => 10n ** BigInt(decimal);
1543
+ var decimalFromMultiplier = (multiplier) => Math.log10(Number.parseFloat(multiplier.toString()));
1544
+
1545
+ class BigIntArithmetics {
1546
+ decimalMultiplier = 10n ** 8n;
1547
+ bigIntValue = 0n;
1548
+ decimal;
1549
+ static fromBigInt(value, decimal) {
1550
+ return new BigIntArithmetics({
1551
+ decimal,
1552
+ value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })
1553
+ });
1554
+ }
1555
+ static shiftDecimals({
1556
+ value,
1557
+ from,
1558
+ to
1559
+ }) {
1560
+ return BigIntArithmetics.fromBigInt(value.getBaseValue("bigint") * toMultiplier(to) / toMultiplier(from), to);
1561
+ }
1562
+ constructor(params) {
1563
+ const value = getStringValue(params);
1564
+ const isComplex = typeof params === "object";
1565
+ this.decimal = isComplex ? params.decimal : undefined;
1566
+ this.decimalMultiplier = isComplex && "decimalMultiplier" in params ? params.decimalMultiplier : toMultiplier(Math.max(getFloatDecimals(toSafeValue(value)), this.decimal || 0));
1567
+ this.#setValue(value);
1568
+ }
1569
+ set(value) {
1570
+ return new this.constructor({ decimal: this.decimal, value, identifier: this.toString() });
1571
+ }
1572
+ add(...args) {
1573
+ return this.#arithmetics("add", ...args);
1574
+ }
1575
+ sub(...args) {
1576
+ return this.#arithmetics("sub", ...args);
1577
+ }
1578
+ mul(...args) {
1579
+ return this.#arithmetics("mul", ...args);
1580
+ }
1581
+ div(...args) {
1582
+ return this.#arithmetics("div", ...args);
1583
+ }
1584
+ gt(value) {
1585
+ return this.#comparison("gt", value);
1586
+ }
1587
+ gte(value) {
1588
+ return this.#comparison("gte", value);
1589
+ }
1590
+ lt(value) {
1591
+ return this.#comparison("lt", value);
1592
+ }
1593
+ lte(value) {
1594
+ return this.#comparison("lte", value);
1595
+ }
1596
+ eqValue(value) {
1597
+ return this.#comparison("eqValue", value);
1598
+ }
1599
+ getValue(type) {
1600
+ const value = this.formatBigIntToSafeValue(this.bigIntValue, this.decimal || decimalFromMultiplier(this.decimalMultiplier));
1601
+ switch (type) {
1602
+ case "number":
1603
+ return Number(value);
1604
+ case "string":
1605
+ return value;
1606
+ case "bigint":
1607
+ return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
1608
+ }
1609
+ }
1610
+ getBaseValue(type) {
1611
+ const divisor = this.decimalMultiplier / toMultiplier(this.decimal || BaseDecimal.THOR);
1612
+ const baseValue = this.bigIntValue / divisor;
1613
+ switch (type) {
1614
+ case "number":
1615
+ return Number(baseValue);
1616
+ case "string":
1617
+ return baseValue.toString();
1618
+ case "bigint":
1619
+ return baseValue;
1620
+ }
1621
+ }
1622
+ getBigIntValue(value, decimal) {
1623
+ if (!decimal && typeof value === "object")
1624
+ return value.bigIntValue;
1625
+ const stringValue = getStringValue(value);
1626
+ const safeValue = toSafeValue(stringValue);
1627
+ if (safeValue === "0" || safeValue === "undefined")
1628
+ return 0n;
1629
+ return this.#toBigInt(safeValue, decimal);
1630
+ }
1631
+ toSignificant(significantDigits = 6) {
1632
+ const [int, dec] = this.getValue("string").split(".");
1633
+ const integer = int || "";
1634
+ const decimal = dec || "";
1635
+ const valueLength = Number.parseInt(integer) ? integer.length + decimal.length : decimal.length;
1636
+ if (valueLength <= significantDigits) {
1637
+ return this.getValue("string");
1638
+ }
1639
+ if (integer.length >= significantDigits) {
1640
+ return integer.slice(0, significantDigits).padEnd(integer.length, "0");
1641
+ }
1642
+ if (Number.parseInt(integer)) {
1643
+ return `${integer}.${decimal.slice(0, significantDigits - integer.length)}`.padEnd(significantDigits - integer.length, "0");
1644
+ }
1645
+ const trimmedDecimal = Number.parseInt(decimal);
1646
+ const slicedDecimal = `${trimmedDecimal}`.slice(0, significantDigits);
1647
+ return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, "0")}`;
1648
+ }
1649
+ toFixed(fixedDigits = 6) {
1650
+ const [int, dec] = this.getValue("string").split(".");
1651
+ const integer = int || "";
1652
+ const decimal = dec || "";
1653
+ if (Number.parseInt(integer)) {
1654
+ return `${integer}.${decimal.slice(0, fixedDigits)}`.padEnd(fixedDigits, "0");
1655
+ }
1656
+ const trimmedDecimal = Number.parseInt(decimal);
1657
+ const slicedDecimal = `${trimmedDecimal}`.slice(0, fixedDigits);
1658
+ return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, "0")}`;
1659
+ }
1660
+ toAbbreviation(digits = 2) {
1661
+ const value = this.getValue("number");
1662
+ const abbreviations = ["", "K", "M", "B", "T", "Q", "Qi", "S"];
1663
+ const tier = Math.floor(Math.log10(Math.abs(value)) / 3);
1664
+ const suffix = abbreviations[tier];
1665
+ if (!suffix)
1666
+ return this.getValue("string");
1667
+ const scale = 10 ** (tier * 3);
1668
+ const scaled = value / scale;
1669
+ return `${scaled.toFixed(digits)}${suffix}`;
1670
+ }
1671
+ toCurrency(currency = "$", {
1672
+ currencyPosition = "start",
1673
+ decimal = 2,
1674
+ decimalSeparator = ".",
1675
+ thousandSeparator = ","
1676
+ } = {}) {
1677
+ const value = this.getValue("number");
1678
+ const [int = "", dec = ""] = value.toFixed(6).split(".");
1679
+ const integer = int.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
1680
+ const parsedValue = int || dec ? int === "0" ? `${Number.parseFloat(`0.${dec}`)}`.replace(".", decimalSeparator) : `${integer}${Number.parseInt(dec) ? `${decimalSeparator}${dec.slice(0, decimal)}` : ""}` : "0.00";
1681
+ return `${currencyPosition === "start" ? currency : ""}${parsedValue}${currencyPosition === "end" ? currency : ""}`;
1682
+ }
1683
+ formatBigIntToSafeValue(value, decimal) {
1684
+ const bigIntDecimal = decimal || this.decimal || DEFAULT_DECIMAL;
1685
+ const decimalToUseForConversion = Math.max(bigIntDecimal, decimalFromMultiplier(this.decimalMultiplier));
1686
+ const isNegative = value < 0n;
1687
+ const valueString = value.toString().substring(isNegative ? 1 : 0);
1688
+ const padLength = decimalToUseForConversion - (valueString.length - 1);
1689
+ const parsedValueString = padLength > 0 ? "0".repeat(padLength) + valueString : valueString;
1690
+ const decimalIndex = parsedValueString.length - decimalToUseForConversion;
1691
+ let decimalString = parsedValueString.slice(-decimalToUseForConversion);
1692
+ if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
1693
+ decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
1694
+ } else {
1695
+ decimalString = decimalString.substring(0, bigIntDecimal);
1696
+ }
1697
+ return `${isNegative ? "-" : ""}${parsedValueString.slice(0, decimalIndex)}.${decimalString}`.replace(/\.?0*$/, "");
1698
+ }
1699
+ #arithmetics(method, ...args) {
1700
+ const precisionDecimal = this.#retrievePrecisionDecimal(this, ...args);
1701
+ const decimal = Math.max(precisionDecimal, decimalFromMultiplier(this.decimalMultiplier));
1702
+ const precisionDecimalMultiplier = toMultiplier(decimal);
1703
+ const result = args.reduce((acc, arg) => {
1704
+ const value2 = this.getBigIntValue(arg, decimal);
1705
+ switch (method) {
1706
+ case "add":
1707
+ return acc + value2;
1708
+ case "sub":
1709
+ return acc - value2;
1710
+ case "mul":
1711
+ return acc * value2 / precisionDecimalMultiplier;
1712
+ case "div": {
1713
+ if (value2 === 0n)
1714
+ throw new RangeError("Division by zero");
1715
+ return acc * precisionDecimalMultiplier / value2;
1716
+ }
1717
+ default:
1718
+ return acc;
1719
+ }
1720
+ }, this.bigIntValue * precisionDecimalMultiplier / this.decimalMultiplier);
1721
+ const value = formatBigIntToSafeValue({
1722
+ bigIntDecimal: decimal,
1723
+ decimal,
1724
+ value: result
1725
+ });
1726
+ return new this.constructor({
1727
+ decimalMultiplier: toMultiplier(decimal),
1728
+ decimal: this.decimal,
1729
+ value,
1730
+ identifier: this.toString()
1731
+ });
1732
+ }
1733
+ #comparison(method, ...args) {
1734
+ const decimal = this.#retrievePrecisionDecimal(this, ...args);
1735
+ const value = this.getBigIntValue(args[0] || "0", decimal);
1736
+ const compareToValue = this.getBigIntValue(this, decimal);
1737
+ switch (method) {
1738
+ case "gt":
1739
+ return compareToValue > value;
1740
+ case "gte":
1741
+ return compareToValue >= value;
1742
+ case "lt":
1743
+ return compareToValue < value;
1744
+ case "lte":
1745
+ return compareToValue <= value;
1746
+ case "eqValue":
1747
+ return compareToValue === value;
1748
+ }
1749
+ }
1750
+ #setValue(value) {
1751
+ const safeValue = toSafeValue(value) || "0";
1752
+ this.bigIntValue = this.#toBigInt(safeValue);
1753
+ }
1754
+ #retrievePrecisionDecimal(...args) {
1755
+ const decimals = args.map((arg) => {
1756
+ const isObject = typeof arg === "object";
1757
+ const value = isObject ? arg.decimal || decimalFromMultiplier(arg.decimalMultiplier) : getFloatDecimals(toSafeValue(arg));
1758
+ return value;
1759
+ }).filter(Boolean);
1760
+ return Math.max(...decimals, DEFAULT_DECIMAL);
1761
+ }
1762
+ #toBigInt(value, decimal) {
1763
+ const multiplier = decimal ? toMultiplier(decimal) : this.decimalMultiplier;
1764
+ const padDecimal = decimalFromMultiplier(multiplier);
1765
+ const [integerPart = "", decimalPart = ""] = value.split(".");
1766
+ return BigInt(`${integerPart}${decimalPart.padEnd(padDecimal, "0")}`);
1767
+ }
1768
+ }
1769
+ var numberFormatter = Intl.NumberFormat("fullwide", {
1770
+ useGrouping: false,
1771
+ maximumFractionDigits: 20
1772
+ });
1773
+
1774
+ // src/modules/swapKitNumber.ts
1775
+ class SwapKitNumber extends BigIntArithmetics {
1776
+ constructor() {
1777
+ super(...arguments);
1778
+ }
1779
+ eq(value) {
1780
+ return this.eqValue(value);
1781
+ }
1782
+ static fromBigInt(value, decimal) {
1783
+ return new SwapKitNumber({
1784
+ decimal,
1785
+ value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })
1786
+ });
1787
+ }
1788
+ }
1789
+
1790
+ // src/modules/assetValue.ts
1791
+ function getMinAmountByChain(chain) {
1792
+ const asset2 = AssetValue.fromChainOrSignature(chain);
1793
+ switch (chain) {
1794
+ case Chain.Bitcoin:
1795
+ case Chain.Litecoin:
1796
+ case Chain.BitcoinCash:
1797
+ return asset2.set(0.00010001);
1798
+ case Chain.Dogecoin:
1799
+ return asset2.set(1.00000001);
1800
+ case Chain.Avalanche:
1801
+ case Chain.Ethereum:
1802
+ return asset2.set(0.00000001);
1803
+ case Chain.THORChain:
1804
+ case Chain.Maya:
1805
+ return asset2.set(0);
1806
+ case Chain.Cosmos:
1807
+ return asset2.set(0.000001);
1808
+ default:
1809
+ return asset2.set(0.00000001);
1810
+ }
1811
+ }
1812
+ async function createAssetValue(identifier, value = 0) {
1813
+ validateIdentifier(identifier);
1814
+ const staticToken = staticTokensMap.get(identifier.toUpperCase());
1815
+ const decimal = staticToken?.decimal || await getDecimal(getAssetInfo(identifier));
1816
+ if (!staticToken) {
1817
+ staticTokensMap.set(identifier.toUpperCase(), { identifier, decimal });
1818
+ }
1819
+ return new AssetValue({ decimal, value: safeValue(value, decimal), identifier });
1820
+ }
1821
+ var createSyntheticAssetValue = function(identifier, value = 0) {
1822
+ const [synthChain, symbol] = identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain ? identifier.split(".").slice(1).join().split("/") : identifier.split("/");
1823
+ if (!(synthChain && symbol))
1824
+ throw new Error("Invalid asset identifier");
1825
+ return new AssetValue({
1826
+ decimal: 8,
1827
+ value: safeValue(value, 8),
1828
+ identifier: `${Chain.THORChain}.${synthChain}/${symbol}`
1829
+ });
1830
+ };
1831
+ var safeValue = function(value, decimal) {
1832
+ return typeof value === "bigint" ? formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal }) : value;
1833
+ };
1834
+ var getAssetInfo = function(identifier) {
1835
+ const isSynthetic = identifier.slice(0, 14).includes("/");
1836
+ const isThorchain = identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain;
1837
+ const isMaya = identifier.split(".")?.[0]?.toUpperCase() === Chain.Maya;
1838
+ const [synthChain, synthSymbol = ""] = isThorchain || isMaya ? identifier.split(".").slice(1).join().split("/") : identifier.split("/");
1839
+ if (isSynthetic && !(synthChain && synthSymbol))
1840
+ throw new Error("Invalid asset identifier");
1841
+ const adjustedIdentifier = identifier.includes(".") && !isSynthetic ? identifier : `${isMaya ? Chain.Maya : Chain.THORChain}.${synthSymbol}`;
1842
+ const [chain, ...rest] = adjustedIdentifier.split(".");
1843
+ const [ticker, address] = (isSynthetic ? synthSymbol : rest.join(".")).split("-");
1844
+ const symbol = isSynthetic ? synthSymbol : rest.join(".");
1845
+ return {
1846
+ address: address?.toLowerCase(),
1847
+ chain,
1848
+ isGasAsset: isGasAsset({ chain, symbol }),
1849
+ isSynthetic,
1850
+ symbol: (isSynthetic ? `${synthChain}/` : "") + (address ? `${ticker}-${address?.toLowerCase() ?? ""}` : symbol),
1851
+ ticker
1852
+ };
1853
+ };
1854
+ var staticTokensMap = new Map;
1855
+
1856
+ class AssetValue extends BigIntArithmetics {
1857
+ address;
1858
+ chain;
1859
+ isGasAsset = false;
1860
+ isSynthetic = false;
1861
+ symbol;
1862
+ tax;
1863
+ ticker;
1864
+ type;
1865
+ chainId;
1866
+ constructor({
1867
+ value,
1868
+ decimal,
1869
+ tax,
1870
+ chain,
1871
+ symbol,
1872
+ identifier
1873
+ }) {
1874
+ super(typeof value === "object" ? value : { decimal, value });
1875
+ const assetInfo = getAssetInfo(identifier || `${chain}.${symbol}`);
1876
+ this.type = getAssetType(assetInfo);
1877
+ this.tax = tax;
1878
+ this.chain = assetInfo.chain;
1879
+ this.ticker = assetInfo.ticker;
1880
+ this.symbol = assetInfo.symbol;
1881
+ this.address = assetInfo.address;
1882
+ this.isSynthetic = assetInfo.isSynthetic;
1883
+ this.isGasAsset = assetInfo.isGasAsset;
1884
+ this.chainId = ChainToChainId[assetInfo.chain];
1885
+ }
1886
+ toString() {
1887
+ return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
1888
+ }
1889
+ toUrl() {
1890
+ return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
1891
+ }
1892
+ eq({ chain, symbol }) {
1893
+ return this.chain === chain && this.symbol === symbol;
1894
+ }
1895
+ static fromUrl(urlAsset, value = 0) {
1896
+ const [chain, ticker, symbol] = urlAsset.split(".");
1897
+ if (!(chain && ticker))
1898
+ throw new Error("Invalid asset url");
1899
+ const assetString = chain === Chain.THORChain && symbol ? `${chain}.${ticker}/${symbol}` : urlAsset;
1900
+ return createAssetValue(assetString, value);
1901
+ }
1902
+ static fromString(assetString, value = 0) {
1903
+ return createAssetValue(assetString, value);
1904
+ }
1905
+ static fromIdentifier(assetString, value = 0) {
1906
+ return createAssetValue(assetString, value);
1907
+ }
1908
+ static fromStringSync(assetString, value = 0) {
1909
+ const { chain, isSynthetic } = getAssetInfo(assetString);
1910
+ const tokenInfo = staticTokensMap.get(assetString.toUpperCase());
1911
+ if (isSynthetic)
1912
+ return createSyntheticAssetValue(assetString, value);
1913
+ const { tax, decimal, identifier } = tokenInfo || {
1914
+ decimal: BaseDecimal[chain],
1915
+ identifier: assetString
1916
+ };
1917
+ return new AssetValue({
1918
+ tax,
1919
+ value: safeValue(value, decimal),
1920
+ identifier: isSynthetic ? assetString : identifier,
1921
+ decimal: isSynthetic ? 8 : decimal
1922
+ });
1923
+ }
1924
+ static async fromStringWithBase(assetString, value = 0, baseDecimal = BaseDecimal.THOR) {
1925
+ const shiftedAmount = BigIntArithmetics.shiftDecimals({
1926
+ value: SwapKitNumber.fromBigInt(BigInt(value)),
1927
+ from: 0,
1928
+ to: baseDecimal
1929
+ }).getBaseValue("string");
1930
+ const assetValue = await AssetValue.fromString(assetString, value);
1931
+ return assetValue.set(shiftedAmount);
1932
+ }
1933
+ static fromStringWithBaseSync(assetString, value = 0, baseDecimal = BaseDecimal.THOR) {
1934
+ const { chain, isSynthetic } = getAssetInfo(assetString);
1935
+ const tokenInfo = staticTokensMap.get(assetString.toUpperCase());
1936
+ if (isSynthetic)
1937
+ return createSyntheticAssetValue(assetString, value);
1938
+ const { tax, decimal, identifier } = tokenInfo || {
1939
+ decimal: BaseDecimal[chain],
1940
+ identifier: assetString
1941
+ };
1942
+ return new AssetValue({
1943
+ tax,
1944
+ value: safeValue(BigInt(value), baseDecimal),
1945
+ identifier,
1946
+ decimal
1947
+ });
1948
+ }
1949
+ static fromIdentifierSync(assetString, value = 0) {
1950
+ const { chain, isSynthetic } = getAssetInfo(assetString);
1951
+ const tokenInfo = staticTokensMap.get(assetString);
1952
+ if (isSynthetic)
1953
+ return createSyntheticAssetValue(assetString, value);
1954
+ const { tax, decimal, identifier } = tokenInfo || {
1955
+ decimal: BaseDecimal[chain],
1956
+ identifier: assetString
1957
+ };
1958
+ return new AssetValue({ tax, decimal, identifier, value: safeValue(value, decimal) });
1959
+ }
1960
+ static fromChainOrSignature(assetString, value = 0) {
1961
+ const { decimal, identifier } = getCommonAssetInfo(assetString);
1962
+ return new AssetValue({ value: safeValue(value, decimal), decimal, identifier });
1963
+ }
1964
+ static loadStaticAssets() {
1965
+ return new Promise((resolve, reject) => {
1966
+ try {
1967
+ import("@swapkit/tokens").then((tokenPackages) => {
1968
+ for (const tokenList of Object.values(tokenPackages)) {
1969
+ for (const { identifier, chain, ...rest } of tokenList.tokens) {
1970
+ staticTokensMap.set(identifier.toUpperCase(), {
1971
+ identifier,
1972
+ decimal: "decimals" in rest ? rest.decimals : BaseDecimal[chain]
1973
+ });
1974
+ }
1975
+ }
1976
+ resolve({ ok: true });
1977
+ });
1978
+ } catch (error) {
1979
+ console.error(error);
1980
+ reject({
1981
+ ok: false,
1982
+ error,
1983
+ message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
1984
+ });
1985
+ }
1986
+ });
1987
+ }
1988
+ }
1989
+ export {
1990
+ wrapWithThrow,
1991
+ wrapMethodWithNetworkSwitch,
1992
+ validateTNS,
1993
+ validateIdentifier,
1994
+ switchEVMWalletNetwork,
1995
+ setRequestClientConfig,
1996
+ prepareNetworkSwitch,
1997
+ okxMobileEnabled,
1998
+ isWeb3Detected,
1999
+ isGasAsset,
2000
+ isDetected,
2001
+ getTHORNameCost,
2002
+ getSymmetricWithdraw,
2003
+ getSymmetricPoolShare,
2004
+ getMinAmountByChain,
2005
+ getMemoFor,
2006
+ getMAYANameCost,
2007
+ getLiquiditySlippage,
2008
+ getEstimatedPoolShare,
2009
+ getETHDefaultWallet,
2010
+ getDecimal,
2011
+ getCommonAssetInfo,
2012
+ getAsymmetricRuneWithdrawAmount,
2013
+ getAsymmetricRuneShare,
2014
+ getAsymmetricAssetWithdrawAmount,
2015
+ getAsymmetricAssetShare,
2016
+ getAssetType,
2017
+ gasFeeMultiplier,
2018
+ formatBigIntToSafeValue,
2019
+ findAssetBy,
2020
+ filterAssets,
2021
+ erc20ABI,
2022
+ derivationPathToString,
2023
+ defaultRequestHeaders,
2024
+ assetFromString,
2025
+ addEVMWalletNetwork,
2026
+ addAccountsChangedCallback,
2027
+ WalletOption,
2028
+ UTXOChains,
2029
+ TCSupportedChains,
2030
+ TCEthereumVaultAbi,
2031
+ TCBscDepositABI,
2032
+ TCAvalancheDepositABI,
2033
+ SwapKitNumber,
2034
+ SwapKitError,
2035
+ SubstrateChains,
2036
+ SWAP_OUT,
2037
+ SWAP_IN,
2038
+ RequestClient,
2039
+ RPCUrl,
2040
+ QuoteMode,
2041
+ NetworkDerivationPath,
2042
+ MemoType,
2043
+ MAYASupportedChains,
2044
+ LedgerErrorCode,
2045
+ FeeOption,
2046
+ ExplorerUrl,
2047
+ EVMChains,
2048
+ DerivationPath,
2049
+ CosmosChains,
2050
+ ContractAddress,
2051
+ ChainToRPC,
2052
+ ChainToHexChainId,
2053
+ ChainToExplorerUrl,
2054
+ ChainToChainId,
2055
+ ChainIdToChain,
2056
+ ChainId,
2057
+ Chain,
2058
+ BigIntArithmetics,
2059
+ BaseDecimal,
2060
+ AssetValue,
2061
+ ApproveMode,
2062
+ AGG_SWAP
2063
+ };
2064
+
2065
+ //# debugId=4052E9867E846E9864756e2164756e21