@swapkit/core 1.0.0-rc.115 → 1.0.0-rc.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +648 -2671
- package/dist/index.es.js.map +1 -1
- package/package.json +17 -15
package/dist/index.es.js
CHANGED
|
@@ -1,2140 +1,187 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
if (!
|
|
5
|
-
throw TypeError("Cannot " +
|
|
1
|
+
var re = Object.defineProperty;
|
|
2
|
+
var ye = (r, e, t) => e in r ? re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var y = (r, e, t) => (ye(r, typeof e != "symbol" ? e + "" : e, t), t), ue = (r, e, t) => {
|
|
4
|
+
if (!e.has(r))
|
|
5
|
+
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (
|
|
7
|
+
var M = (r, e, t) => (ue(r, e, "read from private field"), t ? t.call(r) : e.get(r)), F = (r, e, t) => {
|
|
8
|
+
if (e.has(r))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
|
|
10
|
+
e instanceof WeakSet ? e.add(r) : e.set(r, t);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
name: "allowance",
|
|
40
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
41
|
-
stateMutability: "view",
|
|
42
|
-
type: "function"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
inputs: [
|
|
46
|
-
{ internalType: "address", name: "spender", type: "address" },
|
|
47
|
-
{ internalType: "uint256", name: "value", type: "uint256" }
|
|
48
|
-
],
|
|
49
|
-
name: "approve",
|
|
50
|
-
outputs: [{ internalType: "bool", name: "success", type: "bool" }],
|
|
51
|
-
stateMutability: "nonpayable",
|
|
52
|
-
type: "function"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
56
|
-
name: "balanceOf",
|
|
57
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
58
|
-
stateMutability: "view",
|
|
59
|
-
type: "function"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
inputs: [],
|
|
63
|
-
name: "decimals",
|
|
64
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
65
|
-
stateMutability: "view",
|
|
66
|
-
type: "function"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
inputs: [],
|
|
70
|
-
name: "name",
|
|
71
|
-
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
72
|
-
stateMutability: "view",
|
|
73
|
-
type: "function"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
inputs: [],
|
|
77
|
-
name: "symbol",
|
|
78
|
-
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
79
|
-
stateMutability: "view",
|
|
80
|
-
type: "function"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
inputs: [],
|
|
84
|
-
name: "totalSupply",
|
|
85
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
86
|
-
stateMutability: "view",
|
|
87
|
-
type: "function"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
inputs: [
|
|
91
|
-
{ internalType: "address", name: "to", type: "address" },
|
|
92
|
-
{ internalType: "uint256", name: "value", type: "uint256" }
|
|
93
|
-
],
|
|
94
|
-
name: "transfer",
|
|
95
|
-
outputs: [{ internalType: "bool", name: "success", type: "bool" }],
|
|
96
|
-
stateMutability: "nonpayable",
|
|
97
|
-
type: "function"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
inputs: [
|
|
101
|
-
{ internalType: "address", name: "from", type: "address" },
|
|
102
|
-
{ internalType: "address", name: "to", type: "address" },
|
|
103
|
-
{ internalType: "uint256", name: "value", type: "uint256" }
|
|
104
|
-
],
|
|
105
|
-
name: "transferFrom",
|
|
106
|
-
outputs: [{ internalType: "bool", name: "success", type: "bool" }],
|
|
107
|
-
stateMutability: "nonpayable",
|
|
108
|
-
type: "function"
|
|
109
|
-
}
|
|
110
|
-
], wt = [
|
|
111
|
-
{
|
|
112
|
-
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
113
|
-
stateMutability: "nonpayable",
|
|
114
|
-
type: "constructor"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
anonymous: !1,
|
|
118
|
-
inputs: [
|
|
119
|
-
{ indexed: !0, internalType: "address", name: "to", type: "address" },
|
|
120
|
-
{ indexed: !0, internalType: "address", name: "asset", type: "address" },
|
|
121
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
122
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
123
|
-
],
|
|
124
|
-
name: "Deposit",
|
|
125
|
-
type: "event"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
anonymous: !1,
|
|
129
|
-
inputs: [
|
|
130
|
-
{ indexed: !0, internalType: "address", name: "oldVault", type: "address" },
|
|
131
|
-
{ indexed: !0, internalType: "address", name: "newVault", type: "address" },
|
|
132
|
-
{ indexed: !1, internalType: "address", name: "asset", type: "address" },
|
|
133
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
134
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
135
|
-
],
|
|
136
|
-
name: "TransferAllowance",
|
|
137
|
-
type: "event"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
anonymous: !1,
|
|
141
|
-
inputs: [
|
|
142
|
-
{ indexed: !0, internalType: "address", name: "vault", type: "address" },
|
|
143
|
-
{ indexed: !0, internalType: "address", name: "to", type: "address" },
|
|
144
|
-
{ indexed: !1, internalType: "address", name: "asset", type: "address" },
|
|
145
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
146
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
147
|
-
],
|
|
148
|
-
name: "TransferOut",
|
|
149
|
-
type: "event"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
anonymous: !1,
|
|
153
|
-
inputs: [
|
|
154
|
-
{ indexed: !0, internalType: "address", name: "vault", type: "address" },
|
|
155
|
-
{ indexed: !1, internalType: "address", name: "target", type: "address" },
|
|
156
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
157
|
-
{ indexed: !1, internalType: "address", name: "finalAsset", type: "address" },
|
|
158
|
-
{ indexed: !1, internalType: "address", name: "to", type: "address" },
|
|
159
|
-
{ indexed: !1, internalType: "uint256", name: "amountOutMin", type: "uint256" },
|
|
160
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
161
|
-
],
|
|
162
|
-
name: "TransferOutAndCall",
|
|
163
|
-
type: "event"
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
anonymous: !1,
|
|
167
|
-
inputs: [
|
|
168
|
-
{ indexed: !0, internalType: "address", name: "oldVault", type: "address" },
|
|
169
|
-
{ indexed: !0, 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: !1,
|
|
176
|
-
internalType: "struct THORChain_Router.Coin[]",
|
|
177
|
-
name: "coins",
|
|
178
|
-
type: "tuple[]"
|
|
179
|
-
},
|
|
180
|
-
{ indexed: !1, 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
|
-
], At = [
|
|
286
|
-
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
287
|
-
{
|
|
288
|
-
anonymous: !1,
|
|
289
|
-
inputs: [
|
|
290
|
-
{ indexed: !0, internalType: "address", name: "to", type: "address" },
|
|
291
|
-
{ indexed: !0, internalType: "address", name: "asset", type: "address" },
|
|
292
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
293
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
294
|
-
],
|
|
295
|
-
name: "Deposit",
|
|
296
|
-
type: "event"
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
anonymous: !1,
|
|
300
|
-
inputs: [
|
|
301
|
-
{ indexed: !0, internalType: "address", name: "oldVault", type: "address" },
|
|
302
|
-
{ indexed: !0, internalType: "address", name: "newVault", type: "address" },
|
|
303
|
-
{ indexed: !1, internalType: "address", name: "asset", type: "address" },
|
|
304
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
305
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
306
|
-
],
|
|
307
|
-
name: "TransferAllowance",
|
|
308
|
-
type: "event"
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
anonymous: !1,
|
|
312
|
-
inputs: [
|
|
313
|
-
{ indexed: !0, internalType: "address", name: "vault", type: "address" },
|
|
314
|
-
{ indexed: !0, internalType: "address", name: "to", type: "address" },
|
|
315
|
-
{ indexed: !1, internalType: "address", name: "asset", type: "address" },
|
|
316
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
317
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
318
|
-
],
|
|
319
|
-
name: "TransferOut",
|
|
320
|
-
type: "event"
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
anonymous: !1,
|
|
324
|
-
inputs: [
|
|
325
|
-
{ indexed: !0, internalType: "address", name: "vault", type: "address" },
|
|
326
|
-
{ indexed: !1, internalType: "address", name: "target", type: "address" },
|
|
327
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
328
|
-
{ indexed: !1, internalType: "address", name: "finalAsset", type: "address" },
|
|
329
|
-
{ indexed: !1, internalType: "address", name: "to", type: "address" },
|
|
330
|
-
{ indexed: !1, internalType: "uint256", name: "amountOutMin", type: "uint256" },
|
|
331
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
332
|
-
],
|
|
333
|
-
name: "TransferOutAndCall",
|
|
334
|
-
type: "event"
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
anonymous: !1,
|
|
338
|
-
inputs: [
|
|
339
|
-
{ indexed: !0, internalType: "address", name: "oldVault", type: "address" },
|
|
340
|
-
{ indexed: !0, internalType: "address", name: "newVault", type: "address" },
|
|
341
|
-
{
|
|
342
|
-
components: [
|
|
343
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
344
|
-
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
345
|
-
],
|
|
346
|
-
indexed: !1,
|
|
347
|
-
internalType: "struct AvaxRouter.Coin[]",
|
|
348
|
-
name: "coins",
|
|
349
|
-
type: "tuple[]"
|
|
350
|
-
},
|
|
351
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
352
|
-
],
|
|
353
|
-
name: "VaultTransfer",
|
|
354
|
-
type: "event"
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
inputs: [
|
|
358
|
-
{ internalType: "address payable", name: "vault", type: "address" },
|
|
359
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
360
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
361
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
362
|
-
],
|
|
363
|
-
name: "deposit",
|
|
364
|
-
outputs: [],
|
|
365
|
-
stateMutability: "payable",
|
|
366
|
-
type: "function"
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
inputs: [
|
|
370
|
-
{ internalType: "address payable", name: "vault", type: "address" },
|
|
371
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
372
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
373
|
-
{ internalType: "string", name: "memo", type: "string" },
|
|
374
|
-
{ internalType: "uint256", name: "expiration", type: "uint256" }
|
|
375
|
-
],
|
|
376
|
-
name: "depositWithExpiry",
|
|
377
|
-
outputs: [],
|
|
378
|
-
stateMutability: "payable",
|
|
379
|
-
type: "function"
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
inputs: [
|
|
383
|
-
{ internalType: "address", name: "router", type: "address" },
|
|
384
|
-
{ internalType: "address payable", name: "asgard", type: "address" },
|
|
385
|
-
{
|
|
386
|
-
components: [
|
|
387
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
388
|
-
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
389
|
-
],
|
|
390
|
-
internalType: "struct AvaxRouter.Coin[]",
|
|
391
|
-
name: "coins",
|
|
392
|
-
type: "tuple[]"
|
|
393
|
-
},
|
|
394
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
395
|
-
],
|
|
396
|
-
name: "returnVaultAssets",
|
|
397
|
-
outputs: [],
|
|
398
|
-
stateMutability: "payable",
|
|
399
|
-
type: "function"
|
|
400
|
-
},
|
|
401
|
-
{
|
|
402
|
-
inputs: [
|
|
403
|
-
{ internalType: "address", name: "router", type: "address" },
|
|
404
|
-
{ internalType: "address", name: "newVault", type: "address" },
|
|
405
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
406
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
407
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
408
|
-
],
|
|
409
|
-
name: "transferAllowance",
|
|
410
|
-
outputs: [],
|
|
411
|
-
stateMutability: "nonpayable",
|
|
412
|
-
type: "function"
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
inputs: [
|
|
416
|
-
{ internalType: "address payable", name: "to", type: "address" },
|
|
417
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
418
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
419
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
420
|
-
],
|
|
421
|
-
name: "transferOut",
|
|
422
|
-
outputs: [],
|
|
423
|
-
stateMutability: "payable",
|
|
424
|
-
type: "function"
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
inputs: [
|
|
428
|
-
{ internalType: "address payable", name: "target", type: "address" },
|
|
429
|
-
{ internalType: "address", name: "finalToken", type: "address" },
|
|
430
|
-
{ internalType: "address", name: "to", type: "address" },
|
|
431
|
-
{ internalType: "uint256", name: "amountOutMin", type: "uint256" },
|
|
432
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
433
|
-
],
|
|
434
|
-
name: "transferOutAndCall",
|
|
435
|
-
outputs: [],
|
|
436
|
-
stateMutability: "payable",
|
|
437
|
-
type: "function"
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
inputs: [
|
|
441
|
-
{ internalType: "address", name: "vault", type: "address" },
|
|
442
|
-
{ internalType: "address", name: "token", type: "address" }
|
|
443
|
-
],
|
|
444
|
-
name: "vaultAllowance",
|
|
445
|
-
outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
|
|
446
|
-
stateMutability: "view",
|
|
447
|
-
type: "function"
|
|
448
|
-
}
|
|
449
|
-
], gt = [
|
|
450
|
-
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
451
|
-
{
|
|
452
|
-
anonymous: !1,
|
|
453
|
-
inputs: [
|
|
454
|
-
{ indexed: !0, internalType: "address", name: "to", type: "address" },
|
|
455
|
-
{ indexed: !0, internalType: "address", name: "asset", type: "address" },
|
|
456
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
457
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
458
|
-
],
|
|
459
|
-
name: "Deposit",
|
|
460
|
-
type: "event"
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
anonymous: !1,
|
|
464
|
-
inputs: [
|
|
465
|
-
{ indexed: !0, internalType: "address", name: "oldVault", type: "address" },
|
|
466
|
-
{ indexed: !0, internalType: "address", name: "newVault", type: "address" },
|
|
467
|
-
{ indexed: !1, internalType: "address", name: "asset", type: "address" },
|
|
468
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
469
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
470
|
-
],
|
|
471
|
-
name: "TransferAllowance",
|
|
472
|
-
type: "event"
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
anonymous: !1,
|
|
476
|
-
inputs: [
|
|
477
|
-
{ indexed: !0, internalType: "address", name: "vault", type: "address" },
|
|
478
|
-
{ indexed: !0, internalType: "address", name: "to", type: "address" },
|
|
479
|
-
{ indexed: !1, internalType: "address", name: "asset", type: "address" },
|
|
480
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
481
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
482
|
-
],
|
|
483
|
-
name: "TransferOut",
|
|
484
|
-
type: "event"
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
anonymous: !1,
|
|
488
|
-
inputs: [
|
|
489
|
-
{ indexed: !0, internalType: "address", name: "vault", type: "address" },
|
|
490
|
-
{ indexed: !1, internalType: "address", name: "target", type: "address" },
|
|
491
|
-
{ indexed: !1, internalType: "uint256", name: "amount", type: "uint256" },
|
|
492
|
-
{ indexed: !1, internalType: "address", name: "finalAsset", type: "address" },
|
|
493
|
-
{ indexed: !1, internalType: "address", name: "to", type: "address" },
|
|
494
|
-
{ indexed: !1, internalType: "uint256", name: "amountOutMin", type: "uint256" },
|
|
495
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
496
|
-
],
|
|
497
|
-
name: "TransferOutAndCall",
|
|
498
|
-
type: "event"
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
anonymous: !1,
|
|
502
|
-
inputs: [
|
|
503
|
-
{ indexed: !0, internalType: "address", name: "oldVault", type: "address" },
|
|
504
|
-
{ indexed: !0, internalType: "address", name: "newVault", type: "address" },
|
|
505
|
-
{
|
|
506
|
-
components: [
|
|
507
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
508
|
-
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
509
|
-
],
|
|
510
|
-
indexed: !1,
|
|
511
|
-
internalType: "struct THORChain_Router.Coin[]",
|
|
512
|
-
name: "coins",
|
|
513
|
-
type: "tuple[]"
|
|
514
|
-
},
|
|
515
|
-
{ indexed: !1, internalType: "string", name: "memo", type: "string" }
|
|
516
|
-
],
|
|
517
|
-
name: "VaultTransfer",
|
|
518
|
-
type: "event"
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
inputs: [
|
|
522
|
-
{ internalType: "address payable", name: "vault", type: "address" },
|
|
523
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
524
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
525
|
-
{ internalType: "string", name: "memo", type: "string" },
|
|
526
|
-
{ internalType: "uint256", name: "expiration", type: "uint256" }
|
|
527
|
-
],
|
|
528
|
-
name: "depositWithExpiry",
|
|
529
|
-
outputs: [],
|
|
530
|
-
stateMutability: "payable",
|
|
531
|
-
type: "function"
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
inputs: [
|
|
535
|
-
{ internalType: "address", name: "router", type: "address" },
|
|
536
|
-
{ internalType: "address payable", name: "asgard", type: "address" },
|
|
537
|
-
{
|
|
538
|
-
components: [
|
|
539
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
540
|
-
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
541
|
-
],
|
|
542
|
-
internalType: "struct THORChain_Router.Coin[]",
|
|
543
|
-
name: "coins",
|
|
544
|
-
type: "tuple[]"
|
|
545
|
-
},
|
|
546
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
547
|
-
],
|
|
548
|
-
name: "returnVaultAssets",
|
|
549
|
-
outputs: [],
|
|
550
|
-
stateMutability: "payable",
|
|
551
|
-
type: "function"
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
inputs: [
|
|
555
|
-
{ internalType: "address", name: "router", type: "address" },
|
|
556
|
-
{ internalType: "address", name: "newVault", type: "address" },
|
|
557
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
558
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
559
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
560
|
-
],
|
|
561
|
-
name: "transferAllowance",
|
|
562
|
-
outputs: [],
|
|
563
|
-
stateMutability: "nonpayable",
|
|
564
|
-
type: "function"
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
inputs: [
|
|
568
|
-
{ internalType: "address payable", name: "to", type: "address" },
|
|
569
|
-
{ internalType: "address", name: "asset", type: "address" },
|
|
570
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
571
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
572
|
-
],
|
|
573
|
-
name: "transferOut",
|
|
574
|
-
outputs: [],
|
|
575
|
-
stateMutability: "payable",
|
|
576
|
-
type: "function"
|
|
577
|
-
},
|
|
578
|
-
{
|
|
579
|
-
inputs: [
|
|
580
|
-
{ internalType: "address payable", name: "target", type: "address" },
|
|
581
|
-
{ internalType: "address", name: "finalToken", type: "address" },
|
|
582
|
-
{ internalType: "address", name: "to", type: "address" },
|
|
583
|
-
{ internalType: "uint256", name: "amountOutMin", type: "uint256" },
|
|
584
|
-
{ internalType: "string", name: "memo", type: "string" }
|
|
585
|
-
],
|
|
586
|
-
name: "transferOutAndCall",
|
|
587
|
-
outputs: [],
|
|
588
|
-
stateMutability: "payable",
|
|
589
|
-
type: "function"
|
|
590
|
-
},
|
|
591
|
-
{
|
|
592
|
-
inputs: [
|
|
593
|
-
{ internalType: "address", name: "vault", type: "address" },
|
|
594
|
-
{ internalType: "address", name: "token", type: "address" }
|
|
595
|
-
],
|
|
596
|
-
name: "vaultAllowance",
|
|
597
|
-
outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
|
|
598
|
-
stateMutability: "view",
|
|
599
|
-
type: "function"
|
|
600
|
-
}
|
|
601
|
-
];
|
|
602
|
-
var _t = /* @__PURE__ */ ((e) => (e.TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC", e.TC_SUPPORTED_TO_ETH = "TC-ERC20", e.TC_SUPPORTED_TO_AVAX = "TC-ARC20", e.TC_SUPPORTED_TO_BSC = "TC-BEP20", e.ETH_TO_TC_SUPPORTED = "ERC20-TC", e.ETH_TO_ETH = "ERC20-ERC20", e.ETH_TO_AVAX = "ERC20-ARC20", e.ETH_TO_BSC = "ERC20-BEP20", e.AVAX_TO_TC_SUPPORTED = "ARC20-TC", e.AVAX_TO_ETH = "ARC20-ERC20", e.AVAX_TO_AVAX = "ARC20-ARC20", e.AVAX_TO_BSC = "ARC20-BEP20", e.BSC_TO_TC_SUPPORTED = "BEP20-TC", e.BSC_TO_ETH = "BEP20-ERC20", e.BSC_TO_AVAX = "BEP20-ARC20", e.BSC_TO_BSC = "BEP20-BEP20", e))(_t || {});
|
|
603
|
-
const Mt = [
|
|
604
|
-
"ERC20-ERC20",
|
|
605
|
-
"ARC20-ARC20",
|
|
606
|
-
"BEP20-BEP20"
|
|
607
|
-
/* BSC_TO_BSC */
|
|
608
|
-
], vt = [
|
|
609
|
-
"ERC20-TC",
|
|
610
|
-
"ERC20-ARC20",
|
|
611
|
-
"ERC20-BEP20",
|
|
612
|
-
"ARC20-TC",
|
|
613
|
-
"ARC20-ERC20",
|
|
614
|
-
"ARC20-BEP20",
|
|
615
|
-
"BEP20-TC",
|
|
616
|
-
"BEP20-ERC20",
|
|
617
|
-
"BEP20-ARC20"
|
|
618
|
-
/* BSC_TO_AVAX */
|
|
619
|
-
], Ct = [
|
|
620
|
-
"TC-TC",
|
|
621
|
-
"TC-ERC20",
|
|
622
|
-
"TC-ARC20",
|
|
623
|
-
"TC-BEP20"
|
|
624
|
-
/* TC_SUPPORTED_TO_BSC */
|
|
625
|
-
];
|
|
626
|
-
var r = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(r || {}), Et = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(Et || {}), Ot = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DASH = "m/44'/5'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.DOT = "////", e.ETH = "m/44'/60'/0'/0", e.FLIP = "////", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(Ot || {});
|
|
627
|
-
const Zn = {
|
|
628
|
-
ARB: [44, 60, 0, 0, 0],
|
|
629
|
-
AVAX: [44, 60, 0, 0, 0],
|
|
630
|
-
BCH: [44, 145, 0, 0, 0],
|
|
631
|
-
BNB: [44, 714, 0, 0, 0],
|
|
632
|
-
BSC: [44, 60, 0, 0, 0],
|
|
633
|
-
BTC: [84, 0, 0, 0, 0],
|
|
634
|
-
DASH: [44, 5, 0, 0, 0],
|
|
635
|
-
DOGE: [44, 3, 0, 0, 0],
|
|
636
|
-
ETH: [44, 60, 0, 0, 0],
|
|
637
|
-
GAIA: [44, 118, 0, 0, 0],
|
|
638
|
-
KUJI: [44, 118, 0, 0, 0],
|
|
639
|
-
LTC: [84, 2, 0, 0, 0],
|
|
640
|
-
MATIC: [44, 60, 0, 0, 0],
|
|
641
|
-
MAYA: [44, 931, 0, 0, 0],
|
|
642
|
-
OP: [44, 60, 0, 0, 0],
|
|
643
|
-
THOR: [44, 931, 0, 0, 0],
|
|
644
|
-
// Polkadot and related network derivation path is not number based
|
|
645
|
-
DOT: [0, 0, 0, 0, 0],
|
|
646
|
-
FLIP: [0, 0, 0, 0, 0]
|
|
647
|
-
};
|
|
648
|
-
var g = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.DOT = 10] = "DOT", e[e.ETH = 18] = "ETH", e[e.FLIP = 18] = "FLIP", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e[e.ZEC = 8] = "ZEC", e))(g || {});
|
|
649
|
-
const zn = [
|
|
650
|
-
"DOT",
|
|
651
|
-
"FLIP"
|
|
652
|
-
/* Chainflip */
|
|
653
|
-
], je = [
|
|
654
|
-
"ETH",
|
|
655
|
-
"AVAX",
|
|
656
|
-
"BSC",
|
|
657
|
-
"ARB",
|
|
658
|
-
"OP",
|
|
659
|
-
"MATIC"
|
|
660
|
-
/* Polygon */
|
|
661
|
-
], ea = je, kt = [
|
|
662
|
-
"BTC",
|
|
663
|
-
"BCH",
|
|
664
|
-
"DASH",
|
|
665
|
-
"DOGE",
|
|
666
|
-
"LTC"
|
|
667
|
-
/* Litecoin */
|
|
668
|
-
], ta = kt, xt = [
|
|
669
|
-
"GAIA",
|
|
670
|
-
"THOR",
|
|
671
|
-
"BNB",
|
|
672
|
-
"MAYA",
|
|
673
|
-
"KUJI"
|
|
674
|
-
/* Kujira */
|
|
675
|
-
], na = xt, St = [
|
|
676
|
-
"AVAX",
|
|
677
|
-
"BNB",
|
|
678
|
-
"BSC",
|
|
679
|
-
"BTC",
|
|
680
|
-
"BCH",
|
|
681
|
-
"GAIA",
|
|
682
|
-
"DOGE",
|
|
683
|
-
"ETH",
|
|
684
|
-
"LTC",
|
|
685
|
-
"THOR"
|
|
686
|
-
/* THORChain */
|
|
687
|
-
], aa = St;
|
|
688
|
-
var Re = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dash = "dash", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(Re || {}), Ke = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dash = "https://node-router.thorswap.net/dash", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Ke || {}), U = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(U || {});
|
|
689
|
-
const ce = Object.values(r), Rt = Object.keys(r), Be = ce.reduce(
|
|
690
|
-
(e, t) => {
|
|
691
|
-
const n = Rt.find((a) => r[a] === t);
|
|
692
|
-
return n && (e[t] = n), e;
|
|
693
|
-
},
|
|
694
|
-
{}
|
|
695
|
-
), Qe = ce.reduce(
|
|
696
|
-
(e, t) => (e[t] = Re[Be[t]], e),
|
|
697
|
-
{}
|
|
698
|
-
), Bt = ce.reduce(
|
|
699
|
-
(e, t) => (e[t] = Ke[Be[t]], e),
|
|
700
|
-
{}
|
|
701
|
-
), ia = ce.reduce(
|
|
702
|
-
(e, t) => {
|
|
703
|
-
const n = `${Be[t]}Hex`;
|
|
704
|
-
return e[t] = Re[n], e;
|
|
705
|
-
},
|
|
706
|
-
{}
|
|
707
|
-
), sa = {
|
|
708
|
-
"0xa4b1": "ARB",
|
|
709
|
-
42161: "ARB",
|
|
710
|
-
"0xa86a": "AVAX",
|
|
711
|
-
43114: "AVAX",
|
|
712
|
-
"0x38": "BSC",
|
|
713
|
-
56: "BSC",
|
|
714
|
-
"Binance-Chain-Tigris": "BNB",
|
|
715
|
-
bitcoincash: "BCH",
|
|
716
|
-
bitcoin: "BTC",
|
|
717
|
-
chainflip: "FLIP",
|
|
718
|
-
"cosmoshub-4": "GAIA",
|
|
719
|
-
dash: "DASH",
|
|
720
|
-
dogecoin: "DOGE",
|
|
721
|
-
"0x1": "ETH",
|
|
722
|
-
"kaiyo-1": "KUJI",
|
|
723
|
-
1: "ETH",
|
|
724
|
-
litecoin: "LTC",
|
|
725
|
-
"mayachain-stagenet-v1": "MAYA",
|
|
726
|
-
"mayachain-mainnet-v1": "MAYA",
|
|
727
|
-
"0xa": "OP",
|
|
728
|
-
10: "OP",
|
|
729
|
-
polkadot: "DOT",
|
|
730
|
-
"0x89": "MATIC",
|
|
731
|
-
137: "MATIC",
|
|
732
|
-
"thorchain-stagenet-v2": "THOR",
|
|
733
|
-
"thorchain-mainnet-v1": "THOR"
|
|
734
|
-
/* THORChain */
|
|
735
|
-
}, Ye = {
|
|
736
|
-
ARB: "https://arbiscan.io",
|
|
737
|
-
AVAX: "https://snowtrace.io",
|
|
738
|
-
BSC: "https://bscscan.com",
|
|
739
|
-
BNB: "https://explorer.binance.org",
|
|
740
|
-
BCH: "https://www.blockchair.com/bitcoin-cash",
|
|
741
|
-
BTC: "https://blockchair.com/bitcoin",
|
|
742
|
-
FLIP: "https://explorer.polkascan.io/polkadot",
|
|
743
|
-
GAIA: "https://cosmos.bigdipper.live",
|
|
744
|
-
DASH: "https://blockchair.com/dash",
|
|
745
|
-
DOGE: "https://blockchair.com/dogecoin",
|
|
746
|
-
KUJI: "https://finder.kujira.network/kaiyo-1",
|
|
747
|
-
ETH: "https://etherscan.io",
|
|
748
|
-
LTC: "https://blockchair.com/litecoin",
|
|
749
|
-
MAYA: "https://www.mayascan.org",
|
|
750
|
-
OP: "https://optimistic.etherscan.io",
|
|
751
|
-
DOT: "https://polkadot.subscan.io/",
|
|
752
|
-
MATIC: "https://polygonscan.com",
|
|
753
|
-
THOR: "https://runescan.io"
|
|
754
|
-
};
|
|
755
|
-
var w = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(w || {}), Y = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(Y || {}), It = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.KEEPKEY = "KEEPKEY", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.OKX_MOBILE = "OKX_MOBILE", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(It || {}), Pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e[e.LockedDevice = 21781] = "LockedDevice", e[e.TC_NotFound = 65535] = "TC_NotFound", e))(Pt || {}), Ht = Object.defineProperty, Dt = (e, t, n) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, P = (e, t, n) => (Dt(e, typeof t != "symbol" ? t + "" : t, n), n), Ft = (e, t, n) => {
|
|
756
|
-
if (!t.has(e))
|
|
757
|
-
throw TypeError("Cannot " + n);
|
|
758
|
-
}, Z = (e, t, n) => {
|
|
759
|
-
if (t.has(e))
|
|
760
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
761
|
-
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
762
|
-
}, E = (e, t, n) => (Ft(e, t, "access private method"), n), be = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(be || {}), Ie = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dash = "dash", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(Ie || {}), Je = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dash = "https://node-router.thorswap.net/dash", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Je || {}), N = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(N || {});
|
|
763
|
-
const fe = Object.values(be), Lt = Object.keys(be), Pe = fe.reduce(
|
|
764
|
-
(e, t) => {
|
|
765
|
-
const n = Lt.find((a) => be[a] === t);
|
|
766
|
-
return n && (e[t] = n), e;
|
|
767
|
-
},
|
|
768
|
-
{}
|
|
769
|
-
);
|
|
770
|
-
fe.reduce(
|
|
771
|
-
(e, t) => (e[t] = Ie[Pe[t]], e),
|
|
772
|
-
{}
|
|
773
|
-
);
|
|
774
|
-
fe.reduce(
|
|
775
|
-
(e, t) => (e[t] = Je[Pe[t]], e),
|
|
776
|
-
{}
|
|
777
|
-
);
|
|
778
|
-
fe.reduce(
|
|
779
|
-
(e, t) => {
|
|
780
|
-
const n = `${Pe[t]}Hex`;
|
|
781
|
-
return e[t] = Ie[n], e;
|
|
782
|
-
},
|
|
783
|
-
{}
|
|
784
|
-
);
|
|
785
|
-
class Ve extends Error {
|
|
786
|
-
constructor(t, n, a) {
|
|
787
|
-
const i = t.status || t.status === 0 ? t.status : "", s = t.statusText || "", p = `${i} ${s}`.trim(), u = p ? `status code ${p}` : "an unknown error";
|
|
788
|
-
super(`Request failed with ${u}`), Object.defineProperty(this, "response", {
|
|
789
|
-
enumerable: !0,
|
|
790
|
-
configurable: !0,
|
|
791
|
-
writable: !0,
|
|
792
|
-
value: void 0
|
|
793
|
-
}), Object.defineProperty(this, "request", {
|
|
794
|
-
enumerable: !0,
|
|
795
|
-
configurable: !0,
|
|
796
|
-
writable: !0,
|
|
797
|
-
value: void 0
|
|
798
|
-
}), Object.defineProperty(this, "options", {
|
|
799
|
-
enumerable: !0,
|
|
800
|
-
configurable: !0,
|
|
801
|
-
writable: !0,
|
|
802
|
-
value: void 0
|
|
803
|
-
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
class Ze extends Error {
|
|
807
|
-
constructor(t) {
|
|
808
|
-
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
809
|
-
enumerable: !0,
|
|
810
|
-
configurable: !0,
|
|
811
|
-
writable: !0,
|
|
812
|
-
value: void 0
|
|
813
|
-
}), this.name = "TimeoutError", this.request = t;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
const pe = (e) => e !== null && typeof e == "object", re = (...e) => {
|
|
817
|
-
for (const t of e)
|
|
818
|
-
if ((!pe(t) || Array.isArray(t)) && t !== void 0)
|
|
819
|
-
throw new TypeError("The `options` argument must be an object");
|
|
820
|
-
return He({}, ...e);
|
|
821
|
-
}, ze = (e = {}, t = {}) => {
|
|
822
|
-
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, i = new globalThis.Headers(t);
|
|
823
|
-
for (const [s, p] of i.entries())
|
|
824
|
-
a && p === "undefined" || p === void 0 ? n.delete(s) : n.set(s, p);
|
|
825
|
-
return n;
|
|
826
|
-
}, He = (...e) => {
|
|
827
|
-
let t = {}, n = {};
|
|
828
|
-
for (const a of e)
|
|
829
|
-
if (Array.isArray(a))
|
|
830
|
-
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
831
|
-
else if (pe(a)) {
|
|
832
|
-
for (let [i, s] of Object.entries(a))
|
|
833
|
-
pe(s) && i in t && (s = He(t[i], s)), t = { ...t, [i]: s };
|
|
834
|
-
pe(a.headers) && (n = ze(n, a.headers), t.headers = n);
|
|
835
|
-
}
|
|
836
|
-
return t;
|
|
837
|
-
}, Vt = (() => {
|
|
838
|
-
let e = !1, t = !1;
|
|
839
|
-
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
840
|
-
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
841
|
-
body: new globalThis.ReadableStream(),
|
|
842
|
-
method: "POST",
|
|
843
|
-
// @ts-expect-error - Types are outdated.
|
|
844
|
-
get duplex() {
|
|
845
|
-
return e = !0, "half";
|
|
846
|
-
}
|
|
847
|
-
}).headers.has("Content-Type")), e && !t;
|
|
848
|
-
})(), Nt = typeof globalThis.AbortController == "function", qt = typeof globalThis.ReadableStream == "function", Wt = typeof globalThis.FormData == "function", et = ["get", "post", "put", "patch", "head", "delete"], $t = {
|
|
849
|
-
json: "application/json",
|
|
850
|
-
text: "text/*",
|
|
851
|
-
formData: "multipart/form-data",
|
|
852
|
-
arrayBuffer: "*/*",
|
|
853
|
-
blob: "*/*"
|
|
854
|
-
}, Ae = 2147483647, tt = Symbol("stop"), Ut = {
|
|
855
|
-
json: !0,
|
|
856
|
-
parseJson: !0,
|
|
857
|
-
searchParams: !0,
|
|
858
|
-
prefixUrl: !0,
|
|
859
|
-
retry: !0,
|
|
860
|
-
timeout: !0,
|
|
861
|
-
hooks: !0,
|
|
862
|
-
throwHttpErrors: !0,
|
|
863
|
-
onDownloadProgress: !0,
|
|
864
|
-
fetch: !0
|
|
865
|
-
}, Xt = {
|
|
866
|
-
method: !0,
|
|
867
|
-
headers: !0,
|
|
868
|
-
body: !0,
|
|
869
|
-
mode: !0,
|
|
870
|
-
credentials: !0,
|
|
871
|
-
cache: !0,
|
|
872
|
-
redirect: !0,
|
|
873
|
-
referrer: !0,
|
|
874
|
-
referrerPolicy: !0,
|
|
875
|
-
integrity: !0,
|
|
876
|
-
keepalive: !0,
|
|
877
|
-
signal: !0,
|
|
878
|
-
window: !0,
|
|
879
|
-
dispatcher: !0,
|
|
880
|
-
duplex: !0
|
|
881
|
-
}, Gt = (e) => et.includes(e) ? e.toUpperCase() : e, jt = ["get", "put", "head", "delete", "options", "trace"], Kt = [408, 413, 429, 500, 502, 503, 504], nt = [413, 429, 503], Ne = {
|
|
882
|
-
limit: 2,
|
|
883
|
-
methods: jt,
|
|
884
|
-
statusCodes: Kt,
|
|
885
|
-
afterStatusCodes: nt,
|
|
886
|
-
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
887
|
-
backoffLimit: Number.POSITIVE_INFINITY,
|
|
888
|
-
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
889
|
-
}, Qt = (e = {}) => {
|
|
890
|
-
if (typeof e == "number")
|
|
891
|
-
return {
|
|
892
|
-
...Ne,
|
|
893
|
-
limit: e
|
|
894
|
-
};
|
|
895
|
-
if (e.methods && !Array.isArray(e.methods))
|
|
896
|
-
throw new Error("retry.methods must be an array");
|
|
897
|
-
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
898
|
-
throw new Error("retry.statusCodes must be an array");
|
|
899
|
-
return {
|
|
900
|
-
...Ne,
|
|
901
|
-
...e,
|
|
902
|
-
afterStatusCodes: nt
|
|
903
|
-
};
|
|
904
|
-
};
|
|
905
|
-
async function Yt(e, t, n, a) {
|
|
906
|
-
return new Promise((i, s) => {
|
|
907
|
-
const p = setTimeout(() => {
|
|
908
|
-
n && n.abort(), s(new Ze(e));
|
|
909
|
-
}, a.timeout);
|
|
910
|
-
a.fetch(e, t).then(i).catch(s).then(() => {
|
|
911
|
-
clearTimeout(p);
|
|
912
|
-
});
|
|
913
|
-
});
|
|
914
|
-
}
|
|
915
|
-
async function Jt(e, { signal: t }) {
|
|
916
|
-
return new Promise((n, a) => {
|
|
917
|
-
t && (t.throwIfAborted(), t.addEventListener("abort", i, { once: !0 }));
|
|
918
|
-
function i() {
|
|
919
|
-
clearTimeout(s), a(t.reason);
|
|
920
|
-
}
|
|
921
|
-
const s = setTimeout(() => {
|
|
922
|
-
t == null || t.removeEventListener("abort", i), n();
|
|
923
|
-
}, e);
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
const Zt = (e, t) => {
|
|
927
|
-
const n = {};
|
|
928
|
-
for (const a in t)
|
|
929
|
-
!(a in Xt) && !(a in Ut) && !(a in e) && (n[a] = t[a]);
|
|
930
|
-
return n;
|
|
931
|
-
};
|
|
932
|
-
class oe {
|
|
933
|
-
static create(t, n) {
|
|
934
|
-
const a = new oe(t, n), i = async () => {
|
|
935
|
-
if (typeof a._options.timeout == "number" && a._options.timeout > Ae)
|
|
936
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${Ae}`);
|
|
937
|
-
await Promise.resolve();
|
|
938
|
-
let p = await a._fetch();
|
|
939
|
-
for (const u of a._options.hooks.afterResponse) {
|
|
940
|
-
const y = await u(a.request, a._options, a._decorateResponse(p.clone()));
|
|
941
|
-
y instanceof globalThis.Response && (p = y);
|
|
942
|
-
}
|
|
943
|
-
if (a._decorateResponse(p), !p.ok && a._options.throwHttpErrors) {
|
|
944
|
-
let u = new Ve(p, a.request, a._options);
|
|
945
|
-
for (const y of a._options.hooks.beforeError)
|
|
946
|
-
u = await y(u);
|
|
947
|
-
throw u;
|
|
948
|
-
}
|
|
949
|
-
if (a._options.onDownloadProgress) {
|
|
950
|
-
if (typeof a._options.onDownloadProgress != "function")
|
|
951
|
-
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
952
|
-
if (!qt)
|
|
953
|
-
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
954
|
-
return a._stream(p.clone(), a._options.onDownloadProgress);
|
|
955
|
-
}
|
|
956
|
-
return p;
|
|
957
|
-
}, s = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(i) : i();
|
|
958
|
-
for (const [p, u] of Object.entries($t))
|
|
959
|
-
s[p] = async () => {
|
|
960
|
-
a.request.headers.set("accept", a.request.headers.get("accept") || u);
|
|
961
|
-
const y = (await s).clone();
|
|
962
|
-
if (p === "json") {
|
|
963
|
-
if (y.status === 204 || (await y.clone().arrayBuffer()).byteLength === 0)
|
|
964
|
-
return "";
|
|
965
|
-
if (n.parseJson)
|
|
966
|
-
return n.parseJson(await y.text());
|
|
967
|
-
}
|
|
968
|
-
return y[p]();
|
|
969
|
-
};
|
|
970
|
-
return s;
|
|
971
|
-
}
|
|
972
|
-
// eslint-disable-next-line complexity
|
|
973
|
-
constructor(t, n = {}) {
|
|
974
|
-
Object.defineProperty(this, "request", {
|
|
975
|
-
enumerable: !0,
|
|
976
|
-
configurable: !0,
|
|
977
|
-
writable: !0,
|
|
978
|
-
value: void 0
|
|
979
|
-
}), Object.defineProperty(this, "abortController", {
|
|
980
|
-
enumerable: !0,
|
|
981
|
-
configurable: !0,
|
|
982
|
-
writable: !0,
|
|
983
|
-
value: void 0
|
|
984
|
-
}), Object.defineProperty(this, "_retryCount", {
|
|
985
|
-
enumerable: !0,
|
|
986
|
-
configurable: !0,
|
|
987
|
-
writable: !0,
|
|
988
|
-
value: 0
|
|
989
|
-
}), Object.defineProperty(this, "_input", {
|
|
990
|
-
enumerable: !0,
|
|
991
|
-
configurable: !0,
|
|
992
|
-
writable: !0,
|
|
993
|
-
value: void 0
|
|
994
|
-
}), Object.defineProperty(this, "_options", {
|
|
995
|
-
enumerable: !0,
|
|
996
|
-
configurable: !0,
|
|
997
|
-
writable: !0,
|
|
998
|
-
value: void 0
|
|
999
|
-
}), this._input = t;
|
|
1000
|
-
const a = "credentials" in Request.prototype;
|
|
1001
|
-
if (this._options = {
|
|
1002
|
-
credentials: a ? this._input.credentials : void 0,
|
|
1003
|
-
...n,
|
|
1004
|
-
headers: ze(this._input.headers, n.headers),
|
|
1005
|
-
hooks: He({
|
|
1006
|
-
beforeRequest: [],
|
|
1007
|
-
beforeRetry: [],
|
|
1008
|
-
beforeError: [],
|
|
1009
|
-
afterResponse: []
|
|
1010
|
-
}, n.hooks),
|
|
1011
|
-
method: Gt(n.method ?? this._input.method),
|
|
1012
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1013
|
-
prefixUrl: String(n.prefixUrl || ""),
|
|
1014
|
-
retry: Qt(n.retry),
|
|
1015
|
-
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1016
|
-
timeout: n.timeout ?? 1e4,
|
|
1017
|
-
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
1018
|
-
}, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))
|
|
1019
|
-
throw new TypeError("`input` must be a string, URL, or Request");
|
|
1020
|
-
if (this._options.prefixUrl && typeof this._input == "string") {
|
|
1021
|
-
if (this._input.startsWith("/"))
|
|
1022
|
-
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1023
|
-
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1024
|
-
}
|
|
1025
|
-
if (Nt) {
|
|
1026
|
-
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1027
|
-
const i = this._options.signal;
|
|
1028
|
-
this._options.signal.addEventListener("abort", () => {
|
|
1029
|
-
this.abortController.abort(i.reason);
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
this._options.signal = this.abortController.signal;
|
|
1033
|
-
}
|
|
1034
|
-
if (Vt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1035
|
-
const i = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i);
|
|
1036
|
-
(Wt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
|
|
1037
|
-
}
|
|
1038
|
-
this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
|
|
1039
|
-
}
|
|
1040
|
-
_calculateRetryDelay(t) {
|
|
1041
|
-
if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof Ze)) {
|
|
1042
|
-
if (t instanceof Ve) {
|
|
1043
|
-
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1044
|
-
return 0;
|
|
1045
|
-
const a = t.response.headers.get("Retry-After");
|
|
1046
|
-
if (a && this._options.retry.afterStatusCodes.includes(t.response.status)) {
|
|
1047
|
-
let i = Number(a);
|
|
1048
|
-
return Number.isNaN(i) ? i = Date.parse(a) - Date.now() : i *= 1e3, this._options.retry.maxRetryAfter !== void 0 && i > this._options.retry.maxRetryAfter ? 0 : i;
|
|
1049
|
-
}
|
|
1050
|
-
if (t.response.status === 413)
|
|
1051
|
-
return 0;
|
|
1052
|
-
}
|
|
1053
|
-
const n = this._options.retry.delay(this._retryCount);
|
|
1054
|
-
return Math.min(this._options.retry.backoffLimit, n);
|
|
1055
|
-
}
|
|
1056
|
-
return 0;
|
|
1057
|
-
}
|
|
1058
|
-
_decorateResponse(t) {
|
|
1059
|
-
return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
|
|
1060
|
-
}
|
|
1061
|
-
async _retry(t) {
|
|
1062
|
-
try {
|
|
1063
|
-
return await t();
|
|
1064
|
-
} catch (n) {
|
|
1065
|
-
const a = Math.min(this._calculateRetryDelay(n), Ae);
|
|
1066
|
-
if (a !== 0 && this._retryCount > 0) {
|
|
1067
|
-
await Jt(a, { signal: this._options.signal });
|
|
1068
|
-
for (const i of this._options.hooks.beforeRetry)
|
|
1069
|
-
if (await i({
|
|
1070
|
-
request: this.request,
|
|
1071
|
-
options: this._options,
|
|
1072
|
-
error: n,
|
|
1073
|
-
retryCount: this._retryCount
|
|
1074
|
-
}) === tt)
|
|
1075
|
-
return;
|
|
1076
|
-
return this._retry(t);
|
|
1077
|
-
}
|
|
1078
|
-
throw n;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
async _fetch() {
|
|
1082
|
-
for (const n of this._options.hooks.beforeRequest) {
|
|
1083
|
-
const a = await n(this.request, this._options);
|
|
1084
|
-
if (a instanceof Request) {
|
|
1085
|
-
this.request = a;
|
|
1086
|
-
break;
|
|
1087
|
-
}
|
|
1088
|
-
if (a instanceof Response)
|
|
1089
|
-
return a;
|
|
1090
|
-
}
|
|
1091
|
-
const t = Zt(this.request, this._options);
|
|
1092
|
-
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Yt(this.request.clone(), t, this.abortController, this._options);
|
|
1093
|
-
}
|
|
1094
|
-
/* istanbul ignore next */
|
|
1095
|
-
_stream(t, n) {
|
|
1096
|
-
const a = Number(t.headers.get("content-length")) || 0;
|
|
1097
|
-
let i = 0;
|
|
1098
|
-
return t.status === 204 ? (n && n({ percent: 1, totalBytes: a, transferredBytes: i }, new Uint8Array()), new globalThis.Response(null, {
|
|
1099
|
-
status: t.status,
|
|
1100
|
-
statusText: t.statusText,
|
|
1101
|
-
headers: t.headers
|
|
1102
|
-
})) : new globalThis.Response(new globalThis.ReadableStream({
|
|
1103
|
-
async start(s) {
|
|
1104
|
-
const p = t.body.getReader();
|
|
1105
|
-
n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
|
|
1106
|
-
async function u() {
|
|
1107
|
-
const { done: y, value: o } = await p.read();
|
|
1108
|
-
if (y) {
|
|
1109
|
-
s.close();
|
|
1110
|
-
return;
|
|
1111
|
-
}
|
|
1112
|
-
if (n) {
|
|
1113
|
-
i += o.byteLength;
|
|
1114
|
-
const l = a === 0 ? 0 : i / a;
|
|
1115
|
-
n({ percent: l, transferredBytes: i, totalBytes: a }, o);
|
|
1116
|
-
}
|
|
1117
|
-
s.enqueue(o), await u();
|
|
1118
|
-
}
|
|
1119
|
-
await u();
|
|
1120
|
-
}
|
|
1121
|
-
}), {
|
|
1122
|
-
status: t.status,
|
|
1123
|
-
statusText: t.statusText,
|
|
1124
|
-
headers: t.headers
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
/*! MIT License © Sindre Sorhus */
|
|
1129
|
-
const Ce = (e) => {
|
|
1130
|
-
const t = (n, a) => oe.create(n, re(e, a));
|
|
1131
|
-
for (const n of et)
|
|
1132
|
-
t[n] = (a, i) => oe.create(a, re(e, i, { method: n }));
|
|
1133
|
-
return t.create = (n) => Ce(re(n)), t.extend = (n) => Ce(re(e, n)), t.stop = tt, t;
|
|
1134
|
-
}, at = Ce();
|
|
1135
|
-
let ue;
|
|
1136
|
-
const L = {
|
|
1137
|
-
CachedPrices: `${N.ThorswapApi}/tokenlist/cached-price`,
|
|
1138
|
-
GasRates: `${N.ThorswapApi}/resource-worker/gasPrice/getAll`,
|
|
1139
|
-
Quote: `${N.ThorswapApi}/aggregator/tokens/quote`,
|
|
1140
|
-
Txn: `${N.ThorswapApi}/apiusage/v2/txn`,
|
|
1141
|
-
TokenlistProviders: `${N.ThorswapApi}/tokenlist/providers`,
|
|
1142
|
-
TokenList: `${N.ThorswapStatic}/token-list`,
|
|
1143
|
-
Thorname: `${N.ThorswapApi}/thorname`
|
|
1144
|
-
}, it = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, qe = () => ue || (ue = at.create({ headers: it }), ue), ra = ({ apiKey: e, ...t }) => {
|
|
1145
|
-
ue = at.create({
|
|
1146
|
-
...t,
|
|
1147
|
-
headers: { ...it, ...t.headers, "x-api-key": e }
|
|
1148
|
-
});
|
|
1149
|
-
}, k = {
|
|
1150
|
-
get: (e, t) => qe().get(e, t).json(),
|
|
1151
|
-
post: (e, t) => qe().post(e, t).json()
|
|
1152
|
-
}, zt = ({ tokens: e, ...t }) => {
|
|
1153
|
-
const n = new URLSearchParams(), a = e.filter(
|
|
1154
|
-
(i, s, p) => p.findIndex((u) => u === i) === s
|
|
1155
|
-
);
|
|
1156
|
-
for (const i of a)
|
|
1157
|
-
n.append("tokens", JSON.stringify(i));
|
|
1158
|
-
return t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"), k.post(L.CachedPrices, {
|
|
1159
|
-
body: n.toString(),
|
|
1160
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
1161
|
-
});
|
|
1162
|
-
}, pa = {
|
|
1163
|
-
getCachedPrices: zt,
|
|
1164
|
-
getQuote: (e) => k.get(L.Quote, { searchParams: e }),
|
|
1165
|
-
getGasRates: () => k.get(L.GasRates),
|
|
1166
|
-
getTxnDetails: (e) => k.get(L.Txn, { searchParams: e }),
|
|
1167
|
-
getTokenlistProviders: () => k.get(L.TokenlistProviders),
|
|
1168
|
-
getTokenList: (e) => k.get(`${L.TokenList}/${e}.json`),
|
|
1169
|
-
getThornameAddresses: (e) => k.get(`${L.Thorname}/${e}`),
|
|
1170
|
-
getThornameRegisteredChains: (e) => k.get(`${L.Thorname}/chains/${e}`),
|
|
1171
|
-
getThornameRlookup: (e, t) => k.get(`${L.Thorname}/rlookup`, { searchParams: { address: e, chain: t } })
|
|
1172
|
-
};
|
|
1173
|
-
var en = /* @__PURE__ */ ((e) => (e.SWAP_TC_TO_TC = "SWAP:TC-TC", e.SWAP_ETH_TO_TC = "SWAP:ERC20-TC", e.SWAP_TC_TO_ETH = "SWAP:TC-ERC20", e.SWAP_ETH_TO_ETH = "SWAP:ERC20-ERC20", e.SWAP_AVAX_TO_TC = "SWAP:AVAX-TC", e.SWAP_TC_TO_AVAX = "SWAP:TC-AVAX", e.SWAP_AVAX_TO_AVAX = "SWAP:AVAX-AVAX", e.SWAP_ETH_TO_AVAX = "SWAP:ETH-AVAX", e.SWAP_AVAX_TO_ETH = "SWAP:AVAX-ETH", e.SWAP_TC_TO_GAIA = "SWAP:TC-GAIA", e.SWAP_GAIA_TO_TC = "SWAP:GAIA-TC", e.SWAP_TC_TO_BNB = "SWAP:TC-BNB", e.SWAP_BNB_TO_TC = "SWAP:BNB-TC", e.SWAP_TC_TO_BTC = "SWAP:TC-BTC", e.SWAP_BTC_TO_TC = "SWAP:BTC-TC", e.SWAP_TC_TO_BCH = "SWAP:TC-BCH", e.SWAP_BCH_TO_TC = "SWAP:BCH-TC", e.SWAP_TC_TO_LTC = "SWAP:TC-LTC", e.SWAP_LTC_TO_TC = "SWAP:LTC-TC", e.SWAP_TC_TO_DOGE = "SWAP:TC-DOGE", e.SWAP_DOGE_TO_TC = "SWAP:DOGE-TC", e.TC_STATUS = "TC:STATUS", e.TC_TRANSFER = "TC:TRANSFER", e.TC_DEPOSIT = "TC:DEPOSIT", e.TC_SEND = "TC:SEND", e.TC_SWITCH = "TC:SWITCH", e.TC_LP_ADD = "TC:ADDLIQUIDITY", e.TC_LP_WITHDRAW = "TC:WITHDRAW", e.TC_TNS_CREATE = "TC:TNS-CREATE", e.TC_TNS_EXTEND = "TC:TNS-EXTEND", e.TC_TNS_UPDATE = "TC:TNS-UPDATE", e.TC_SAVINGS_ADD = "TC:ADDSAVINGS", e.TC_SAVINGS_WITHDRAW = "TC:WITHDRAWSAVINGS", e.TC_LENDING_OPEN = "TC:LENDINGOPEN", e.TC_LENDING_CLOSE = "TC:LENDINGCLOSE", e.ETH_APPROVAL = "ETH:APPROVAL", e.ETH_STATUS = "ETH:STATUS", e.ETH_TRANSFER_TO_TC = "ETH:TRANSFER:IN", e.ETH_TRANSFER_FROM_TC = "ETH:TRANSFER:OUT", e.AVAX_APPROVAL = "AVAX:APPROVAL", e.AVAX_STATUS = "AVAX:STATUS", e.AVAX_TRANSFER_TO_TC = "AVAX:TRANSFER:IN", e.AVAX_TRANSFER_FROM_TC = "AVAX:TRANSFER:OUT", e.BSC_APPROVAL = "BSC:APPROVAL", e.BSC_STATUS = "BSC:STATUS", e.BSC_TRANSFER_TO_TC = "BSC:TRANSFER:IN", e.BSC_TRANSFER_FROM_TC = "BSC:TRANSFER:OUT", e.APPROVAL = "APPROVAL", e.STATUS = "STATUS", e.TRANSFER_TO_TC = "TRANSFER:IN", e.TRANSFER_FROM_TC = "TRANSFER:OUT", e.UNSUPPORTED = "UNSUPPORTED", e.TC_LENDING = "TC:LENDING", e))(en || {}), tn = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.SUCCESS = "success", e.CANCELLED = "cancelled", e.REFUNDED = "refunded", e.REPLACED = "replaced", e.ERROR = "error", e.UNKNOWN = "unknown", e.NOT_STARTED = "not_started", e.NOT_FOUND = "not_found", e.RETRIES_EXCEEDED = "retries_exceeded", e.STREAMING = "streaming", e))(tn || {}), nn = /* @__PURE__ */ ((e) => (e[e.NOT_STARTED = 0] = "NOT_STARTED", e[e.SUCCESS = 1] = "SUCCESS", e[e.REFUNDED = 2] = "REFUNDED", e))(nn || {});
|
|
1174
|
-
const an = "0x313ce567", st = async ({ chain: e, to: t }) => {
|
|
1175
|
-
try {
|
|
1176
|
-
const { result: n } = await k.post(Bt[e], {
|
|
1177
|
-
headers: {
|
|
1178
|
-
accept: "*/*",
|
|
1179
|
-
"content-type": "application/json",
|
|
1180
|
-
"cache-control": "no-cache"
|
|
1181
|
-
},
|
|
1182
|
-
body: JSON.stringify({
|
|
1183
|
-
id: 44,
|
|
1184
|
-
jsonrpc: "2.0",
|
|
1185
|
-
method: "eth_call",
|
|
1186
|
-
params: [{ to: t.toLowerCase(), data: an }, "latest"]
|
|
1187
|
-
})
|
|
1188
|
-
});
|
|
1189
|
-
return Number.parseInt(BigInt(n).toString());
|
|
1190
|
-
} catch (n) {
|
|
1191
|
-
return console.error(n), g[e];
|
|
1192
|
-
}
|
|
1193
|
-
}, sn = (e) => {
|
|
1194
|
-
if (e === r.Ethereum)
|
|
1195
|
-
return g.ETH;
|
|
1196
|
-
const [, t] = e.split("-");
|
|
1197
|
-
return t != null && t.startsWith("0x") ? st({ chain: r.Ethereum, to: t }) : g.ETH;
|
|
1198
|
-
}, rn = (e) => {
|
|
1199
|
-
const [, t] = e.split("-");
|
|
1200
|
-
return t != null && t.startsWith("0x") ? st({ chain: r.Avalanche, to: t.toLowerCase() }) : g.AVAX;
|
|
1201
|
-
}, pn = (e) => (e === r.BinanceSmartChain, g.BSC), un = ({ chain: e, symbol: t }) => {
|
|
1202
|
-
switch (e) {
|
|
1203
|
-
case r.Ethereum:
|
|
1204
|
-
return sn(t);
|
|
1205
|
-
case r.Avalanche:
|
|
1206
|
-
return rn(t);
|
|
1207
|
-
case r.BinanceSmartChain:
|
|
1208
|
-
return pn(t);
|
|
1209
|
-
default:
|
|
1210
|
-
return g[e];
|
|
1211
|
-
}
|
|
1212
|
-
}, yn = {
|
|
1213
|
-
[Y.Average]: 1.2,
|
|
1214
|
-
[Y.Fast]: 1.5,
|
|
1215
|
-
[Y.Fastest]: 2
|
|
1216
|
-
}, rt = ({ chain: e, symbol: t }) => {
|
|
1217
|
-
switch (e) {
|
|
1218
|
-
case r.Arbitrum:
|
|
1219
|
-
case r.Optimism:
|
|
1220
|
-
return t === "ETH";
|
|
1221
|
-
case r.Maya:
|
|
1222
|
-
return t === "CACAO";
|
|
1223
|
-
case r.Kujira:
|
|
1224
|
-
return t === "KUJI";
|
|
1225
|
-
case r.Cosmos:
|
|
1226
|
-
return t === "ATOM";
|
|
1227
|
-
case r.Polygon:
|
|
1228
|
-
return t === "MATIC";
|
|
1229
|
-
case r.BinanceSmartChain:
|
|
1230
|
-
return t === "BNB";
|
|
1231
|
-
case r.THORChain:
|
|
1232
|
-
return t === "RUNE";
|
|
1233
|
-
default:
|
|
1234
|
-
return t === e;
|
|
1235
|
-
}
|
|
1236
|
-
}, on = (e) => {
|
|
1237
|
-
switch (e) {
|
|
1238
|
-
case `${r.Ethereum}.THOR`:
|
|
1239
|
-
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
1240
|
-
case `${r.Ethereum}.vTHOR`:
|
|
1241
|
-
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
1242
|
-
case r.Cosmos:
|
|
1243
|
-
return { identifier: "GAIA.ATOM", decimal: g[e] };
|
|
1244
|
-
case r.THORChain:
|
|
1245
|
-
return { identifier: "THOR.RUNE", decimal: g[e] };
|
|
1246
|
-
case r.BinanceSmartChain:
|
|
1247
|
-
return { identifier: "BSC.BNB", decimal: g[e] };
|
|
1248
|
-
case r.Maya:
|
|
1249
|
-
return { identifier: "MAYA.CACAO", decimal: g.MAYA };
|
|
1250
|
-
case `${r.Maya}.MAYA`:
|
|
1251
|
-
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
1252
|
-
case `${r.Kujira}.USK`:
|
|
1253
|
-
return { identifier: `${r.Kujira}.USK`, decimal: 6 };
|
|
1254
|
-
default:
|
|
1255
|
-
return { identifier: `${e}.${e}`, decimal: g[e] };
|
|
1256
|
-
}
|
|
1257
|
-
}, dn = ({ chain: e, symbol: t }) => {
|
|
1258
|
-
if (t.includes("/"))
|
|
1259
|
-
return "Synth";
|
|
1260
|
-
switch (e) {
|
|
1261
|
-
case r.Cosmos:
|
|
1262
|
-
return t === "ATOM" ? "Native" : r.Cosmos;
|
|
1263
|
-
case r.Kujira:
|
|
1264
|
-
return t === r.Kujira ? "Native" : r.Kujira;
|
|
1265
|
-
case r.Binance:
|
|
1266
|
-
return t === r.Binance ? "Native" : "BEP2";
|
|
1267
|
-
case r.BinanceSmartChain:
|
|
1268
|
-
return t === r.Binance ? "Native" : "BEP20";
|
|
1269
|
-
case r.Ethereum:
|
|
1270
|
-
return t === r.Ethereum ? "Native" : "ERC20";
|
|
1271
|
-
case r.Avalanche:
|
|
1272
|
-
return t === r.Avalanche ? "Native" : r.Avalanche;
|
|
1273
|
-
case r.Polygon:
|
|
1274
|
-
return t === r.Polygon ? "Native" : "POLYGON";
|
|
1275
|
-
case r.Arbitrum:
|
|
1276
|
-
return [r.Ethereum, r.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
1277
|
-
case r.Optimism:
|
|
1278
|
-
return [r.Ethereum, r.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
1279
|
-
default:
|
|
1280
|
-
return "Native";
|
|
1281
|
-
}
|
|
1282
|
-
}, ua = (e) => {
|
|
1283
|
-
var t;
|
|
1284
|
-
const [n, ...a] = e.split("."), i = e.includes("/"), s = a.join("."), p = (t = s == null ? void 0 : s.split("-")) == null ? void 0 : t[0];
|
|
1285
|
-
return { chain: n, symbol: s, ticker: p, synth: i };
|
|
1286
|
-
}, ln = new RegExp(
|
|
1287
|
-
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
1288
|
-
"gmi"
|
|
1289
|
-
), mn = (e) => {
|
|
1290
|
-
const [t, n] = e.split(".");
|
|
1291
|
-
if (!je.includes(t))
|
|
1292
|
-
return !0;
|
|
1293
|
-
const [, a] = n.split("-");
|
|
1294
|
-
return rt({ chain: t, symbol: n }) || !!a;
|
|
1295
|
-
}, ya = (e) => e.filter(({ chain: t, value: n, symbol: a }) => {
|
|
1296
|
-
const i = `${t}.${a}`;
|
|
1297
|
-
return !ln.test(i) && mn(i) && n !== "0";
|
|
1298
|
-
});
|
|
1299
|
-
async function oa(e) {
|
|
1300
|
-
const t = await import("@swapkit/tokens");
|
|
1301
|
-
for (const n of Object.values(t))
|
|
1302
|
-
for (const { identifier: a, chain: i, ...s } of n.tokens)
|
|
1303
|
-
if ("identifier" in e && a === e.identifier || "address" in s && "chain" in e && i === e.chain && s.address.toLowerCase() === e.contract.toLowerCase())
|
|
1304
|
-
return a;
|
|
1305
|
-
}
|
|
1306
|
-
function Tn({
|
|
1307
|
-
liquidityUnits: e,
|
|
1308
|
-
poolUnits: t,
|
|
1309
|
-
runeDepth: n
|
|
1310
|
-
}) {
|
|
1311
|
-
const a = S(e), i = S(t), s = S(n), p = a.mul(s), u = i.mul(i).mul(2), y = i.mul(a).mul(2), o = a.mul(a), l = i.mul(i).mul(i);
|
|
1312
|
-
return p.mul(u.sub(y).add(o)).div(l);
|
|
1313
|
-
}
|
|
1314
|
-
function cn({
|
|
1315
|
-
liquidityUnits: e,
|
|
1316
|
-
poolUnits: t,
|
|
1317
|
-
assetDepth: n
|
|
1318
|
-
}) {
|
|
1319
|
-
const a = S(e), i = S(t), s = S(n), p = a.mul(s), u = i.mul(i).mul(2), y = i.mul(a).mul(2), o = a.mul(a), l = p.mul(u.sub(y).add(o)), b = i.mul(i).mul(i);
|
|
1320
|
-
return l.div(b);
|
|
1321
|
-
}
|
|
1322
|
-
function da({
|
|
1323
|
-
percent: e,
|
|
1324
|
-
runeDepth: t,
|
|
1325
|
-
liquidityUnits: n,
|
|
1326
|
-
poolUnits: a
|
|
1327
|
-
}) {
|
|
1328
|
-
return Tn({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1329
|
-
}
|
|
1330
|
-
function la({
|
|
1331
|
-
percent: e,
|
|
1332
|
-
assetDepth: t,
|
|
1333
|
-
liquidityUnits: n,
|
|
1334
|
-
poolUnits: a
|
|
1335
|
-
}) {
|
|
1336
|
-
return cn({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1337
|
-
}
|
|
1338
|
-
function S(e) {
|
|
1339
|
-
return F.fromBigInt(BigInt(e), g.THOR);
|
|
1340
|
-
}
|
|
1341
|
-
function bn({
|
|
1342
|
-
liquidityUnits: e,
|
|
1343
|
-
poolUnits: t,
|
|
1344
|
-
runeDepth: n,
|
|
1345
|
-
assetDepth: a
|
|
1346
|
-
}) {
|
|
1347
|
-
return {
|
|
1348
|
-
assetAmount: S(a).mul(e).div(t),
|
|
1349
|
-
runeAmount: S(n).mul(e).div(t)
|
|
1350
|
-
};
|
|
1351
|
-
}
|
|
1352
|
-
function ma({
|
|
1353
|
-
liquidityUnits: e,
|
|
1354
|
-
poolUnits: t,
|
|
1355
|
-
runeDepth: n,
|
|
1356
|
-
assetDepth: a,
|
|
1357
|
-
percent: i
|
|
1358
|
-
}) {
|
|
1359
|
-
return Object.fromEntries(
|
|
1360
|
-
Object.entries(bn({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1361
|
-
([s, p]) => [s, p.mul(i)]
|
|
1362
|
-
)
|
|
1363
|
-
);
|
|
1364
|
-
}
|
|
1365
|
-
function Ta({
|
|
1366
|
-
runeDepth: e,
|
|
1367
|
-
poolUnits: t,
|
|
1368
|
-
assetDepth: n,
|
|
1369
|
-
liquidityUnits: a,
|
|
1370
|
-
runeAmount: i,
|
|
1371
|
-
assetAmount: s
|
|
1372
|
-
}) {
|
|
1373
|
-
const p = new F({ value: e, decimal: 8 }), u = new F({ value: n, decimal: 8 }), y = new F({ value: t, decimal: 8 }), o = new F({ value: i, decimal: 8 }), l = new F({ value: s, decimal: 8 }), b = o.mul(u), T = l.mul(p), f = o.mul(l), _ = p.mul(u), M = y.mul(b.add(T.add(f.mul(2)))), v = b.add(T.add(_.mul(2))), C = M.div(v), R = S(a).add(C);
|
|
1374
|
-
if (C.getBaseValue("number") === 0)
|
|
1375
|
-
return R.div(y).getBaseValue("number");
|
|
1376
|
-
const J = y.add(R);
|
|
1377
|
-
return R.div(J).getBaseValue("number");
|
|
1378
|
-
}
|
|
1379
|
-
function ca({
|
|
1380
|
-
runeAmount: e,
|
|
1381
|
-
assetAmount: t,
|
|
1382
|
-
runeDepth: n,
|
|
1383
|
-
assetDepth: a
|
|
1384
|
-
}) {
|
|
1385
|
-
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1386
|
-
return 0;
|
|
1387
|
-
const i = S(n), s = S(a), p = S(t), u = S(e), y = p.mul(i).sub(s.mul(u)), o = s.mul(u).add(i.mul(s));
|
|
1388
|
-
return Math.abs(y.div(o).getBaseValue("number"));
|
|
1389
|
-
}
|
|
1390
|
-
const I = (e, t) => {
|
|
1391
|
-
switch (e) {
|
|
1392
|
-
case w.LEAVE:
|
|
1393
|
-
case w.BOND: {
|
|
1394
|
-
const { address: n } = t;
|
|
1395
|
-
return `${e}:${n}`;
|
|
1396
|
-
}
|
|
1397
|
-
case w.UNBOND: {
|
|
1398
|
-
const { address: n, unbondAmount: a } = t;
|
|
1399
|
-
return `${e}:${n}:${a}`;
|
|
1400
|
-
}
|
|
1401
|
-
case w.THORNAME_REGISTER: {
|
|
1402
|
-
const { name: n, chain: a, address: i, owner: s } = t;
|
|
1403
|
-
return `${e}:${n}:${a}:${i}${s ? `:${s}` : ""}`;
|
|
1404
|
-
}
|
|
1405
|
-
case w.DEPOSIT: {
|
|
1406
|
-
const { chain: n, symbol: a, address: i, singleSide: s } = t;
|
|
1407
|
-
return s ? `${e}:${n}/${a}` : `${e}:${((p, u) => {
|
|
1408
|
-
switch (p) {
|
|
1409
|
-
case r.Litecoin:
|
|
1410
|
-
return "l";
|
|
1411
|
-
case r.Dogecoin:
|
|
1412
|
-
return "d";
|
|
1413
|
-
case r.BitcoinCash:
|
|
1414
|
-
return "c";
|
|
1415
|
-
default:
|
|
1416
|
-
return `${p}.${u}`;
|
|
1417
|
-
}
|
|
1418
|
-
})(n, a)}:${i || ""}`;
|
|
1419
|
-
}
|
|
1420
|
-
case w.WITHDRAW: {
|
|
1421
|
-
const { chain: n, ticker: a, symbol: i, basisPoints: s, targetAssetString: p, singleSide: u } = t, y = n === "ETH" && a !== "ETH" ? `${a}-${i.slice(-3)}` : i, o = !u && p ? `:${p}` : "";
|
|
1422
|
-
return `${e}:${n}${u ? "/" : "."}${y}:${s}${o}`;
|
|
1423
|
-
}
|
|
1424
|
-
case w.OPEN_LOAN:
|
|
1425
|
-
case w.CLOSE_LOAN: {
|
|
1426
|
-
const { asset: n, address: a } = t;
|
|
1427
|
-
return `${e}:${n}:${a}`;
|
|
1428
|
-
}
|
|
1429
|
-
default:
|
|
1430
|
-
return "";
|
|
1431
|
-
}
|
|
1432
|
-
};
|
|
1433
|
-
function ba(e) {
|
|
1434
|
-
if (e < 0)
|
|
1435
|
-
throw new Error("Invalid number of year");
|
|
1436
|
-
return 10 + e;
|
|
1437
|
-
}
|
|
1438
|
-
function fa(e) {
|
|
1439
|
-
if (e < 0)
|
|
1440
|
-
throw new Error("Invalid number of year");
|
|
1441
|
-
return Math.round((10 + e * 1.0512) * 1e10) / 1e10;
|
|
1442
|
-
}
|
|
1443
|
-
function ha(e) {
|
|
1444
|
-
if (e.length > 30)
|
|
1445
|
-
return !1;
|
|
1446
|
-
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1447
|
-
return !!e.match(t);
|
|
1448
|
-
}
|
|
1449
|
-
function wa(e) {
|
|
1450
|
-
if (e.length > 30)
|
|
1451
|
-
return !1;
|
|
1452
|
-
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1453
|
-
return !!e.match(t);
|
|
1454
|
-
}
|
|
1455
|
-
function Aa([e, t, n, a, i]) {
|
|
1456
|
-
return `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`;
|
|
1457
|
-
}
|
|
1458
|
-
const We = [...Object.values(r), "TERRA"];
|
|
1459
|
-
function fn(e = "") {
|
|
1460
|
-
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1461
|
-
if (We.includes(n))
|
|
1462
|
-
return !0;
|
|
1463
|
-
const [a] = t.split("/");
|
|
1464
|
-
if (We.includes(a))
|
|
1465
|
-
return !0;
|
|
1466
|
-
throw new Error(
|
|
1467
|
-
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1468
|
-
);
|
|
1469
|
-
}
|
|
1470
|
-
const ne = 8, W = (e) => 10n ** BigInt(e), te = (e) => Math.log10(Number.parseFloat(e.toString()));
|
|
1471
|
-
function he({
|
|
1472
|
-
value: e,
|
|
1473
|
-
bigIntDecimal: t = ne,
|
|
1474
|
-
decimal: n = ne
|
|
1475
|
-
}) {
|
|
1476
|
-
if (n === 0)
|
|
1477
|
-
return e.toString();
|
|
1478
|
-
const a = e < 0n;
|
|
1479
|
-
let i = e.toString().substring(a ? 1 : 0);
|
|
1480
|
-
const s = n - (i.length - 1);
|
|
1481
|
-
s > 0 && (i = "0".repeat(s) + i);
|
|
1482
|
-
const p = i.length - n;
|
|
1483
|
-
let u = i.slice(-n);
|
|
1484
|
-
return Number.parseInt(u[t]) >= 5 ? u = `${u.substring(0, t - 1)}${(Number.parseInt(u[t - 1]) + 1).toString()}` : u = u.substring(0, t), `${a ? "-" : ""}${i.slice(0, p)}.${u}`.replace(
|
|
1485
|
-
/\.?0*$/,
|
|
1486
|
-
""
|
|
1487
|
-
);
|
|
1488
|
-
}
|
|
1489
|
-
var G, z, q, j, Ee, pt, ye, ge, de, Oe;
|
|
1490
|
-
const hn = class ke {
|
|
1491
|
-
constructor(t) {
|
|
1492
|
-
Z(this, G), Z(this, q), Z(this, Ee), Z(this, ye), Z(this, de), P(this, "decimalMultiplier", 10n ** 8n), P(this, "bigIntValue", 0n), P(this, "decimal");
|
|
1493
|
-
const n = Se(t), a = typeof t == "object";
|
|
1494
|
-
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : W(Math.max(ut(le(n)), this.decimal || 0)), E(this, Ee, pt).call(this, n);
|
|
1495
|
-
}
|
|
1496
|
-
static fromBigInt(t, n) {
|
|
1497
|
-
return new ke({
|
|
1498
|
-
decimal: n,
|
|
1499
|
-
value: he({ value: t, bigIntDecimal: n, decimal: n })
|
|
1500
|
-
});
|
|
1501
|
-
}
|
|
1502
|
-
static shiftDecimals({
|
|
1503
|
-
value: t,
|
|
1504
|
-
from: n,
|
|
1505
|
-
to: a
|
|
1506
|
-
}) {
|
|
1507
|
-
return ke.fromBigInt(
|
|
1508
|
-
t.getBaseValue("bigint") * W(a) / W(n),
|
|
1509
|
-
a
|
|
1510
|
-
);
|
|
1511
|
-
}
|
|
1512
|
-
set(t) {
|
|
1513
|
-
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1514
|
-
}
|
|
1515
|
-
add(...t) {
|
|
1516
|
-
return E(this, G, z).call(this, "add", ...t);
|
|
1517
|
-
}
|
|
1518
|
-
sub(...t) {
|
|
1519
|
-
return E(this, G, z).call(this, "sub", ...t);
|
|
1520
|
-
}
|
|
1521
|
-
mul(...t) {
|
|
1522
|
-
return E(this, G, z).call(this, "mul", ...t);
|
|
1523
|
-
}
|
|
1524
|
-
div(...t) {
|
|
1525
|
-
return E(this, G, z).call(this, "div", ...t);
|
|
1526
|
-
}
|
|
1527
|
-
gt(t) {
|
|
1528
|
-
return E(this, q, j).call(this, "gt", t);
|
|
1529
|
-
}
|
|
1530
|
-
gte(t) {
|
|
1531
|
-
return E(this, q, j).call(this, "gte", t);
|
|
1532
|
-
}
|
|
1533
|
-
lt(t) {
|
|
1534
|
-
return E(this, q, j).call(this, "lt", t);
|
|
1535
|
-
}
|
|
1536
|
-
lte(t) {
|
|
1537
|
-
return E(this, q, j).call(this, "lte", t);
|
|
1538
|
-
}
|
|
1539
|
-
eqValue(t) {
|
|
1540
|
-
return E(this, q, j).call(this, "eqValue", t);
|
|
1541
|
-
}
|
|
1542
|
-
// @ts-expect-error False positive
|
|
1543
|
-
getValue(t) {
|
|
1544
|
-
const n = this.formatBigIntToSafeValue(
|
|
1545
|
-
this.bigIntValue,
|
|
1546
|
-
this.decimal || te(this.decimalMultiplier)
|
|
1547
|
-
);
|
|
1548
|
-
switch (t) {
|
|
1549
|
-
case "number":
|
|
1550
|
-
return Number(n);
|
|
1551
|
-
case "string":
|
|
1552
|
-
return n;
|
|
1553
|
-
case "bigint":
|
|
1554
|
-
return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
// @ts-expect-error
|
|
1558
|
-
getBaseValue(t) {
|
|
1559
|
-
const n = this.decimalMultiplier / W(this.decimal || g.THOR), a = this.bigIntValue / n;
|
|
1560
|
-
switch (t) {
|
|
1561
|
-
case "number":
|
|
1562
|
-
return Number(a);
|
|
1563
|
-
case "string":
|
|
1564
|
-
return a.toString();
|
|
1565
|
-
case "bigint":
|
|
1566
|
-
return a;
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
getBigIntValue(t, n) {
|
|
1570
|
-
if (!n && typeof t == "object")
|
|
1571
|
-
return t.bigIntValue;
|
|
1572
|
-
const a = Se(t), i = le(a);
|
|
1573
|
-
return i === "0" || i === "undefined" ? 0n : E(this, de, Oe).call(this, i, n);
|
|
1574
|
-
}
|
|
1575
|
-
toSignificant(t = 6) {
|
|
1576
|
-
const [n, a] = this.getValue("string").split("."), i = n || "", s = a || "";
|
|
1577
|
-
if ((Number.parseInt(i) ? i.length + s.length : s.length) <= t)
|
|
1578
|
-
return this.getValue("string");
|
|
1579
|
-
if (i.length >= t)
|
|
1580
|
-
return i.slice(0, t).padEnd(i.length, "0");
|
|
1581
|
-
if (Number.parseInt(i))
|
|
1582
|
-
return `${i}.${s.slice(0, t - i.length)}`.padEnd(
|
|
1583
|
-
t - i.length,
|
|
1584
|
-
"0"
|
|
1585
|
-
);
|
|
1586
|
-
const p = Number.parseInt(s), u = `${p}`.slice(0, t);
|
|
1587
|
-
return `0.${u.padStart(
|
|
1588
|
-
s.length - `${p}`.length + u.length,
|
|
1589
|
-
"0"
|
|
1590
|
-
)}`;
|
|
1591
|
-
}
|
|
1592
|
-
toFixed(t = 6) {
|
|
1593
|
-
const [n, a] = this.getValue("string").split("."), i = n || "", s = a || "";
|
|
1594
|
-
if (Number.parseInt(i))
|
|
1595
|
-
return `${i}.${s.slice(0, t)}`.padEnd(t, "0");
|
|
1596
|
-
const p = Number.parseInt(s), u = `${p}`.slice(0, t);
|
|
1597
|
-
return `0.${u.padStart(
|
|
1598
|
-
s.length - `${p}`.length + u.length,
|
|
1599
|
-
"0"
|
|
1600
|
-
)}`;
|
|
1601
|
-
}
|
|
1602
|
-
toAbbreviation(t = 2) {
|
|
1603
|
-
const n = this.getValue("number"), a = ["", "K", "M", "B", "T", "Q", "Qi", "S"], i = Math.floor(Math.log10(Math.abs(n)) / 3), s = a[i];
|
|
1604
|
-
if (!s)
|
|
1605
|
-
return this.getValue("string");
|
|
1606
|
-
const p = 10 ** (i * 3);
|
|
1607
|
-
return `${(n / p).toFixed(t)}${s}`;
|
|
1608
|
-
}
|
|
1609
|
-
toCurrency(t = "$", {
|
|
1610
|
-
currencyPosition: n = "start",
|
|
1611
|
-
decimal: a = 2,
|
|
1612
|
-
decimalSeparator: i = ".",
|
|
1613
|
-
thousandSeparator: s = ","
|
|
1614
|
-
} = {}) {
|
|
1615
|
-
const p = this.getValue("number"), [u, y = ""] = p.toFixed(6).split("."), o = u.replace(/\B(?=(\d{3})+(?!\d))/g, s), l = u || y ? u === "0" ? `${Number.parseFloat(`0.${y}`)}`.replace(".", i) : `${o}${Number.parseInt(y) ? `${i}${y.slice(0, a)}` : ""}` : "0.00";
|
|
1616
|
-
return `${n === "start" ? t : ""}${l}${n === "end" ? t : ""}`;
|
|
1617
|
-
}
|
|
1618
|
-
formatBigIntToSafeValue(t, n) {
|
|
1619
|
-
const a = n || this.decimal || ne, i = Math.max(
|
|
1620
|
-
a,
|
|
1621
|
-
te(this.decimalMultiplier)
|
|
1622
|
-
), s = t < 0n, p = t.toString().substring(s ? 1 : 0), u = i - (p.length - 1), y = u > 0 ? "0".repeat(u) + p : p, o = y.length - i;
|
|
1623
|
-
let l = y.slice(-i);
|
|
1624
|
-
return Number.parseInt(l[a]) >= 5 ? l = `${l.substring(0, a - 1)}${(Number.parseInt(l[a - 1]) + 1).toString()}` : l = l.substring(0, a), `${s ? "-" : ""}${y.slice(
|
|
1625
|
-
0,
|
|
1626
|
-
o
|
|
1627
|
-
)}.${l}`.replace(/\.?0*$/, "");
|
|
1628
|
-
}
|
|
1629
|
-
};
|
|
1630
|
-
G = /* @__PURE__ */ new WeakSet(), z = function(e, ...t) {
|
|
1631
|
-
const n = E(this, ye, ge).call(this, this, ...t), a = Math.max(n, te(this.decimalMultiplier)), i = W(a), s = t.reduce(
|
|
1632
|
-
(u, y) => {
|
|
1633
|
-
const o = this.getBigIntValue(y, a);
|
|
1634
|
-
switch (e) {
|
|
1635
|
-
case "add":
|
|
1636
|
-
return u + o;
|
|
1637
|
-
case "sub":
|
|
1638
|
-
return u - o;
|
|
1639
|
-
case "mul":
|
|
1640
|
-
return u * o / i;
|
|
1641
|
-
case "div": {
|
|
1642
|
-
if (o === 0n)
|
|
1643
|
-
throw new RangeError("Division by zero");
|
|
1644
|
-
return u * i / o;
|
|
1645
|
-
}
|
|
1646
|
-
default:
|
|
1647
|
-
return u;
|
|
1648
|
-
}
|
|
1649
|
-
},
|
|
1650
|
-
//normalize is to precision multiplier base
|
|
1651
|
-
this.bigIntValue * i / this.decimalMultiplier
|
|
1652
|
-
), p = he({
|
|
1653
|
-
bigIntDecimal: a,
|
|
1654
|
-
decimal: a,
|
|
1655
|
-
value: s
|
|
1656
|
-
});
|
|
1657
|
-
return new this.constructor({
|
|
1658
|
-
decimalMultiplier: W(a),
|
|
1659
|
-
decimal: this.decimal,
|
|
1660
|
-
value: p,
|
|
1661
|
-
identifier: this.toString()
|
|
1662
|
-
});
|
|
1663
|
-
}, q = /* @__PURE__ */ new WeakSet(), j = function(e, ...t) {
|
|
1664
|
-
const n = E(this, ye, ge).call(this, this, ...t), a = this.getBigIntValue(t[0], n), i = this.getBigIntValue(this, n);
|
|
1665
|
-
switch (e) {
|
|
1666
|
-
case "gt":
|
|
1667
|
-
return i > a;
|
|
1668
|
-
case "gte":
|
|
1669
|
-
return i >= a;
|
|
1670
|
-
case "lt":
|
|
1671
|
-
return i < a;
|
|
1672
|
-
case "lte":
|
|
1673
|
-
return i <= a;
|
|
1674
|
-
case "eqValue":
|
|
1675
|
-
return i === a;
|
|
1676
|
-
}
|
|
1677
|
-
}, Ee = /* @__PURE__ */ new WeakSet(), pt = function(e) {
|
|
1678
|
-
const t = le(e) || "0";
|
|
1679
|
-
this.bigIntValue = E(this, de, Oe).call(this, t);
|
|
1680
|
-
}, ye = /* @__PURE__ */ new WeakSet(), ge = function(...e) {
|
|
1681
|
-
const t = e.map((n) => typeof n == "object" ? n.decimal || te(n.decimalMultiplier) : ut(le(n))).filter(Boolean);
|
|
1682
|
-
return Math.max(...t, ne);
|
|
1683
|
-
}, de = /* @__PURE__ */ new WeakSet(), Oe = function(e, t) {
|
|
1684
|
-
const n = t ? W(t) : this.decimalMultiplier, a = te(n), [i = "", s = ""] = e.split(".");
|
|
1685
|
-
return BigInt(`${i}${s.padEnd(a, "0")}`);
|
|
1686
|
-
};
|
|
1687
|
-
let xe = hn;
|
|
1688
|
-
const wn = Intl.NumberFormat("fullwide", {
|
|
1689
|
-
useGrouping: !1,
|
|
1690
|
-
maximumFractionDigits: 20
|
|
1691
|
-
});
|
|
1692
|
-
function le(e) {
|
|
1693
|
-
const t = `${typeof e == "number" ? wn.format(e) : Se(e)}`.replaceAll(",", ".").split(".");
|
|
1694
|
-
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1695
|
-
}
|
|
1696
|
-
function ut(e) {
|
|
1697
|
-
var t;
|
|
1698
|
-
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1699
|
-
return Math.max(n, ne);
|
|
1700
|
-
}
|
|
1701
|
-
function Se(e) {
|
|
1702
|
-
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1703
|
-
}
|
|
1704
|
-
class F extends xe {
|
|
1705
|
-
eq(t) {
|
|
1706
|
-
return this.eqValue(t);
|
|
1707
|
-
}
|
|
1708
|
-
static fromBigInt(t, n) {
|
|
1709
|
-
return new F({
|
|
1710
|
-
decimal: n,
|
|
1711
|
-
value: he({ value: t, bigIntDecimal: n, decimal: n })
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
const K = /* @__PURE__ */ new Map();
|
|
1716
|
-
class x extends xe {
|
|
1717
|
-
constructor({
|
|
1718
|
-
value: t,
|
|
1719
|
-
decimal: n,
|
|
1720
|
-
tax: a,
|
|
1721
|
-
chain: i,
|
|
1722
|
-
symbol: s,
|
|
1723
|
-
identifier: p
|
|
1724
|
-
}) {
|
|
1725
|
-
super(typeof t == "object" ? t : { decimal: n, value: t }), P(this, "address"), P(this, "chain"), P(this, "isGasAsset", !1), P(this, "isSynthetic", !1), P(this, "symbol"), P(this, "tax"), P(this, "ticker"), P(this, "type");
|
|
1726
|
-
const u = ee(p || `${i}.${s}`);
|
|
1727
|
-
this.type = dn(u), this.tax = a, this.chain = u.chain, this.ticker = u.ticker, this.symbol = u.symbol, this.address = u.address, this.isSynthetic = u.isSynthetic, this.isGasAsset = u.isGasAsset;
|
|
1728
|
-
}
|
|
1729
|
-
toString() {
|
|
1730
|
-
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
1731
|
-
}
|
|
1732
|
-
toUrl() {
|
|
1733
|
-
return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
|
|
1734
|
-
}
|
|
1735
|
-
eq({ chain: t, symbol: n }) {
|
|
1736
|
-
return this.chain === t && this.symbol === n;
|
|
1737
|
-
}
|
|
1738
|
-
chainId() {
|
|
1739
|
-
return Qe[this.chain];
|
|
1740
|
-
}
|
|
1741
|
-
// THOR.RUNE
|
|
1742
|
-
// THOR.ETH.ETH
|
|
1743
|
-
// ETH.THOR-0x1234567890
|
|
1744
|
-
static fromUrl(t, n = 0) {
|
|
1745
|
-
const [a, i, s] = t.split(".");
|
|
1746
|
-
if (!(a && i))
|
|
1747
|
-
throw new Error("Invalid asset url");
|
|
1748
|
-
const p = a === r.THORChain && s ? `${a}.${i}/${s}` : t;
|
|
1749
|
-
return Me(p, n);
|
|
1750
|
-
}
|
|
1751
|
-
static fromString(t, n = 0) {
|
|
1752
|
-
return Me(t, n);
|
|
1753
|
-
}
|
|
1754
|
-
static fromIdentifier(t, n = 0) {
|
|
1755
|
-
return Me(t, n);
|
|
1756
|
-
}
|
|
1757
|
-
static fromStringSync(t, n = 0) {
|
|
1758
|
-
const { chain: a, isSynthetic: i } = ee(t), s = K.get(t.toUpperCase());
|
|
1759
|
-
if (i)
|
|
1760
|
-
return ve(t, n);
|
|
1761
|
-
const { tax: p, decimal: u, identifier: y } = s || {
|
|
1762
|
-
decimal: g[a],
|
|
1763
|
-
identifier: t
|
|
1764
|
-
};
|
|
1765
|
-
return new x({
|
|
1766
|
-
tax: p,
|
|
1767
|
-
value: Q(n, u),
|
|
1768
|
-
identifier: i ? t : y,
|
|
1769
|
-
decimal: i ? 8 : u
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
static async fromStringWithBase(t, n = 0, a = g.THOR) {
|
|
1773
|
-
const i = xe.shiftDecimals({
|
|
1774
|
-
value: F.fromBigInt(BigInt(n)),
|
|
1775
|
-
from: 0,
|
|
1776
|
-
to: a
|
|
1777
|
-
}).getBaseValue("string");
|
|
1778
|
-
return (await x.fromString(t, n)).set(i);
|
|
1779
|
-
}
|
|
1780
|
-
static fromStringWithBaseSync(t, n = 0, a = g.THOR) {
|
|
1781
|
-
const { chain: i, isSynthetic: s } = ee(t), p = K.get(t.toUpperCase());
|
|
1782
|
-
if (s)
|
|
1783
|
-
return ve(t, n);
|
|
1784
|
-
const { tax: u, decimal: y, identifier: o } = p || {
|
|
1785
|
-
decimal: g[i],
|
|
1786
|
-
identifier: t
|
|
1787
|
-
};
|
|
1788
|
-
return new x({
|
|
1789
|
-
tax: u,
|
|
1790
|
-
value: Q(BigInt(n), a),
|
|
1791
|
-
identifier: o,
|
|
1792
|
-
decimal: y
|
|
1793
|
-
});
|
|
1794
|
-
}
|
|
1795
|
-
static fromIdentifierSync(t, n = 0) {
|
|
1796
|
-
const { chain: a, isSynthetic: i } = ee(t), s = K.get(t);
|
|
1797
|
-
if (i)
|
|
1798
|
-
return ve(t, n);
|
|
1799
|
-
const { tax: p, decimal: u, identifier: y } = s || {
|
|
1800
|
-
decimal: g[a],
|
|
1801
|
-
identifier: t
|
|
1802
|
-
};
|
|
1803
|
-
return new x({ tax: p, decimal: u, identifier: y, value: Q(n, u) });
|
|
1804
|
-
}
|
|
1805
|
-
static fromChainOrSignature(t, n = 0) {
|
|
1806
|
-
const { decimal: a, identifier: i } = on(t);
|
|
1807
|
-
return new x({ value: Q(n, a), decimal: a, identifier: i });
|
|
1808
|
-
}
|
|
1809
|
-
static loadStaticAssets() {
|
|
1810
|
-
return new Promise(
|
|
1811
|
-
(t, n) => {
|
|
1812
|
-
try {
|
|
1813
|
-
import("@swapkit/tokens").then((a) => {
|
|
1814
|
-
for (const i of Object.values(a))
|
|
1815
|
-
for (const { identifier: s, chain: p, ...u } of i.tokens)
|
|
1816
|
-
K.set(s.toUpperCase(), {
|
|
1817
|
-
identifier: s,
|
|
1818
|
-
decimal: "decimals" in u ? u.decimals : g[p]
|
|
1819
|
-
});
|
|
1820
|
-
t({ ok: !0 });
|
|
1821
|
-
});
|
|
1822
|
-
} catch (a) {
|
|
1823
|
-
console.error(a), n({
|
|
1824
|
-
ok: !1,
|
|
1825
|
-
error: a,
|
|
1826
|
-
message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
|
|
1827
|
-
});
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
);
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
function _e(e) {
|
|
1834
|
-
const t = x.fromChainOrSignature(e);
|
|
1835
|
-
switch (e) {
|
|
1836
|
-
case r.Bitcoin:
|
|
1837
|
-
case r.Litecoin:
|
|
1838
|
-
case r.BitcoinCash:
|
|
1839
|
-
return t.set(10001e-8);
|
|
1840
|
-
case r.Dogecoin:
|
|
1841
|
-
return t.set(1.00000001);
|
|
1842
|
-
case r.Avalanche:
|
|
1843
|
-
case r.Ethereum:
|
|
1844
|
-
return t.set(1e-8);
|
|
1845
|
-
case r.THORChain:
|
|
1846
|
-
case r.Maya:
|
|
1847
|
-
return t.set(0);
|
|
1848
|
-
case r.Cosmos:
|
|
1849
|
-
return t.set(1e-6);
|
|
1850
|
-
default:
|
|
1851
|
-
return t.set(1e-8);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
async function Me(e, t = 0) {
|
|
1855
|
-
fn(e);
|
|
1856
|
-
const n = K.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await un(ee(e));
|
|
1857
|
-
return n || K.set(e.toUpperCase(), { identifier: e, decimal: a }), new x({ decimal: a, value: Q(t, a), identifier: e });
|
|
1858
|
-
}
|
|
1859
|
-
function ve(e, t = 0) {
|
|
1860
|
-
const [n, a] = e.split(".")[0].toUpperCase() === r.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1861
|
-
if (!(n && a))
|
|
1862
|
-
throw new Error("Invalid asset identifier");
|
|
1863
|
-
return new x({
|
|
1864
|
-
decimal: 8,
|
|
1865
|
-
value: Q(t, 8),
|
|
1866
|
-
identifier: `${r.THORChain}.${n}/${a}`
|
|
1867
|
-
});
|
|
1868
|
-
}
|
|
1869
|
-
function Q(e, t) {
|
|
1870
|
-
return typeof e == "bigint" ? he({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1871
|
-
}
|
|
1872
|
-
function ee(e) {
|
|
1873
|
-
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".")[0].toUpperCase() === r.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1874
|
-
if (t && !(n && a))
|
|
1875
|
-
throw new Error("Invalid asset identifier");
|
|
1876
|
-
const i = e.includes(".") && !t ? e : `${r.THORChain}.${a}`, [s, ...p] = i.split("."), [u, y] = (t ? a : p.join(".")).split("-"), o = t ? a : p.join(".");
|
|
1877
|
-
return {
|
|
1878
|
-
address: y == null ? void 0 : y.toLowerCase(),
|
|
1879
|
-
chain: s,
|
|
1880
|
-
isGasAsset: rt({ chain: s, symbol: o }),
|
|
1881
|
-
isSynthetic: t,
|
|
1882
|
-
symbol: (t ? `${n}/` : "") + (y ? `${u}-${(y == null ? void 0 : y.toLowerCase()) ?? ""}` : o),
|
|
1883
|
-
ticker: u
|
|
1884
|
-
};
|
|
1885
|
-
}
|
|
1886
|
-
const An = {
|
|
1887
|
-
/**
|
|
1888
|
-
* Core
|
|
1889
|
-
*/
|
|
1890
|
-
core_wallet_connection_not_found: 10001,
|
|
1891
|
-
core_estimated_max_spendable_chain_not_supported: 10002,
|
|
1892
|
-
core_extend_error: 10003,
|
|
1893
|
-
core_inbound_data_not_found: 10004,
|
|
1894
|
-
core_approve_asset_address_or_from_not_found: 10005,
|
|
1895
|
-
core_plugin_not_found: 10006,
|
|
1896
|
-
core_chain_halted: 10099,
|
|
1897
|
-
/**
|
|
1898
|
-
* Core - Wallet Connection
|
|
1899
|
-
*/
|
|
1900
|
-
core_wallet_xdefi_not_installed: 10101,
|
|
1901
|
-
core_wallet_evmwallet_not_installed: 10102,
|
|
1902
|
-
core_wallet_walletconnect_not_installed: 10103,
|
|
1903
|
-
core_wallet_keystore_not_installed: 10104,
|
|
1904
|
-
core_wallet_ledger_not_installed: 10105,
|
|
1905
|
-
core_wallet_trezor_not_installed: 10106,
|
|
1906
|
-
core_wallet_keplr_not_installed: 10107,
|
|
1907
|
-
core_wallet_okx_not_installed: 10108,
|
|
1908
|
-
core_wallet_keepkey_not_installed: 10109,
|
|
1909
|
-
/**
|
|
1910
|
-
* Core - Swap
|
|
1911
|
-
*/
|
|
1912
|
-
core_swap_invalid_params: 10200,
|
|
1913
|
-
core_swap_route_not_complete: 10201,
|
|
1914
|
-
core_swap_asset_not_recognized: 10202,
|
|
1915
|
-
core_swap_contract_not_found: 10203,
|
|
1916
|
-
core_swap_route_transaction_not_found: 10204,
|
|
1917
|
-
core_swap_contract_not_supported: 10205,
|
|
1918
|
-
core_swap_transaction_error: 10206,
|
|
1919
|
-
core_swap_quote_mode_not_supported: 10207,
|
|
1920
|
-
/**
|
|
1921
|
-
* Core - Transaction
|
|
1922
|
-
*/
|
|
1923
|
-
core_transaction_deposit_error: 10301,
|
|
1924
|
-
core_transaction_create_liquidity_rune_error: 10302,
|
|
1925
|
-
core_transaction_create_liquidity_asset_error: 10303,
|
|
1926
|
-
core_transaction_create_liquidity_invalid_params: 10304,
|
|
1927
|
-
core_transaction_add_liquidity_invalid_params: 10305,
|
|
1928
|
-
core_transaction_add_liquidity_no_rune_address: 10306,
|
|
1929
|
-
core_transaction_add_liquidity_rune_error: 10307,
|
|
1930
|
-
core_transaction_add_liquidity_asset_error: 10308,
|
|
1931
|
-
core_transaction_withdraw_error: 10309,
|
|
1932
|
-
core_transaction_deposit_to_pool_error: 10310,
|
|
1933
|
-
core_transaction_deposit_insufficient_funds_error: 10311,
|
|
1934
|
-
core_transaction_deposit_gas_error: 10312,
|
|
1935
|
-
core_transaction_invalid_sender_address: 10313,
|
|
1936
|
-
core_transaction_deposit_server_error: 10314,
|
|
1937
|
-
core_transaction_user_rejected: 10315,
|
|
1938
|
-
/**
|
|
1939
|
-
* Wallets
|
|
1940
|
-
*/
|
|
1941
|
-
wallet_ledger_connection_error: 20001,
|
|
1942
|
-
wallet_ledger_connection_claimed: 20002,
|
|
1943
|
-
wallet_ledger_get_address_error: 20003,
|
|
1944
|
-
wallet_ledger_device_not_found: 20004,
|
|
1945
|
-
wallet_ledger_device_locked: 20005,
|
|
1946
|
-
/**
|
|
1947
|
-
* Chainflip
|
|
1948
|
-
*/
|
|
1949
|
-
chainflip_channel_error: 30001,
|
|
1950
|
-
chainflip_broker_recipient_error: 30002,
|
|
1951
|
-
/**
|
|
1952
|
-
* THORChain
|
|
1953
|
-
*/
|
|
1954
|
-
/**
|
|
1955
|
-
* Helpers
|
|
1956
|
-
*/
|
|
1957
|
-
helpers_number_different_decimals: 99101
|
|
1958
|
-
};
|
|
1959
|
-
class d extends Error {
|
|
1960
|
-
constructor(t, n) {
|
|
1961
|
-
n && console.error(n, {
|
|
1962
|
-
stack: n == null ? void 0 : n.stack,
|
|
1963
|
-
message: n == null ? void 0 : n.message
|
|
1964
|
-
}), super(t, {
|
|
1965
|
-
cause: { code: An[t], message: t }
|
|
1966
|
-
}), Object.setPrototypeOf(this, d.prototype);
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
const yt = ({ chain: e, txHash: t }) => {
|
|
1970
|
-
const n = Ye[e];
|
|
1971
|
-
switch (e) {
|
|
1972
|
-
case r.Binance:
|
|
1973
|
-
case r.Maya:
|
|
1974
|
-
case r.Kujira:
|
|
1975
|
-
case r.THORChain:
|
|
1976
|
-
return `${n}/tx/${t.startsWith("0x") ? t.slice(2) : t}`;
|
|
1977
|
-
case r.Arbitrum:
|
|
1978
|
-
case r.Avalanche:
|
|
1979
|
-
case r.BinanceSmartChain:
|
|
1980
|
-
case r.Ethereum:
|
|
1981
|
-
case r.Optimism:
|
|
1982
|
-
case r.Polkadot:
|
|
1983
|
-
case r.Polygon:
|
|
1984
|
-
return `${n}/tx/${t.startsWith("0x") ? t : `0x${t}`}`;
|
|
1985
|
-
case r.Cosmos:
|
|
1986
|
-
return `${n}/transactions/${t}`;
|
|
1987
|
-
case r.Litecoin:
|
|
1988
|
-
case r.Bitcoin:
|
|
1989
|
-
case r.BitcoinCash:
|
|
1990
|
-
case r.Dogecoin:
|
|
1991
|
-
return `${n}/transaction/${t.toLowerCase()}`;
|
|
12
|
+
import { AssetValue as L, SwapKitError as s, RequestClient as N, SwapKitNumber as oe, getMemoFor as O, getMinAmountByChain as U, gasFeeMultiplier as de } from "@swapkit/helpers";
|
|
13
|
+
export * from "@swapkit/helpers";
|
|
14
|
+
import { ChainToExplorerUrl as Y, Chain as a, ApiUrl as B, AGG_SWAP as le, ChainToChainId as me, SWAP_OUT as Te, SWAP_IN as ce, FeeOption as K, TCAvalancheDepositABI as be, TCBscDepositABI as fe, TCEthereumVaultAbi as we, MemoType as v } from "@swapkit/types";
|
|
15
|
+
export * from "@swapkit/types";
|
|
16
|
+
const ee = ({ chain: r, txHash: e }) => {
|
|
17
|
+
const t = Y[r];
|
|
18
|
+
switch (r) {
|
|
19
|
+
case a.Binance:
|
|
20
|
+
case a.Maya:
|
|
21
|
+
case a.Kujira:
|
|
22
|
+
case a.THORChain:
|
|
23
|
+
return `${t}/tx/${e.startsWith("0x") ? e.slice(2) : e}`;
|
|
24
|
+
case a.Arbitrum:
|
|
25
|
+
case a.Avalanche:
|
|
26
|
+
case a.BinanceSmartChain:
|
|
27
|
+
case a.Ethereum:
|
|
28
|
+
case a.Optimism:
|
|
29
|
+
case a.Polkadot:
|
|
30
|
+
case a.Polygon:
|
|
31
|
+
return `${t}/tx/${e.startsWith("0x") ? e : `0x${e}`}`;
|
|
32
|
+
case a.Cosmos:
|
|
33
|
+
return `${t}/transactions/${e}`;
|
|
34
|
+
case a.Litecoin:
|
|
35
|
+
case a.Bitcoin:
|
|
36
|
+
case a.BitcoinCash:
|
|
37
|
+
case a.Dogecoin:
|
|
38
|
+
return `${t}/transaction/${e.toLowerCase()}`;
|
|
1992
39
|
default:
|
|
1993
|
-
throw new Error(`Unsupported chain: ${
|
|
40
|
+
throw new Error(`Unsupported chain: ${r}`);
|
|
1994
41
|
}
|
|
1995
|
-
},
|
|
1996
|
-
const
|
|
1997
|
-
switch (
|
|
1998
|
-
case
|
|
1999
|
-
case
|
|
2000
|
-
case
|
|
2001
|
-
case
|
|
2002
|
-
case
|
|
2003
|
-
case
|
|
2004
|
-
case
|
|
2005
|
-
case
|
|
2006
|
-
case
|
|
2007
|
-
case
|
|
2008
|
-
case
|
|
2009
|
-
case
|
|
2010
|
-
case
|
|
2011
|
-
case
|
|
2012
|
-
case
|
|
2013
|
-
return `${
|
|
2014
|
-
case
|
|
2015
|
-
return `${
|
|
42
|
+
}, te = ({ chain: r, address: e }) => {
|
|
43
|
+
const t = Y[r];
|
|
44
|
+
switch (r) {
|
|
45
|
+
case a.Arbitrum:
|
|
46
|
+
case a.Avalanche:
|
|
47
|
+
case a.Binance:
|
|
48
|
+
case a.BinanceSmartChain:
|
|
49
|
+
case a.Bitcoin:
|
|
50
|
+
case a.BitcoinCash:
|
|
51
|
+
case a.Dogecoin:
|
|
52
|
+
case a.Ethereum:
|
|
53
|
+
case a.Kujira:
|
|
54
|
+
case a.Litecoin:
|
|
55
|
+
case a.Maya:
|
|
56
|
+
case a.Optimism:
|
|
57
|
+
case a.Polkadot:
|
|
58
|
+
case a.Polygon:
|
|
59
|
+
case a.THORChain:
|
|
60
|
+
return `${t}/address/${e}`;
|
|
61
|
+
case a.Cosmos:
|
|
62
|
+
return `${t}/account/${e}`;
|
|
2016
63
|
default:
|
|
2017
|
-
throw new Error(`Unsupported chain: ${
|
|
64
|
+
throw new Error(`Unsupported chain: ${r}`);
|
|
2018
65
|
}
|
|
2019
66
|
};
|
|
2020
|
-
var
|
|
2021
|
-
function
|
|
2022
|
-
stagenet:
|
|
2023
|
-
wallets:
|
|
2024
|
-
plugins:
|
|
2025
|
-
config:
|
|
2026
|
-
apis:
|
|
2027
|
-
rpcUrls:
|
|
67
|
+
var Me = /* @__PURE__ */ ((r) => (r.Approve = "approve", r.CheckOnly = "checkOnly", r))(Me || {});
|
|
68
|
+
function ze({
|
|
69
|
+
stagenet: r,
|
|
70
|
+
wallets: e,
|
|
71
|
+
plugins: t,
|
|
72
|
+
config: n = {},
|
|
73
|
+
apis: p,
|
|
74
|
+
rpcUrls: i
|
|
2028
75
|
}) {
|
|
2029
|
-
const
|
|
2030
|
-
for (const
|
|
2031
|
-
const { name:
|
|
2032
|
-
|
|
76
|
+
const o = {}, c = {};
|
|
77
|
+
for (const u of t) {
|
|
78
|
+
const { name: m, methods: _ } = u({ wallets: o, stagenet: r });
|
|
79
|
+
c[m] = _;
|
|
2033
80
|
}
|
|
2034
|
-
const
|
|
2035
|
-
addChain:
|
|
2036
|
-
config:
|
|
2037
|
-
apis:
|
|
2038
|
-
rpcUrls:
|
|
2039
|
-
}),
|
|
2040
|
-
function
|
|
2041
|
-
const
|
|
2042
|
-
if (!
|
|
2043
|
-
throw new
|
|
2044
|
-
return
|
|
81
|
+
const f = e.reduce((u, m) => (u[m.connectMethodName] = m.connect({
|
|
82
|
+
addChain: w,
|
|
83
|
+
config: n,
|
|
84
|
+
apis: p,
|
|
85
|
+
rpcUrls: i
|
|
86
|
+
}), u), {});
|
|
87
|
+
function b(u) {
|
|
88
|
+
const m = c[u] || Object.values(c)[0];
|
|
89
|
+
if (!m)
|
|
90
|
+
throw new s("core_plugin_not_found", "Could not find the requested plugin");
|
|
91
|
+
return m;
|
|
2045
92
|
}
|
|
2046
|
-
function
|
|
2047
|
-
|
|
93
|
+
function w(u) {
|
|
94
|
+
o[u.chain] = u;
|
|
2048
95
|
}
|
|
2049
|
-
function
|
|
2050
|
-
assetValue:
|
|
2051
|
-
type:
|
|
2052
|
-
contractAddress:
|
|
96
|
+
function T({
|
|
97
|
+
assetValue: u,
|
|
98
|
+
type: m = "checkOnly",
|
|
99
|
+
contractAddress: _
|
|
2053
100
|
}) {
|
|
2054
|
-
const { address:
|
|
2055
|
-
if (
|
|
2056
|
-
return Promise.resolve(
|
|
2057
|
-
const
|
|
2058
|
-
if (!
|
|
2059
|
-
throw new
|
|
2060
|
-
const
|
|
2061
|
-
if (!(
|
|
2062
|
-
throw new
|
|
2063
|
-
const
|
|
2064
|
-
return
|
|
2065
|
-
amount:
|
|
2066
|
-
assetAddress:
|
|
2067
|
-
from:
|
|
2068
|
-
spenderAddress:
|
|
101
|
+
const { address: x, chain: R, isGasAsset: ie, isSynthetic: pe } = u, G = [a.Ethereum, a.Avalanche, a.BinanceSmartChain].includes(R);
|
|
102
|
+
if (G && ie || !G || pe)
|
|
103
|
+
return Promise.resolve(m === "checkOnly" ? !0 : "approved");
|
|
104
|
+
const C = o[R], Q = m === "checkOnly" ? C == null ? void 0 : C.isApproved : C == null ? void 0 : C.approve;
|
|
105
|
+
if (!Q)
|
|
106
|
+
throw new s("core_wallet_connection_not_found");
|
|
107
|
+
const $ = l(R);
|
|
108
|
+
if (!(x && $))
|
|
109
|
+
throw new s("core_approve_asset_address_or_from_not_found");
|
|
110
|
+
const se = _;
|
|
111
|
+
return Q({
|
|
112
|
+
amount: u.getBaseValue("bigint"),
|
|
113
|
+
assetAddress: x,
|
|
114
|
+
from: $,
|
|
115
|
+
spenderAddress: se
|
|
2069
116
|
});
|
|
2070
117
|
}
|
|
2071
|
-
function
|
|
2072
|
-
return
|
|
118
|
+
function d(u) {
|
|
119
|
+
return o[u];
|
|
2073
120
|
}
|
|
2074
|
-
function
|
|
2075
|
-
var
|
|
2076
|
-
return ((
|
|
121
|
+
function l(u) {
|
|
122
|
+
var m;
|
|
123
|
+
return ((m = d(u)) == null ? void 0 : m.address) || "";
|
|
2077
124
|
}
|
|
2078
|
-
function
|
|
2079
|
-
var
|
|
2080
|
-
return ((
|
|
125
|
+
function A(u) {
|
|
126
|
+
var m;
|
|
127
|
+
return ((m = d(u)) == null ? void 0 : m.balance) || [];
|
|
2081
128
|
}
|
|
2082
|
-
function
|
|
2083
|
-
return
|
|
129
|
+
function k(u, m) {
|
|
130
|
+
return ee({ chain: u, txHash: m });
|
|
2084
131
|
}
|
|
2085
|
-
function
|
|
2086
|
-
return
|
|
132
|
+
function h(u, m) {
|
|
133
|
+
return te({ chain: u, address: m });
|
|
2087
134
|
}
|
|
2088
|
-
function
|
|
2089
|
-
var
|
|
2090
|
-
return (
|
|
135
|
+
function g({ address: u, chain: m }) {
|
|
136
|
+
var _, x;
|
|
137
|
+
return (x = (_ = d(m)) == null ? void 0 : _.validateAddress) == null ? void 0 : x.call(_, u);
|
|
2091
138
|
}
|
|
2092
|
-
async function
|
|
2093
|
-
const
|
|
139
|
+
async function I(u, m) {
|
|
140
|
+
const _ = [L.fromChainOrSignature(u)], x = d(u);
|
|
2094
141
|
try {
|
|
2095
|
-
if (!
|
|
2096
|
-
throw new
|
|
2097
|
-
const
|
|
2098
|
-
return
|
|
2099
|
-
} catch (
|
|
2100
|
-
throw new
|
|
142
|
+
if (!x)
|
|
143
|
+
throw new s("core_wallet_connection_not_found");
|
|
144
|
+
const R = await (x == null ? void 0 : x.getBalance(x.address, m));
|
|
145
|
+
return x.balance = R != null && R.length ? R : _, x;
|
|
146
|
+
} catch (R) {
|
|
147
|
+
throw new s("core_wallet_connection_not_found", R);
|
|
2101
148
|
}
|
|
2102
149
|
}
|
|
2103
|
-
function
|
|
2104
|
-
return
|
|
2105
|
-
assetValue:
|
|
2106
|
-
contractAddress:
|
|
150
|
+
function D(u, m) {
|
|
151
|
+
return T({
|
|
152
|
+
assetValue: u,
|
|
153
|
+
contractAddress: m,
|
|
2107
154
|
type: "approve"
|
|
2108
155
|
/* Approve */
|
|
2109
156
|
});
|
|
2110
157
|
}
|
|
2111
|
-
function
|
|
2112
|
-
return
|
|
2113
|
-
assetValue:
|
|
2114
|
-
contractAddress:
|
|
158
|
+
function X(u, m) {
|
|
159
|
+
return T({
|
|
160
|
+
assetValue: u,
|
|
161
|
+
contractAddress: m,
|
|
2115
162
|
type: "checkOnly"
|
|
2116
163
|
/* CheckOnly */
|
|
2117
164
|
});
|
|
2118
165
|
}
|
|
2119
|
-
function
|
|
2120
|
-
return
|
|
166
|
+
function ae({ provider: u, ...m }) {
|
|
167
|
+
return b(u == null ? void 0 : u.name).swap({ provider: u, ...m });
|
|
2121
168
|
}
|
|
2122
169
|
return {
|
|
2123
|
-
...
|
|
2124
|
-
...
|
|
2125
|
-
approveAssetValue:
|
|
2126
|
-
getAddress:
|
|
2127
|
-
getBalance:
|
|
2128
|
-
getExplorerAddressUrl:
|
|
2129
|
-
getExplorerTxUrl:
|
|
2130
|
-
getWallet:
|
|
2131
|
-
getWalletWithBalance:
|
|
2132
|
-
isAssetValueApproved:
|
|
2133
|
-
swap:
|
|
2134
|
-
validateAddress:
|
|
170
|
+
...c,
|
|
171
|
+
...f,
|
|
172
|
+
approveAssetValue: D,
|
|
173
|
+
getAddress: l,
|
|
174
|
+
getBalance: A,
|
|
175
|
+
getExplorerAddressUrl: h,
|
|
176
|
+
getExplorerTxUrl: k,
|
|
177
|
+
getWallet: d,
|
|
178
|
+
getWalletWithBalance: I,
|
|
179
|
+
isAssetValueApproved: X,
|
|
180
|
+
swap: ae,
|
|
181
|
+
validateAddress: g
|
|
2135
182
|
};
|
|
2136
183
|
}
|
|
2137
|
-
const
|
|
184
|
+
const Ae = [
|
|
2138
185
|
{
|
|
2139
186
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2140
187
|
stateMutability: "nonpayable",
|
|
@@ -2225,7 +272,7 @@ const _n = [
|
|
|
2225
272
|
type: "function"
|
|
2226
273
|
},
|
|
2227
274
|
{ stateMutability: "payable", type: "receive" }
|
|
2228
|
-
],
|
|
275
|
+
], ve = [
|
|
2229
276
|
{
|
|
2230
277
|
inputs: [
|
|
2231
278
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2369,7 +416,7 @@ const _n = [
|
|
|
2369
416
|
type: "function"
|
|
2370
417
|
},
|
|
2371
418
|
{ stateMutability: "payable", type: "receive" }
|
|
2372
|
-
],
|
|
419
|
+
], ke = [
|
|
2373
420
|
{
|
|
2374
421
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2375
422
|
stateMutability: "nonpayable",
|
|
@@ -2474,7 +521,7 @@ const _n = [
|
|
|
2474
521
|
type: "function"
|
|
2475
522
|
},
|
|
2476
523
|
{ stateMutability: "payable", type: "receive" }
|
|
2477
|
-
],
|
|
524
|
+
], he = [
|
|
2478
525
|
{
|
|
2479
526
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2480
527
|
stateMutability: "nonpayable",
|
|
@@ -2565,7 +612,7 @@ const _n = [
|
|
|
2565
612
|
type: "function"
|
|
2566
613
|
},
|
|
2567
614
|
{ stateMutability: "payable", type: "receive" }
|
|
2568
|
-
],
|
|
615
|
+
], ge = [
|
|
2569
616
|
{
|
|
2570
617
|
inputs: [
|
|
2571
618
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2709,7 +756,7 @@ const _n = [
|
|
|
2709
756
|
type: "function"
|
|
2710
757
|
},
|
|
2711
758
|
{ stateMutability: "payable", type: "receive" }
|
|
2712
|
-
],
|
|
759
|
+
], xe = [
|
|
2713
760
|
{
|
|
2714
761
|
inputs: [
|
|
2715
762
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2828,7 +875,7 @@ const _n = [
|
|
|
2828
875
|
type: "function"
|
|
2829
876
|
},
|
|
2830
877
|
{ stateMutability: "payable", type: "receive" }
|
|
2831
|
-
],
|
|
878
|
+
], Z = [
|
|
2832
879
|
{
|
|
2833
880
|
inputs: [{ internalType: "address", name: "_WETH", type: "address" }],
|
|
2834
881
|
stateMutability: "nonpayable",
|
|
@@ -3229,7 +1276,7 @@ const _n = [
|
|
|
3229
1276
|
type: "function"
|
|
3230
1277
|
},
|
|
3231
1278
|
{ stateMutability: "payable", type: "receive" }
|
|
3232
|
-
],
|
|
1279
|
+
], j = [
|
|
3233
1280
|
{
|
|
3234
1281
|
inputs: [
|
|
3235
1282
|
{
|
|
@@ -5416,7 +3463,7 @@ const _n = [
|
|
|
5416
3463
|
stateMutability: "payable",
|
|
5417
3464
|
type: "receive"
|
|
5418
3465
|
}
|
|
5419
|
-
],
|
|
3466
|
+
], z = [
|
|
5420
3467
|
{
|
|
5421
3468
|
inputs: [
|
|
5422
3469
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -5755,7 +3802,7 @@ const _n = [
|
|
|
5755
3802
|
type: "function"
|
|
5756
3803
|
},
|
|
5757
3804
|
{ stateMutability: "payable", type: "receive" }
|
|
5758
|
-
],
|
|
3805
|
+
], _e = [
|
|
5759
3806
|
{
|
|
5760
3807
|
inputs: [
|
|
5761
3808
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6094,7 +4141,7 @@ const _n = [
|
|
|
6094
4141
|
type: "function"
|
|
6095
4142
|
},
|
|
6096
4143
|
{ stateMutability: "payable", type: "receive" }
|
|
6097
|
-
],
|
|
4144
|
+
], Oe = [
|
|
6098
4145
|
{
|
|
6099
4146
|
inputs: [
|
|
6100
4147
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6433,7 +4480,7 @@ const _n = [
|
|
|
6433
4480
|
type: "function"
|
|
6434
4481
|
},
|
|
6435
4482
|
{ stateMutability: "payable", type: "receive" }
|
|
6436
|
-
],
|
|
4483
|
+
], Ee = [
|
|
6437
4484
|
{
|
|
6438
4485
|
inputs: [
|
|
6439
4486
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6772,7 +4819,7 @@ const _n = [
|
|
|
6772
4819
|
type: "function"
|
|
6773
4820
|
},
|
|
6774
4821
|
{ stateMutability: "payable", type: "receive" }
|
|
6775
|
-
],
|
|
4822
|
+
], Re = [
|
|
6776
4823
|
{
|
|
6777
4824
|
inputs: [
|
|
6778
4825
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -7111,7 +5158,7 @@ const _n = [
|
|
|
7111
5158
|
type: "function"
|
|
7112
5159
|
},
|
|
7113
5160
|
{ stateMutability: "payable", type: "receive" }
|
|
7114
|
-
],
|
|
5161
|
+
], Ie = [
|
|
7115
5162
|
{
|
|
7116
5163
|
inputs: [
|
|
7117
5164
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -7364,7 +5411,7 @@ const _n = [
|
|
|
7364
5411
|
type: "function"
|
|
7365
5412
|
},
|
|
7366
5413
|
{ stateMutability: "payable", type: "receive" }
|
|
7367
|
-
],
|
|
5414
|
+
], Fe = [
|
|
7368
5415
|
{
|
|
7369
5416
|
inputs: [
|
|
7370
5417
|
{ internalType: "address", name: "_weth", type: "address" },
|
|
@@ -7534,23 +5581,23 @@ const _n = [
|
|
|
7534
5581
|
type: "function"
|
|
7535
5582
|
},
|
|
7536
5583
|
{ stateMutability: "payable", type: "receive" }
|
|
7537
|
-
],
|
|
5584
|
+
], Se = {
|
|
7538
5585
|
// AVAX
|
|
7539
|
-
["0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106".toLowerCase()]:
|
|
7540
|
-
["0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9".toLowerCase()]:
|
|
7541
|
-
["0x60aE616a2155Ee3d9A68541Ba4544862310933d4".toLowerCase()]:
|
|
7542
|
-
["0x1111111254fb6c44bAC0beD2854e76F90643097d".toLowerCase()]:
|
|
7543
|
-
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]:
|
|
5586
|
+
["0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106".toLowerCase()]: _e,
|
|
5587
|
+
["0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9".toLowerCase()]: Fe,
|
|
5588
|
+
["0x60aE616a2155Ee3d9A68541Ba4544862310933d4".toLowerCase()]: Ee,
|
|
5589
|
+
["0x1111111254fb6c44bAC0beD2854e76F90643097d".toLowerCase()]: j,
|
|
5590
|
+
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]: Z,
|
|
7544
5591
|
// BSC
|
|
7545
|
-
["0x10ED43C718714eb63d5aA57B78B54704E256024E".toLowerCase()]:
|
|
5592
|
+
["0x10ED43C718714eb63d5aA57B78B54704E256024E".toLowerCase()]: z,
|
|
7546
5593
|
// ETH
|
|
7547
|
-
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]:
|
|
7548
|
-
["0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f".toLowerCase()]:
|
|
7549
|
-
["0xEfF92A263d31888d860bD50809A8D171709b7b1c".toLowerCase()]:
|
|
7550
|
-
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".toLowerCase()]:
|
|
7551
|
-
["0xE592427A0AEce92De3Edee1F18E0157C05861564".toLowerCase()]:
|
|
7552
|
-
["0x1111111254fb6c44bac0bed2854e76f90643097d".toLowerCase()]:
|
|
7553
|
-
},
|
|
5594
|
+
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]: Z,
|
|
5595
|
+
["0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f".toLowerCase()]: Oe,
|
|
5596
|
+
["0xEfF92A263d31888d860bD50809A8D171709b7b1c".toLowerCase()]: z,
|
|
5597
|
+
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".toLowerCase()]: Re,
|
|
5598
|
+
["0xE592427A0AEce92De3Edee1F18E0157C05861564".toLowerCase()]: Ie,
|
|
5599
|
+
["0x1111111254fb6c44bac0bed2854e76f90643097d".toLowerCase()]: j
|
|
5600
|
+
}, Ce = [
|
|
7554
5601
|
{
|
|
7555
5602
|
inputs: [
|
|
7556
5603
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7669,7 +5716,7 @@ const _n = [
|
|
|
7669
5716
|
type: "function"
|
|
7670
5717
|
},
|
|
7671
5718
|
{ stateMutability: "payable", type: "receive" }
|
|
7672
|
-
],
|
|
5719
|
+
], Be = [
|
|
7673
5720
|
{
|
|
7674
5721
|
inputs: [
|
|
7675
5722
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7788,7 +5835,7 @@ const _n = [
|
|
|
7788
5835
|
type: "function"
|
|
7789
5836
|
},
|
|
7790
5837
|
{ stateMutability: "payable", type: "receive" }
|
|
7791
|
-
],
|
|
5838
|
+
], qe = [
|
|
7792
5839
|
{
|
|
7793
5840
|
inputs: [
|
|
7794
5841
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7907,7 +5954,7 @@ const _n = [
|
|
|
7907
5954
|
type: "function"
|
|
7908
5955
|
},
|
|
7909
5956
|
{ stateMutability: "payable", type: "receive" }
|
|
7910
|
-
],
|
|
5957
|
+
], He = [
|
|
7911
5958
|
{
|
|
7912
5959
|
inputs: [
|
|
7913
5960
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8034,7 +6081,7 @@ const _n = [
|
|
|
8034
6081
|
type: "function"
|
|
8035
6082
|
},
|
|
8036
6083
|
{ stateMutability: "payable", type: "receive" }
|
|
8037
|
-
],
|
|
6084
|
+
], Pe = [
|
|
8038
6085
|
{
|
|
8039
6086
|
inputs: [
|
|
8040
6087
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8161,7 +6208,7 @@ const _n = [
|
|
|
8161
6208
|
type: "function"
|
|
8162
6209
|
},
|
|
8163
6210
|
{ stateMutability: "payable", type: "receive" }
|
|
8164
|
-
],
|
|
6211
|
+
], Le = [
|
|
8165
6212
|
{
|
|
8166
6213
|
inputs: [
|
|
8167
6214
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8288,7 +6335,7 @@ const _n = [
|
|
|
8288
6335
|
type: "function"
|
|
8289
6336
|
},
|
|
8290
6337
|
{ stateMutability: "payable", type: "receive" }
|
|
8291
|
-
],
|
|
6338
|
+
], We = [
|
|
8292
6339
|
{
|
|
8293
6340
|
inputs: [
|
|
8294
6341
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8415,7 +6462,7 @@ const _n = [
|
|
|
8415
6462
|
type: "function"
|
|
8416
6463
|
},
|
|
8417
6464
|
{ stateMutability: "payable", type: "receive" }
|
|
8418
|
-
],
|
|
6465
|
+
], Ve = [
|
|
8419
6466
|
{
|
|
8420
6467
|
inputs: [
|
|
8421
6468
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8542,697 +6589,627 @@ const _n = [
|
|
|
8542
6589
|
type: "function"
|
|
8543
6590
|
},
|
|
8544
6591
|
{ stateMutability: "payable", type: "receive" }
|
|
8545
|
-
],
|
|
8546
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
8547
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
8548
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
8549
|
-
},
|
|
8550
|
-
...
|
|
8551
|
-
...
|
|
6592
|
+
], ne = {
|
|
6593
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Ae,
|
|
6594
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: ke,
|
|
6595
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: he
|
|
6596
|
+
}, De = {
|
|
6597
|
+
...Se,
|
|
6598
|
+
...ne,
|
|
8552
6599
|
// AVAX
|
|
8553
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
8554
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
8555
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
6600
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: xe,
|
|
6601
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: ve,
|
|
6602
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: Be,
|
|
8556
6603
|
// BSC
|
|
8557
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
6604
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: ge,
|
|
8558
6605
|
// ETH
|
|
8559
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
8560
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
8561
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
8562
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
8563
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
8564
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
8565
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
8566
|
-
},
|
|
8567
|
-
streamSwap:
|
|
8568
|
-
contractAddress:
|
|
8569
|
-
recipient:
|
|
8570
|
-
toChecksumAddress:
|
|
6606
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Ce,
|
|
6607
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: qe,
|
|
6608
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: He,
|
|
6609
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: Pe,
|
|
6610
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: Le,
|
|
6611
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: We,
|
|
6612
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: Ve
|
|
6613
|
+
}, Xe = ({
|
|
6614
|
+
streamSwap: r,
|
|
6615
|
+
contractAddress: e,
|
|
6616
|
+
recipient: t,
|
|
6617
|
+
toChecksumAddress: n,
|
|
8571
6618
|
calldata: {
|
|
8572
|
-
amount:
|
|
8573
|
-
amountOutMin:
|
|
8574
|
-
data:
|
|
8575
|
-
deadline:
|
|
8576
|
-
memo:
|
|
8577
|
-
router:
|
|
8578
|
-
memoStreamingSwap:
|
|
8579
|
-
tcMemo:
|
|
8580
|
-
tcRouter:
|
|
8581
|
-
tcVault:
|
|
8582
|
-
vault:
|
|
8583
|
-
token:
|
|
6619
|
+
amount: p,
|
|
6620
|
+
amountOutMin: i = "",
|
|
6621
|
+
data: o = "",
|
|
6622
|
+
deadline: c,
|
|
6623
|
+
memo: f,
|
|
6624
|
+
router: b,
|
|
6625
|
+
memoStreamingSwap: w,
|
|
6626
|
+
tcMemo: T,
|
|
6627
|
+
tcRouter: d,
|
|
6628
|
+
tcVault: l,
|
|
6629
|
+
vault: A,
|
|
6630
|
+
token: k
|
|
8584
6631
|
}
|
|
8585
6632
|
}) => {
|
|
8586
|
-
const
|
|
8587
|
-
if (
|
|
6633
|
+
const h = !!ne[e.toLowerCase()];
|
|
6634
|
+
if (h && !b)
|
|
8588
6635
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
8589
|
-
const
|
|
8590
|
-
if (!(
|
|
6636
|
+
const g = T || f, I = r && w || g;
|
|
6637
|
+
if (!(l || A))
|
|
8591
6638
|
throw new Error("TC Vault is required on calldata");
|
|
8592
|
-
if (!(
|
|
6639
|
+
if (!(d || b))
|
|
8593
6640
|
throw new Error("TC Router is required on calldata");
|
|
8594
|
-
if (!
|
|
6641
|
+
if (!I)
|
|
8595
6642
|
throw new Error("TC Memo is required on calldata");
|
|
8596
|
-
if (!
|
|
6643
|
+
if (!k)
|
|
8597
6644
|
throw new Error("Token is required on calldata");
|
|
8598
|
-
const
|
|
6645
|
+
const D = [
|
|
8599
6646
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
],
|
|
8606
|
-
return [...
|
|
8607
|
-
},
|
|
8608
|
-
const
|
|
8609
|
-
return
|
|
8610
|
-
},
|
|
8611
|
-
const
|
|
8612
|
-
return
|
|
8613
|
-
},
|
|
8614
|
-
const
|
|
8615
|
-
return
|
|
8616
|
-
},
|
|
8617
|
-
(
|
|
6647
|
+
n(d || b),
|
|
6648
|
+
n(l || A),
|
|
6649
|
+
I.replace("{recipientAddress}", t),
|
|
6650
|
+
n(k),
|
|
6651
|
+
p
|
|
6652
|
+
], X = h ? [n(b), o, c] : [i, c];
|
|
6653
|
+
return [...D, ...X];
|
|
6654
|
+
}, Ue = (r) => {
|
|
6655
|
+
const e = r ? B.MayanodeStagenet : B.MayanodeMainnet;
|
|
6656
|
+
return N.get(`${e}/mayachain/mimir`);
|
|
6657
|
+
}, Ne = (r) => {
|
|
6658
|
+
const e = r ? B.ThornodeStagenet : B.ThornodeMainnet;
|
|
6659
|
+
return N.get(`${e}/thorchain/inbound_addresses`);
|
|
6660
|
+
}, Ge = (r) => {
|
|
6661
|
+
const e = r ? B.ThornodeStagenet : B.ThornodeMainnet;
|
|
6662
|
+
return N.get(`${e}/thorchain/mimir`);
|
|
6663
|
+
}, J = () => Object.values(a).reduce(
|
|
6664
|
+
(r, e) => (r[e] = null, r),
|
|
8618
6665
|
{}
|
|
8619
|
-
),
|
|
8620
|
-
chain:
|
|
8621
|
-
address:
|
|
6666
|
+
), Qe = ({
|
|
6667
|
+
chain: r,
|
|
6668
|
+
address: e
|
|
8622
6669
|
}) => {
|
|
8623
|
-
if (!
|
|
6670
|
+
if (!e)
|
|
8624
6671
|
return !1;
|
|
8625
|
-
switch (
|
|
8626
|
-
case
|
|
8627
|
-
return !
|
|
6672
|
+
switch (r) {
|
|
6673
|
+
case a.Bitcoin:
|
|
6674
|
+
return !e.startsWith("bc1p");
|
|
8628
6675
|
default:
|
|
8629
6676
|
return !0;
|
|
8630
6677
|
}
|
|
8631
6678
|
};
|
|
8632
|
-
var
|
|
8633
|
-
class
|
|
8634
|
-
constructor({ stagenet:
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
var
|
|
8640
|
-
return ((
|
|
6679
|
+
var S, W, q, E, H, V, P;
|
|
6680
|
+
class Je {
|
|
6681
|
+
constructor({ stagenet: e } = {}) {
|
|
6682
|
+
y(this, "connectedChains", J());
|
|
6683
|
+
y(this, "connectedWallets", J());
|
|
6684
|
+
y(this, "stagenet", !1);
|
|
6685
|
+
y(this, "getAddress", (e) => {
|
|
6686
|
+
var t;
|
|
6687
|
+
return ((t = this.connectedChains[e]) == null ? void 0 : t.address) || "";
|
|
8641
6688
|
});
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
const
|
|
8647
|
-
return (
|
|
6689
|
+
y(this, "getExplorerTxUrl", (e, t) => ee({ chain: e, txHash: t }));
|
|
6690
|
+
y(this, "getWallet", (e) => this.connectedWallets[e]);
|
|
6691
|
+
y(this, "getExplorerAddressUrl", (e, t) => te({ chain: e, address: t }));
|
|
6692
|
+
y(this, "getBalance", async (e, t) => {
|
|
6693
|
+
const n = await this.getWalletByChain(e, t);
|
|
6694
|
+
return (n == null ? void 0 : n.balance) || [];
|
|
8648
6695
|
});
|
|
8649
|
-
|
|
8650
|
-
streamSwap:
|
|
8651
|
-
recipient:
|
|
8652
|
-
route:
|
|
8653
|
-
feeOptionKey:
|
|
6696
|
+
y(this, "swap", async ({
|
|
6697
|
+
streamSwap: e,
|
|
6698
|
+
recipient: t,
|
|
6699
|
+
route: n,
|
|
6700
|
+
feeOptionKey: p = K.Average
|
|
8654
6701
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
|
|
8655
6702
|
}) => {
|
|
8656
|
-
var
|
|
6703
|
+
var c, f;
|
|
8657
6704
|
const {
|
|
8658
|
-
meta: { quoteMode:
|
|
6705
|
+
meta: { quoteMode: i }
|
|
8659
6706
|
// evmTransactionDetails: contractCallParams,
|
|
8660
|
-
} =
|
|
8661
|
-
if (!
|
|
8662
|
-
throw new
|
|
8663
|
-
if (
|
|
8664
|
-
const
|
|
8665
|
-
if (!(
|
|
8666
|
-
throw new
|
|
8667
|
-
if (!(
|
|
8668
|
-
throw new
|
|
8669
|
-
const { data:
|
|
8670
|
-
data:
|
|
8671
|
-
from:
|
|
8672
|
-
to:
|
|
8673
|
-
chainId: BigInt(
|
|
8674
|
-
value:
|
|
6707
|
+
} = n, o = i.startsWith("ERC20-") ? a.Ethereum : i.startsWith("ARC20-") ? a.Avalanche : i.startsWith("BEP20-") ? a.BinanceSmartChain : void 0;
|
|
6708
|
+
if (!n.complete)
|
|
6709
|
+
throw new s("core_swap_route_not_complete");
|
|
6710
|
+
if (le.includes(i) && o) {
|
|
6711
|
+
const b = this.connectedWallets[o];
|
|
6712
|
+
if (!(b != null && b.sendTransaction))
|
|
6713
|
+
throw new s("core_wallet_connection_not_found");
|
|
6714
|
+
if (!(e ? (c = n == null ? void 0 : n.streamingSwap) == null ? void 0 : c.transaction : n == null ? void 0 : n.transaction))
|
|
6715
|
+
throw new s("core_swap_route_transaction_not_found");
|
|
6716
|
+
const { data: T, from: d, to: l, value: A } = n.transaction, k = {
|
|
6717
|
+
data: T,
|
|
6718
|
+
from: d,
|
|
6719
|
+
to: l.toLowerCase(),
|
|
6720
|
+
chainId: BigInt(me[o]),
|
|
6721
|
+
value: A ? BigInt(A) : 0n
|
|
8675
6722
|
};
|
|
8676
|
-
return
|
|
6723
|
+
return b.sendTransaction(k, p);
|
|
8677
6724
|
}
|
|
8678
|
-
if (
|
|
8679
|
-
if (!
|
|
8680
|
-
throw new
|
|
8681
|
-
const
|
|
8682
|
-
if (!
|
|
8683
|
-
throw new
|
|
8684
|
-
const { address:
|
|
8685
|
-
contract:
|
|
8686
|
-
calldata: { expiration:
|
|
8687
|
-
} =
|
|
6725
|
+
if (Te.includes(i)) {
|
|
6726
|
+
if (!n.calldata.fromAsset)
|
|
6727
|
+
throw new s("core_swap_asset_not_recognized");
|
|
6728
|
+
const b = await L.fromString(n.calldata.fromAsset);
|
|
6729
|
+
if (!b)
|
|
6730
|
+
throw new s("core_swap_asset_not_recognized");
|
|
6731
|
+
const { address: w } = await M(this, S).call(this, b.chain), {
|
|
6732
|
+
contract: T,
|
|
6733
|
+
calldata: { expiration: d, amountIn: l, memo: A, memoStreamingSwap: k }
|
|
6734
|
+
} = n, h = b.add(oe.fromBigInt(BigInt(l), b.decimal)), g = e && k || A;
|
|
8688
6735
|
return this.deposit({
|
|
8689
|
-
expiration:
|
|
8690
|
-
assetValue:
|
|
8691
|
-
memo:
|
|
8692
|
-
feeOptionKey:
|
|
8693
|
-
router:
|
|
8694
|
-
recipient:
|
|
6736
|
+
expiration: d,
|
|
6737
|
+
assetValue: h,
|
|
6738
|
+
memo: g,
|
|
6739
|
+
feeOptionKey: p,
|
|
6740
|
+
router: T,
|
|
6741
|
+
recipient: w
|
|
8695
6742
|
});
|
|
8696
6743
|
}
|
|
8697
|
-
if (
|
|
8698
|
-
const { calldata:
|
|
8699
|
-
if (!
|
|
8700
|
-
throw new
|
|
8701
|
-
const
|
|
8702
|
-
if (!(
|
|
8703
|
-
throw new
|
|
8704
|
-
const { getProvider:
|
|
8705
|
-
if (!
|
|
8706
|
-
throw new
|
|
8707
|
-
contractAddress:
|
|
6744
|
+
if (ce.includes(i) && o) {
|
|
6745
|
+
const { calldata: b, contract: w } = n;
|
|
6746
|
+
if (!w)
|
|
6747
|
+
throw new s("core_swap_contract_not_found");
|
|
6748
|
+
const T = this.connectedWallets[o], d = this.getAddress(o);
|
|
6749
|
+
if (!(T != null && T.sendTransaction && d))
|
|
6750
|
+
throw new s("core_wallet_connection_not_found");
|
|
6751
|
+
const { getProvider: l, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), k = l(o), h = De[w.toLowerCase()];
|
|
6752
|
+
if (!h)
|
|
6753
|
+
throw new s("core_swap_contract_not_supported", {
|
|
6754
|
+
contractAddress: w
|
|
8708
6755
|
});
|
|
8709
|
-
const
|
|
8710
|
-
...
|
|
8711
|
-
streamSwap:
|
|
8712
|
-
toChecksumAddress:
|
|
8713
|
-
contractAddress:
|
|
8714
|
-
recipient:
|
|
8715
|
-
calldata:
|
|
6756
|
+
const I = await (await ((f = T.createContract) == null ? void 0 : f.call(T, w, h, k))).getFunction("swapIn").populateTransaction(
|
|
6757
|
+
...Xe({
|
|
6758
|
+
streamSwap: e,
|
|
6759
|
+
toChecksumAddress: A,
|
|
6760
|
+
contractAddress: w,
|
|
6761
|
+
recipient: t,
|
|
6762
|
+
calldata: b
|
|
8716
6763
|
}),
|
|
8717
|
-
{ from:
|
|
6764
|
+
{ from: d }
|
|
8718
6765
|
);
|
|
8719
|
-
return
|
|
6766
|
+
return T.sendTransaction(I, p);
|
|
8720
6767
|
}
|
|
8721
|
-
throw new
|
|
6768
|
+
throw new s("core_swap_quote_mode_not_supported", { quoteMode: i });
|
|
8722
6769
|
});
|
|
8723
|
-
|
|
8724
|
-
var
|
|
8725
|
-
const
|
|
8726
|
-
if (!
|
|
6770
|
+
y(this, "getWalletByChain", async (e, t) => {
|
|
6771
|
+
var o, c;
|
|
6772
|
+
const n = this.getAddress(e);
|
|
6773
|
+
if (!n)
|
|
8727
6774
|
return null;
|
|
8728
|
-
const
|
|
6775
|
+
const p = [L.fromChainOrSignature(e)], i = (o = this.connectedChains[e]) == null ? void 0 : o.walletType;
|
|
8729
6776
|
try {
|
|
8730
|
-
const
|
|
8731
|
-
return this.connectedChains[
|
|
8732
|
-
address:
|
|
8733
|
-
balance:
|
|
8734
|
-
walletType:
|
|
8735
|
-
}, { ...this.connectedChains[
|
|
8736
|
-
} catch (
|
|
8737
|
-
return console.error(
|
|
6777
|
+
const f = await ((c = this.getWallet(e)) == null ? void 0 : c.getBalance(n, t));
|
|
6778
|
+
return this.connectedChains[e] = {
|
|
6779
|
+
address: n,
|
|
6780
|
+
balance: f != null && f.length ? f : p,
|
|
6781
|
+
walletType: i
|
|
6782
|
+
}, { ...this.connectedChains[e] };
|
|
6783
|
+
} catch (f) {
|
|
6784
|
+
return console.error(f), { address: n, balance: p, walletType: i };
|
|
8738
6785
|
}
|
|
8739
6786
|
});
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
var
|
|
8744
|
-
return (
|
|
6787
|
+
y(this, "approveAssetValue", (e, t) => M(this, q).call(this, { assetValue: e, type: "approve", contractAddress: t }));
|
|
6788
|
+
y(this, "isAssetValueApproved", (e, t) => M(this, q).call(this, { assetValue: e, contractAddress: t, type: "checkOnly" }));
|
|
6789
|
+
y(this, "validateAddress", ({ address: e, chain: t }) => {
|
|
6790
|
+
var n, p;
|
|
6791
|
+
return (p = (n = this.getWallet(t)) == null ? void 0 : n.validateAddress) == null ? void 0 : p.call(n, e);
|
|
8745
6792
|
});
|
|
8746
|
-
|
|
8747
|
-
const
|
|
8748
|
-
if (!
|
|
8749
|
-
throw new
|
|
6793
|
+
y(this, "transfer", async (e) => {
|
|
6794
|
+
const t = this.connectedWallets[e.assetValue.chain];
|
|
6795
|
+
if (!t)
|
|
6796
|
+
throw new s("core_wallet_connection_not_found");
|
|
8750
6797
|
try {
|
|
8751
|
-
return await
|
|
8752
|
-
} catch (
|
|
8753
|
-
throw new
|
|
6798
|
+
return await t.transfer(M(this, P).call(this, e));
|
|
6799
|
+
} catch (n) {
|
|
6800
|
+
throw new s("core_swap_transaction_error", n);
|
|
8754
6801
|
}
|
|
8755
6802
|
});
|
|
8756
|
-
|
|
8757
|
-
assetValue:
|
|
8758
|
-
recipient:
|
|
8759
|
-
router:
|
|
8760
|
-
...
|
|
6803
|
+
y(this, "deposit", async ({
|
|
6804
|
+
assetValue: e,
|
|
6805
|
+
recipient: t,
|
|
6806
|
+
router: n,
|
|
6807
|
+
...p
|
|
8761
6808
|
}) => {
|
|
8762
|
-
const { chain:
|
|
8763
|
-
if (!await
|
|
8764
|
-
address:
|
|
8765
|
-
chain:
|
|
6809
|
+
const { chain: i, symbol: o, ticker: c } = e, f = this.connectedWallets[i], b = this.connectedChains[i];
|
|
6810
|
+
if (!await Qe({
|
|
6811
|
+
address: b == null ? void 0 : b.address,
|
|
6812
|
+
chain: i
|
|
8766
6813
|
}))
|
|
8767
|
-
throw new
|
|
8768
|
-
if (!
|
|
8769
|
-
throw new
|
|
8770
|
-
const
|
|
8771
|
-
assetValue:
|
|
8772
|
-
recipient:
|
|
8773
|
-
router:
|
|
8774
|
-
...
|
|
6814
|
+
throw new s("core_transaction_invalid_sender_address");
|
|
6815
|
+
if (!f)
|
|
6816
|
+
throw new s("core_wallet_connection_not_found");
|
|
6817
|
+
const T = M(this, P).call(this, {
|
|
6818
|
+
assetValue: e,
|
|
6819
|
+
recipient: t,
|
|
6820
|
+
router: n,
|
|
6821
|
+
...p
|
|
8775
6822
|
});
|
|
8776
6823
|
try {
|
|
8777
|
-
switch (
|
|
8778
|
-
case
|
|
8779
|
-
case
|
|
8780
|
-
const
|
|
8781
|
-
return await (
|
|
6824
|
+
switch (i) {
|
|
6825
|
+
case a.THORChain:
|
|
6826
|
+
case a.Maya: {
|
|
6827
|
+
const d = f;
|
|
6828
|
+
return await (t === "" ? d.deposit(T) : d.transfer(T));
|
|
8782
6829
|
}
|
|
8783
|
-
case
|
|
8784
|
-
case
|
|
8785
|
-
case
|
|
8786
|
-
const { getChecksumAddressFromAsset:
|
|
8787
|
-
return await
|
|
8788
|
-
abi:
|
|
8789
|
-
contractAddress:
|
|
6830
|
+
case a.Ethereum:
|
|
6831
|
+
case a.BinanceSmartChain:
|
|
6832
|
+
case a.Avalanche: {
|
|
6833
|
+
const { getChecksumAddressFromAsset: d } = await import("@swapkit/toolbox-evm"), l = i === a.Avalanche ? be : i === a.BinanceSmartChain ? fe : we;
|
|
6834
|
+
return await f.call({
|
|
6835
|
+
abi: l,
|
|
6836
|
+
contractAddress: n || (await M(this, S).call(this, i)).router,
|
|
8790
6837
|
funcName: "depositWithExpiry",
|
|
8791
6838
|
funcParams: [
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
6839
|
+
t,
|
|
6840
|
+
d({ chain: i, symbol: o, ticker: c }, i),
|
|
6841
|
+
e.getBaseValue("string"),
|
|
6842
|
+
T.memo,
|
|
6843
|
+
p.expiration || Number.parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
8797
6844
|
],
|
|
8798
6845
|
txOverrides: {
|
|
8799
|
-
from:
|
|
8800
|
-
value:
|
|
6846
|
+
from: T.from,
|
|
6847
|
+
value: e.isGasAsset ? e.getBaseValue("bigint") : void 0
|
|
8801
6848
|
}
|
|
8802
6849
|
});
|
|
8803
6850
|
}
|
|
8804
6851
|
default:
|
|
8805
|
-
return await
|
|
6852
|
+
return await f.transfer(T);
|
|
8806
6853
|
}
|
|
8807
|
-
} catch (
|
|
8808
|
-
const
|
|
8809
|
-
throw new
|
|
6854
|
+
} catch (d) {
|
|
6855
|
+
const l = typeof d == "string" ? d.toLowerCase() : d == null ? void 0 : d.message.toLowerCase(), A = l == null ? void 0 : l.includes("insufficient funds"), k = l == null ? void 0 : l.includes("gas"), h = l == null ? void 0 : l.includes("server"), g = l == null ? void 0 : l.includes("user rejected"), I = A ? "core_transaction_deposit_insufficient_funds_error" : k ? "core_transaction_deposit_gas_error" : h ? "core_transaction_deposit_server_error" : g ? "core_transaction_user_rejected" : "core_transaction_deposit_error";
|
|
6856
|
+
throw new s(I, d);
|
|
8810
6857
|
}
|
|
8811
6858
|
});
|
|
8812
6859
|
/**
|
|
8813
6860
|
* TC related Methods
|
|
8814
6861
|
*/
|
|
8815
|
-
|
|
8816
|
-
runeAssetValue:
|
|
8817
|
-
assetValue:
|
|
6862
|
+
y(this, "createLiquidity", async ({
|
|
6863
|
+
runeAssetValue: e,
|
|
6864
|
+
assetValue: t
|
|
8818
6865
|
}) => {
|
|
8819
|
-
if (
|
|
8820
|
-
throw new
|
|
8821
|
-
let
|
|
6866
|
+
if (e.lte(0) || t.lte(0))
|
|
6867
|
+
throw new s("core_transaction_create_liquidity_invalid_params");
|
|
6868
|
+
let n = "", p = "";
|
|
8822
6869
|
try {
|
|
8823
|
-
|
|
8824
|
-
assetValue:
|
|
8825
|
-
memo:
|
|
8826
|
-
...
|
|
8827
|
-
address: this.getAddress(
|
|
6870
|
+
n = await M(this, E).call(this, {
|
|
6871
|
+
assetValue: e,
|
|
6872
|
+
memo: O(v.DEPOSIT, {
|
|
6873
|
+
...t,
|
|
6874
|
+
address: this.getAddress(t.chain)
|
|
8828
6875
|
})
|
|
8829
6876
|
});
|
|
8830
|
-
} catch (
|
|
8831
|
-
throw new
|
|
6877
|
+
} catch (i) {
|
|
6878
|
+
throw new s("core_transaction_create_liquidity_rune_error", i);
|
|
8832
6879
|
}
|
|
8833
6880
|
try {
|
|
8834
|
-
|
|
8835
|
-
assetValue:
|
|
8836
|
-
memo:
|
|
8837
|
-
...
|
|
8838
|
-
address: this.getAddress(
|
|
6881
|
+
p = await M(this, E).call(this, {
|
|
6882
|
+
assetValue: t,
|
|
6883
|
+
memo: O(v.DEPOSIT, {
|
|
6884
|
+
...t,
|
|
6885
|
+
address: this.getAddress(a.THORChain)
|
|
8839
6886
|
})
|
|
8840
6887
|
});
|
|
8841
|
-
} catch (
|
|
8842
|
-
throw new
|
|
6888
|
+
} catch (i) {
|
|
6889
|
+
throw new s("core_transaction_create_liquidity_asset_error", i);
|
|
8843
6890
|
}
|
|
8844
|
-
return { runeTx:
|
|
6891
|
+
return { runeTx: n, assetTx: p };
|
|
8845
6892
|
});
|
|
8846
|
-
|
|
8847
|
-
runeAssetValue:
|
|
8848
|
-
assetValue:
|
|
8849
|
-
runeAddr:
|
|
8850
|
-
assetAddr:
|
|
8851
|
-
isPendingSymmAsset:
|
|
8852
|
-
mode:
|
|
6893
|
+
y(this, "addLiquidity", async ({
|
|
6894
|
+
runeAssetValue: e,
|
|
6895
|
+
assetValue: t,
|
|
6896
|
+
runeAddr: n,
|
|
6897
|
+
assetAddr: p,
|
|
6898
|
+
isPendingSymmAsset: i,
|
|
6899
|
+
mode: o = "sym"
|
|
8853
6900
|
}) => {
|
|
8854
|
-
const { chain:
|
|
8855
|
-
if (!(
|
|
8856
|
-
throw new
|
|
8857
|
-
if (
|
|
8858
|
-
throw new
|
|
8859
|
-
let
|
|
8860
|
-
if (
|
|
6901
|
+
const { chain: c, symbol: f } = t, b = o === "sym", w = (e == null ? void 0 : e.gt(0)) && (b || o === "rune"), T = (t == null ? void 0 : t.gt(0)) && (b || o === "asset"), d = i || w, l = d ? n || this.getAddress(a.THORChain) : "", A = b || o === "asset" ? p || this.getAddress(c) : "";
|
|
6902
|
+
if (!(w || T))
|
|
6903
|
+
throw new s("core_transaction_add_liquidity_invalid_params");
|
|
6904
|
+
if (d && !l)
|
|
6905
|
+
throw new s("core_transaction_add_liquidity_no_rune_address");
|
|
6906
|
+
let k, h;
|
|
6907
|
+
if (w && e)
|
|
8861
6908
|
try {
|
|
8862
|
-
|
|
8863
|
-
assetValue:
|
|
8864
|
-
memo:
|
|
8865
|
-
chain:
|
|
8866
|
-
symbol:
|
|
8867
|
-
address:
|
|
6909
|
+
k = await M(this, E).call(this, {
|
|
6910
|
+
assetValue: e,
|
|
6911
|
+
memo: O(v.DEPOSIT, {
|
|
6912
|
+
chain: c,
|
|
6913
|
+
symbol: f,
|
|
6914
|
+
address: A
|
|
8868
6915
|
})
|
|
8869
6916
|
});
|
|
8870
|
-
} catch (
|
|
8871
|
-
throw new
|
|
6917
|
+
} catch (g) {
|
|
6918
|
+
throw new s("core_transaction_add_liquidity_rune_error", g);
|
|
8872
6919
|
}
|
|
8873
|
-
if (
|
|
6920
|
+
if (T && t)
|
|
8874
6921
|
try {
|
|
8875
|
-
|
|
8876
|
-
assetValue:
|
|
8877
|
-
memo:
|
|
8878
|
-
chain:
|
|
8879
|
-
symbol:
|
|
8880
|
-
address:
|
|
6922
|
+
h = await M(this, E).call(this, {
|
|
6923
|
+
assetValue: t,
|
|
6924
|
+
memo: O(v.DEPOSIT, {
|
|
6925
|
+
chain: c,
|
|
6926
|
+
symbol: f,
|
|
6927
|
+
address: l
|
|
8881
6928
|
})
|
|
8882
6929
|
});
|
|
8883
|
-
} catch (
|
|
8884
|
-
throw new
|
|
6930
|
+
} catch (g) {
|
|
6931
|
+
throw new s("core_transaction_add_liquidity_asset_error", g);
|
|
8885
6932
|
}
|
|
8886
|
-
return { runeTx:
|
|
6933
|
+
return { runeTx: k, assetTx: h };
|
|
8887
6934
|
});
|
|
8888
|
-
|
|
8889
|
-
assetValue:
|
|
8890
|
-
poolAddress:
|
|
8891
|
-
address:
|
|
8892
|
-
symmetric:
|
|
6935
|
+
y(this, "addLiquidityPart", ({
|
|
6936
|
+
assetValue: e,
|
|
6937
|
+
poolAddress: t,
|
|
6938
|
+
address: n,
|
|
6939
|
+
symmetric: p
|
|
8893
6940
|
}) => {
|
|
8894
|
-
if (
|
|
8895
|
-
throw new
|
|
8896
|
-
const
|
|
8897
|
-
chain:
|
|
8898
|
-
symbol:
|
|
8899
|
-
address:
|
|
6941
|
+
if (p && !n)
|
|
6942
|
+
throw new s("core_transaction_add_liquidity_invalid_params");
|
|
6943
|
+
const i = O(v.DEPOSIT, {
|
|
6944
|
+
chain: t.split(".")[0],
|
|
6945
|
+
symbol: t.split(".")[1],
|
|
6946
|
+
address: p ? n : ""
|
|
8900
6947
|
});
|
|
8901
|
-
return
|
|
6948
|
+
return M(this, E).call(this, { assetValue: e, memo: i });
|
|
8902
6949
|
});
|
|
8903
|
-
|
|
8904
|
-
memo:
|
|
8905
|
-
assetValue:
|
|
8906
|
-
percent:
|
|
8907
|
-
from:
|
|
8908
|
-
to:
|
|
6950
|
+
y(this, "withdraw", ({
|
|
6951
|
+
memo: e,
|
|
6952
|
+
assetValue: t,
|
|
6953
|
+
percent: n,
|
|
6954
|
+
from: p,
|
|
6955
|
+
to: i
|
|
8909
6956
|
}) => {
|
|
8910
|
-
const
|
|
8911
|
-
symbol:
|
|
8912
|
-
chain:
|
|
8913
|
-
ticker:
|
|
8914
|
-
basisPoints: Math.min(1e4, Math.round(
|
|
8915
|
-
targetAssetString:
|
|
6957
|
+
const o = i === "rune" && p !== "rune" ? L.fromChainOrSignature(a.THORChain) : p === "sym" && i === "sym" || p === "rune" || p === "asset" ? void 0 : t, c = U(p === "asset" ? t.chain : a.THORChain), f = e || O(v.WITHDRAW, {
|
|
6958
|
+
symbol: t.symbol,
|
|
6959
|
+
chain: t.chain,
|
|
6960
|
+
ticker: t.ticker,
|
|
6961
|
+
basisPoints: Math.min(1e4, Math.round(n * 100)),
|
|
6962
|
+
targetAssetString: o == null ? void 0 : o.toString(),
|
|
8916
6963
|
singleSide: !1
|
|
8917
6964
|
});
|
|
8918
|
-
return
|
|
6965
|
+
return M(this, E).call(this, { assetValue: c, memo: f });
|
|
8919
6966
|
});
|
|
8920
|
-
|
|
8921
|
-
assetValue:
|
|
8922
|
-
memo:
|
|
8923
|
-
percent:
|
|
8924
|
-
type:
|
|
6967
|
+
y(this, "savings", ({
|
|
6968
|
+
assetValue: e,
|
|
6969
|
+
memo: t,
|
|
6970
|
+
percent: n,
|
|
6971
|
+
type: p
|
|
8925
6972
|
}) => {
|
|
8926
|
-
const
|
|
8927
|
-
ticker:
|
|
8928
|
-
symbol:
|
|
8929
|
-
chain:
|
|
6973
|
+
const i = p === "add" ? v.DEPOSIT : v.WITHDRAW, o = t || O(i, {
|
|
6974
|
+
ticker: e.ticker,
|
|
6975
|
+
symbol: e.symbol,
|
|
6976
|
+
chain: e.chain,
|
|
8930
6977
|
singleSide: !0,
|
|
8931
|
-
basisPoints:
|
|
8932
|
-
}),
|
|
8933
|
-
return
|
|
6978
|
+
basisPoints: n ? Math.min(1e4, Math.round(n * 100)) : void 0
|
|
6979
|
+
}), c = i === v.DEPOSIT ? e : U(e.chain);
|
|
6980
|
+
return M(this, E).call(this, { memo: o, assetValue: c });
|
|
8934
6981
|
});
|
|
8935
|
-
|
|
8936
|
-
assetValue:
|
|
8937
|
-
memo:
|
|
8938
|
-
minAmount:
|
|
8939
|
-
type:
|
|
8940
|
-
}) =>
|
|
8941
|
-
assetValue:
|
|
8942
|
-
memo:
|
|
8943
|
-
asset:
|
|
8944
|
-
minAmount:
|
|
8945
|
-
address: this.getAddress(
|
|
6982
|
+
y(this, "loan", ({
|
|
6983
|
+
assetValue: e,
|
|
6984
|
+
memo: t,
|
|
6985
|
+
minAmount: n,
|
|
6986
|
+
type: p
|
|
6987
|
+
}) => M(this, E).call(this, {
|
|
6988
|
+
assetValue: e,
|
|
6989
|
+
memo: t || O(p === "open" ? v.OPEN_LOAN : v.CLOSE_LOAN, {
|
|
6990
|
+
asset: e.toString(),
|
|
6991
|
+
minAmount: n.toString(),
|
|
6992
|
+
address: this.getAddress(e.chain)
|
|
8946
6993
|
})
|
|
8947
6994
|
}));
|
|
8948
|
-
|
|
8949
|
-
type:
|
|
8950
|
-
assetValue:
|
|
8951
|
-
address:
|
|
6995
|
+
y(this, "nodeAction", ({
|
|
6996
|
+
type: e,
|
|
6997
|
+
assetValue: t,
|
|
6998
|
+
address: n
|
|
8952
6999
|
}) => {
|
|
8953
|
-
const
|
|
8954
|
-
address:
|
|
8955
|
-
unbondAmount:
|
|
7000
|
+
const p = e === "bond" ? v.BOND : e === "unbond" ? v.UNBOND : v.LEAVE, i = O(p, {
|
|
7001
|
+
address: n,
|
|
7002
|
+
unbondAmount: e === "unbond" ? t.getBaseValue("number") : void 0
|
|
8956
7003
|
});
|
|
8957
|
-
return
|
|
8958
|
-
memo:
|
|
8959
|
-
assetValue:
|
|
7004
|
+
return M(this, H).call(this, {
|
|
7005
|
+
memo: i,
|
|
7006
|
+
assetValue: e === "bond" ? t : U(a.THORChain)
|
|
8960
7007
|
});
|
|
8961
7008
|
});
|
|
8962
|
-
|
|
8963
|
-
assetValue:
|
|
8964
|
-
...
|
|
8965
|
-
}) =>
|
|
8966
|
-
assetValue:
|
|
8967
|
-
memo:
|
|
7009
|
+
y(this, "registerThorname", ({
|
|
7010
|
+
assetValue: e,
|
|
7011
|
+
...t
|
|
7012
|
+
}) => M(this, H).call(this, {
|
|
7013
|
+
assetValue: e,
|
|
7014
|
+
memo: O(v.THORNAME_REGISTER, t)
|
|
8968
7015
|
}));
|
|
8969
|
-
|
|
8970
|
-
assetValue:
|
|
8971
|
-
...
|
|
8972
|
-
}) =>
|
|
8973
|
-
assetValue:
|
|
8974
|
-
memo:
|
|
7016
|
+
y(this, "registerMayaname", ({
|
|
7017
|
+
assetValue: e,
|
|
7018
|
+
...t
|
|
7019
|
+
}) => M(this, V).call(this, {
|
|
7020
|
+
assetValue: e,
|
|
7021
|
+
memo: O(v.THORNAME_REGISTER, t)
|
|
8975
7022
|
}));
|
|
8976
|
-
|
|
7023
|
+
y(this, "extend", ({ wallets: e, config: t, apis: n = {}, rpcUrls: p = {} }) => {
|
|
8977
7024
|
try {
|
|
8978
|
-
for (const
|
|
8979
|
-
this[
|
|
8980
|
-
addChain:
|
|
8981
|
-
config:
|
|
8982
|
-
apis:
|
|
8983
|
-
rpcUrls:
|
|
7025
|
+
for (const i of e)
|
|
7026
|
+
this[i.connectMethodName] = i.connect({
|
|
7027
|
+
addChain: M(this, W),
|
|
7028
|
+
config: t || {},
|
|
7029
|
+
apis: n,
|
|
7030
|
+
rpcUrls: p
|
|
8984
7031
|
});
|
|
8985
|
-
} catch (
|
|
8986
|
-
throw new
|
|
7032
|
+
} catch (i) {
|
|
7033
|
+
throw new s("core_extend_error", i);
|
|
8987
7034
|
}
|
|
8988
7035
|
});
|
|
8989
|
-
|
|
8990
|
-
chain:
|
|
8991
|
-
params:
|
|
7036
|
+
y(this, "estimateMaxSendableAmount", async ({
|
|
7037
|
+
chain: e,
|
|
7038
|
+
params: t
|
|
8992
7039
|
}) => {
|
|
8993
|
-
const
|
|
8994
|
-
switch (
|
|
8995
|
-
case
|
|
8996
|
-
case
|
|
8997
|
-
case
|
|
8998
|
-
case
|
|
8999
|
-
case
|
|
9000
|
-
case
|
|
9001
|
-
const { estimateMaxSendableAmount:
|
|
9002
|
-
return
|
|
9003
|
-
...
|
|
9004
|
-
toolbox:
|
|
7040
|
+
const n = this.getWallet(e);
|
|
7041
|
+
switch (e) {
|
|
7042
|
+
case a.Arbitrum:
|
|
7043
|
+
case a.Avalanche:
|
|
7044
|
+
case a.BinanceSmartChain:
|
|
7045
|
+
case a.Ethereum:
|
|
7046
|
+
case a.Optimism:
|
|
7047
|
+
case a.Polygon: {
|
|
7048
|
+
const { estimateMaxSendableAmount: p } = await import("@swapkit/toolbox-evm");
|
|
7049
|
+
return p({
|
|
7050
|
+
...t,
|
|
7051
|
+
toolbox: n
|
|
9005
7052
|
});
|
|
9006
7053
|
}
|
|
9007
|
-
case
|
|
9008
|
-
case
|
|
9009
|
-
case
|
|
9010
|
-
case
|
|
9011
|
-
return
|
|
9012
|
-
case
|
|
9013
|
-
case
|
|
9014
|
-
case
|
|
9015
|
-
const { estimateMaxSendableAmount:
|
|
9016
|
-
return
|
|
9017
|
-
...
|
|
9018
|
-
toolbox:
|
|
7054
|
+
case a.Bitcoin:
|
|
7055
|
+
case a.BitcoinCash:
|
|
7056
|
+
case a.Dogecoin:
|
|
7057
|
+
case a.Litecoin:
|
|
7058
|
+
return n.estimateMaxSendableAmount(t);
|
|
7059
|
+
case a.Binance:
|
|
7060
|
+
case a.THORChain:
|
|
7061
|
+
case a.Cosmos: {
|
|
7062
|
+
const { estimateMaxSendableAmount: p } = await import("@swapkit/toolbox-cosmos");
|
|
7063
|
+
return p({
|
|
7064
|
+
...t,
|
|
7065
|
+
toolbox: n
|
|
9019
7066
|
});
|
|
9020
7067
|
}
|
|
9021
7068
|
default:
|
|
9022
|
-
throw new
|
|
7069
|
+
throw new s("core_estimated_max_spendable_chain_not_supported");
|
|
9023
7070
|
}
|
|
9024
7071
|
});
|
|
9025
7072
|
/**
|
|
9026
7073
|
* Wallet connection methods
|
|
9027
7074
|
*/
|
|
9028
7075
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9029
|
-
|
|
9030
|
-
throw new
|
|
7076
|
+
y(this, "connectXDEFI", async (e) => {
|
|
7077
|
+
throw new s("core_wallet_xdefi_not_installed");
|
|
9031
7078
|
});
|
|
9032
7079
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9033
|
-
|
|
9034
|
-
throw new
|
|
7080
|
+
y(this, "connectEVMWallet", async (e, t) => {
|
|
7081
|
+
throw new s("core_wallet_evmwallet_not_installed");
|
|
9035
7082
|
});
|
|
9036
7083
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9037
|
-
|
|
9038
|
-
throw new
|
|
7084
|
+
y(this, "connectWalletconnect", async (e, t) => {
|
|
7085
|
+
throw new s("core_wallet_walletconnect_not_installed");
|
|
9039
7086
|
});
|
|
9040
7087
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9041
|
-
|
|
9042
|
-
throw new
|
|
7088
|
+
y(this, "connectKeepkey", async (e, t) => {
|
|
7089
|
+
throw new s("core_wallet_keepkey_not_installed");
|
|
9043
7090
|
});
|
|
9044
7091
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9045
|
-
|
|
9046
|
-
throw new
|
|
7092
|
+
y(this, "connectKeystore", async (e, t) => {
|
|
7093
|
+
throw new s("core_wallet_keystore_not_installed");
|
|
9047
7094
|
});
|
|
9048
7095
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9049
|
-
|
|
9050
|
-
throw new
|
|
7096
|
+
y(this, "connectLedger", async (e, t) => {
|
|
7097
|
+
throw new s("core_wallet_ledger_not_installed");
|
|
9051
7098
|
});
|
|
9052
7099
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9053
|
-
|
|
9054
|
-
throw new
|
|
7100
|
+
y(this, "connectTrezor", async (e, t) => {
|
|
7101
|
+
throw new s("core_wallet_trezor_not_installed");
|
|
9055
7102
|
});
|
|
9056
7103
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9057
|
-
|
|
9058
|
-
throw new
|
|
7104
|
+
y(this, "connectKeplr", async (e) => {
|
|
7105
|
+
throw new s("core_wallet_keplr_not_installed");
|
|
9059
7106
|
});
|
|
9060
7107
|
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9061
|
-
|
|
9062
|
-
throw new
|
|
7108
|
+
y(this, "connectOkx", async (e) => {
|
|
7109
|
+
throw new s("core_wallet_okx_not_installed");
|
|
9063
7110
|
});
|
|
9064
|
-
|
|
9065
|
-
this.connectedChains[
|
|
7111
|
+
y(this, "disconnectChain", (e) => {
|
|
7112
|
+
this.connectedChains[e] = null, this.connectedWallets[e] = null;
|
|
9066
7113
|
});
|
|
9067
|
-
|
|
9068
|
-
switch (
|
|
9069
|
-
case
|
|
9070
|
-
case
|
|
9071
|
-
return { gas_rate: "0", router: "", address: "", halted: !1, chain:
|
|
7114
|
+
F(this, S, async (e) => {
|
|
7115
|
+
switch (e) {
|
|
7116
|
+
case a.Maya:
|
|
7117
|
+
case a.THORChain:
|
|
7118
|
+
return { gas_rate: "0", router: "", address: "", halted: !1, chain: e };
|
|
9072
7119
|
default: {
|
|
9073
|
-
const
|
|
9074
|
-
if (!
|
|
9075
|
-
throw new
|
|
9076
|
-
if (
|
|
9077
|
-
throw new
|
|
9078
|
-
return
|
|
7120
|
+
const n = (await Ne(this.stagenet)).find((p) => p.chain === e);
|
|
7121
|
+
if (!n)
|
|
7122
|
+
throw new s("core_inbound_data_not_found");
|
|
7123
|
+
if (n != null && n.halted)
|
|
7124
|
+
throw new s("core_chain_halted");
|
|
7125
|
+
return n;
|
|
9079
7126
|
}
|
|
9080
7127
|
}
|
|
9081
7128
|
});
|
|
9082
|
-
|
|
9083
|
-
chain:
|
|
9084
|
-
address:
|
|
9085
|
-
balance:
|
|
9086
|
-
walletType:
|
|
9087
|
-
...
|
|
7129
|
+
F(this, W, ({
|
|
7130
|
+
chain: e,
|
|
7131
|
+
address: t,
|
|
7132
|
+
balance: n,
|
|
7133
|
+
walletType: p,
|
|
7134
|
+
...i
|
|
9088
7135
|
}) => {
|
|
9089
|
-
this.connectedChains[
|
|
9090
|
-
address:
|
|
9091
|
-
balance:
|
|
9092
|
-
walletType:
|
|
9093
|
-
}, this.connectedWallets[
|
|
7136
|
+
this.connectedChains[e] = {
|
|
7137
|
+
address: t || "",
|
|
7138
|
+
balance: n || [],
|
|
7139
|
+
walletType: p || "unknown"
|
|
7140
|
+
}, this.connectedWallets[e] = { ...i };
|
|
9094
7141
|
});
|
|
9095
|
-
|
|
9096
|
-
assetValue:
|
|
9097
|
-
type:
|
|
9098
|
-
contractAddress:
|
|
7142
|
+
F(this, q, async ({
|
|
7143
|
+
assetValue: e,
|
|
7144
|
+
type: t = "checkOnly",
|
|
7145
|
+
contractAddress: n
|
|
9099
7146
|
}) => {
|
|
9100
|
-
const { address:
|
|
9101
|
-
if (
|
|
7147
|
+
const { address: p, chain: i, isGasAsset: o, isSynthetic: c } = e, f = [a.Ethereum, a.Avalanche, a.BinanceSmartChain].includes(i);
|
|
7148
|
+
if (f && o || !f || c)
|
|
9102
7149
|
return !0;
|
|
9103
|
-
const
|
|
9104
|
-
if (!
|
|
9105
|
-
throw new
|
|
9106
|
-
const
|
|
9107
|
-
if (!(
|
|
9108
|
-
throw new
|
|
9109
|
-
const
|
|
9110
|
-
return
|
|
9111
|
-
amount:
|
|
9112
|
-
assetAddress:
|
|
9113
|
-
from:
|
|
9114
|
-
spenderAddress:
|
|
7150
|
+
const w = this.connectedWallets[i], T = t === "checkOnly" ? w == null ? void 0 : w.isApproved : w == null ? void 0 : w.approve;
|
|
7151
|
+
if (!T)
|
|
7152
|
+
throw new s("core_wallet_connection_not_found");
|
|
7153
|
+
const d = this.getAddress(i);
|
|
7154
|
+
if (!(p && d))
|
|
7155
|
+
throw new s("core_approve_asset_address_or_from_not_found");
|
|
7156
|
+
const l = n || (await M(this, S).call(this, i)).router;
|
|
7157
|
+
return T({
|
|
7158
|
+
amount: e.getBaseValue("bigint"),
|
|
7159
|
+
assetAddress: p,
|
|
7160
|
+
from: d,
|
|
7161
|
+
spenderAddress: l
|
|
9115
7162
|
});
|
|
9116
7163
|
});
|
|
9117
|
-
|
|
9118
|
-
assetValue:
|
|
9119
|
-
memo:
|
|
9120
|
-
feeOptionKey:
|
|
7164
|
+
F(this, E, async ({
|
|
7165
|
+
assetValue: e,
|
|
7166
|
+
memo: t,
|
|
7167
|
+
feeOptionKey: n = K.Fast
|
|
9121
7168
|
}) => {
|
|
9122
7169
|
const {
|
|
9123
|
-
gas_rate:
|
|
9124
|
-
router:
|
|
9125
|
-
address:
|
|
9126
|
-
} = await
|
|
7170
|
+
gas_rate: p,
|
|
7171
|
+
router: i,
|
|
7172
|
+
address: o
|
|
7173
|
+
} = await M(this, S).call(this, e.chain), c = (Number.parseInt(p) || 0) * de[n];
|
|
9127
7174
|
return this.deposit({
|
|
9128
|
-
assetValue:
|
|
9129
|
-
recipient:
|
|
9130
|
-
memo:
|
|
9131
|
-
router:
|
|
9132
|
-
feeRate:
|
|
7175
|
+
assetValue: e,
|
|
7176
|
+
recipient: o,
|
|
7177
|
+
memo: t,
|
|
7178
|
+
router: i,
|
|
7179
|
+
feeRate: c
|
|
9133
7180
|
});
|
|
9134
7181
|
});
|
|
9135
|
-
|
|
9136
|
-
memo:
|
|
9137
|
-
assetValue:
|
|
7182
|
+
F(this, H, async ({
|
|
7183
|
+
memo: e,
|
|
7184
|
+
assetValue: t
|
|
9138
7185
|
}) => {
|
|
9139
|
-
const
|
|
9140
|
-
if (
|
|
9141
|
-
throw new
|
|
9142
|
-
return this.deposit({ assetValue:
|
|
7186
|
+
const n = await Ge(this.stagenet);
|
|
7187
|
+
if (n.HALTCHAINGLOBAL >= 1 || n.HALTTHORCHAIN >= 1)
|
|
7188
|
+
throw new s("core_chain_halted");
|
|
7189
|
+
return this.deposit({ assetValue: t, recipient: "", memo: e });
|
|
9143
7190
|
});
|
|
9144
|
-
|
|
9145
|
-
memo:
|
|
9146
|
-
assetValue:
|
|
7191
|
+
F(this, V, async ({
|
|
7192
|
+
memo: e,
|
|
7193
|
+
assetValue: t
|
|
9147
7194
|
}) => {
|
|
9148
|
-
const
|
|
9149
|
-
if (
|
|
9150
|
-
throw new
|
|
9151
|
-
return this.deposit({ assetValue:
|
|
7195
|
+
const n = await Ue(this.stagenet);
|
|
7196
|
+
if (n.HALTCHAINGLOBAL >= 1 || n.HALTTHORCHAIN >= 1)
|
|
7197
|
+
throw new s("core_chain_halted");
|
|
7198
|
+
return this.deposit({ assetValue: t, recipient: "", memo: e });
|
|
9152
7199
|
});
|
|
9153
|
-
|
|
9154
|
-
...
|
|
9155
|
-
memo:
|
|
9156
|
-
from: this.getAddress(
|
|
9157
|
-
assetValue:
|
|
7200
|
+
F(this, P, ({ assetValue: e, ...t }) => ({
|
|
7201
|
+
...t,
|
|
7202
|
+
memo: t.memo || "",
|
|
7203
|
+
from: this.getAddress(e.chain),
|
|
7204
|
+
assetValue: e
|
|
9158
7205
|
}));
|
|
9159
|
-
this.stagenet = !!
|
|
7206
|
+
this.stagenet = !!e;
|
|
9160
7207
|
}
|
|
9161
7208
|
}
|
|
9162
|
-
|
|
7209
|
+
S = new WeakMap(), W = new WeakMap(), q = new WeakMap(), E = new WeakMap(), H = new WeakMap(), V = new WeakMap(), P = new WeakMap();
|
|
9163
7210
|
export {
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
gn as ApproveMode,
|
|
9168
|
-
x as AssetValue,
|
|
9169
|
-
g as BaseDecimal,
|
|
9170
|
-
xe as BigIntArithmetics,
|
|
9171
|
-
r as Chain,
|
|
9172
|
-
Re as ChainId,
|
|
9173
|
-
sa as ChainIdToChain,
|
|
9174
|
-
Qe as ChainToChainId,
|
|
9175
|
-
Ye as ChainToExplorerUrl,
|
|
9176
|
-
ia as ChainToHexChainId,
|
|
9177
|
-
Bt as ChainToRPC,
|
|
9178
|
-
Et as ContractAddress,
|
|
9179
|
-
na as CosmosChainList,
|
|
9180
|
-
xt as CosmosChains,
|
|
9181
|
-
Ot as DerivationPath,
|
|
9182
|
-
ea as EVMChainList,
|
|
9183
|
-
je as EVMChains,
|
|
9184
|
-
Y as FeeOption,
|
|
9185
|
-
Pt as LedgerErrorCode,
|
|
9186
|
-
w as MemoType,
|
|
9187
|
-
Zn as NetworkDerivationPath,
|
|
9188
|
-
_t as QuoteMode,
|
|
9189
|
-
Ke as RPCUrl,
|
|
9190
|
-
k as RequestClient,
|
|
9191
|
-
vt as SWAP_IN,
|
|
9192
|
-
Ct as SWAP_OUT,
|
|
9193
|
-
nn as StreamingSwapProgressStatus,
|
|
9194
|
-
zn as SubstrateChains,
|
|
9195
|
-
ga as SwapKit,
|
|
9196
|
-
pa as SwapKitApi,
|
|
9197
|
-
_a as SwapKitCore,
|
|
9198
|
-
d as SwapKitError,
|
|
9199
|
-
F as SwapKitNumber,
|
|
9200
|
-
At as TCAvalancheDepositABI,
|
|
9201
|
-
gt as TCBscDepositABI,
|
|
9202
|
-
wt as TCEthereumVaultAbi,
|
|
9203
|
-
aa as TCSupportedChainList,
|
|
9204
|
-
St as TCSupportedChains,
|
|
9205
|
-
en as TransactionType,
|
|
9206
|
-
tn as TxStatus,
|
|
9207
|
-
ta as UTXOChainList,
|
|
9208
|
-
kt as UTXOChains,
|
|
9209
|
-
It as WalletOption,
|
|
9210
|
-
ua as assetFromString,
|
|
9211
|
-
it as defaultRequestHeaders,
|
|
9212
|
-
Aa as derivationPathToString,
|
|
9213
|
-
Jn as erc20ABI,
|
|
9214
|
-
ya as filterAssets,
|
|
9215
|
-
oa as findAssetBy,
|
|
9216
|
-
he as formatBigIntToSafeValue,
|
|
9217
|
-
yn as gasFeeMultiplier,
|
|
9218
|
-
dn as getAssetType,
|
|
9219
|
-
cn as getAsymmetricAssetShare,
|
|
9220
|
-
la as getAsymmetricAssetWithdrawAmount,
|
|
9221
|
-
Tn as getAsymmetricRuneShare,
|
|
9222
|
-
da as getAsymmetricRuneWithdrawAmount,
|
|
9223
|
-
on as getCommonAssetInfo,
|
|
9224
|
-
un as getDecimal,
|
|
9225
|
-
Ta as getEstimatedPoolShare,
|
|
9226
|
-
ca as getLiquiditySlippage,
|
|
9227
|
-
fa as getMAYANameCost,
|
|
9228
|
-
I as getMemoFor,
|
|
9229
|
-
_e as getMinAmountByChain,
|
|
9230
|
-
bn as getSymmetricPoolShare,
|
|
9231
|
-
ma as getSymmetricWithdraw,
|
|
9232
|
-
ba as getTHORNameCost,
|
|
9233
|
-
rt as isGasAsset,
|
|
9234
|
-
ra as setRequestClientConfig,
|
|
9235
|
-
wa as validateMAYAName,
|
|
9236
|
-
ha as validateTHORName
|
|
7211
|
+
Me as ApproveMode,
|
|
7212
|
+
ze as SwapKit,
|
|
7213
|
+
Je as SwapKitCore
|
|
9237
7214
|
};
|
|
9238
7215
|
//# sourceMappingURL=index.es.js.map
|