@swapkit/helpers 1.0.0-rc.79 → 1.0.0-rc.80

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.es.js CHANGED
@@ -1,431 +1,21 @@
1
- var Ne = Object.defineProperty;
2
- var ve = (e, t, n) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var _ = (e, t, n) => (ve(e, typeof t != "symbol" ? t + "" : t, n), n), $e = (e, t, n) => {
4
- if (!t.has(e))
5
- throw TypeError("Cannot " + n);
1
+ var it = Object.defineProperty;
2
+ var st = (n, t, e) => t in n ? it(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var f = (n, t, e) => (st(n, typeof t != "symbol" ? t + "" : t, e), e), at = (n, t, e) => {
4
+ if (!t.has(n))
5
+ throw TypeError("Cannot " + e);
6
6
  };
7
- var R = (e, t, n) => {
8
- if (t.has(e))
7
+ var v = (n, t, e) => {
8
+ if (t.has(n))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
- t instanceof WeakSet ? t.add(e) : t.set(e, n);
10
+ t instanceof WeakSet ? t.add(n) : t.set(n, e);
11
11
  };
12
- var p = (e, t, n) => ($e(e, t, "access private method"), n);
13
- import { FeeOption as K, BaseDecimal as d, Chain as u, EVMChains as Ie, ChainToRPC as Be, MemoType as C, ChainToChainId as De } from "@swapkit/types";
14
- var F = /* @__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))(F || {}), ne = /* @__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))(ne || {}), de = /* @__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))(de || {}), S = /* @__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))(S || {});
15
- const G = Object.values(F), Ve = Object.keys(F), re = G.reduce(
16
- (e, t) => {
17
- const n = Ve.find((r) => F[r] === t);
18
- return n && (e[t] = n), e;
19
- },
20
- {}
21
- );
22
- G.reduce(
23
- (e, t) => (e[t] = ne[re[t]], e),
24
- {}
25
- );
26
- G.reduce(
27
- (e, t) => (e[t] = de[re[t]], e),
28
- {}
29
- );
30
- G.reduce(
31
- (e, t) => {
32
- const n = `${re[t]}Hex`;
33
- return e[t] = ne[n], e;
34
- },
35
- {}
36
- );
37
- class ae extends Error {
38
- constructor(t, n, r) {
39
- const s = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", o = `${s} ${i}`.trim(), c = o ? `status code ${o}` : "an unknown error";
40
- super(`Request failed with ${c}`), Object.defineProperty(this, "response", {
41
- enumerable: !0,
42
- configurable: !0,
43
- writable: !0,
44
- value: void 0
45
- }), Object.defineProperty(this, "request", {
46
- enumerable: !0,
47
- configurable: !0,
48
- writable: !0,
49
- value: void 0
50
- }), Object.defineProperty(this, "options", {
51
- enumerable: !0,
52
- configurable: !0,
53
- writable: !0,
54
- value: void 0
55
- }), this.name = "HTTPError", this.response = t, this.request = n, this.options = r;
56
- }
57
- }
58
- class pe extends Error {
59
- constructor(t) {
60
- super("Request timed out"), Object.defineProperty(this, "request", {
61
- enumerable: !0,
62
- configurable: !0,
63
- writable: !0,
64
- value: void 0
65
- }), this.name = "TimeoutError", this.request = t;
66
- }
67
- }
68
- const M = (e) => e !== null && typeof e == "object", x = (...e) => {
69
- for (const t of e)
70
- if ((!M(t) || Array.isArray(t)) && t !== void 0)
71
- throw new TypeError("The `options` argument must be an object");
72
- return se({}, ...e);
73
- }, me = (e = {}, t = {}) => {
74
- const n = new globalThis.Headers(e), r = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
75
- for (const [i, o] of s.entries())
76
- r && o === "undefined" || o === void 0 ? n.delete(i) : n.set(i, o);
77
- return n;
78
- }, se = (...e) => {
79
- let t = {}, n = {};
80
- for (const r of e)
81
- if (Array.isArray(r))
82
- Array.isArray(t) || (t = []), t = [...t, ...r];
83
- else if (M(r)) {
84
- for (let [s, i] of Object.entries(r))
85
- M(i) && s in t && (i = se(t[s], i)), t = { ...t, [s]: i };
86
- M(r.headers) && (n = me(n, r.headers), t.headers = n);
87
- }
88
- return t;
89
- }, He = (() => {
90
- let e = !1, t = !1;
91
- const n = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
92
- return n && r && (t = new globalThis.Request("https://empty.invalid", {
93
- body: new globalThis.ReadableStream(),
94
- method: "POST",
95
- // @ts-expect-error - Types are outdated.
96
- get duplex() {
97
- return e = !0, "half";
98
- }
99
- }).headers.has("Content-Type")), e && !t;
100
- })(), xe = typeof globalThis.AbortController == "function", ke = typeof globalThis.ReadableStream == "function", Me = typeof globalThis.FormData == "function", _e = ["get", "post", "put", "patch", "head", "delete"], Le = {
101
- json: "application/json",
102
- text: "text/*",
103
- formData: "multipart/form-data",
104
- arrayBuffer: "*/*",
105
- blob: "*/*"
106
- }, Y = 2147483647, fe = Symbol("stop"), We = {
107
- json: !0,
108
- parseJson: !0,
109
- searchParams: !0,
110
- prefixUrl: !0,
111
- retry: !0,
112
- timeout: !0,
113
- hooks: !0,
114
- throwHttpErrors: !0,
115
- onDownloadProgress: !0,
116
- fetch: !0
117
- }, Ue = {
118
- method: !0,
119
- headers: !0,
120
- body: !0,
121
- mode: !0,
122
- credentials: !0,
123
- cache: !0,
124
- redirect: !0,
125
- referrer: !0,
126
- referrerPolicy: !0,
127
- integrity: !0,
128
- keepalive: !0,
129
- signal: !0,
130
- window: !0,
131
- dispatcher: !0,
132
- duplex: !0
133
- }, je = (e) => _e.includes(e) ? e.toUpperCase() : e, qe = ["get", "put", "head", "delete", "options", "trace"], Fe = [408, 413, 429, 500, 502, 503, 504], Te = [413, 429, 503], ce = {
134
- limit: 2,
135
- methods: qe,
136
- statusCodes: Fe,
137
- afterStatusCodes: Te,
138
- maxRetryAfter: Number.POSITIVE_INFINITY,
139
- backoffLimit: Number.POSITIVE_INFINITY,
140
- delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
141
- }, Ge = (e = {}) => {
142
- if (typeof e == "number")
143
- return {
144
- ...ce,
145
- limit: e
146
- };
147
- if (e.methods && !Array.isArray(e.methods))
148
- throw new Error("retry.methods must be an array");
149
- if (e.statusCodes && !Array.isArray(e.statusCodes))
150
- throw new Error("retry.statusCodes must be an array");
151
- return {
152
- ...ce,
153
- ...e,
154
- afterStatusCodes: Te
155
- };
156
- };
157
- async function Xe(e, t, n, r) {
158
- return new Promise((s, i) => {
159
- const o = setTimeout(() => {
160
- n && n.abort(), i(new pe(e));
161
- }, r.timeout);
162
- r.fetch(e, t).then(s).catch(i).then(() => {
163
- clearTimeout(o);
164
- });
165
- });
166
- }
167
- async function Ke(e, { signal: t }) {
168
- return new Promise((n, r) => {
169
- t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
170
- function s() {
171
- clearTimeout(i), r(t.reason);
172
- }
173
- const i = setTimeout(() => {
174
- t == null || t.removeEventListener("abort", s), n();
175
- }, e);
176
- });
177
- }
178
- const Ye = (e, t) => {
179
- const n = {};
180
- for (const r in t)
181
- !(r in Ue) && !(r in We) && !(r in e) && (n[r] = t[r]);
182
- return n;
183
- };
184
- class W {
185
- static create(t, n) {
186
- const r = new W(t, n), s = async () => {
187
- if (typeof r._options.timeout == "number" && r._options.timeout > Y)
188
- throw new RangeError(`The \`timeout\` option cannot be greater than ${Y}`);
189
- await Promise.resolve();
190
- let o = await r._fetch();
191
- for (const c of r._options.hooks.afterResponse) {
192
- const a = await c(r.request, r._options, r._decorateResponse(o.clone()));
193
- a instanceof globalThis.Response && (o = a);
194
- }
195
- if (r._decorateResponse(o), !o.ok && r._options.throwHttpErrors) {
196
- let c = new ae(o, r.request, r._options);
197
- for (const a of r._options.hooks.beforeError)
198
- c = await a(c);
199
- throw c;
200
- }
201
- if (r._options.onDownloadProgress) {
202
- if (typeof r._options.onDownloadProgress != "function")
203
- throw new TypeError("The `onDownloadProgress` option must be a function");
204
- if (!ke)
205
- throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
206
- return r._stream(o.clone(), r._options.onDownloadProgress);
207
- }
208
- return o;
209
- }, i = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(s) : s();
210
- for (const [o, c] of Object.entries(Le))
211
- i[o] = async () => {
212
- r.request.headers.set("accept", r.request.headers.get("accept") || c);
213
- const a = (await i).clone();
214
- if (o === "json") {
215
- if (a.status === 204 || (await a.clone().arrayBuffer()).byteLength === 0)
216
- return "";
217
- if (n.parseJson)
218
- return n.parseJson(await a.text());
219
- }
220
- return a[o]();
221
- };
222
- return i;
223
- }
224
- // eslint-disable-next-line complexity
225
- constructor(t, n = {}) {
226
- Object.defineProperty(this, "request", {
227
- enumerable: !0,
228
- configurable: !0,
229
- writable: !0,
230
- value: void 0
231
- }), Object.defineProperty(this, "abortController", {
232
- enumerable: !0,
233
- configurable: !0,
234
- writable: !0,
235
- value: void 0
236
- }), Object.defineProperty(this, "_retryCount", {
237
- enumerable: !0,
238
- configurable: !0,
239
- writable: !0,
240
- value: 0
241
- }), Object.defineProperty(this, "_input", {
242
- enumerable: !0,
243
- configurable: !0,
244
- writable: !0,
245
- value: void 0
246
- }), Object.defineProperty(this, "_options", {
247
- enumerable: !0,
248
- configurable: !0,
249
- writable: !0,
250
- value: void 0
251
- }), this._input = t;
252
- const r = "credentials" in Request.prototype;
253
- if (this._options = {
254
- credentials: r ? this._input.credentials : void 0,
255
- ...n,
256
- headers: me(this._input.headers, n.headers),
257
- hooks: se({
258
- beforeRequest: [],
259
- beforeRetry: [],
260
- beforeError: [],
261
- afterResponse: []
262
- }, n.hooks),
263
- method: je(n.method ?? this._input.method),
264
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
265
- prefixUrl: String(n.prefixUrl || ""),
266
- retry: Ge(n.retry),
267
- throwHttpErrors: n.throwHttpErrors !== !1,
268
- timeout: n.timeout ?? 1e4,
269
- fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
270
- }, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))
271
- throw new TypeError("`input` must be a string, URL, or Request");
272
- if (this._options.prefixUrl && typeof this._input == "string") {
273
- if (this._input.startsWith("/"))
274
- throw new Error("`input` must not begin with a slash when using `prefixUrl`");
275
- this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
276
- }
277
- if (xe) {
278
- if (this.abortController = new globalThis.AbortController(), this._options.signal) {
279
- const s = this._options.signal;
280
- this._options.signal.addEventListener("abort", () => {
281
- this.abortController.abort(s.reason);
282
- });
283
- }
284
- this._options.signal = this.abortController.signal;
285
- }
286
- if (He && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
287
- const s = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, s);
288
- (Me && 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(i, { ...this.request }), this._options);
289
- }
290
- 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 }));
291
- }
292
- _calculateRetryDelay(t) {
293
- if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof pe)) {
294
- if (t instanceof ae) {
295
- if (!this._options.retry.statusCodes.includes(t.response.status))
296
- return 0;
297
- const r = t.response.headers.get("Retry-After");
298
- if (r && this._options.retry.afterStatusCodes.includes(t.response.status)) {
299
- let s = Number(r);
300
- return Number.isNaN(s) ? s = Date.parse(r) - Date.now() : s *= 1e3, this._options.retry.maxRetryAfter !== void 0 && s > this._options.retry.maxRetryAfter ? 0 : s;
301
- }
302
- if (t.response.status === 413)
303
- return 0;
304
- }
305
- const n = this._options.retry.delay(this._retryCount);
306
- return Math.min(this._options.retry.backoffLimit, n);
307
- }
308
- return 0;
309
- }
310
- _decorateResponse(t) {
311
- return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
312
- }
313
- async _retry(t) {
314
- try {
315
- return await t();
316
- } catch (n) {
317
- const r = Math.min(this._calculateRetryDelay(n), Y);
318
- if (r !== 0 && this._retryCount > 0) {
319
- await Ke(r, { signal: this._options.signal });
320
- for (const s of this._options.hooks.beforeRetry)
321
- if (await s({
322
- request: this.request,
323
- options: this._options,
324
- error: n,
325
- retryCount: this._retryCount
326
- }) === fe)
327
- return;
328
- return this._retry(t);
329
- }
330
- throw n;
331
- }
332
- }
333
- async _fetch() {
334
- for (const n of this._options.hooks.beforeRequest) {
335
- const r = await n(this.request, this._options);
336
- if (r instanceof Request) {
337
- this.request = r;
338
- break;
339
- }
340
- if (r instanceof Response)
341
- return r;
342
- }
343
- const t = Ye(this.request, this._options);
344
- return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Xe(this.request.clone(), t, this.abortController, this._options);
345
- }
346
- /* istanbul ignore next */
347
- _stream(t, n) {
348
- const r = Number(t.headers.get("content-length")) || 0;
349
- let s = 0;
350
- return t.status === 204 ? (n && n({ percent: 1, totalBytes: r, transferredBytes: s }, new Uint8Array()), new globalThis.Response(null, {
351
- status: t.status,
352
- statusText: t.statusText,
353
- headers: t.headers
354
- })) : new globalThis.Response(new globalThis.ReadableStream({
355
- async start(i) {
356
- const o = t.body.getReader();
357
- n && n({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array());
358
- async function c() {
359
- const { done: a, value: l } = await o.read();
360
- if (a) {
361
- i.close();
362
- return;
363
- }
364
- if (n) {
365
- s += l.byteLength;
366
- const h = r === 0 ? 0 : s / r;
367
- n({ percent: h, transferredBytes: s, totalBytes: r }, l);
368
- }
369
- i.enqueue(l), await c();
370
- }
371
- await c();
372
- }
373
- }), {
374
- status: t.status,
375
- statusText: t.statusText,
376
- headers: t.headers
377
- });
378
- }
379
- }
380
- /*! MIT License © Sindre Sorhus */
381
- const z = (e) => {
382
- const t = (n, r) => W.create(n, x(e, r));
383
- for (const n of _e)
384
- t[n] = (r, s) => W.create(r, x(e, s, { method: n }));
385
- return t.create = (n) => z(x(n)), t.extend = (n) => z(x(e, n)), t.stop = fe, t;
386
- }, ge = z();
387
- let L;
388
- const T = {
389
- CachedPrices: `${S.ThorswapApi}/tokenlist/cached-price`,
390
- GasRates: `${S.ThorswapApi}/resource-worker/gasPrice/getAll`,
391
- Quote: `${S.ThorswapApi}/aggregator/tokens/quote`,
392
- Txn: `${S.ThorswapApi}/apiusage/v2/txn`,
393
- TokenlistProviders: `${S.ThorswapApi}/tokenlist/providers`,
394
- TokenList: `${S.ThorswapStatic}/token-list`,
395
- Thorname: `${S.ThorswapApi}/thorname`
396
- }, Ae = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, ue = () => L || (L = ge.create({ headers: Ae }), L), Tt = ({ apiKey: e, ...t }) => {
397
- L = ge.create({
398
- ...t,
399
- headers: { ...Ae, ...t.headers, "x-api-key": e }
400
- });
401
- }, f = {
402
- get: (e, t) => ue().get(e, t).json(),
403
- post: (e, t) => ue().post(e, t).json()
404
- }, Je = ({ tokens: e, ...t }) => {
405
- const n = new URLSearchParams(), r = e.filter(
406
- (s, i, o) => o.findIndex((c) => c === s) === i
407
- );
408
- for (const s of r)
409
- n.append("tokens", JSON.stringify(s));
410
- return t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"), f.post(T.CachedPrices, {
411
- body: n.toString(),
412
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
413
- });
414
- }, gt = {
415
- getCachedPrices: Je,
416
- getQuote: (e) => f.get(T.Quote, { searchParams: e }),
417
- getGasRates: () => f.get(T.GasRates),
418
- getTxnDetails: (e) => f.get(T.Txn, { searchParams: e }),
419
- getTokenlistProviders: () => f.get(T.TokenlistProviders),
420
- getTokenList: (e) => f.get(`${T.TokenList}/${e}.json`),
421
- getThornameAddresses: (e) => f.get(`${T.Thorname}/${e}`),
422
- getThornameRegisteredChains: (e) => f.get(`${T.Thorname}/chains/${e}`),
423
- getThornameRlookup: (e, t) => f.get(`${T.Thorname}/rlookup`, { searchParams: { address: e, chain: t } })
424
- };
425
- var Qe = /* @__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))(Qe || {}), ze = /* @__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))(ze || {}), Ze = /* @__PURE__ */ ((e) => (e[e.NOT_STARTED = 0] = "NOT_STARTED", e[e.SUCCESS = 1] = "SUCCESS", e[e.REFUNDED = 2] = "REFUNDED", e))(Ze || {});
426
- const et = "0x313ce567", Ce = async ({ chain: e, to: t }) => {
12
+ var h = (n, t, e) => (at(n, t, "access private method"), e);
13
+ import { RequestClient as ct } from "@swapkit/api";
14
+ export * from "@swapkit/api";
15
+ import { FeeOption as P, BaseDecimal as m, Chain as a, EVMChains as ot, ChainToRPC as lt, MemoType as $, ChainToChainId as ut } from "@swapkit/types";
16
+ const dt = "0x313ce567", z = async ({ chain: n, to: t }) => {
427
17
  try {
428
- const { result: n } = await f.post(Be[e], {
18
+ const { result: e } = await ct.post(lt[n], {
429
19
  headers: {
430
20
  accept: "*/*",
431
21
  "content-type": "application/json",
@@ -435,336 +25,336 @@ const et = "0x313ce567", Ce = async ({ chain: e, to: t }) => {
435
25
  id: 44,
436
26
  jsonrpc: "2.0",
437
27
  method: "eth_call",
438
- params: [{ to: t.toLowerCase(), data: et }, "latest"]
28
+ params: [{ to: t.toLowerCase(), data: dt }, "latest"]
439
29
  })
440
30
  });
441
- return Number.parseInt(BigInt(n).toString());
442
- } catch (n) {
443
- return console.error(n), d[e];
444
- }
445
- }, tt = (e) => {
446
- if (e === u.Ethereum)
447
- return d.ETH;
448
- const [, t] = e.split("-");
449
- return t != null && t.startsWith("0x") ? Ce({ chain: u.Ethereum, to: t }) : d.ETH;
450
- }, nt = (e) => {
451
- const [, t] = e.split("-");
452
- return t != null && t.startsWith("0x") ? Ce({ chain: u.Avalanche, to: t.toLowerCase() }) : d.AVAX;
453
- }, rt = (e) => e === u.BinanceSmartChain ? d.BSC : d.BSC, st = ({ chain: e, symbol: t }) => {
454
- switch (e) {
455
- case u.Ethereum:
456
- return tt(t);
457
- case u.Avalanche:
458
- return nt(t);
459
- case u.BinanceSmartChain:
460
- return rt(t);
31
+ return Number.parseInt(BigInt(e).toString());
32
+ } catch (e) {
33
+ return console.error(e), m[n];
34
+ }
35
+ }, mt = (n) => {
36
+ if (n === a.Ethereum)
37
+ return m.ETH;
38
+ const [, t] = n.split("-");
39
+ return t != null && t.startsWith("0x") ? z({ chain: a.Ethereum, to: t }) : m.ETH;
40
+ }, ht = (n) => {
41
+ const [, t] = n.split("-");
42
+ return t != null && t.startsWith("0x") ? z({ chain: a.Avalanche, to: t.toLowerCase() }) : m.AVAX;
43
+ }, _t = (n) => n === a.BinanceSmartChain ? m.BSC : m.BSC, ft = ({ chain: n, symbol: t }) => {
44
+ switch (n) {
45
+ case a.Ethereum:
46
+ return mt(t);
47
+ case a.Avalanche:
48
+ return ht(t);
49
+ case a.BinanceSmartChain:
50
+ return _t(t);
461
51
  default:
462
- return d[e];
463
- }
464
- }, At = {
465
- [K.Average]: 1.2,
466
- [K.Fast]: 1.5,
467
- [K.Fastest]: 2
468
- }, Se = ({ chain: e, symbol: t }) => {
469
- switch (e) {
470
- case u.Arbitrum:
471
- case u.Optimism:
52
+ return m[n];
53
+ }
54
+ }, Ot = {
55
+ [P.Average]: 1.2,
56
+ [P.Fast]: 1.5,
57
+ [P.Fastest]: 2
58
+ }, J = ({ chain: n, symbol: t }) => {
59
+ switch (n) {
60
+ case a.Arbitrum:
61
+ case a.Optimism:
472
62
  return t === "ETH";
473
- case u.Maya:
63
+ case a.Maya:
474
64
  return t === "CACAO";
475
- case u.Kujira:
65
+ case a.Kujira:
476
66
  return t === "KUJI";
477
- case u.Cosmos:
67
+ case a.Cosmos:
478
68
  return t === "ATOM";
479
- case u.Polygon:
69
+ case a.Polygon:
480
70
  return t === "MATIC";
481
- case u.BinanceSmartChain:
71
+ case a.BinanceSmartChain:
482
72
  return t === "BNB";
483
- case u.THORChain:
73
+ case a.THORChain:
484
74
  return t === "RUNE";
485
75
  default:
486
- return t === e;
76
+ return t === n;
487
77
  }
488
- }, it = (e) => {
489
- switch (e) {
490
- case `${u.Ethereum}.THOR`:
78
+ }, gt = (n) => {
79
+ switch (n) {
80
+ case `${a.Ethereum}.THOR`:
491
81
  return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
492
- case `${u.Ethereum}.vTHOR`:
82
+ case `${a.Ethereum}.vTHOR`:
493
83
  return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
494
- case u.Cosmos:
495
- return { identifier: "GAIA.ATOM", decimal: d[e] };
496
- case u.THORChain:
497
- return { identifier: "THOR.RUNE", decimal: d[e] };
498
- case u.BinanceSmartChain:
499
- return { identifier: "BSC.BNB", decimal: d[e] };
500
- case u.Maya:
501
- return { identifier: "MAYA.CACAO", decimal: d.MAYA };
502
- case `${u.Maya}.MAYA`:
84
+ case a.Cosmos:
85
+ return { identifier: "GAIA.ATOM", decimal: m[n] };
86
+ case a.THORChain:
87
+ return { identifier: "THOR.RUNE", decimal: m[n] };
88
+ case a.BinanceSmartChain:
89
+ return { identifier: "BSC.BNB", decimal: m[n] };
90
+ case a.Maya:
91
+ return { identifier: "MAYA.CACAO", decimal: m.MAYA };
92
+ case `${a.Maya}.MAYA`:
503
93
  return { identifier: "MAYA.MAYA", decimal: 4 };
504
- case `${u.Kujira}.USK`:
505
- return { identifier: `${u.Kujira}.USK`, decimal: 6 };
94
+ case `${a.Kujira}.USK`:
95
+ return { identifier: `${a.Kujira}.USK`, decimal: 6 };
506
96
  default:
507
- return { identifier: `${e}.${e}`, decimal: d[e] };
97
+ return { identifier: `${n}.${n}`, decimal: m[n] };
508
98
  }
509
- }, ot = ({ chain: e, symbol: t }) => {
99
+ }, pt = ({ chain: n, symbol: t }) => {
510
100
  if (t.includes("/"))
511
101
  return "Synth";
512
- switch (e) {
513
- case u.Cosmos:
514
- return t === "ATOM" ? "Native" : u.Cosmos;
515
- case u.Kujira:
516
- return t === u.Kujira ? "Native" : u.Kujira;
517
- case u.Binance:
518
- return t === u.Binance ? "Native" : "BEP2";
519
- case u.BinanceSmartChain:
520
- return t === u.Binance ? "Native" : "BEP20";
521
- case u.Ethereum:
522
- return t === u.Ethereum ? "Native" : "ERC20";
523
- case u.Avalanche:
524
- return t === u.Avalanche ? "Native" : u.Avalanche;
525
- case u.Polygon:
526
- return t === u.Polygon ? "Native" : "POLYGON";
527
- case u.Arbitrum:
528
- return [u.Ethereum, u.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
529
- case u.Optimism:
530
- return [u.Ethereum, u.Optimism].includes(t) ? "Native" : "OPTIMISM";
102
+ switch (n) {
103
+ case a.Cosmos:
104
+ return t === "ATOM" ? "Native" : a.Cosmos;
105
+ case a.Kujira:
106
+ return t === a.Kujira ? "Native" : a.Kujira;
107
+ case a.Binance:
108
+ return t === a.Binance ? "Native" : "BEP2";
109
+ case a.BinanceSmartChain:
110
+ return t === a.Binance ? "Native" : "BEP20";
111
+ case a.Ethereum:
112
+ return t === a.Ethereum ? "Native" : "ERC20";
113
+ case a.Avalanche:
114
+ return t === a.Avalanche ? "Native" : a.Avalanche;
115
+ case a.Polygon:
116
+ return t === a.Polygon ? "Native" : "POLYGON";
117
+ case a.Arbitrum:
118
+ return [a.Ethereum, a.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
119
+ case a.Optimism:
120
+ return [a.Ethereum, a.Optimism].includes(t) ? "Native" : "OPTIMISM";
531
121
  default:
532
122
  return "Native";
533
123
  }
534
- }, Ct = (e) => {
535
- var o;
536
- const [t, ...n] = e.split("."), r = e.includes("/"), s = n.join("."), i = (o = s == null ? void 0 : s.split("-")) == null ? void 0 : o[0];
537
- return { chain: t, symbol: s, ticker: i, synth: r };
538
- }, at = new RegExp(
124
+ }, Tt = (n) => {
125
+ var l;
126
+ const [t, ...e] = n.split("."), r = n.includes("/"), i = e.join("."), s = (l = i == null ? void 0 : i.split("-")) == null ? void 0 : l[0];
127
+ return { chain: t, symbol: i, ticker: s, synth: r };
128
+ }, $t = new RegExp(
539
129
  /(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
540
130
  "gmi"
541
- ), ct = (e) => {
542
- const [t, n] = e.split(".");
543
- if (!Ie.includes(t))
131
+ ), At = (n) => {
132
+ const [t, e] = n.split(".");
133
+ if (!ot.includes(t))
544
134
  return !0;
545
- const [, r] = n.split("-");
546
- return Se({ chain: t, symbol: n }) || !!r;
547
- }, St = (e) => e.filter(({ chain: t, value: n, symbol: r }) => {
548
- const s = `${t}.${r}`;
549
- return !at.test(s) && ct(s) && n !== "0";
135
+ const [, r] = e.split("-");
136
+ return J({ chain: t, symbol: e }) || !!r;
137
+ }, Vt = (n) => n.filter(({ chain: t, value: e, symbol: r }) => {
138
+ const i = `${t}.${r}`;
139
+ return !$t.test(i) && At(i) && e !== "0";
550
140
  });
551
- async function bt(e) {
141
+ async function Nt(n) {
552
142
  const t = await import("@swapkit/tokens");
553
- for (const n of Object.values(t))
554
- for (const { identifier: r, chain: s, ...i } of n.tokens)
555
- if ("identifier" in e && r === e.identifier || "address" in i && "chain" in e && s === e.chain && i.address.toLowerCase() === e.contract.toLowerCase())
143
+ for (const e of Object.values(t))
144
+ for (const { identifier: r, chain: i, ...s } of e.tokens)
145
+ if ("identifier" in n && r === n.identifier || "address" in s && "chain" in n && i === n.chain && s.address.toLowerCase() === n.contract.toLowerCase())
556
146
  return r;
557
147
  }
558
- function ut({
559
- liquidityUnits: e,
148
+ function bt({
149
+ liquidityUnits: n,
560
150
  poolUnits: t,
561
- runeDepth: n
151
+ runeDepth: e
562
152
  }) {
563
- const r = m(e), s = m(t), i = m(n), o = r.mul(i), c = s.mul(s).mul(2), a = s.mul(r).mul(2), l = r.mul(r), h = s.mul(s).mul(s);
564
- return o.mul(c.sub(a).add(l)).div(h);
153
+ const r = _(n), i = _(t), s = _(e), l = r.mul(s), o = i.mul(i).mul(2), c = i.mul(r).mul(2), u = r.mul(r), d = i.mul(i).mul(i);
154
+ return l.mul(o.sub(c).add(u)).div(d);
565
155
  }
566
- function lt({
567
- liquidityUnits: e,
156
+ function wt({
157
+ liquidityUnits: n,
568
158
  poolUnits: t,
569
- assetDepth: n
159
+ assetDepth: e
570
160
  }) {
571
- const r = m(e), s = m(t), i = m(n), o = r.mul(i), c = s.mul(s).mul(2), a = s.mul(r).mul(2), l = r.mul(r), h = o.mul(c.sub(a).add(l)), N = s.mul(s).mul(s);
572
- return h.div(N);
161
+ const r = _(n), i = _(t), s = _(e), l = r.mul(s), o = i.mul(i).mul(2), c = i.mul(r).mul(2), u = r.mul(r), d = l.mul(o.sub(c).add(u)), y = i.mul(i).mul(i);
162
+ return d.div(y);
573
163
  }
574
- function wt({
575
- percent: e,
164
+ function Et({
165
+ percent: n,
576
166
  runeDepth: t,
577
- liquidityUnits: n,
167
+ liquidityUnits: e,
578
168
  poolUnits: r
579
169
  }) {
580
- return ut({ runeDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
170
+ return bt({ runeDepth: t, liquidityUnits: e, poolUnits: r }).mul(n);
581
171
  }
582
- function yt({
583
- percent: e,
172
+ function Rt({
173
+ percent: n,
584
174
  assetDepth: t,
585
- liquidityUnits: n,
175
+ liquidityUnits: e,
586
176
  poolUnits: r
587
177
  }) {
588
- return lt({ assetDepth: t, liquidityUnits: n, poolUnits: r }).mul(e);
178
+ return wt({ assetDepth: t, liquidityUnits: e, poolUnits: r }).mul(n);
589
179
  }
590
- function m(e) {
591
- return g.fromBigInt(BigInt(e), d.THOR);
180
+ function _(n) {
181
+ return g.fromBigInt(BigInt(n), m.THOR);
592
182
  }
593
- function ht({
594
- liquidityUnits: e,
183
+ function vt({
184
+ liquidityUnits: n,
595
185
  poolUnits: t,
596
- runeDepth: n,
186
+ runeDepth: e,
597
187
  assetDepth: r
598
188
  }) {
599
189
  return {
600
- assetAmount: m(r).mul(e).div(t),
601
- runeAmount: m(n).mul(e).div(t)
190
+ assetAmount: _(r).mul(n).div(t),
191
+ runeAmount: _(e).mul(n).div(t)
602
192
  };
603
193
  }
604
- function Rt({
605
- liquidityUnits: e,
194
+ function xt({
195
+ liquidityUnits: n,
606
196
  poolUnits: t,
607
- runeDepth: n,
197
+ runeDepth: e,
608
198
  assetDepth: r,
609
- percent: s
199
+ percent: i
610
200
  }) {
611
201
  return Object.fromEntries(
612
- Object.entries(ht({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: r })).map(
613
- ([i, o]) => [i, o.mul(s)]
202
+ Object.entries(vt({ liquidityUnits: n, poolUnits: t, runeDepth: e, assetDepth: r })).map(
203
+ ([s, l]) => [s, l.mul(i)]
614
204
  )
615
205
  );
616
206
  }
617
- function Et({
618
- runeDepth: e,
207
+ function kt({
208
+ runeDepth: n,
619
209
  poolUnits: t,
620
- assetDepth: n,
210
+ assetDepth: e,
621
211
  liquidityUnits: r,
622
- runeAmount: s,
623
- assetAmount: i
212
+ runeAmount: i,
213
+ assetAmount: s
624
214
  }) {
625
- const o = new g({ value: e, decimal: 8 }), c = new g({ value: n, decimal: 8 }), a = new g({ value: t, decimal: 8 }), l = new g({ value: s, decimal: 8 }), h = new g({ value: i, decimal: 8 }), N = l.mul(c), ie = h.mul(o), ye = l.mul(h), Re = o.mul(c), Ee = a.mul(N.add(ie.add(ye.mul(2)))), Pe = N.add(ie.add(Re.mul(2))), oe = Ee.div(Pe), X = m(r).add(oe);
626
- if (oe.getBaseValue("number") === 0)
627
- return X.div(a).getBaseValue("number");
628
- const Oe = a.add(X);
629
- return X.div(Oe).getBaseValue("number");
630
- }
631
- function Pt({
632
- runeAmount: e,
215
+ const l = new g({ value: n, decimal: 8 }), o = new g({ value: e, decimal: 8 }), c = new g({ value: t, decimal: 8 }), u = new g({ value: i, decimal: 8 }), d = new g({ value: s, decimal: 8 }), y = u.mul(o), W = d.mul(l), Z = u.mul(d), tt = l.mul(o), et = c.mul(y.add(W.add(Z.mul(2)))), nt = y.add(W.add(tt.mul(2))), G = et.div(nt), j = _(r).add(G);
216
+ if (G.getBaseValue("number") === 0)
217
+ return j.div(c).getBaseValue("number");
218
+ const rt = c.add(j);
219
+ return j.div(rt).getBaseValue("number");
220
+ }
221
+ function Ht({
222
+ runeAmount: n,
633
223
  assetAmount: t,
634
- runeDepth: n,
224
+ runeDepth: e,
635
225
  assetDepth: r
636
226
  }) {
637
- if (e === "0" || t === "0" || n === "0" || r === "0")
227
+ if (n === "0" || t === "0" || e === "0" || r === "0")
638
228
  return 0;
639
- const s = m(n), i = m(r), o = m(t), c = m(e), a = o.mul(s).sub(i.mul(c)), l = i.mul(c).add(s.mul(i));
640
- return Math.abs(a.div(l).getBaseValue("number"));
641
- }
642
- const Ot = (e, t) => {
643
- switch (e) {
644
- case C.LEAVE:
645
- case C.BOND: {
646
- const { address: n } = t;
647
- return `${e}:${n}`;
229
+ const i = _(e), s = _(r), l = _(t), o = _(n), c = l.mul(i).sub(s.mul(o)), u = s.mul(o).add(i.mul(s));
230
+ return Math.abs(c.div(u).getBaseValue("number"));
231
+ }
232
+ const jt = (n, t) => {
233
+ switch (n) {
234
+ case $.LEAVE:
235
+ case $.BOND: {
236
+ const { address: e } = t;
237
+ return `${n}:${e}`;
648
238
  }
649
- case C.UNBOND: {
650
- const { address: n, unbondAmount: r } = t;
651
- return `${e}:${n}:${r}`;
239
+ case $.UNBOND: {
240
+ const { address: e, unbondAmount: r } = t;
241
+ return `${n}:${e}:${r}`;
652
242
  }
653
- case C.THORNAME_REGISTER: {
654
- const { name: n, chain: r, address: s, owner: i } = t;
655
- return `${e}:${n}:${r}:${s}${i ? `:${i}` : ""}`;
243
+ case $.THORNAME_REGISTER: {
244
+ const { name: e, chain: r, address: i, owner: s } = t;
245
+ return `${n}:${e}:${r}:${i}${s ? `:${s}` : ""}`;
656
246
  }
657
- case C.DEPOSIT: {
658
- const { chain: n, symbol: r, address: s, singleSide: i } = t;
659
- return i ? `${e}:${n}/${r}` : `${e}:${((c, a) => {
660
- switch (c) {
661
- case u.Litecoin:
247
+ case $.DEPOSIT: {
248
+ const { chain: e, symbol: r, address: i, singleSide: s } = t;
249
+ return s ? `${n}:${e}/${r}` : `${n}:${((o, c) => {
250
+ switch (o) {
251
+ case a.Litecoin:
662
252
  return "l";
663
- case u.Dogecoin:
253
+ case a.Dogecoin:
664
254
  return "d";
665
- case u.BitcoinCash:
255
+ case a.BitcoinCash:
666
256
  return "c";
667
257
  default:
668
- return `${c}.${a}`;
258
+ return `${o}.${c}`;
669
259
  }
670
- })(n, r)}:${s || ""}`;
260
+ })(e, r)}:${i || ""}`;
671
261
  }
672
- case C.WITHDRAW: {
673
- const { chain: n, ticker: r, symbol: s, basisPoints: i, targetAssetString: o, singleSide: c } = t, a = n === "ETH" && r !== "ETH" ? `${r}-${s.slice(-3)}` : s, l = !c && o ? `:${o}` : "";
674
- return `${e}:${n}${c ? "/" : "."}${a}:${i}${l}`;
262
+ case $.WITHDRAW: {
263
+ const { chain: e, ticker: r, symbol: i, basisPoints: s, targetAssetString: l, singleSide: o } = t, c = e === "ETH" && r !== "ETH" ? `${r}-${i.slice(-3)}` : i, u = !o && l ? `:${l}` : "";
264
+ return `${n}:${e}${o ? "/" : "."}${c}:${s}${u}`;
675
265
  }
676
- case C.OPEN_LOAN:
677
- case C.CLOSE_LOAN: {
678
- const { asset: n, address: r } = t;
679
- return `${e}:${n}:${r}`;
266
+ case $.OPEN_LOAN:
267
+ case $.CLOSE_LOAN: {
268
+ const { asset: e, address: r } = t;
269
+ return `${n}:${e}:${r}`;
680
270
  }
681
271
  default:
682
272
  return "";
683
273
  }
684
274
  };
685
- function Nt(e) {
686
- if (e < 0)
275
+ function Pt(n) {
276
+ if (n < 0)
687
277
  throw new Error("Invalid number of year");
688
- return 10 + e;
278
+ return 10 + n;
689
279
  }
690
- function vt(e) {
691
- if (e < 0)
280
+ function Dt(n) {
281
+ if (n < 0)
692
282
  throw new Error("Invalid number of year");
693
- return Math.round((10 + e * 1.0512) * 1e10) / 1e10;
283
+ return Math.round((10 + n * 1.0512) * 1e10) / 1e10;
694
284
  }
695
- function $t(e) {
696
- if (e.length > 30)
285
+ function Lt(n) {
286
+ if (n.length > 30)
697
287
  return !1;
698
288
  const t = /^[a-zA-Z0-9+_-]+$/g;
699
- return !!e.match(t);
289
+ return !!n.match(t);
700
290
  }
701
- function It(e) {
702
- if (e.length > 30)
291
+ function Ut(n) {
292
+ if (n.length > 30)
703
293
  return !1;
704
294
  const t = /^[a-zA-Z0-9+_-]+$/g;
705
- return !!e.match(t);
295
+ return !!n.match(t);
706
296
  }
707
- function Bt([e, t, n, r, s]) {
708
- return `${e}'/${t}'/${n}'/${r}${typeof s != "number" ? "" : `/${s}`}`;
297
+ function Ft([n, t, e, r, i]) {
298
+ return `${n}'/${t}'/${e}'/${r}${typeof i != "number" ? "" : `/${i}`}`;
709
299
  }
710
- const le = [...Object.values(u), "TERRA"];
711
- function dt(e = "") {
712
- const t = e.toUpperCase(), [n] = t.split(".");
713
- if (le.includes(n))
300
+ const K = [...Object.values(a), "TERRA"];
301
+ function Ct(n = "") {
302
+ const t = n.toUpperCase(), [e] = t.split(".");
303
+ if (K.includes(e))
714
304
  return !0;
715
305
  const [r] = t.split("/");
716
- if (le.includes(r))
306
+ if (K.includes(r))
717
307
  return !0;
718
308
  throw new Error(
719
- `Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
309
+ `Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
720
310
  );
721
311
  }
722
- const B = 8, w = (e) => 10n ** BigInt(e), v = (e) => Math.log10(Number.parseFloat(e.toString()));
723
- function U({
724
- value: e,
725
- bigIntDecimal: t = B,
726
- decimal: n = B
312
+ const T = 8, b = (n) => 10n ** BigInt(n), B = (n) => Math.log10(Number.parseFloat(n.toString()));
313
+ function x({
314
+ value: n,
315
+ bigIntDecimal: t = T,
316
+ decimal: e = T
727
317
  }) {
728
- if (n === 0)
729
- return e.toString();
730
- const r = e < 0n;
731
- let s = e.toString().substring(r ? 1 : 0);
732
- const i = n - (s.length - 1);
733
- i > 0 && (s = "0".repeat(i) + s);
734
- const o = s.length - n;
735
- let c = s.slice(-n);
736
- return Number.parseInt(c[t]) >= 5 ? c = `${c.substring(0, t - 1)}${(Number.parseInt(c[t - 1]) + 1).toString()}` : c = c.substring(0, t), `${r ? "-" : ""}${s.slice(0, o)}.${c}`.replace(
318
+ if (e === 0)
319
+ return n.toString();
320
+ const r = n < 0n;
321
+ let i = n.toString().substring(r ? 1 : 0);
322
+ const s = e - (i.length - 1);
323
+ s > 0 && (i = "0".repeat(s) + i);
324
+ const l = i.length - e;
325
+ let o = i.slice(-e);
326
+ return Number.parseInt(o[t]) >= 5 ? o = `${o.substring(0, t - 1)}${(Number.parseInt(o[t - 1]) + 1).toString()}` : o = o.substring(0, t), `${r ? "-" : ""}${i.slice(0, l)}.${o}`.replace(
737
327
  /\.?0*$/,
738
328
  ""
739
329
  );
740
330
  }
741
- var y, $, b, E, j, be, V, Z, H, ee;
742
- const q = class q {
331
+ var w, M, A, C, k, Q, N, U, E, F;
332
+ const H = class H {
743
333
  constructor(t) {
744
- R(this, y);
745
- R(this, b);
746
- R(this, j);
747
- R(this, V);
748
- R(this, H);
749
- _(this, "decimalMultiplier", 10n ** 8n);
750
- _(this, "bigIntValue", 0n);
751
- _(this, "decimal");
752
- const n = te(t), r = typeof t == "object";
753
- this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : w(Math.max(he(k(n)), this.decimal || 0)), p(this, j, be).call(this, n);
754
- }
755
- static fromBigInt(t, n) {
756
- return new q({
757
- decimal: n,
758
- value: U({ value: t, bigIntDecimal: n, decimal: n })
334
+ v(this, w);
335
+ v(this, A);
336
+ v(this, k);
337
+ v(this, N);
338
+ v(this, E);
339
+ f(this, "decimalMultiplier", 10n ** 8n);
340
+ f(this, "bigIntValue", 0n);
341
+ f(this, "decimal");
342
+ const e = q(t), r = typeof t == "object";
343
+ this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : b(Math.max(Y(R(e)), this.decimal || 0)), h(this, k, Q).call(this, e);
344
+ }
345
+ static fromBigInt(t, e) {
346
+ return new H({
347
+ decimal: e,
348
+ value: x({ value: t, bigIntDecimal: e, decimal: e })
759
349
  });
760
350
  }
761
351
  static shiftDecimals({
762
352
  value: t,
763
- from: n,
353
+ from: e,
764
354
  to: r
765
355
  }) {
766
- return q.fromBigInt(
767
- t.getBaseValue("bigint") * w(r) / w(n),
356
+ return H.fromBigInt(
357
+ t.getBaseValue("bigint") * b(r) / b(e),
768
358
  r
769
359
  );
770
360
  }
@@ -772,50 +362,50 @@ const q = class q {
772
362
  return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
773
363
  }
774
364
  add(...t) {
775
- return p(this, y, $).call(this, "add", ...t);
365
+ return h(this, w, M).call(this, "add", ...t);
776
366
  }
777
367
  sub(...t) {
778
- return p(this, y, $).call(this, "sub", ...t);
368
+ return h(this, w, M).call(this, "sub", ...t);
779
369
  }
780
370
  mul(...t) {
781
- return p(this, y, $).call(this, "mul", ...t);
371
+ return h(this, w, M).call(this, "mul", ...t);
782
372
  }
783
373
  div(...t) {
784
- return p(this, y, $).call(this, "div", ...t);
374
+ return h(this, w, M).call(this, "div", ...t);
785
375
  }
786
376
  gt(t) {
787
- return p(this, b, E).call(this, "gt", t);
377
+ return h(this, A, C).call(this, "gt", t);
788
378
  }
789
379
  gte(t) {
790
- return p(this, b, E).call(this, "gte", t);
380
+ return h(this, A, C).call(this, "gte", t);
791
381
  }
792
382
  lt(t) {
793
- return p(this, b, E).call(this, "lt", t);
383
+ return h(this, A, C).call(this, "lt", t);
794
384
  }
795
385
  lte(t) {
796
- return p(this, b, E).call(this, "lte", t);
386
+ return h(this, A, C).call(this, "lte", t);
797
387
  }
798
388
  eqValue(t) {
799
- return p(this, b, E).call(this, "eqValue", t);
389
+ return h(this, A, C).call(this, "eqValue", t);
800
390
  }
801
391
  // @ts-expect-error False positive
802
392
  getValue(t) {
803
- const n = this.formatBigIntToSafeValue(
393
+ const e = this.formatBigIntToSafeValue(
804
394
  this.bigIntValue,
805
- this.decimal || v(this.decimalMultiplier)
395
+ this.decimal || B(this.decimalMultiplier)
806
396
  );
807
397
  switch (t) {
808
398
  case "number":
809
- return Number(n);
399
+ return Number(e);
810
400
  case "string":
811
- return n;
401
+ return e;
812
402
  case "bigint":
813
403
  return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
814
404
  }
815
405
  }
816
406
  // @ts-expect-error
817
407
  getBaseValue(t) {
818
- const n = this.decimalMultiplier / w(this.decimal || d.THOR), r = this.bigIntValue / n;
408
+ const e = this.decimalMultiplier / b(this.decimal || m.THOR), r = this.bigIntValue / e;
819
409
  switch (t) {
820
410
  case "number":
821
411
  return Number(r);
@@ -825,173 +415,173 @@ const q = class q {
825
415
  return r;
826
416
  }
827
417
  }
828
- getBigIntValue(t, n) {
829
- if (!n && typeof t == "object")
418
+ getBigIntValue(t, e) {
419
+ if (!e && typeof t == "object")
830
420
  return t.bigIntValue;
831
- const r = te(t), s = k(r);
832
- return s === "0" || s === "undefined" ? 0n : p(this, H, ee).call(this, s, n);
421
+ const r = q(t), i = R(r);
422
+ return i === "0" || i === "undefined" ? 0n : h(this, E, F).call(this, i, e);
833
423
  }
834
424
  toSignificant(t = 6) {
835
- const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
836
- if ((Number.parseInt(s) ? s.length + i.length : i.length) <= t)
425
+ const [e, r] = this.getValue("string").split("."), i = e || "", s = r || "";
426
+ if ((Number.parseInt(i) ? i.length + s.length : s.length) <= t)
837
427
  return this.getValue("string");
838
- if (s.length >= t)
839
- return s.slice(0, t).padEnd(s.length, "0");
840
- if (Number.parseInt(s))
841
- return `${s}.${i.slice(0, t - s.length)}`.padEnd(
842
- t - s.length,
428
+ if (i.length >= t)
429
+ return i.slice(0, t).padEnd(i.length, "0");
430
+ if (Number.parseInt(i))
431
+ return `${i}.${s.slice(0, t - i.length)}`.padEnd(
432
+ t - i.length,
843
433
  "0"
844
434
  );
845
- const c = Number.parseInt(i), a = `${c}`.slice(0, t);
846
- return `0.${a.padStart(
847
- i.length - `${c}`.length + a.length,
435
+ const o = Number.parseInt(s), c = `${o}`.slice(0, t);
436
+ return `0.${c.padStart(
437
+ s.length - `${o}`.length + c.length,
848
438
  "0"
849
439
  )}`;
850
440
  }
851
441
  toFixed(t = 6) {
852
- const [n, r] = this.getValue("string").split("."), s = n || "", i = r || "";
853
- if (Number.parseInt(s))
854
- return `${s}.${i.slice(0, t)}`.padEnd(t, "0");
855
- const o = Number.parseInt(i), c = `${o}`.slice(0, t);
856
- return `0.${c.padStart(
857
- i.length - `${o}`.length + c.length,
442
+ const [e, r] = this.getValue("string").split("."), i = e || "", s = r || "";
443
+ if (Number.parseInt(i))
444
+ return `${i}.${s.slice(0, t)}`.padEnd(t, "0");
445
+ const l = Number.parseInt(s), o = `${l}`.slice(0, t);
446
+ return `0.${o.padStart(
447
+ s.length - `${l}`.length + o.length,
858
448
  "0"
859
449
  )}`;
860
450
  }
861
451
  toAbbreviation(t = 2) {
862
- const n = this.getValue("number"), r = ["", "K", "M", "B", "T", "Q", "Qi", "S"], s = Math.floor(Math.log10(Math.abs(n)) / 3), i = r[s];
863
- if (!i)
452
+ const e = this.getValue("number"), r = ["", "K", "M", "B", "T", "Q", "Qi", "S"], i = Math.floor(Math.log10(Math.abs(e)) / 3), s = r[i];
453
+ if (!s)
864
454
  return this.getValue("string");
865
- const o = 10 ** (s * 3);
866
- return `${(n / o).toFixed(t)}${i}`;
455
+ const l = 10 ** (i * 3);
456
+ return `${(e / l).toFixed(t)}${s}`;
867
457
  }
868
458
  toCurrency(t = "$", {
869
- currencyPosition: n = "start",
459
+ currencyPosition: e = "start",
870
460
  decimal: r = 2,
871
- decimalSeparator: s = ".",
872
- thousandSeparator: i = ","
461
+ decimalSeparator: i = ".",
462
+ thousandSeparator: s = ","
873
463
  } = {}) {
874
- const o = this.getValue("number"), [c, a = ""] = o.toFixed(6).split("."), l = c.replace(/\B(?=(\d{3})+(?!\d))/g, i), h = c || a ? c === "0" ? `${Number.parseFloat(`0.${a}`)}`.replace(".", s) : `${l}${Number.parseInt(a) ? `${s}${a.slice(0, r)}` : ""}` : "0.00";
875
- return `${n === "start" ? t : ""}${h}${n === "end" ? t : ""}`;
464
+ const l = this.getValue("number"), [o, c = ""] = l.toFixed(6).split("."), u = o.replace(/\B(?=(\d{3})+(?!\d))/g, s), d = o || c ? o === "0" ? `${Number.parseFloat(`0.${c}`)}`.replace(".", i) : `${u}${Number.parseInt(c) ? `${i}${c.slice(0, r)}` : ""}` : "0.00";
465
+ return `${e === "start" ? t : ""}${d}${e === "end" ? t : ""}`;
876
466
  }
877
- formatBigIntToSafeValue(t, n) {
878
- const r = n || this.decimal || B, s = Math.max(
467
+ formatBigIntToSafeValue(t, e) {
468
+ const r = e || this.decimal || T, i = Math.max(
879
469
  r,
880
- v(this.decimalMultiplier)
881
- ), i = t < 0n, o = t.toString().substring(i ? 1 : 0), c = s - (o.length - 1), a = c > 0 ? "0".repeat(c) + o : o, l = a.length - s;
882
- let h = a.slice(-s);
883
- return Number.parseInt(h[r]) >= 5 ? h = `${h.substring(0, r - 1)}${(Number.parseInt(h[r - 1]) + 1).toString()}` : h = h.substring(0, r), `${i ? "-" : ""}${a.slice(
470
+ B(this.decimalMultiplier)
471
+ ), s = t < 0n, l = t.toString().substring(s ? 1 : 0), o = i - (l.length - 1), c = o > 0 ? "0".repeat(o) + l : l, u = c.length - i;
472
+ let d = c.slice(-i);
473
+ return Number.parseInt(d[r]) >= 5 ? d = `${d.substring(0, r - 1)}${(Number.parseInt(d[r - 1]) + 1).toString()}` : d = d.substring(0, r), `${s ? "-" : ""}${c.slice(
884
474
  0,
885
- l
886
- )}.${h}`.replace(/\.?0*$/, "");
475
+ u
476
+ )}.${d}`.replace(/\.?0*$/, "");
887
477
  }
888
478
  };
889
- y = new WeakSet(), $ = function(t, ...n) {
890
- const r = p(this, V, Z).call(this, this, ...n), s = Math.max(r, v(this.decimalMultiplier)), i = w(s), o = n.reduce(
891
- (a, l) => {
892
- const h = this.getBigIntValue(l, s);
479
+ w = new WeakSet(), M = function(t, ...e) {
480
+ const r = h(this, N, U).call(this, this, ...e), i = Math.max(r, B(this.decimalMultiplier)), s = b(i), l = e.reduce(
481
+ (c, u) => {
482
+ const d = this.getBigIntValue(u, i);
893
483
  switch (t) {
894
484
  case "add":
895
- return a + h;
485
+ return c + d;
896
486
  case "sub":
897
- return a - h;
487
+ return c - d;
898
488
  case "mul":
899
- return a * h / i;
489
+ return c * d / s;
900
490
  case "div": {
901
- if (h === 0n)
491
+ if (d === 0n)
902
492
  throw new RangeError("Division by zero");
903
- return a * i / h;
493
+ return c * s / d;
904
494
  }
905
495
  default:
906
- return a;
496
+ return c;
907
497
  }
908
498
  },
909
499
  //normalize is to precision multiplier base
910
- this.bigIntValue * i / this.decimalMultiplier
911
- ), c = U({
912
- bigIntDecimal: s,
913
- decimal: s,
914
- value: o
500
+ this.bigIntValue * s / this.decimalMultiplier
501
+ ), o = x({
502
+ bigIntDecimal: i,
503
+ decimal: i,
504
+ value: l
915
505
  });
916
506
  return new this.constructor({
917
- decimalMultiplier: w(s),
507
+ decimalMultiplier: b(i),
918
508
  decimal: this.decimal,
919
- value: c,
509
+ value: o,
920
510
  identifier: this.toString()
921
511
  });
922
- }, b = new WeakSet(), E = function(t, ...n) {
923
- const r = p(this, V, Z).call(this, this, ...n), s = this.getBigIntValue(n[0], r), i = this.getBigIntValue(this, r);
512
+ }, A = new WeakSet(), C = function(t, ...e) {
513
+ const r = h(this, N, U).call(this, this, ...e), i = this.getBigIntValue(e[0], r), s = this.getBigIntValue(this, r);
924
514
  switch (t) {
925
515
  case "gt":
926
- return i > s;
516
+ return s > i;
927
517
  case "gte":
928
- return i >= s;
518
+ return s >= i;
929
519
  case "lt":
930
- return i < s;
520
+ return s < i;
931
521
  case "lte":
932
- return i <= s;
522
+ return s <= i;
933
523
  case "eqValue":
934
- return i === s;
935
- }
936
- }, j = new WeakSet(), be = function(t) {
937
- const n = k(t) || "0";
938
- this.bigIntValue = p(this, H, ee).call(this, n);
939
- }, V = new WeakSet(), Z = function(...t) {
940
- const n = t.map((r) => typeof r == "object" ? r.decimal || v(r.decimalMultiplier) : he(k(r))).filter(Boolean);
941
- return Math.max(...n, B);
942
- }, H = new WeakSet(), ee = function(t, n) {
943
- const r = n ? w(n) : this.decimalMultiplier, s = v(r), [i = "", o = ""] = t.split(".");
944
- return BigInt(`${i}${o.padEnd(s, "0")}`);
524
+ return s === i;
525
+ }
526
+ }, k = new WeakSet(), Q = function(t) {
527
+ const e = R(t) || "0";
528
+ this.bigIntValue = h(this, E, F).call(this, e);
529
+ }, N = new WeakSet(), U = function(...t) {
530
+ const e = t.map((r) => typeof r == "object" ? r.decimal || B(r.decimalMultiplier) : Y(R(r))).filter(Boolean);
531
+ return Math.max(...e, T);
532
+ }, E = new WeakSet(), F = function(t, e) {
533
+ const r = e ? b(e) : this.decimalMultiplier, i = B(r), [s = "", l = ""] = t.split(".");
534
+ return BigInt(`${s}${l.padEnd(i, "0")}`);
945
535
  };
946
- let D = q;
947
- const pt = Intl.NumberFormat("fullwide", {
536
+ let V = H;
537
+ const It = Intl.NumberFormat("fullwide", {
948
538
  useGrouping: !1,
949
539
  maximumFractionDigits: 20
950
540
  });
951
- function k(e) {
952
- const n = `${typeof e == "number" ? pt.format(e) : te(e)}`.replaceAll(",", ".").split(".");
953
- return n.length > 1 ? `${n.slice(0, -1).join("")}.${n.at(-1)}` : n[0];
541
+ function R(n) {
542
+ const e = `${typeof n == "number" ? It.format(n) : q(n)}`.replaceAll(",", ".").split(".");
543
+ return e.length > 1 ? `${e.slice(0, -1).join("")}.${e.at(-1)}` : e[0];
954
544
  }
955
- function he(e) {
956
- var n;
957
- const t = ((n = e.split(".")[1]) == null ? void 0 : n.length) || 0;
958
- return Math.max(t, B);
545
+ function Y(n) {
546
+ var e;
547
+ const t = ((e = n.split(".")[1]) == null ? void 0 : e.length) || 0;
548
+ return Math.max(t, T);
959
549
  }
960
- function te(e) {
961
- return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
550
+ function q(n) {
551
+ return typeof n == "object" ? "getValue" in n ? n.getValue("string") : n.value : n;
962
552
  }
963
- class g extends D {
553
+ class g extends V {
964
554
  eq(t) {
965
555
  return this.eqValue(t);
966
556
  }
967
- static fromBigInt(t, n) {
557
+ static fromBigInt(t, e) {
968
558
  return new g({
969
- decimal: n,
970
- value: U({ value: t, bigIntDecimal: n, decimal: n })
559
+ decimal: e,
560
+ value: x({ value: t, bigIntDecimal: e, decimal: e })
971
561
  });
972
562
  }
973
563
  }
974
- const P = /* @__PURE__ */ new Map();
975
- class A extends D {
564
+ const I = /* @__PURE__ */ new Map();
565
+ class p extends V {
976
566
  constructor({
977
- value: n,
567
+ value: e,
978
568
  decimal: r,
979
- tax: s,
980
- chain: i,
981
- symbol: o,
982
- identifier: c
569
+ tax: i,
570
+ chain: s,
571
+ symbol: l,
572
+ identifier: o
983
573
  }) {
984
- super(typeof n == "object" ? n : { decimal: r, value: n });
985
- _(this, "address");
986
- _(this, "chain");
987
- _(this, "isGasAsset", !1);
988
- _(this, "isSynthetic", !1);
989
- _(this, "symbol");
990
- _(this, "tax");
991
- _(this, "ticker");
992
- _(this, "type");
993
- const a = I(c || `${i}.${o}`);
994
- this.type = ot(a), this.tax = s, this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset;
574
+ super(typeof e == "object" ? e : { decimal: r, value: e });
575
+ f(this, "address");
576
+ f(this, "chain");
577
+ f(this, "isGasAsset", !1);
578
+ f(this, "isSynthetic", !1);
579
+ f(this, "symbol");
580
+ f(this, "tax");
581
+ f(this, "ticker");
582
+ f(this, "type");
583
+ const c = O(o || `${s}.${l}`);
584
+ this.type = pt(c), this.tax = i, this.chain = c.chain, this.ticker = c.ticker, this.symbol = c.symbol, this.address = c.address, this.isSynthetic = c.isSynthetic, this.isGasAsset = c.isGasAsset;
995
585
  }
996
586
  toString() {
997
587
  return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
@@ -999,97 +589,97 @@ class A extends D {
999
589
  toUrl() {
1000
590
  return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
1001
591
  }
1002
- eq({ chain: n, symbol: r }) {
1003
- return this.chain === n && this.symbol === r;
592
+ eq({ chain: e, symbol: r }) {
593
+ return this.chain === e && this.symbol === r;
1004
594
  }
1005
595
  chainId() {
1006
- return De[this.chain];
596
+ return ut[this.chain];
1007
597
  }
1008
598
  // THOR.RUNE
1009
599
  // THOR.ETH.ETH
1010
600
  // ETH.THOR-0x1234567890
1011
- static fromUrl(n, r = 0) {
1012
- const [s, i, o] = n.split(".");
1013
- if (!(s && i))
601
+ static fromUrl(e, r = 0) {
602
+ const [i, s, l] = e.split(".");
603
+ if (!(i && s))
1014
604
  throw new Error("Invalid asset url");
1015
- const c = s === u.THORChain && o ? `${s}.${i}/${o}` : n;
1016
- return J(c, r);
1017
- }
1018
- static fromString(n, r = 0) {
1019
- return J(n, r);
1020
- }
1021
- static fromIdentifier(n, r = 0) {
1022
- return J(n, r);
1023
- }
1024
- static fromStringSync(n, r = 0) {
1025
- const { chain: s, isSynthetic: i } = I(n), o = P.get(n.toUpperCase());
1026
- if (i)
1027
- return Q(n, r);
1028
- const { tax: c, decimal: a, identifier: l } = o || {
1029
- decimal: d[s],
1030
- identifier: n
605
+ const o = i === a.THORChain && l ? `${i}.${s}/${l}` : e;
606
+ return D(o, r);
607
+ }
608
+ static fromString(e, r = 0) {
609
+ return D(e, r);
610
+ }
611
+ static fromIdentifier(e, r = 0) {
612
+ return D(e, r);
613
+ }
614
+ static fromStringSync(e, r = 0) {
615
+ const { chain: i, isSynthetic: s } = O(e), l = I.get(e.toUpperCase());
616
+ if (s)
617
+ return L(e, r);
618
+ const { tax: o, decimal: c, identifier: u } = l || {
619
+ decimal: m[i],
620
+ identifier: e
1031
621
  };
1032
- return new A({
1033
- tax: c,
1034
- value: O(r, a),
1035
- identifier: i ? n : l,
1036
- decimal: i ? 8 : a
622
+ return new p({
623
+ tax: o,
624
+ value: S(r, c),
625
+ identifier: s ? e : u,
626
+ decimal: s ? 8 : c
1037
627
  });
1038
628
  }
1039
- static async fromStringWithBase(n, r = 0, s = d.THOR) {
1040
- const i = D.shiftDecimals({
629
+ static async fromStringWithBase(e, r = 0, i = m.THOR) {
630
+ const s = V.shiftDecimals({
1041
631
  value: g.fromBigInt(BigInt(r)),
1042
632
  from: 0,
1043
- to: s
633
+ to: i
1044
634
  }).getBaseValue("string");
1045
- return (await A.fromString(n, r)).set(i);
1046
- }
1047
- static fromStringWithBaseSync(n, r = 0, s = d.THOR) {
1048
- const { chain: i, isSynthetic: o } = I(n), c = P.get(n.toUpperCase());
1049
- if (o)
1050
- return Q(n, r);
1051
- const { tax: a, decimal: l, identifier: h } = c || {
1052
- decimal: d[i],
1053
- identifier: n
635
+ return (await p.fromString(e, r)).set(s);
636
+ }
637
+ static fromStringWithBaseSync(e, r = 0, i = m.THOR) {
638
+ const { chain: s, isSynthetic: l } = O(e), o = I.get(e.toUpperCase());
639
+ if (l)
640
+ return L(e, r);
641
+ const { tax: c, decimal: u, identifier: d } = o || {
642
+ decimal: m[s],
643
+ identifier: e
1054
644
  };
1055
- return new A({
1056
- tax: a,
1057
- value: O(BigInt(r), s),
1058
- identifier: h,
1059
- decimal: l
645
+ return new p({
646
+ tax: c,
647
+ value: S(BigInt(r), i),
648
+ identifier: d,
649
+ decimal: u
1060
650
  });
1061
651
  }
1062
- static fromIdentifierSync(n, r = 0) {
1063
- const { chain: s, isSynthetic: i } = I(n), o = P.get(n);
1064
- if (i)
1065
- return Q(n, r);
1066
- const { tax: c, decimal: a, identifier: l } = o || {
1067
- decimal: d[s],
1068
- identifier: n
652
+ static fromIdentifierSync(e, r = 0) {
653
+ const { chain: i, isSynthetic: s } = O(e), l = I.get(e);
654
+ if (s)
655
+ return L(e, r);
656
+ const { tax: o, decimal: c, identifier: u } = l || {
657
+ decimal: m[i],
658
+ identifier: e
1069
659
  };
1070
- return new A({ tax: c, decimal: a, identifier: l, value: O(r, a) });
660
+ return new p({ tax: o, decimal: c, identifier: u, value: S(r, c) });
1071
661
  }
1072
- static fromChainOrSignature(n, r = 0) {
1073
- const { decimal: s, identifier: i } = it(n);
1074
- return new A({ value: O(r, s), decimal: s, identifier: i });
662
+ static fromChainOrSignature(e, r = 0) {
663
+ const { decimal: i, identifier: s } = gt(e);
664
+ return new p({ value: S(r, i), decimal: i, identifier: s });
1075
665
  }
1076
666
  static loadStaticAssets() {
1077
667
  return new Promise(
1078
- (n, r) => {
668
+ (e, r) => {
1079
669
  try {
1080
- import("@swapkit/tokens").then((s) => {
1081
- for (const i of Object.values(s))
1082
- for (const { identifier: o, chain: c, ...a } of i.tokens)
1083
- P.set(o.toUpperCase(), {
1084
- identifier: o,
1085
- decimal: "decimals" in a ? a.decimals : d[c]
670
+ import("@swapkit/tokens").then((i) => {
671
+ for (const s of Object.values(i))
672
+ for (const { identifier: l, chain: o, ...c } of s.tokens)
673
+ I.set(l.toUpperCase(), {
674
+ identifier: l,
675
+ decimal: "decimals" in c ? c.decimals : m[o]
1086
676
  });
1087
- n({ ok: !0 });
677
+ e({ ok: !0 });
1088
678
  });
1089
- } catch (s) {
1090
- console.error(s), r({
679
+ } catch (i) {
680
+ console.error(i), r({
1091
681
  ok: !1,
1092
- error: s,
682
+ error: i,
1093
683
  message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
1094
684
  });
1095
685
  }
@@ -1097,60 +687,60 @@ class A extends D {
1097
687
  );
1098
688
  }
1099
689
  }
1100
- function Dt(e) {
1101
- const t = A.fromChainOrSignature(e);
1102
- switch (e) {
1103
- case u.Bitcoin:
1104
- case u.Litecoin:
1105
- case u.BitcoinCash:
690
+ function qt(n) {
691
+ const t = p.fromChainOrSignature(n);
692
+ switch (n) {
693
+ case a.Bitcoin:
694
+ case a.Litecoin:
695
+ case a.BitcoinCash:
1106
696
  return t.set(10001e-8);
1107
- case u.Dogecoin:
697
+ case a.Dogecoin:
1108
698
  return t.set(1.00000001);
1109
- case u.Avalanche:
1110
- case u.Ethereum:
699
+ case a.Avalanche:
700
+ case a.Ethereum:
1111
701
  return t.set(1e-8);
1112
- case u.THORChain:
1113
- case u.Maya:
702
+ case a.THORChain:
703
+ case a.Maya:
1114
704
  return t.set(0);
1115
- case u.Cosmos:
705
+ case a.Cosmos:
1116
706
  return t.set(1e-6);
1117
707
  default:
1118
708
  return t.set(1e-8);
1119
709
  }
1120
710
  }
1121
- async function J(e, t = 0) {
1122
- dt(e);
1123
- const n = P.get(e.toUpperCase()), r = (n == null ? void 0 : n.decimal) || await st(I(e));
1124
- return n || P.set(e.toUpperCase(), { identifier: e, decimal: r }), new A({ decimal: r, value: O(t, r), identifier: e });
711
+ async function D(n, t = 0) {
712
+ Ct(n);
713
+ const e = I.get(n.toUpperCase()), r = (e == null ? void 0 : e.decimal) || await ft(O(n));
714
+ return e || I.set(n.toUpperCase(), { identifier: n, decimal: r }), new p({ decimal: r, value: S(t, r), identifier: n });
1125
715
  }
1126
- function Q(e, t = 0) {
1127
- const [n, r] = e.split(".")[0].toUpperCase() === u.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1128
- if (!(n && r))
716
+ function L(n, t = 0) {
717
+ const [e, r] = n.split(".")[0].toUpperCase() === a.THORChain ? n.split(".").slice(1).join().split("/") : n.split("/");
718
+ if (!(e && r))
1129
719
  throw new Error("Invalid asset identifier");
1130
- return new A({
720
+ return new p({
1131
721
  decimal: 8,
1132
- value: O(t, 8),
1133
- identifier: `${u.THORChain}.${n}/${r}`
722
+ value: S(t, 8),
723
+ identifier: `${a.THORChain}.${e}/${r}`
1134
724
  });
1135
725
  }
1136
- function O(e, t) {
1137
- return typeof e == "bigint" ? U({ value: e, bigIntDecimal: t, decimal: t }) : e;
726
+ function S(n, t) {
727
+ return typeof n == "bigint" ? x({ value: n, bigIntDecimal: t, decimal: t }) : n;
1138
728
  }
1139
- function I(e) {
1140
- const t = e.slice(0, 14).includes("/"), [n, r] = e.split(".")[0].toUpperCase() === u.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
1141
- if (t && !(n && r))
729
+ function O(n) {
730
+ const t = n.slice(0, 14).includes("/"), [e, r] = n.split(".")[0].toUpperCase() === a.THORChain ? n.split(".").slice(1).join().split("/") : n.split("/");
731
+ if (t && !(e && r))
1142
732
  throw new Error("Invalid asset identifier");
1143
- const s = e.includes(".") && !t ? e : `${u.THORChain}.${r}`, [i, ...o] = s.split("."), [c, a] = (t ? r : o.join(".")).split("-"), l = t ? r : o.join(".");
733
+ const i = n.includes(".") && !t ? n : `${a.THORChain}.${r}`, [s, ...l] = i.split("."), [o, c] = (t ? r : l.join(".")).split("-"), u = t ? r : l.join(".");
1144
734
  return {
1145
- address: a == null ? void 0 : a.toLowerCase(),
1146
- chain: i,
1147
- isGasAsset: Se({ chain: i, symbol: l }),
735
+ address: c == null ? void 0 : c.toLowerCase(),
736
+ chain: s,
737
+ isGasAsset: J({ chain: s, symbol: u }),
1148
738
  isSynthetic: t,
1149
- symbol: (t ? `${n}/` : "") + (a ? `${c}-${(a == null ? void 0 : a.toLowerCase()) ?? ""}` : l),
1150
- ticker: c
739
+ symbol: (t ? `${e}/` : "") + (c ? `${o}-${(c == null ? void 0 : c.toLowerCase()) ?? ""}` : u),
740
+ ticker: o
1151
741
  };
1152
742
  }
1153
- const mt = {
743
+ const St = {
1154
744
  /**
1155
745
  * Core
1156
746
  */
@@ -1223,52 +813,44 @@ const mt = {
1223
813
  */
1224
814
  helpers_number_different_decimals: 99101
1225
815
  };
1226
- class we extends Error {
1227
- constructor(t, n) {
1228
- n && console.error(n, {
1229
- stack: n == null ? void 0 : n.stack,
1230
- message: n == null ? void 0 : n.message
816
+ class X extends Error {
817
+ constructor(t, e) {
818
+ e && console.error(e, {
819
+ stack: e == null ? void 0 : e.stack,
820
+ message: e == null ? void 0 : e.message
1231
821
  }), super(t, {
1232
- cause: { code: mt[t], message: t }
1233
- }), Object.setPrototypeOf(this, we.prototype);
822
+ cause: { code: St[t], message: t }
823
+ }), Object.setPrototypeOf(this, X.prototype);
1234
824
  }
1235
825
  }
1236
826
  export {
1237
- T as ApiEndpoints,
1238
- A as AssetValue,
1239
- D as BigIntArithmetics,
1240
- f as RequestClient,
1241
- Ze as StreamingSwapProgressStatus,
1242
- gt as SwapKitApi,
1243
- we as SwapKitError,
827
+ p as AssetValue,
828
+ V as BigIntArithmetics,
829
+ X as SwapKitError,
1244
830
  g as SwapKitNumber,
1245
- Qe as TransactionType,
1246
- ze as TxStatus,
1247
- Ct as assetFromString,
1248
- Ae as defaultRequestHeaders,
1249
- Bt as derivationPathToString,
1250
- St as filterAssets,
1251
- bt as findAssetBy,
1252
- U as formatBigIntToSafeValue,
1253
- At as gasFeeMultiplier,
1254
- ot as getAssetType,
1255
- lt as getAsymmetricAssetShare,
1256
- yt as getAsymmetricAssetWithdrawAmount,
1257
- ut as getAsymmetricRuneShare,
1258
- wt as getAsymmetricRuneWithdrawAmount,
1259
- it as getCommonAssetInfo,
1260
- st as getDecimal,
1261
- Et as getEstimatedPoolShare,
1262
- Pt as getLiquiditySlippage,
1263
- vt as getMAYANameCost,
1264
- Ot as getMemoFor,
1265
- Dt as getMinAmountByChain,
1266
- ht as getSymmetricPoolShare,
1267
- Rt as getSymmetricWithdraw,
1268
- Nt as getTHORNameCost,
1269
- Se as isGasAsset,
1270
- Tt as setRequestClientConfig,
1271
- It as validateMAYAName,
1272
- $t as validateTHORName
831
+ Tt as assetFromString,
832
+ Ft as derivationPathToString,
833
+ Vt as filterAssets,
834
+ Nt as findAssetBy,
835
+ x as formatBigIntToSafeValue,
836
+ Ot as gasFeeMultiplier,
837
+ pt as getAssetType,
838
+ wt as getAsymmetricAssetShare,
839
+ Rt as getAsymmetricAssetWithdrawAmount,
840
+ bt as getAsymmetricRuneShare,
841
+ Et as getAsymmetricRuneWithdrawAmount,
842
+ gt as getCommonAssetInfo,
843
+ ft as getDecimal,
844
+ kt as getEstimatedPoolShare,
845
+ Ht as getLiquiditySlippage,
846
+ Dt as getMAYANameCost,
847
+ jt as getMemoFor,
848
+ qt as getMinAmountByChain,
849
+ vt as getSymmetricPoolShare,
850
+ xt as getSymmetricWithdraw,
851
+ Pt as getTHORNameCost,
852
+ J as isGasAsset,
853
+ Ut as validateMAYAName,
854
+ Lt as validateTHORName
1273
855
  };
1274
856
  //# sourceMappingURL=index.es.js.map