@swapkit/helpers 1.0.0-rc.23 → 1.0.0-rc.25

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,19 +1,19 @@
1
- var gt = Object.defineProperty;
2
- var bt = (s, t, e) => t in s ? gt(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var f = (s, t, e) => (bt(s, typeof t != "symbol" ? t + "" : t, e), e), yt = (s, t, e) => {
4
- if (!t.has(s))
1
+ var yt = Object.defineProperty;
2
+ var wt = (r, t, e) => t in r ? yt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var f = (r, t, e) => (wt(r, typeof t != "symbol" ? t + "" : t, e), e), At = (r, t, e) => {
4
+ if (!t.has(r))
5
5
  throw TypeError("Cannot " + e);
6
6
  };
7
- var y = (s, t, e) => {
8
- if (t.has(s))
7
+ var y = (r, t, e) => {
8
+ if (t.has(r))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
- t instanceof WeakSet ? t.add(s) : t.set(s, e);
10
+ t instanceof WeakSet ? t.add(r) : t.set(r, e);
11
11
  };
12
- var m = (s, t, e) => (yt(s, t, "access private method"), e);
13
- import { FeeOption as L, BaseDecimal as d, Chain as o, EVMChainList as wt, ChainToRPC as At, MemoType as g } from "@swapkit/types";
14
- const vt = "0x313ce567", nt = async ({ chain: s, to: t }) => {
12
+ var d = (r, t, e) => (At(r, t, "access private method"), e);
13
+ import { FeeOption as D, BaseDecimal as p, Chain as o, EVMChainList as vt, ChainToRPC as Tt, MemoType as g } from "@swapkit/types";
14
+ const $t = "0x313ce567", ot = async ({ chain: r, to: t }) => {
15
15
  try {
16
- const { result: e } = await Zt.post(At[s], {
16
+ const { result: e } = await te.post(Tt[r], {
17
17
  headers: {
18
18
  accept: "*/*",
19
19
  "content-type": "application/json",
@@ -23,38 +23,38 @@ const vt = "0x313ce567", nt = async ({ chain: s, to: t }) => {
23
23
  id: 44,
24
24
  jsonrpc: "2.0",
25
25
  method: "eth_call",
26
- params: [{ to: t.toLowerCase(), data: vt }, "latest"]
26
+ params: [{ to: t.toLowerCase(), data: $t }, "latest"]
27
27
  })
28
28
  });
29
29
  return parseInt(BigInt(e).toString());
30
30
  } catch (e) {
31
- return console.error(e), d[s];
31
+ return console.error(e), p[r];
32
32
  }
33
- }, Tt = async (s) => {
34
- if (s === o.Ethereum)
35
- return d.ETH;
36
- const [, t] = s.split("-");
37
- return t != null && t.startsWith("0x") ? nt({ chain: o.Ethereum, to: t }) : d.ETH;
38
- }, $t = async (s) => {
39
- const [, t] = s.split("-");
40
- return t != null && t.startsWith("0x") ? nt({ chain: o.Avalanche, to: t.toLowerCase() }) : d.AVAX;
41
- }, Rt = async (s) => s === o.BinanceSmartChain ? d.BSC : d.BSC, St = async ({ chain: s, symbol: t }) => {
42
- switch (s) {
33
+ }, Rt = async (r) => {
34
+ if (r === o.Ethereum)
35
+ return p.ETH;
36
+ const [, t] = r.split("-");
37
+ return t != null && t.startsWith("0x") ? ot({ chain: o.Ethereum, to: t }) : p.ETH;
38
+ }, St = async (r) => {
39
+ const [, t] = r.split("-");
40
+ return t != null && t.startsWith("0x") ? ot({ chain: o.Avalanche, to: t.toLowerCase() }) : p.AVAX;
41
+ }, Ct = async (r) => r === o.BinanceSmartChain ? p.BSC : p.BSC, It = async ({ chain: r, symbol: t }) => {
42
+ switch (r) {
43
43
  case o.Ethereum:
44
- return Tt(t);
44
+ return Rt(t);
45
45
  case o.Avalanche:
46
- return $t(t);
46
+ return St(t);
47
47
  case o.BinanceSmartChain:
48
- return Rt(t);
48
+ return Ct(t);
49
49
  default:
50
- return d[s];
50
+ return p[r];
51
51
  }
52
- }, ne = {
53
- [L.Average]: 1.2,
54
- [L.Fast]: 1.5,
55
- [L.Fastest]: 2
56
- }, Ct = ({ chain: s, symbol: t }) => {
57
- switch (s) {
52
+ }, ie = {
53
+ [D.Average]: 1.2,
54
+ [D.Fast]: 1.5,
55
+ [D.Fastest]: 2
56
+ }, at = ({ chain: r, symbol: t }) => {
57
+ switch (r) {
58
58
  case o.Bitcoin:
59
59
  case o.BitcoinCash:
60
60
  case o.Litecoin:
@@ -62,7 +62,7 @@ const vt = "0x313ce567", nt = async ({ chain: s, to: t }) => {
62
62
  case o.Binance:
63
63
  case o.Ethereum:
64
64
  case o.Avalanche:
65
- return t === s;
65
+ return t === r;
66
66
  case o.Arbitrum:
67
67
  case o.Optimism:
68
68
  return t === "ETH";
@@ -79,20 +79,20 @@ const vt = "0x313ce567", nt = async ({ chain: s, to: t }) => {
79
79
  case o.THORChain:
80
80
  return t === "RUNE";
81
81
  }
82
- }, It = (s) => {
83
- switch (s) {
82
+ }, Et = (r) => {
83
+ switch (r) {
84
84
  case "ETH.THOR":
85
85
  return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
86
86
  case "ETH.vTHOR":
87
87
  return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
88
88
  case o.Cosmos:
89
- return { identifier: "GAIA.ATOM", decimal: d[s] };
89
+ return { identifier: "GAIA.ATOM", decimal: p[r] };
90
90
  case o.THORChain:
91
- return { identifier: "THOR.RUNE", decimal: d[s] };
91
+ return { identifier: "THOR.RUNE", decimal: p[r] };
92
92
  case o.BinanceSmartChain:
93
- return { identifier: "BSC.BNB", decimal: d[s] };
93
+ return { identifier: "BSC.BNB", decimal: p[r] };
94
94
  case o.Maya:
95
- return { identifier: "MAYA.CACAO", decimal: d.MAYA };
95
+ return { identifier: "MAYA.CACAO", decimal: p.MAYA };
96
96
  case "MAYA.MAYA":
97
97
  return { identifier: "MAYA.MAYA", decimal: 4 };
98
98
  case o.Kujira:
@@ -106,12 +106,12 @@ const vt = "0x313ce567", nt = async ({ chain: s, to: t }) => {
106
106
  case o.Polygon:
107
107
  case o.Bitcoin:
108
108
  case o.Ethereum:
109
- return { identifier: `${s}.${s}`, decimal: d[s] };
109
+ return { identifier: `${r}.${r}`, decimal: p[r] };
110
110
  }
111
- }, Et = ({ chain: s, symbol: t }) => {
111
+ }, Ot = ({ chain: r, symbol: t }) => {
112
112
  if (t.includes("/"))
113
113
  return "Synth";
114
- switch (s) {
114
+ switch (r) {
115
115
  case o.Bitcoin:
116
116
  case o.BitcoinCash:
117
117
  case o.Dogecoin:
@@ -138,127 +138,134 @@ const vt = "0x313ce567", nt = async ({ chain: s, to: t }) => {
138
138
  case o.Optimism:
139
139
  return [o.Ethereum, o.Optimism].includes(t) ? "Native" : "OPTIMISM";
140
140
  }
141
- }, ie = (s) => {
141
+ }, oe = (r) => {
142
142
  var c;
143
- const [t, ...e] = s.split("."), r = s.includes("/"), n = e.join("."), i = (c = n == null ? void 0 : n.split("-")) == null ? void 0 : c[0];
144
- return { chain: t, symbol: n, ticker: i, synth: r };
145
- }, Ot = new RegExp(
143
+ const [t, ...e] = r.split("."), s = r.includes("/"), n = e.join("."), i = (c = n == null ? void 0 : n.split("-")) == null ? void 0 : c[0];
144
+ return { chain: t, symbol: n, ticker: i, synth: s };
145
+ }, Bt = new RegExp(
146
146
  /(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
147
147
  "gmi"
148
- ), Bt = (s) => wt.includes(s.chain) ? !s.isGasAsset && s.address && !Number.isNaN(s.decimal) : !0, oe = (s) => s.filter(
149
- (t) => !t.toString().includes("undefined") && !Ot.test(t.toString()) && Bt(t)
150
- ), Mt = ({
151
- liquidityUnits: s,
148
+ ), Mt = (r) => {
149
+ const [t, e] = r.split(".");
150
+ if (!vt.includes(t))
151
+ return !0;
152
+ const [, s] = e.split("-");
153
+ return at({ chain: t, symbol: e }) || !!s;
154
+ }, ae = (r) => r.filter((t) => {
155
+ const e = `${t.chain}.${t.symbol}`;
156
+ return !Bt.test(e) && Mt(e) && t.value !== "0";
157
+ }), Vt = ({
158
+ liquidityUnits: r,
152
159
  poolUnits: t,
153
160
  runeDepth: e
154
161
  }) => {
155
- const r = p(s), n = p(t), i = p(e), c = r.mul(i), a = n.mul(n).mul(2), u = n.mul(r).mul(2), l = r.mul(r), h = n.mul(n).mul(n);
162
+ const s = m(r), n = m(t), i = m(e), c = s.mul(i), a = n.mul(n).mul(2), u = n.mul(s).mul(2), l = s.mul(s), h = n.mul(n).mul(n);
156
163
  return c.mul(a.sub(u).add(l)).div(h);
157
- }, Vt = ({
158
- liquidityUnits: s,
164
+ }, qt = ({
165
+ liquidityUnits: r,
159
166
  poolUnits: t,
160
167
  assetDepth: e
161
168
  }) => {
162
- const r = p(s), n = p(t), i = p(e), c = r.mul(i), a = n.mul(n).mul(2), u = n.mul(r).mul(2), l = r.mul(r), h = c.mul(a.sub(u).add(l)), _ = n.mul(n).mul(n);
169
+ const s = m(r), n = m(t), i = m(e), c = s.mul(i), a = n.mul(n).mul(2), u = n.mul(s).mul(2), l = s.mul(s), h = c.mul(a.sub(u).add(l)), _ = n.mul(n).mul(n);
163
170
  return h.div(_);
164
- }, ae = ({
165
- percent: s,
171
+ }, ce = ({
172
+ percent: r,
166
173
  runeDepth: t,
167
174
  liquidityUnits: e,
168
- poolUnits: r
169
- }) => Mt({ runeDepth: t, liquidityUnits: e, poolUnits: r }).mul(s), ce = ({
170
- percent: s,
175
+ poolUnits: s
176
+ }) => Vt({ runeDepth: t, liquidityUnits: e, poolUnits: s }).mul(r), ue = ({
177
+ percent: r,
171
178
  assetDepth: t,
172
179
  liquidityUnits: e,
173
- poolUnits: r
174
- }) => Vt({ assetDepth: t, liquidityUnits: e, poolUnits: r }).mul(s), p = (s) => b.fromBigInt(BigInt(s), d.THOR), kt = ({
175
- liquidityUnits: s,
180
+ poolUnits: s
181
+ }) => qt({ assetDepth: t, liquidityUnits: e, poolUnits: s }).mul(r), m = (r) => b.fromBigInt(BigInt(r), p.THOR), xt = ({
182
+ liquidityUnits: r,
176
183
  poolUnits: t,
177
184
  runeDepth: e,
178
- assetDepth: r
185
+ assetDepth: s
179
186
  }) => ({
180
- assetAmount: p(r).mul(s).div(t),
181
- runeAmount: p(e).mul(s).div(t)
182
- }), ue = ({
183
- liquidityUnits: s,
187
+ assetAmount: m(s).mul(r).div(t),
188
+ runeAmount: m(e).mul(r).div(t)
189
+ }), le = ({
190
+ liquidityUnits: r,
184
191
  poolUnits: t,
185
192
  runeDepth: e,
186
- assetDepth: r,
193
+ assetDepth: s,
187
194
  percent: n
188
195
  }) => Object.fromEntries(
189
- Object.entries(kt({ liquidityUnits: s, poolUnits: t, runeDepth: e, assetDepth: r })).map(
196
+ Object.entries(xt({ liquidityUnits: r, poolUnits: t, runeDepth: e, assetDepth: s })).map(
190
197
  ([i, c]) => [i, c.mul(n)]
191
198
  )
192
- ), le = ({
193
- runeDepth: s,
199
+ ), he = ({
200
+ runeDepth: r,
194
201
  poolUnits: t,
195
202
  assetDepth: e,
196
- liquidityUnits: r,
203
+ liquidityUnits: s,
197
204
  runeAmount: n,
198
205
  assetAmount: i
199
206
  }) => {
200
- const c = new b({ value: s, decimal: 8 }), a = new b({ value: e, decimal: 8 }), u = new b({ value: t, decimal: 8 }), l = new b({ value: n, decimal: 8 }), h = new b({ value: i, decimal: 8 }), _ = l.mul(a), T = h.mul(c), j = l.mul(h), mt = c.mul(a), pt = u.mul(_.add(T.add(j.mul(2)))), ft = _.add(T.add(mt.mul(2))), Q = pt.div(ft), H = p(r).add(Q);
201
- if (Q.getBaseValue("number") === 0)
202
- return H.div(u).getBaseValue("number");
203
- const _t = u.add(H);
204
- return H.div(_t).getBaseValue("number");
205
- }, he = ({
206
- runeAmount: s,
207
+ const c = new b({ value: r, decimal: 8 }), a = new b({ value: e, decimal: 8 }), u = new b({ value: t, decimal: 8 }), l = new b({ value: n, decimal: 8 }), h = new b({ value: i, decimal: 8 }), _ = l.mul(a), T = h.mul(c), H = l.mul(h), ft = c.mul(a), _t = u.mul(_.add(T.add(H.mul(2)))), gt = _.add(T.add(ft.mul(2))), X = _t.div(gt), L = m(s).add(X);
208
+ if (X.getBaseValue("number") === 0)
209
+ return L.div(u).getBaseValue("number");
210
+ const bt = u.add(L);
211
+ return L.div(bt).getBaseValue("number");
212
+ }, de = ({
213
+ runeAmount: r,
207
214
  assetAmount: t,
208
215
  runeDepth: e,
209
- assetDepth: r
216
+ assetDepth: s
210
217
  }) => {
211
- if (s === "0" || t === "0" || e === "0" || r === "0")
218
+ if (r === "0" || t === "0" || e === "0" || s === "0")
212
219
  return 0;
213
- const n = p(e), i = p(r), c = p(t), a = p(s), u = c.mul(n).sub(i.mul(a)), l = i.mul(a).add(n.mul(i));
220
+ const n = m(e), i = m(s), c = m(t), a = m(r), u = c.mul(n).sub(i.mul(a)), l = i.mul(a).add(n.mul(i));
214
221
  return Math.abs(u.div(l).getBaseValue("number"));
215
- }, qt = ({
216
- symbol: s,
222
+ }, kt = ({
223
+ symbol: r,
217
224
  ticker: t,
218
225
  chain: e
219
- }) => e === "ETH" && t !== "ETH" ? `${t}-${s.slice(-3)}` : s, de = (s, t) => {
220
- switch (s) {
226
+ }) => e === "ETH" && t !== "ETH" ? `${t}-${r.slice(-3)}` : r, pe = (r, t) => {
227
+ switch (r) {
221
228
  case g.LEAVE:
222
229
  case g.BOND: {
223
230
  const { address: e } = t;
224
- return `${s}:${e}`;
231
+ return `${r}:${e}`;
225
232
  }
226
233
  case g.UNBOND: {
227
- const { address: e, unbondAmount: r } = t;
228
- return `${s}:${e}:${r * 10 ** 8}`;
234
+ const { address: e, unbondAmount: s } = t;
235
+ return `${r}:${e}:${s * 10 ** 8}`;
229
236
  }
230
237
  case g.THORNAME_REGISTER: {
231
- const { name: e, chain: r, address: n, owner: i } = t;
232
- return `${s}:${e}:${r}:${n}${i ? `:${i}` : ""}`;
238
+ const { name: e, chain: s, address: n, owner: i } = t;
239
+ return `${r}:${e}:${s}:${n}${i ? `:${i}` : ""}`;
233
240
  }
234
241
  case g.DEPOSIT: {
235
- const { chain: e, symbol: r, address: n, singleSide: i } = t;
236
- return i ? `${s}:${e}/${r}::t:0` : `${s}:${e}.${r}:${n || ""}:t:0`;
242
+ const { chain: e, symbol: s, address: n, singleSide: i } = t;
243
+ return i ? `${r}:${e}/${s}::t:0` : `${r}:${e}.${s}:${n || ""}:t:0`;
237
244
  }
238
245
  case g.WITHDRAW: {
239
- const { chain: e, ticker: r, symbol: n, basisPoints: i, targetAssetString: c, singleSide: a } = t, u = !a && c ? `:${c}` : "", l = qt({ chain: e, symbol: n, ticker: r });
240
- return `${s}:${e}${a ? "/" : "."}${l}:${i}${u}`;
246
+ const { chain: e, ticker: s, symbol: n, basisPoints: i, targetAssetString: c, singleSide: a } = t, u = !a && c ? `:${c}` : "", l = kt({ chain: e, symbol: n, ticker: s });
247
+ return `${r}:${e}${a ? "/" : "."}${l}:${i}${u}`;
241
248
  }
242
249
  case g.OPEN_LOAN:
243
250
  case g.CLOSE_LOAN: {
244
- const { asset: e, address: r } = t;
245
- return `${s}:${e}:${r}`;
251
+ const { asset: e, address: s } = t;
252
+ return `${r}:${e}:${s}`;
246
253
  }
247
254
  default:
248
255
  return "";
249
256
  }
250
- }, me = (s) => {
251
- if (s < 0)
257
+ }, me = (r) => {
258
+ if (r < 0)
252
259
  throw new Error("Invalid number of year");
253
- return 10 + s;
254
- }, pe = (s) => {
255
- if (s.length > 30)
260
+ return 10 + r;
261
+ }, fe = (r) => {
262
+ if (r.length > 30)
256
263
  return !1;
257
264
  const t = /^[a-zA-Z0-9+_-]+$/g;
258
- return !!s.match(t);
259
- }, fe = ([s, t, e, r, n]) => `${s}'/${t}'/${e}'/${r}${typeof n != "number" ? "" : `/${n}`}`;
260
- class X extends Error {
261
- constructor(t, e, r) {
265
+ return !!r.match(t);
266
+ }, _e = ([r, t, e, s, n]) => `${r}'/${t}'/${e}'/${s}${typeof n != "number" ? "" : `/${n}`}`;
267
+ class Z extends Error {
268
+ constructor(t, e, s) {
262
269
  const n = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", c = `${n} ${i}`.trim(), a = c ? `status code ${c}` : "an unknown error";
263
270
  super(`Request failed with ${a}`), Object.defineProperty(this, "response", {
264
271
  enumerable: !0,
@@ -275,10 +282,10 @@ class X extends Error {
275
282
  configurable: !0,
276
283
  writable: !0,
277
284
  value: void 0
278
- }), this.name = "HTTPError", this.response = t, this.request = e, this.options = r;
285
+ }), this.name = "HTTPError", this.response = t, this.request = e, this.options = s;
279
286
  }
280
287
  }
281
- class it extends Error {
288
+ class ct extends Error {
282
289
  constructor(t) {
283
290
  super("Request timed out"), Object.defineProperty(this, "request", {
284
291
  enumerable: !0,
@@ -288,45 +295,45 @@ class it extends Error {
288
295
  }), this.name = "TimeoutError", this.request = t;
289
296
  }
290
297
  }
291
- const V = (s) => s !== null && typeof s == "object", M = (...s) => {
292
- for (const t of s)
293
- if ((!V(t) || Array.isArray(t)) && t !== void 0)
298
+ const x = (r) => r !== null && typeof r == "object", V = (...r) => {
299
+ for (const t of r)
300
+ if ((!x(t) || Array.isArray(t)) && t !== void 0)
294
301
  throw new TypeError("The `options` argument must be an object");
295
- return J({}, ...s);
296
- }, ot = (s = {}, t = {}) => {
297
- const e = new globalThis.Headers(s), r = t instanceof globalThis.Headers, n = new globalThis.Headers(t);
302
+ return K({}, ...r);
303
+ }, ut = (r = {}, t = {}) => {
304
+ const e = new globalThis.Headers(r), s = t instanceof globalThis.Headers, n = new globalThis.Headers(t);
298
305
  for (const [i, c] of n.entries())
299
- r && c === "undefined" || c === void 0 ? e.delete(i) : e.set(i, c);
306
+ s && c === "undefined" || c === void 0 ? e.delete(i) : e.set(i, c);
300
307
  return e;
301
- }, J = (...s) => {
308
+ }, K = (...r) => {
302
309
  let t = {}, e = {};
303
- for (const r of s)
304
- if (Array.isArray(r))
305
- Array.isArray(t) || (t = []), t = [...t, ...r];
306
- else if (V(r)) {
307
- for (let [n, i] of Object.entries(r))
308
- V(i) && n in t && (i = J(t[n], i)), t = { ...t, [n]: i };
309
- V(r.headers) && (e = ot(e, r.headers), t.headers = e);
310
+ for (const s of r)
311
+ if (Array.isArray(s))
312
+ Array.isArray(t) || (t = []), t = [...t, ...s];
313
+ else if (x(s)) {
314
+ for (let [n, i] of Object.entries(s))
315
+ x(i) && n in t && (i = K(t[n], i)), t = { ...t, [n]: i };
316
+ x(s.headers) && (e = ut(e, s.headers), t.headers = e);
310
317
  }
311
318
  return t;
312
- }, xt = (() => {
313
- let s = !1, t = !1;
314
- const e = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
315
- return e && r && (t = new globalThis.Request("https://empty.invalid", {
319
+ }, Pt = (() => {
320
+ let r = !1, t = !1;
321
+ const e = typeof globalThis.ReadableStream == "function", s = typeof globalThis.Request == "function";
322
+ return e && s && (t = new globalThis.Request("https://empty.invalid", {
316
323
  body: new globalThis.ReadableStream(),
317
324
  method: "POST",
318
325
  // @ts-expect-error - Types are outdated.
319
326
  get duplex() {
320
- return s = !0, "half";
327
+ return r = !0, "half";
321
328
  }
322
- }).headers.has("Content-Type")), s && !t;
323
- })(), Pt = typeof globalThis.AbortController == "function", Nt = typeof globalThis.ReadableStream == "function", jt = typeof globalThis.FormData == "function", at = ["get", "post", "put", "patch", "head", "delete"], Ht = {
329
+ }).headers.has("Content-Type")), r && !t;
330
+ })(), Nt = typeof globalThis.AbortController == "function", jt = typeof globalThis.ReadableStream == "function", Ht = typeof globalThis.FormData == "function", lt = ["get", "post", "put", "patch", "head", "delete"], Lt = {
324
331
  json: "application/json",
325
332
  text: "text/*",
326
333
  formData: "multipart/form-data",
327
334
  arrayBuffer: "*/*",
328
335
  blob: "*/*"
329
- }, D = 2147483647, ct = Symbol("stop"), Lt = {
336
+ }, U = 2147483647, ht = Symbol("stop"), Dt = {
330
337
  json: !0,
331
338
  parseJson: !0,
332
339
  searchParams: !0,
@@ -337,7 +344,7 @@ const V = (s) => s !== null && typeof s == "object", M = (...s) => {
337
344
  throwHttpErrors: !0,
338
345
  onDownloadProgress: !0,
339
346
  fetch: !0
340
- }, Dt = {
347
+ }, Ut = {
341
348
  method: !0,
342
349
  headers: !0,
343
350
  body: !0,
@@ -353,86 +360,86 @@ const V = (s) => s !== null && typeof s == "object", M = (...s) => {
353
360
  window: !0,
354
361
  dispatcher: !0,
355
362
  duplex: !0
356
- }, Ut = (s) => at.includes(s) ? s.toUpperCase() : s, Ft = ["get", "put", "head", "delete", "options", "trace"], Wt = [408, 413, 429, 500, 502, 503, 504], ut = [413, 429, 503], Z = {
363
+ }, Ft = (r) => lt.includes(r) ? r.toUpperCase() : r, Wt = ["get", "put", "head", "delete", "options", "trace"], Gt = [408, 413, 429, 500, 502, 503, 504], dt = [413, 429, 503], tt = {
357
364
  limit: 2,
358
- methods: Ft,
359
- statusCodes: Wt,
360
- afterStatusCodes: ut,
365
+ methods: Wt,
366
+ statusCodes: Gt,
367
+ afterStatusCodes: dt,
361
368
  maxRetryAfter: Number.POSITIVE_INFINITY,
362
369
  backoffLimit: Number.POSITIVE_INFINITY,
363
- delay: (s) => 0.3 * 2 ** (s - 1) * 1e3
364
- }, Gt = (s = {}) => {
365
- if (typeof s == "number")
370
+ delay: (r) => 0.3 * 2 ** (r - 1) * 1e3
371
+ }, Yt = (r = {}) => {
372
+ if (typeof r == "number")
366
373
  return {
367
- ...Z,
368
- limit: s
374
+ ...tt,
375
+ limit: r
369
376
  };
370
- if (s.methods && !Array.isArray(s.methods))
377
+ if (r.methods && !Array.isArray(r.methods))
371
378
  throw new Error("retry.methods must be an array");
372
- if (s.statusCodes && !Array.isArray(s.statusCodes))
379
+ if (r.statusCodes && !Array.isArray(r.statusCodes))
373
380
  throw new Error("retry.statusCodes must be an array");
374
381
  return {
375
- ...Z,
376
- ...s,
377
- afterStatusCodes: ut
382
+ ...tt,
383
+ ...r,
384
+ afterStatusCodes: dt
378
385
  };
379
386
  };
380
- async function Yt(s, t, e, r) {
387
+ async function zt(r, t, e, s) {
381
388
  return new Promise((n, i) => {
382
389
  const c = setTimeout(() => {
383
- e && e.abort(), i(new it(s));
384
- }, r.timeout);
385
- r.fetch(s, t).then(n).catch(i).then(() => {
390
+ e && e.abort(), i(new ct(r));
391
+ }, s.timeout);
392
+ s.fetch(r, t).then(n).catch(i).then(() => {
386
393
  clearTimeout(c);
387
394
  });
388
395
  });
389
396
  }
390
- async function zt(s, { signal: t }) {
391
- return new Promise((e, r) => {
397
+ async function Jt(r, { signal: t }) {
398
+ return new Promise((e, s) => {
392
399
  t && (t.throwIfAborted(), t.addEventListener("abort", n, { once: !0 }));
393
400
  function n() {
394
- clearTimeout(i), r(t.reason);
401
+ clearTimeout(i), s(t.reason);
395
402
  }
396
403
  const i = setTimeout(() => {
397
404
  t == null || t.removeEventListener("abort", n), e();
398
- }, s);
405
+ }, r);
399
406
  });
400
407
  }
401
- const Jt = (s, t) => {
408
+ const Kt = (r, t) => {
402
409
  const e = {};
403
- for (const r in t)
404
- !(r in Dt) && !(r in Lt) && !(r in s) && (e[r] = t[r]);
410
+ for (const s in t)
411
+ !(s in Ut) && !(s in Dt) && !(s in r) && (e[s] = t[s]);
405
412
  return e;
406
413
  };
407
- class q {
414
+ class P {
408
415
  static create(t, e) {
409
- const r = new q(t, e), n = async () => {
410
- if (typeof r._options.timeout == "number" && r._options.timeout > D)
411
- throw new RangeError(`The \`timeout\` option cannot be greater than ${D}`);
416
+ const s = new P(t, e), n = async () => {
417
+ if (typeof s._options.timeout == "number" && s._options.timeout > U)
418
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${U}`);
412
419
  await Promise.resolve();
413
- let a = await r._fetch();
414
- for (const u of r._options.hooks.afterResponse) {
415
- const l = await u(r.request, r._options, r._decorateResponse(a.clone()));
420
+ let a = await s._fetch();
421
+ for (const u of s._options.hooks.afterResponse) {
422
+ const l = await u(s.request, s._options, s._decorateResponse(a.clone()));
416
423
  l instanceof globalThis.Response && (a = l);
417
424
  }
418
- if (r._decorateResponse(a), !a.ok && r._options.throwHttpErrors) {
419
- let u = new X(a, r.request, r._options);
420
- for (const l of r._options.hooks.beforeError)
425
+ if (s._decorateResponse(a), !a.ok && s._options.throwHttpErrors) {
426
+ let u = new Z(a, s.request, s._options);
427
+ for (const l of s._options.hooks.beforeError)
421
428
  u = await l(u);
422
429
  throw u;
423
430
  }
424
- if (r._options.onDownloadProgress) {
425
- if (typeof r._options.onDownloadProgress != "function")
431
+ if (s._options.onDownloadProgress) {
432
+ if (typeof s._options.onDownloadProgress != "function")
426
433
  throw new TypeError("The `onDownloadProgress` option must be a function");
427
- if (!Nt)
434
+ if (!jt)
428
435
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
429
- return r._stream(a.clone(), r._options.onDownloadProgress);
436
+ return s._stream(a.clone(), s._options.onDownloadProgress);
430
437
  }
431
438
  return a;
432
- }, c = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(n) : n();
433
- for (const [a, u] of Object.entries(Ht))
439
+ }, c = s._options.retry.methods.includes(s.request.method.toLowerCase()) ? s._retry(n) : n();
440
+ for (const [a, u] of Object.entries(Lt))
434
441
  c[a] = async () => {
435
- r.request.headers.set("accept", r.request.headers.get("accept") || u);
442
+ s.request.headers.set("accept", s.request.headers.get("accept") || u);
436
443
  const h = (await c).clone();
437
444
  if (a === "json") {
438
445
  if (h.status === 204 || (await h.clone().arrayBuffer()).byteLength === 0)
@@ -475,17 +482,17 @@ class q {
475
482
  // TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
476
483
  credentials: this._input.credentials || "same-origin",
477
484
  ...e,
478
- headers: ot(this._input.headers, e.headers),
479
- hooks: J({
485
+ headers: ut(this._input.headers, e.headers),
486
+ hooks: K({
480
487
  beforeRequest: [],
481
488
  beforeRetry: [],
482
489
  beforeError: [],
483
490
  afterResponse: []
484
491
  }, e.hooks),
485
- method: Ut(e.method ?? this._input.method),
492
+ method: Ft(e.method ?? this._input.method),
486
493
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
487
494
  prefixUrl: String(e.prefixUrl || ""),
488
- retry: Gt(e.retry),
495
+ retry: Yt(e.retry),
489
496
  throwHttpErrors: e.throwHttpErrors !== !1,
490
497
  timeout: e.timeout ?? 1e4,
491
498
  fetch: e.fetch ?? globalThis.fetch.bind(globalThis)
@@ -496,30 +503,30 @@ class q {
496
503
  throw new Error("`input` must not begin with a slash when using `prefixUrl`");
497
504
  this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
498
505
  }
499
- if (Pt) {
506
+ if (Nt) {
500
507
  if (this.abortController = new globalThis.AbortController(), this._options.signal) {
501
- const r = this._options.signal;
508
+ const s = this._options.signal;
502
509
  this._options.signal.addEventListener("abort", () => {
503
- this.abortController.abort(r.reason);
510
+ this.abortController.abort(s.reason);
504
511
  });
505
512
  }
506
513
  this._options.signal = this.abortController.signal;
507
514
  }
508
- if (xt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
515
+ if (Pt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
509
516
  const n = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, n);
510
- (jt && 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);
517
+ (Ht && 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);
511
518
  }
512
519
  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 }));
513
520
  }
514
521
  _calculateRetryDelay(t) {
515
- if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof it)) {
516
- if (t instanceof X) {
522
+ if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof ct)) {
523
+ if (t instanceof Z) {
517
524
  if (!this._options.retry.statusCodes.includes(t.response.status))
518
525
  return 0;
519
- const r = t.response.headers.get("Retry-After");
520
- if (r && this._options.retry.afterStatusCodes.includes(t.response.status)) {
521
- let n = Number(r);
522
- return Number.isNaN(n) ? n = Date.parse(r) - Date.now() : n *= 1e3, this._options.retry.maxRetryAfter !== void 0 && n > this._options.retry.maxRetryAfter ? 0 : n;
526
+ const s = t.response.headers.get("Retry-After");
527
+ if (s && this._options.retry.afterStatusCodes.includes(t.response.status)) {
528
+ let n = Number(s);
529
+ return Number.isNaN(n) ? n = Date.parse(s) - Date.now() : n *= 1e3, this._options.retry.maxRetryAfter !== void 0 && n > this._options.retry.maxRetryAfter ? 0 : n;
523
530
  }
524
531
  if (t.response.status === 413)
525
532
  return 0;
@@ -536,16 +543,16 @@ class q {
536
543
  try {
537
544
  return await t();
538
545
  } catch (e) {
539
- const r = Math.min(this._calculateRetryDelay(e), D);
540
- if (r !== 0 && this._retryCount > 0) {
541
- await zt(r, { signal: this._options.signal });
546
+ const s = Math.min(this._calculateRetryDelay(e), U);
547
+ if (s !== 0 && this._retryCount > 0) {
548
+ await Jt(s, { signal: this._options.signal });
542
549
  for (const n of this._options.hooks.beforeRetry)
543
550
  if (await n({
544
551
  request: this.request,
545
552
  options: this._options,
546
553
  error: e,
547
554
  retryCount: this._retryCount
548
- }) === ct)
555
+ }) === ht)
549
556
  return;
550
557
  return this._retry(t);
551
558
  }
@@ -554,29 +561,29 @@ class q {
554
561
  }
555
562
  async _fetch() {
556
563
  for (const e of this._options.hooks.beforeRequest) {
557
- const r = await e(this.request, this._options);
558
- if (r instanceof Request) {
559
- this.request = r;
564
+ const s = await e(this.request, this._options);
565
+ if (s instanceof Request) {
566
+ this.request = s;
560
567
  break;
561
568
  }
562
- if (r instanceof Response)
563
- return r;
569
+ if (s instanceof Response)
570
+ return s;
564
571
  }
565
- const t = Jt(this.request, this._options);
566
- return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Yt(this.request.clone(), t, this.abortController, this._options);
572
+ const t = Kt(this.request, this._options);
573
+ return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : zt(this.request.clone(), t, this.abortController, this._options);
567
574
  }
568
575
  /* istanbul ignore next */
569
576
  _stream(t, e) {
570
- const r = Number(t.headers.get("content-length")) || 0;
577
+ const s = Number(t.headers.get("content-length")) || 0;
571
578
  let n = 0;
572
- return t.status === 204 ? (e && e({ percent: 1, totalBytes: r, transferredBytes: n }, new Uint8Array()), new globalThis.Response(null, {
579
+ return t.status === 204 ? (e && e({ percent: 1, totalBytes: s, transferredBytes: n }, new Uint8Array()), new globalThis.Response(null, {
573
580
  status: t.status,
574
581
  statusText: t.statusText,
575
582
  headers: t.headers
576
583
  })) : new globalThis.Response(new globalThis.ReadableStream({
577
584
  async start(i) {
578
585
  const c = t.body.getReader();
579
- e && e({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array());
586
+ e && e({ percent: 0, transferredBytes: 0, totalBytes: s }, new Uint8Array());
580
587
  async function a() {
581
588
  const { done: u, value: l } = await c.read();
582
589
  if (u) {
@@ -585,8 +592,8 @@ class q {
585
592
  }
586
593
  if (e) {
587
594
  n += l.byteLength;
588
- const h = r === 0 ? 0 : n / r;
589
- e({ percent: h, transferredBytes: n, totalBytes: r }, l);
595
+ const h = s === 0 ? 0 : n / s;
596
+ e({ percent: h, transferredBytes: n, totalBytes: s }, l);
590
597
  }
591
598
  i.enqueue(l), await a();
592
599
  }
@@ -600,88 +607,88 @@ class q {
600
607
  }
601
608
  }
602
609
  /*! MIT License © Sindre Sorhus */
603
- const F = (s) => {
604
- const t = (e, r) => q.create(e, M(s, r));
605
- for (const e of at)
606
- t[e] = (r, n) => q.create(r, M(s, n, { method: e }));
607
- return t.create = (e) => F(M(e)), t.extend = (e) => F(M(s, e)), t.stop = ct, t;
608
- }, Kt = F(), Qt = Kt, Xt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, tt = Qt.create({ headers: Xt }), Zt = {
609
- get: (s, t) => tt.get(s, t).json(),
610
- post: (s, t) => tt.post(s, t).json()
611
- }, et = Object.values(o), te = (s = "") => {
612
- const t = s.toUpperCase(), [e] = t.split(".");
613
- if (et.includes(e))
610
+ const F = (r) => {
611
+ const t = (e, s) => P.create(e, V(r, s));
612
+ for (const e of lt)
613
+ t[e] = (s, n) => P.create(s, V(r, n, { method: e }));
614
+ return t.create = (e) => F(V(e)), t.extend = (e) => F(V(r, e)), t.stop = ht, t;
615
+ }, Qt = F(), Xt = Qt, Zt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, et = Xt.create({ headers: Zt }), te = {
616
+ get: (r, t) => et.get(r, t).json(),
617
+ post: (r, t) => et.post(r, t).json()
618
+ }, st = Object.values(o), ee = (r = "") => {
619
+ const t = r.toUpperCase(), [e] = t.split(".");
620
+ if (st.includes(e))
614
621
  return !0;
615
- const [r] = t.split("/");
616
- if (et.includes(r))
622
+ const [s] = t.split("/");
623
+ if (st.includes(s))
617
624
  return !0;
618
625
  throw new Error(
619
- `Invalid identifier: ${s}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
626
+ `Invalid identifier: ${r}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
620
627
  );
621
- }, I = 8, $ = (s) => 10n ** BigInt(s), R = (s) => Math.log10(parseFloat(s.toString()));
622
- function x({
623
- value: s,
628
+ }, I = 8, $ = (r) => 10n ** BigInt(r), R = (r) => Math.log10(parseFloat(r.toString()));
629
+ function N({
630
+ value: r,
624
631
  bigIntDecimal: t = I,
625
632
  decimal: e = I
626
633
  }) {
627
- const r = s < 0n;
628
- let n = s.toString().substring(r ? 1 : 0);
634
+ const s = r < 0n;
635
+ let n = r.toString().substring(s ? 1 : 0);
629
636
  const i = e - (n.length - 1);
630
637
  i > 0 && (n = "0".repeat(i) + n);
631
638
  const c = n.length - e;
632
639
  let a = n.slice(-e);
633
- return parseInt(a[t]) >= 5 ? a = `${a.substring(0, t - 1)}${(parseInt(a[t - 1]) + 1).toString()}` : a = a.substring(0, t), `${r ? "-" : ""}${n.slice(0, c)}.${a}`.replace(
640
+ return parseInt(a[t]) >= 5 ? a = `${a.substring(0, t - 1)}${(parseInt(a[t - 1]) + 1).toString()}` : a = a.substring(0, t), `${s ? "-" : ""}${n.slice(0, c)}.${a}`.replace(
634
641
  /\.?0*$/,
635
642
  ""
636
643
  );
637
644
  }
638
- var A, S, P, lt, N, ht, O, W, v, C, B, G;
639
- const K = class K {
645
+ var A, S, O, W, j, pt, B, G, v, C, M, Y;
646
+ const Q = class Q {
640
647
  constructor(t) {
641
648
  y(this, A);
642
- y(this, P);
643
- y(this, N);
644
649
  y(this, O);
645
- y(this, v);
650
+ y(this, j);
646
651
  y(this, B);
652
+ y(this, v);
653
+ y(this, M);
647
654
  f(this, "decimalMultiplier", 10n ** 8n);
648
655
  f(this, "bigIntValue", 0n);
649
656
  f(this, "decimal");
650
- const e = U(t);
657
+ const e = q(t);
651
658
  this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = $(
652
- Math.max(m(this, B, G).call(this, m(this, v, C).call(this, e)), this.decimal || 0)
653
- ), m(this, P, lt).call(this, e);
659
+ Math.max(d(this, M, Y).call(this, d(this, v, C).call(this, e)), this.decimal || 0)
660
+ ), d(this, O, W).call(this, e);
654
661
  }
655
662
  static fromBigInt(t, e) {
656
- return new K({
663
+ return new Q({
657
664
  decimal: e,
658
- value: x({ value: t, bigIntDecimal: e, decimal: e })
665
+ value: N({ value: t, bigIntDecimal: e, decimal: e })
659
666
  });
660
667
  }
661
668
  static shiftDecimals({
662
669
  value: t,
663
670
  from: e,
664
- to: r
671
+ to: s
665
672
  }) {
666
673
  return this.fromBigInt(
667
- t.getBaseValue("bigint") * $(r) / $(e),
668
- r
674
+ t.getBaseValue("bigint") * $(s) / $(e),
675
+ s
669
676
  );
670
677
  }
671
678
  set(t) {
672
- return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
679
+ return d(this, O, W).call(this, q(t)), this;
673
680
  }
674
681
  add(...t) {
675
- return m(this, A, S).call(this, "add", ...t);
682
+ return d(this, A, S).call(this, "add", ...t);
676
683
  }
677
684
  sub(...t) {
678
- return m(this, A, S).call(this, "sub", ...t);
685
+ return d(this, A, S).call(this, "sub", ...t);
679
686
  }
680
687
  mul(...t) {
681
- return m(this, A, S).call(this, "mul", ...t);
688
+ return d(this, A, S).call(this, "mul", ...t);
682
689
  }
683
690
  div(...t) {
684
- return m(this, A, S).call(this, "div", ...t);
691
+ return d(this, A, S).call(this, "div", ...t);
685
692
  }
686
693
  gt(t) {
687
694
  return this.bigIntValue > this.getBigIntValue(t);
@@ -713,35 +720,35 @@ const K = class K {
713
720
  }
714
721
  }
715
722
  getBaseValue(t) {
716
- const e = this.decimalMultiplier / $(this.decimal || d.THOR), r = this.bigIntValue / e;
723
+ const e = this.decimalMultiplier / $(this.decimal || p.THOR), s = this.bigIntValue / e;
717
724
  switch (t) {
718
725
  case "number":
719
- return Number(r);
726
+ return Number(s);
720
727
  case "string":
721
- return r.toString();
728
+ return s.toString();
722
729
  default:
723
- return r;
730
+ return s;
724
731
  }
725
732
  }
726
733
  getBigIntValue(t, e) {
727
734
  if (!e && typeof t == "object")
728
735
  return t.bigIntValue;
729
- const r = U(t), n = m(this, v, C).call(this, r);
730
- return n === "0" || n === "undefined" ? 0n : m(this, O, W).call(this, n, e);
736
+ const s = q(t), n = d(this, v, C).call(this, s);
737
+ return n === "0" || n === "undefined" ? 0n : d(this, B, G).call(this, n, e);
731
738
  }
732
739
  formatBigIntToSafeValue(t, e) {
733
- const r = e || this.decimal || I, n = Math.max(
734
- r,
740
+ const s = e || this.decimal || I, n = Math.max(
741
+ s,
735
742
  R(this.decimalMultiplier)
736
743
  ), i = t < 0n, c = t.toString().substring(i ? 1 : 0), a = n - (c.length - 1), u = a > 0 ? "0".repeat(a) + c : c, l = u.length - n;
737
744
  let h = u.slice(-n);
738
- return parseInt(h[r]) >= 5 ? h = `${h.substring(0, r - 1)}${(parseInt(h[r - 1]) + 1).toString()}` : h = h.substring(0, r), `${i ? "-" : ""}${u.slice(
745
+ return parseInt(h[s]) >= 5 ? h = `${h.substring(0, s - 1)}${(parseInt(h[s - 1]) + 1).toString()}` : h = h.substring(0, s), `${i ? "-" : ""}${u.slice(
739
746
  0,
740
747
  l
741
748
  )}.${h}`.replace(/\.?0*$/, "");
742
749
  }
743
750
  toSignificant(t = 6) {
744
- const [e, r] = this.getValue("string").split("."), n = e || "", i = r || "";
751
+ const [e, s] = this.getValue("string").split("."), n = e || "", i = s || "";
745
752
  if ((parseInt(n) ? n.length + i.length : i.length) <= t)
746
753
  return this.getValue("string");
747
754
  if (n.length >= t)
@@ -758,7 +765,7 @@ const K = class K {
758
765
  )}`;
759
766
  }
760
767
  toFixed(t = 6) {
761
- const [e, r] = this.getValue("string").split("."), n = e || "", i = r || "";
768
+ const [e, s] = this.getValue("string").split("."), n = e || "", i = s || "";
762
769
  if (parseInt(n))
763
770
  return `${n}.${i.slice(0, t)}`.padEnd(t, "0");
764
771
  const c = parseInt(i), a = `${c}`.slice(0, t);
@@ -768,7 +775,7 @@ const K = class K {
768
775
  )}`;
769
776
  }
770
777
  toAbbreviation(t = 2) {
771
- const e = this.getValue("number"), r = ["", "K", "M", "B", "T", "Q", "Qi", "S"], n = Math.floor(Math.log10(Math.abs(e)) / 3), i = r[n];
778
+ const e = this.getValue("number"), s = ["", "K", "M", "B", "T", "Q", "Qi", "S"], n = Math.floor(Math.log10(Math.abs(e)) / 3), i = s[n];
772
779
  if (!i)
773
780
  return this.getValue("string");
774
781
  const c = 10 ** (n * 3);
@@ -776,18 +783,18 @@ const K = class K {
776
783
  }
777
784
  toCurrency(t = "$", {
778
785
  currencyPosition: e = "start",
779
- decimal: r = 2,
786
+ decimal: s = 2,
780
787
  decimalSeparator: n = ".",
781
788
  thousandSeparator: i = ","
782
789
  } = {}) {
783
- const c = this.getValue("number"), [a, u = ""] = c.toFixed(6).split("."), l = a.replace(/\B(?=(\d{3})+(?!\d))/g, i), h = !a && !u ? "0.00" : a === "0" ? `${parseFloat(`0.${u}`)}`.replace(".", n) : `${l}${u ? `${n}${u.slice(0, r)}` : ""}`;
790
+ const c = this.getValue("number"), [a, u = ""] = c.toFixed(6).split("."), l = a.replace(/\B(?=(\d{3})+(?!\d))/g, i), h = !a && !u ? "0.00" : a === "0" ? `${parseFloat(`0.${u}`)}`.replace(".", n) : `${l}${u ? `${n}${u.slice(0, s)}` : ""}`;
784
791
  return `${e === "start" ? t : ""}${h}${e === "end" ? t : ""}`;
785
792
  }
786
793
  };
787
794
  A = new WeakSet(), S = function(t, ...e) {
788
- const r = m(this, N, ht).call(this, this, ...e), n = $(r), i = e.reduce(
795
+ const s = d(this, j, pt).call(this, this, ...e), n = $(s), i = e.reduce(
789
796
  (a, u) => {
790
- const l = this.getBigIntValue(u, r);
797
+ const l = this.getBigIntValue(u, s);
791
798
  switch (t) {
792
799
  case "add":
793
800
  return a + l;
@@ -806,100 +813,104 @@ A = new WeakSet(), S = function(t, ...e) {
806
813
  },
807
814
  //normalize is to precision multiplier base
808
815
  this.bigIntValue * n / this.decimalMultiplier
809
- ), c = x({
810
- bigIntDecimal: r,
811
- decimal: Math.max(r, R(this.decimalMultiplier)),
816
+ ), c = N({
817
+ bigIntDecimal: s,
818
+ decimal: Math.max(s, R(this.decimalMultiplier)),
812
819
  value: i
813
820
  });
814
821
  return new this.constructor({ decimal: this.decimal, value: c, identifier: this.toString() });
815
- }, P = new WeakSet(), lt = function(t) {
816
- const e = m(this, v, C).call(this, t) || "0";
817
- this.bigIntValue = m(this, O, W).call(this, e);
818
- }, N = new WeakSet(), ht = function(...t) {
822
+ }, O = new WeakSet(), W = function(t) {
823
+ const e = d(this, v, C).call(this, t) || "0";
824
+ this.bigIntValue = d(this, B, G).call(this, e);
825
+ }, j = new WeakSet(), pt = function(...t) {
819
826
  const e = t.map(
820
- (r) => typeof r == "object" ? r.decimal || R(r.decimalMultiplier) : m(this, B, G).call(this, m(this, v, C).call(this, r))
827
+ (s) => typeof s == "object" ? s.decimal || R(s.decimalMultiplier) : d(this, M, Y).call(this, d(this, v, C).call(this, s))
821
828
  ).filter(Boolean);
822
829
  return Math.max(...e, I);
823
- }, O = new WeakSet(), W = function(t, e) {
824
- const r = e ? $(e) : this.decimalMultiplier, n = R(r), [i = "", c = ""] = t.split(".");
830
+ }, B = new WeakSet(), G = function(t, e) {
831
+ const s = e ? $(e) : this.decimalMultiplier, n = R(s), [i = "", c = ""] = t.split(".");
825
832
  return BigInt(`${i}${c.padEnd(n, "0")}`);
826
833
  }, v = new WeakSet(), C = function(t) {
827
- const r = `${typeof t == "number" ? Number(t).toLocaleString("fullwide", {
834
+ const s = `${typeof t == "number" ? Number(t).toLocaleString("fullwide", {
828
835
  useGrouping: !1,
829
836
  maximumFractionDigits: 20
830
- }) : U(t)}`.replaceAll(",", ".").split(".");
831
- return r.length > 1 ? `${r.slice(0, -1).join("")}.${r.at(-1)}` : r[0];
832
- }, B = new WeakSet(), G = function(t) {
833
- var r;
834
- const e = ((r = t.split(".")[1]) == null ? void 0 : r.length) || 0;
837
+ }) : q(t)}`.replaceAll(",", ".").split(".");
838
+ return s.length > 1 ? `${s.slice(0, -1).join("")}.${s.at(-1)}` : s[0];
839
+ }, M = new WeakSet(), Y = function(t) {
840
+ var s;
841
+ const e = ((s = t.split(".")[1]) == null ? void 0 : s.length) || 0;
835
842
  return Math.max(e, I);
836
843
  };
837
- let E = K;
838
- function U(s) {
839
- return typeof s == "object" ? "getValue" in s ? s.getValue("string") : s.value : s;
844
+ let E = Q;
845
+ function q(r) {
846
+ return typeof r == "object" ? "getValue" in r ? r.getValue("string") : r.value : r;
840
847
  }
841
- const k = (s, t) => typeof s == "bigint" ? x({ value: s, bigIntDecimal: t, decimal: t }) : s;
842
- let Y;
843
- const rt = (s) => {
844
- if (!Y)
848
+ const k = (r, t) => typeof r == "bigint" ? N({ value: r, bigIntDecimal: t, decimal: t }) : r;
849
+ let z;
850
+ const rt = (r) => {
851
+ if (!z)
845
852
  throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
846
- return Y.get(s.toUpperCase()) || { decimal: d.THOR, identifier: "" };
847
- }, st = async (s, t = 0) => {
848
- te(s);
849
- const e = await St(z(s)), r = k(t, e);
850
- return new w({ decimal: e, value: r, identifier: s });
851
- };
853
+ return z.get(r.toUpperCase()) || { decimal: p.THOR, identifier: "" };
854
+ }, nt = async (r, t = 0) => {
855
+ ee(r);
856
+ const e = await It(J(r)), s = k(t, e);
857
+ return new w({ decimal: e, value: s, identifier: r });
858
+ }, it = /* @__PURE__ */ new Map();
852
859
  class w extends E {
853
860
  constructor(e) {
861
+ const s = "identifier" in e ? e.identifier : `${e.chain}.${e.symbol}`, n = it.get(s);
862
+ if (n)
863
+ return n.set(e.value);
854
864
  super(
855
865
  e.value instanceof E ? e.value : { decimal: e.decimal, value: e.value }
856
866
  );
857
867
  f(this, "address");
858
- f(this, "chain");
859
868
  f(this, "isSynthetic", !1);
860
869
  f(this, "isGasAsset", !1);
870
+ // @ts-expect-error cache is false positive on that case
871
+ f(this, "chain");
872
+ // @ts-expect-error cache is false positive on that case
861
873
  f(this, "symbol");
874
+ // @ts-expect-error cache is false positive on that case
862
875
  f(this, "ticker");
876
+ // @ts-expect-error cache is false positive on that case
863
877
  f(this, "type");
864
- const r = "identifier" in e ? e.identifier : `${e.chain}.${e.symbol}`, n = z(r);
865
- this.type = Et(n), this.chain = n.chain, this.ticker = n.ticker, this.symbol = n.symbol, this.address = n.address, this.isSynthetic = n.isSynthetic, this.isGasAsset = n.isGasAsset;
866
- }
867
- get assetValue() {
868
- return `${this.getValue("string")} ${this.ticker}`;
878
+ const i = J(s);
879
+ this.type = Ot(i), this.chain = i.chain, this.ticker = i.ticker, this.symbol = i.symbol, this.address = i.address, this.isSynthetic = i.isSynthetic, this.isGasAsset = i.isGasAsset, it.set(s, this);
869
880
  }
870
881
  toString(e = !1) {
871
- const r = this.isSynthetic ? this.symbol.split("-")[0] : `${this.chain}.${this.ticker}`;
872
- return e ? r : (
882
+ const s = this.isSynthetic ? this.symbol.split("-")[0] : this.ticker;
883
+ return e ? s : (
873
884
  // THOR.ETH/ETH | ETH.USDT-0x1234567890
874
885
  `${this.chain}.${this.symbol}`
875
886
  );
876
887
  }
877
- eq({ chain: e, symbol: r }) {
878
- return this.chain === e && this.symbol === r;
888
+ eq({ chain: e, symbol: s }) {
889
+ return this.chain === e && this.symbol === s;
879
890
  }
880
- static async fromString(e, r = 0) {
881
- return st(e, r);
891
+ static async fromString(e, s = 0) {
892
+ return nt(e, s);
882
893
  }
883
- static fromStringSync(e, r = 0) {
884
- const { isSynthetic: n } = z(e), { decimal: i, identifier: c } = rt(
894
+ static fromStringSync(e, s = 0) {
895
+ const { isSynthetic: n } = J(e), { decimal: i, identifier: c } = rt(
885
896
  e
886
- ), a = k(r, i);
897
+ ), a = k(s, i);
887
898
  return c ? new w({ decimal: i, identifier: c, value: a }) : n ? new w({ decimal: 8, identifier: e, value: a }) : void 0;
888
899
  }
889
- static async fromIdentifier(e, r = 0) {
890
- return st(e, r);
900
+ static async fromIdentifier(e, s = 0) {
901
+ return nt(e, s);
891
902
  }
892
- static fromIdentifierSync(e, r = 0) {
893
- const { decimal: n, identifier: i } = rt(e), c = k(r, n);
903
+ static fromIdentifierSync(e, s = 0) {
904
+ const { decimal: n, identifier: i } = rt(e), c = k(s, n);
894
905
  return new w({ decimal: n, identifier: i, value: c });
895
906
  }
896
- static fromChainOrSignature(e, r = 0) {
897
- const { decimal: n, identifier: i } = It(e), c = k(r, n);
907
+ static fromChainOrSignature(e, s = 0) {
908
+ const { decimal: n, identifier: i } = Et(e), c = k(s, n);
898
909
  return new w({ value: c, decimal: n, identifier: i });
899
910
  }
900
911
  static async loadStaticAssets() {
901
912
  return new Promise(
902
- async (e, r) => {
913
+ async (e, s) => {
903
914
  try {
904
915
  const {
905
916
  // Omit ThorchainList from import to avoid decimals conflict (TC uses 8 for all)
@@ -908,15 +919,15 @@ class w extends E {
908
919
  NativeList: i,
909
920
  ...c
910
921
  } = await import("@swapkit/tokens");
911
- Y = [i, ...Object.values(c)].reduce(
922
+ z = [i, ...Object.values(c)].reduce(
912
923
  (u, { tokens: l }) => (l.forEach(({ identifier: h, chain: _, ...T }) => {
913
- const j = "decimals" in T ? T.decimals : d[_];
914
- u.set(h, { identifier: h, decimal: j });
924
+ const H = "decimals" in T ? T.decimals : p[_];
925
+ u.set(h, { identifier: h, decimal: H });
915
926
  }), u),
916
927
  /* @__PURE__ */ new Map()
917
928
  ), e({ ok: !0 });
918
929
  } catch (n) {
919
- console.error(n), r({
930
+ console.error(n), s({
920
931
  ok: !1,
921
932
  error: n,
922
933
  message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
@@ -926,9 +937,9 @@ class w extends E {
926
937
  );
927
938
  }
928
939
  }
929
- const _e = (s) => {
930
- const t = w.fromChainOrSignature(s);
931
- switch (s) {
940
+ const ge = (r) => {
941
+ const t = w.fromChainOrSignature(r);
942
+ switch (r) {
932
943
  case o.Bitcoin:
933
944
  case o.Litecoin:
934
945
  case o.BitcoinCash:
@@ -944,17 +955,17 @@ const _e = (s) => {
944
955
  default:
945
956
  return t.set(1e-8);
946
957
  }
947
- }, z = (s) => {
948
- const t = s.slice(0, 14).includes("/"), [e, r] = s.split(".").pop().split("/"), n = s.includes(".") && !t ? s : `${o.THORChain}.${r}`, [i, c] = n.split("."), [a, u] = (t ? r : c).split("-");
958
+ }, J = (r) => {
959
+ const t = r.slice(0, 14).includes("/"), [e, s] = r.split(".").pop().split("/"), n = r.includes(".") && !t ? r : `${o.THORChain}.${s}`, [i, c] = n.split("."), [a, u] = (t ? s : c).split("-");
949
960
  return {
950
961
  address: u == null ? void 0 : u.toLowerCase(),
951
962
  chain: i,
952
- isGasAsset: Ct({ chain: i, symbol: c }),
963
+ isGasAsset: at({ chain: i, symbol: c }),
953
964
  isSynthetic: t,
954
965
  symbol: (t ? `${e}/` : "") + (u ? `${a}-${(u == null ? void 0 : u.toLowerCase()) ?? ""}` : c),
955
966
  ticker: a
956
967
  };
957
- }, ee = {
968
+ }, se = {
958
969
  /**
959
970
  * Core
960
971
  */
@@ -1011,9 +1022,9 @@ const _e = (s) => {
1011
1022
  */
1012
1023
  helpers_number_different_decimals: 99101
1013
1024
  };
1014
- class dt extends Error {
1025
+ class mt extends Error {
1015
1026
  constructor(t, e) {
1016
- console.error(e), super(t, { cause: { code: ee[t], message: t } }), Object.setPrototypeOf(this, dt.prototype);
1027
+ console.error(e), super(t, { cause: { code: se[t], message: t } }), Object.setPrototypeOf(this, mt.prototype);
1017
1028
  }
1018
1029
  }
1019
1030
  class b extends E {
@@ -1023,35 +1034,35 @@ class b extends E {
1023
1034
  static fromBigInt(t, e) {
1024
1035
  return new b({
1025
1036
  decimal: e,
1026
- value: x({ value: t, bigIntDecimal: e, decimal: e })
1037
+ value: N({ value: t, bigIntDecimal: e, decimal: e })
1027
1038
  });
1028
1039
  }
1029
1040
  }
1030
1041
  export {
1031
1042
  w as AssetValue,
1032
1043
  E as BigIntArithmetics,
1033
- Zt as RequestClient,
1034
- dt as SwapKitError,
1044
+ te as RequestClient,
1045
+ mt as SwapKitError,
1035
1046
  b as SwapKitNumber,
1036
- ie as assetFromString,
1037
- fe as derivationPathToString,
1038
- oe as filterAssets,
1039
- x as formatBigIntToSafeValue,
1040
- ne as gasFeeMultiplier,
1041
- Et as getAssetType,
1042
- Vt as getAsymmetricAssetShare,
1043
- ce as getAsymmetricAssetWithdrawAmount,
1044
- Mt as getAsymmetricRuneShare,
1045
- ae as getAsymmetricRuneWithdrawAmount,
1046
- It as getCommonAssetInfo,
1047
- St as getDecimal,
1048
- le as getEstimatedPoolShare,
1049
- he as getLiquiditySlippage,
1050
- de as getMemoFor,
1051
- _e as getMinAmountByChain,
1052
- kt as getSymmetricPoolShare,
1053
- ue as getSymmetricWithdraw,
1047
+ oe as assetFromString,
1048
+ _e as derivationPathToString,
1049
+ ae as filterAssets,
1050
+ N as formatBigIntToSafeValue,
1051
+ ie as gasFeeMultiplier,
1052
+ Ot as getAssetType,
1053
+ qt as getAsymmetricAssetShare,
1054
+ ue as getAsymmetricAssetWithdrawAmount,
1055
+ Vt as getAsymmetricRuneShare,
1056
+ ce as getAsymmetricRuneWithdrawAmount,
1057
+ Et as getCommonAssetInfo,
1058
+ It as getDecimal,
1059
+ he as getEstimatedPoolShare,
1060
+ de as getLiquiditySlippage,
1061
+ pe as getMemoFor,
1062
+ ge as getMinAmountByChain,
1063
+ xt as getSymmetricPoolShare,
1064
+ le as getSymmetricWithdraw,
1054
1065
  me as getTHORNameCost,
1055
- Ct as isGasAsset,
1056
- pe as validateTHORName
1066
+ at as isGasAsset,
1067
+ fe as validateTHORName
1057
1068
  };