@swapkit/core 1.0.0-rc.56 → 1.0.0-rc.58

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
@@ -690,19 +690,19 @@ let wn = class Ce extends Error {
690
690
  code: s,
691
691
  message: r,
692
692
  type: o,
693
- options: { shouldLog: p, shouldThrow: d, shouldTrace: l } = {
693
+ options: { shouldLog: p, shouldThrow: d, shouldTrace: u } = {
694
694
  shouldLog: !0,
695
695
  shouldThrow: !0,
696
696
  shouldTrace: !0
697
697
  },
698
- displayMessageParams: u
698
+ displayMessageParams: l
699
699
  }) {
700
- const c = r || re(s, u || []) || "";
701
- super(c), C(this, "status"), C(this, "revision"), C(this, "type"), C(this, "module"), C(this, "code"), C(this, "message"), C(this, "display"), C(this, "stack"), C(this, "options"), C(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = re(s, u || []), this.code = s, this.type = o || ve.UNHANDLED_ERROR, this.options = {
700
+ const m = r || re(s, l || []) || "";
701
+ super(m), C(this, "status"), C(this, "revision"), C(this, "type"), C(this, "module"), C(this, "code"), C(this, "message"), C(this, "display"), C(this, "stack"), C(this, "options"), C(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = m, this.display = re(s, l || []), this.code = s, this.type = o || ve.UNHANDLED_ERROR, this.options = {
702
702
  shouldLog: p || !0,
703
- shouldTrace: l || !0,
703
+ shouldTrace: u || !0,
704
704
  shouldThrow: d || !1
705
- }, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
705
+ }, this.displayMessageParams = l || [], this.options.shouldTrace && Error.captureStackTrace(this);
706
706
  }
707
707
  static fromErrorInfo(t) {
708
708
  return new Ce(t);
@@ -839,7 +839,7 @@ const ae = Object.values(i), ot = Object.keys(i), fe = ae.reduce(
839
839
  var ut = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(ut || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), lt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(lt || {}), yt = Object.defineProperty, ct = (e, t, n) => t in e ? yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, I = (e, t, n) => (ct(e, typeof t != "symbol" ? t + "" : t, n), n), mt = (e, t, n) => {
840
840
  if (!t.has(e))
841
841
  throw TypeError("Cannot " + n);
842
- }, $ = (e, t, n) => {
842
+ }, H = (e, t, n) => {
843
843
  if (t.has(e))
844
844
  throw TypeError("Cannot add the same private member more than once");
845
845
  t instanceof WeakSet ? t.add(e) : t.set(e, n);
@@ -992,15 +992,15 @@ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
992
992
  poolUnits: t,
993
993
  runeDepth: n
994
994
  }) => {
995
- const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = s.mul(s).mul(s);
996
- return o.mul(p.sub(d).add(l)).div(u);
995
+ const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), u = a.mul(a), l = s.mul(s).mul(s);
996
+ return o.mul(p.sub(d).add(u)).div(l);
997
997
  }, St = ({
998
998
  liquidityUnits: e,
999
999
  poolUnits: t,
1000
1000
  assetDepth: n
1001
1001
  }) => {
1002
- const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = o.mul(p.sub(d).add(l)), c = s.mul(s).mul(s);
1003
- return u.div(c);
1002
+ const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), u = a.mul(a), l = o.mul(p.sub(d).add(u)), m = s.mul(s).mul(s);
1003
+ return l.div(m);
1004
1004
  }, Cn = ({
1005
1005
  percent: e,
1006
1006
  runeDepth: t,
@@ -1037,7 +1037,7 @@ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
1037
1037
  runeAmount: s,
1038
1038
  assetAmount: r
1039
1039
  }) => {
1040
- const o = new x({ value: e, decimal: 8 }), p = new x({ value: n, decimal: 8 }), d = new x({ value: t, decimal: 8 }), l = new x({ value: s, decimal: 8 }), u = new x({ value: r, decimal: 8 }), c = l.mul(p), _ = u.mul(o), b = l.mul(u), A = o.mul(p), E = d.mul(c.add(_.add(b.mul(2)))), O = c.add(_.add(A.mul(2))), S = E.div(O), D = g(a).add(S);
1040
+ const o = new x({ value: e, decimal: 8 }), p = new x({ value: n, decimal: 8 }), d = new x({ value: t, decimal: 8 }), u = new x({ value: s, decimal: 8 }), l = new x({ value: r, decimal: 8 }), m = u.mul(p), _ = l.mul(o), b = u.mul(l), A = o.mul(p), E = d.mul(m.add(_.add(b.mul(2)))), O = m.add(_.add(A.mul(2))), S = E.div(O), D = g(a).add(S);
1041
1041
  if (S.getBaseValue("number") === 0)
1042
1042
  return D.div(d).getBaseValue("number");
1043
1043
  const ie = d.add(D);
@@ -1050,8 +1050,8 @@ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
1050
1050
  }) => {
1051
1051
  if (e === "0" || t === "0" || n === "0" || a === "0")
1052
1052
  return 0;
1053
- const s = g(n), r = g(a), o = g(t), p = g(e), d = o.mul(s).sub(r.mul(p)), l = r.mul(p).add(s.mul(r));
1054
- return Math.abs(d.div(l).getBaseValue("number"));
1053
+ const s = g(n), r = g(a), o = g(t), p = g(e), d = o.mul(s).sub(r.mul(p)), u = r.mul(p).add(s.mul(r));
1054
+ return Math.abs(d.div(u).getBaseValue("number"));
1055
1055
  }, vt = ({
1056
1056
  symbol: e,
1057
1057
  ticker: t,
@@ -1076,8 +1076,8 @@ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
1076
1076
  return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${s || ""}:t:0`;
1077
1077
  }
1078
1078
  case h.WITHDRAW: {
1079
- const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", l = vt({ chain: n, symbol: s, ticker: a });
1080
- return `${e}:${n}${p ? "/" : "."}${l}:${r}${d}`;
1079
+ const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", u = vt({ chain: n, symbol: s, ticker: a });
1080
+ return `${e}:${n}${p ? "/" : "."}${u}:${r}${d}`;
1081
1081
  }
1082
1082
  case h.OPEN_LOAN:
1083
1083
  case h.CLOSE_LOAN: {
@@ -1201,7 +1201,7 @@ const J = (e) => e !== null && typeof e == "object", X = (...e) => {
1201
1201
  maxRetryAfter: Number.POSITIVE_INFINITY,
1202
1202
  backoffLimit: Number.POSITIVE_INFINITY,
1203
1203
  delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
1204
- }, Ht = (e = {}) => {
1204
+ }, $t = (e = {}) => {
1205
1205
  if (typeof e == "number")
1206
1206
  return {
1207
1207
  ...Ee,
@@ -1217,7 +1217,7 @@ const J = (e) => e !== null && typeof e == "object", X = (...e) => {
1217
1217
  afterStatusCodes: Ue
1218
1218
  };
1219
1219
  };
1220
- async function $t(e, t, n, a) {
1220
+ async function Ht(e, t, n, a) {
1221
1221
  return new Promise((s, r) => {
1222
1222
  const o = setTimeout(() => {
1223
1223
  n && n.abort(), r(new Pe(e));
@@ -1325,7 +1325,7 @@ class Z {
1325
1325
  method: Lt(n.method ?? this._input.method),
1326
1326
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
1327
1327
  prefixUrl: String(n.prefixUrl || ""),
1328
- retry: Ht(n.retry),
1328
+ retry: $t(n.retry),
1329
1329
  throwHttpErrors: n.throwHttpErrors !== !1,
1330
1330
  timeout: n.timeout ?? 1e4,
1331
1331
  fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
@@ -1403,7 +1403,7 @@ class Z {
1403
1403
  return a;
1404
1404
  }
1405
1405
  const t = Ft(this.request, this._options);
1406
- return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : $t(this.request.clone(), t, this.abortController, this._options);
1406
+ return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Ht(this.request.clone(), t, this.abortController, this._options);
1407
1407
  }
1408
1408
  /* istanbul ignore next */
1409
1409
  _stream(t, n) {
@@ -1418,17 +1418,17 @@ class Z {
1418
1418
  const o = t.body.getReader();
1419
1419
  n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
1420
1420
  async function p() {
1421
- const { done: d, value: l } = await o.read();
1421
+ const { done: d, value: u } = await o.read();
1422
1422
  if (d) {
1423
1423
  r.close();
1424
1424
  return;
1425
1425
  }
1426
1426
  if (n) {
1427
- s += l.byteLength;
1428
- const u = a === 0 ? 0 : s / a;
1429
- n({ percent: u, transferredBytes: s, totalBytes: a }, l);
1427
+ s += u.byteLength;
1428
+ const l = a === 0 ? 0 : s / a;
1429
+ n({ percent: l, transferredBytes: s, totalBytes: a }, u);
1430
1430
  }
1431
- r.enqueue(l), await p();
1431
+ r.enqueue(u), await p();
1432
1432
  }
1433
1433
  await p();
1434
1434
  }
@@ -1475,15 +1475,15 @@ function se({
1475
1475
  ""
1476
1476
  );
1477
1477
  }
1478
- var U, k, B, H, le, He, Q, pe, ee, ye;
1479
- const Kt = class $e {
1478
+ var U, k, B, $, le, $e, Q, pe, ee, ye;
1479
+ const Kt = class He {
1480
1480
  constructor(t) {
1481
- $(this, U), $(this, B), $(this, le), $(this, Q), $(this, ee), I(this, "decimalMultiplier", 10n ** 8n), I(this, "bigIntValue", 0n), I(this, "decimal");
1481
+ H(this, U), H(this, B), H(this, le), H(this, Q), H(this, ee), I(this, "decimalMultiplier", 10n ** 8n), I(this, "bigIntValue", 0n), I(this, "decimal");
1482
1482
  const n = me(t), a = typeof t == "object";
1483
- this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max(ke(te(n)), this.decimal || 0)), R(this, le, He).call(this, n);
1483
+ this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max(ke(te(n)), this.decimal || 0)), R(this, le, $e).call(this, n);
1484
1484
  }
1485
1485
  static fromBigInt(t, n) {
1486
- return new $e({
1486
+ return new He({
1487
1487
  decimal: n,
1488
1488
  value: se({ value: t, bigIntDecimal: n, decimal: n })
1489
1489
  });
@@ -1514,19 +1514,19 @@ const Kt = class $e {
1514
1514
  return R(this, U, k).call(this, "div", ...t);
1515
1515
  }
1516
1516
  gt(t) {
1517
- return R(this, B, H).call(this, "gt", t);
1517
+ return R(this, B, $).call(this, "gt", t);
1518
1518
  }
1519
1519
  gte(t) {
1520
- return R(this, B, H).call(this, "gte", t);
1520
+ return R(this, B, $).call(this, "gte", t);
1521
1521
  }
1522
1522
  lt(t) {
1523
- return R(this, B, H).call(this, "lt", t);
1523
+ return R(this, B, $).call(this, "lt", t);
1524
1524
  }
1525
1525
  lte(t) {
1526
- return R(this, B, H).call(this, "lte", t);
1526
+ return R(this, B, $).call(this, "lte", t);
1527
1527
  }
1528
1528
  eqValue(t) {
1529
- return R(this, B, H).call(this, "eqValue", t);
1529
+ return R(this, B, $).call(this, "eqValue", t);
1530
1530
  }
1531
1531
  // @ts-expect-error False positive
1532
1532
  getValue(t) {
@@ -1601,36 +1601,36 @@ const Kt = class $e {
1601
1601
  decimalSeparator: s = ".",
1602
1602
  thousandSeparator: r = ","
1603
1603
  } = {}) {
1604
- const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."), l = p.replace(/\B(?=(\d{3})+(?!\d))/g, r), u = !p && !d ? "0.00" : p === "0" ? `${parseFloat(`0.${d}`)}`.replace(".", s) : `${l}${parseInt(d) ? `${s}${d.slice(0, a)}` : ""}`;
1605
- return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
1604
+ const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."), u = p.replace(/\B(?=(\d{3})+(?!\d))/g, r), l = !p && !d ? "0.00" : p === "0" ? `${parseFloat(`0.${d}`)}`.replace(".", s) : `${u}${parseInt(d) ? `${s}${d.slice(0, a)}` : ""}`;
1605
+ return `${n === "start" ? t : ""}${l}${n === "end" ? t : ""}`;
1606
1606
  }
1607
1607
  formatBigIntToSafeValue(t, n) {
1608
1608
  const a = n || this.decimal || W, s = Math.max(
1609
1609
  a,
1610
1610
  G(this.decimalMultiplier)
1611
- ), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, l = d.length - s;
1612
- let u = d.slice(-s);
1613
- return parseInt(u[a]) >= 5 ? u = `${u.substring(0, a - 1)}${(parseInt(u[a - 1]) + 1).toString()}` : u = u.substring(0, a), `${r ? "-" : ""}${d.slice(
1611
+ ), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, u = d.length - s;
1612
+ let l = d.slice(-s);
1613
+ return parseInt(l[a]) >= 5 ? l = `${l.substring(0, a - 1)}${(parseInt(l[a - 1]) + 1).toString()}` : l = l.substring(0, a), `${r ? "-" : ""}${d.slice(
1614
1614
  0,
1615
- l
1616
- )}.${u}`.replace(/\.?0*$/, "");
1615
+ u
1616
+ )}.${l}`.replace(/\.?0*$/, "");
1617
1617
  }
1618
1618
  };
1619
1619
  U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1620
1620
  const n = R(this, Q, pe).call(this, this, ...t), a = Math.max(n, G(this.decimalMultiplier)), s = L(a), r = t.reduce(
1621
1621
  (p, d) => {
1622
- const l = this.getBigIntValue(d, a);
1622
+ const u = this.getBigIntValue(d, a);
1623
1623
  switch (e) {
1624
1624
  case "add":
1625
- return p + l;
1625
+ return p + u;
1626
1626
  case "sub":
1627
- return p - l;
1627
+ return p - u;
1628
1628
  case "mul":
1629
- return p * l / s;
1629
+ return p * u / s;
1630
1630
  case "div": {
1631
- if (l === 0n)
1631
+ if (u === 0n)
1632
1632
  throw new RangeError("Division by zero");
1633
- return p * s / l;
1633
+ return p * s / u;
1634
1634
  }
1635
1635
  default:
1636
1636
  return p;
@@ -1649,7 +1649,7 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1649
1649
  value: o,
1650
1650
  identifier: this.toString()
1651
1651
  });
1652
- }, B = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
1652
+ }, B = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
1653
1653
  const n = R(this, Q, pe).call(this, this, ...t), a = this.getBigIntValue(t[0], n), s = this.getBigIntValue(this, n);
1654
1654
  switch (e) {
1655
1655
  case "gt":
@@ -1663,7 +1663,7 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1663
1663
  case "eqValue":
1664
1664
  return s === a;
1665
1665
  }
1666
- }, le = /* @__PURE__ */ new WeakSet(), He = function(e) {
1666
+ }, le = /* @__PURE__ */ new WeakSet(), $e = function(e) {
1667
1667
  const t = te(e) || "0";
1668
1668
  this.bigIntValue = R(this, ee, ye).call(this, t);
1669
1669
  }, Q = /* @__PURE__ */ new WeakSet(), pe = function(...e) {
@@ -1752,20 +1752,11 @@ class M extends ce {
1752
1752
  return new Promise(
1753
1753
  async (t, n) => {
1754
1754
  try {
1755
- const {
1756
- // Omit ThorchainList from import to avoid decimals conflict (TC uses 8 for all)
1757
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1758
- ThorchainList: a,
1759
- NativeList: s,
1760
- ...r
1761
- } = await import("@swapkit/tokens");
1762
- Te = [s, ...Object.values(r)].reduce(
1763
- (o, { tokens: p }) => (p.forEach(({ identifier: d, chain: l, ...u }) => {
1764
- const c = "decimals" in u ? u.decimals : w[l];
1765
- o.set(d, { identifier: d, decimal: c });
1766
- }), o),
1767
- /* @__PURE__ */ new Map()
1768
- ), t({ ok: !0 });
1755
+ const a = await import("@swapkit/tokens");
1756
+ Te = Object.values(a).reduce((s, { tokens: r }) => (r.forEach(({ identifier: o, chain: p, ...d }) => {
1757
+ const u = "decimals" in d ? d.decimals : w[p];
1758
+ s.set(o, { identifier: o, decimal: u });
1759
+ }), s), /* @__PURE__ */ new Map()), t({ ok: !0 });
1769
1760
  } catch (a) {
1770
1761
  console.error(a), n({
1771
1762
  ok: !1,
@@ -1863,9 +1854,9 @@ const de = (e) => {
1863
1854
  */
1864
1855
  helpers_number_different_decimals: 99101
1865
1856
  };
1866
- class m extends Error {
1857
+ class c extends Error {
1867
1858
  constructor(t, n) {
1868
- console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: Xt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
1859
+ console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: Xt[t], message: t } }), Object.setPrototypeOf(this, c.prototype);
1869
1860
  }
1870
1861
  }
1871
1862
  class x extends ce {
@@ -3596,9 +3587,9 @@ const Jt = [
3596
3587
  data: o = "",
3597
3588
  deadline: p,
3598
3589
  memo: d,
3599
- router: l,
3600
- memoStreamingSwap: u,
3601
- tcMemo: c,
3590
+ router: u,
3591
+ memoStreamingSwap: l,
3592
+ tcMemo: m,
3602
3593
  tcRouter: _,
3603
3594
  tcVault: b,
3604
3595
  vault: A,
@@ -3606,12 +3597,12 @@ const Jt = [
3606
3597
  }
3607
3598
  }) => {
3608
3599
  const O = !!Fe[t.toLowerCase()];
3609
- if (O && !l)
3600
+ if (O && !u)
3610
3601
  throw new Error("Router is required on calldata for swapIn with GenericContract");
3611
- const S = c || d, D = e && u || S;
3602
+ const S = m || d, D = e && l || S;
3612
3603
  if (!b && !A)
3613
3604
  throw new Error("TC Vault is required on calldata");
3614
- if (!_ && !l)
3605
+ if (!_ && !u)
3615
3606
  throw new Error("TC Router is required on calldata");
3616
3607
  if (!D)
3617
3608
  throw new Error("TC Memo is required on calldata");
@@ -3619,12 +3610,12 @@ const Jt = [
3619
3610
  throw new Error("Token is required on calldata");
3620
3611
  const ie = [
3621
3612
  // v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
3622
- a(_ || l),
3613
+ a(_ || u),
3623
3614
  a(b || A),
3624
3615
  D.replace("{recipientAddress}", n),
3625
3616
  a(E),
3626
3617
  s
3627
- ], Ge = O ? [a(l), o, p] : [r, p];
3618
+ ], Ge = O ? [a(u), o, p] : [r, p];
3628
3619
  return [...ie, ...Ge];
3629
3620
  }, cn = ({ chain: e, txHash: t }) => {
3630
3621
  const n = Ne[e];
@@ -3719,67 +3710,67 @@ class Vn {
3719
3710
  var p, d;
3720
3711
  const { quoteMode: r } = a.meta, o = r.startsWith("ERC20-") ? i.Ethereum : r.startsWith("ARC20-") ? i.Avalanche : i.BinanceSmartChain;
3721
3712
  if (!a.complete)
3722
- throw new m("core_swap_route_not_complete");
3713
+ throw new c("core_swap_route_not_complete");
3723
3714
  try {
3724
3715
  if (Ze.includes(r)) {
3725
- const l = this.connectedWallets[o];
3726
- if (!(l != null && l.sendTransaction))
3727
- throw new m("core_wallet_connection_not_found");
3716
+ const u = this.connectedWallets[o];
3717
+ if (!(u != null && u.sendTransaction))
3718
+ throw new c("core_wallet_connection_not_found");
3728
3719
  if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
3729
- throw new m("core_swap_route_transaction_not_found");
3730
- const { data: c, from: _, to: b, value: A } = a.transaction, E = {
3731
- data: c,
3720
+ throw new c("core_swap_route_transaction_not_found");
3721
+ const { data: m, from: _, to: b, value: A } = a.transaction, E = {
3722
+ data: m,
3732
3723
  from: _,
3733
3724
  to: b.toLowerCase(),
3734
3725
  chainId: BigInt(pt[o]),
3735
3726
  value: A ? BigInt(A) : 0n
3736
3727
  };
3737
- return l.sendTransaction(E, s);
3728
+ return u.sendTransaction(E, s);
3738
3729
  }
3739
3730
  if (tt.includes(r)) {
3740
3731
  if (!a.calldata.fromAsset)
3741
- throw new m("core_swap_asset_not_recognized");
3742
- const l = await M.fromString(a.calldata.fromAsset);
3743
- if (!l)
3744
- throw new m("core_swap_asset_not_recognized");
3745
- const { address: u } = await f(this, V).call(this, l.chain), {
3746
- contract: c,
3732
+ throw new c("core_swap_asset_not_recognized");
3733
+ const u = await M.fromString(a.calldata.fromAsset);
3734
+ if (!u)
3735
+ throw new c("core_swap_asset_not_recognized");
3736
+ const { address: l } = await f(this, V).call(this, u.chain), {
3737
+ contract: m,
3747
3738
  calldata: { expiration: _, amountIn: b, memo: A, memoStreamingSwap: E }
3748
- } = a, O = l.add(x.fromBigInt(BigInt(b), l.decimal)), S = t && E || A;
3739
+ } = a, O = u.add(x.fromBigInt(BigInt(b), u.decimal)), S = t && E || A;
3749
3740
  return this.deposit({
3750
3741
  expiration: _,
3751
3742
  assetValue: O,
3752
3743
  memo: S,
3753
3744
  feeOptionKey: s,
3754
- router: c,
3755
- recipient: u
3745
+ router: m,
3746
+ recipient: l
3756
3747
  });
3757
3748
  }
3758
3749
  if (et.includes(r)) {
3759
- const { calldata: l, contract: u } = a;
3760
- if (!u)
3761
- throw new m("core_swap_contract_not_found");
3762
- const c = this.connectedWallets[o], _ = this.getAddress(o);
3763
- if (!(c != null && c.sendTransaction) || !_)
3764
- throw new m("core_wallet_connection_not_found");
3765
- const { getProvider: b, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), E = b(o), O = ln[u.toLowerCase()];
3750
+ const { calldata: u, contract: l } = a;
3751
+ if (!l)
3752
+ throw new c("core_swap_contract_not_found");
3753
+ const m = this.connectedWallets[o], _ = this.getAddress(o);
3754
+ if (!(m != null && m.sendTransaction) || !_)
3755
+ throw new c("core_wallet_connection_not_found");
3756
+ const { getProvider: b, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), E = b(o), O = ln[l.toLowerCase()];
3766
3757
  if (!O)
3767
- throw new m("core_swap_contract_not_supported", { contractAddress: u });
3768
- const D = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, O, E))).getFunction("swapIn").populateTransaction(
3758
+ throw new c("core_swap_contract_not_supported", { contractAddress: l });
3759
+ const D = await (await ((d = m.createContract) == null ? void 0 : d.call(m, l, O, E))).getFunction("swapIn").populateTransaction(
3769
3760
  ...yn({
3770
3761
  streamSwap: t,
3771
3762
  toChecksumAddress: A,
3772
- contractAddress: u,
3763
+ contractAddress: l,
3773
3764
  recipient: n,
3774
- calldata: l
3765
+ calldata: u
3775
3766
  }),
3776
3767
  { from: _ }
3777
3768
  );
3778
- return c.sendTransaction(D, s);
3769
+ return m.sendTransaction(D, s);
3779
3770
  }
3780
- throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
3781
- } catch (l) {
3782
- throw new m("core_swap_transaction_error", l);
3771
+ throw new c("core_swap_quote_mode_not_supported", { quoteMode: r });
3772
+ } catch (u) {
3773
+ throw new c("core_swap_transaction_error", u);
3783
3774
  }
3784
3775
  });
3785
3776
  T(this, "getWalletByChain", async (t, n) => {
@@ -3808,11 +3799,11 @@ class Vn {
3808
3799
  T(this, "transfer", async (t) => {
3809
3800
  const n = this.connectedWallets[t.assetValue.chain];
3810
3801
  if (!n)
3811
- throw new m("core_wallet_connection_not_found");
3802
+ throw new c("core_wallet_connection_not_found");
3812
3803
  try {
3813
3804
  return await n.transfer(f(this, Y).call(this, t));
3814
3805
  } catch (a) {
3815
- throw new m("core_swap_transaction_error", a);
3806
+ throw new c("core_swap_transaction_error", a);
3816
3807
  }
3817
3808
  });
3818
3809
  T(this, "deposit", async ({
@@ -3823,43 +3814,43 @@ class Vn {
3823
3814
  }) => {
3824
3815
  const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
3825
3816
  if (!await _n({ address: await (d == null ? void 0 : d.getAddress()), chain: r }))
3826
- throw new m("core_transaction_invalid_sender_address");
3817
+ throw new c("core_transaction_invalid_sender_address");
3827
3818
  if (!d)
3828
- throw new m("core_wallet_connection_not_found");
3829
- const l = f(this, Y).call(this, { assetValue: t, recipient: n, router: a, ...s });
3819
+ throw new c("core_wallet_connection_not_found");
3820
+ const u = f(this, Y).call(this, { assetValue: t, recipient: n, router: a, ...s });
3830
3821
  try {
3831
3822
  switch (r) {
3832
3823
  case i.THORChain: {
3833
- const u = d;
3834
- return await (n === "" ? u.deposit(l) : u.transfer(l));
3824
+ const l = d;
3825
+ return await (n === "" ? l.deposit(u) : l.transfer(u));
3835
3826
  }
3836
3827
  case i.Ethereum:
3837
3828
  case i.BinanceSmartChain:
3838
3829
  case i.Avalanche: {
3839
- const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Je : r === i.BinanceSmartChain ? Qe : Xe;
3830
+ const { getChecksumAddressFromAsset: l } = await import("@swapkit/toolbox-evm"), m = r === i.Avalanche ? Je : r === i.BinanceSmartChain ? Qe : Xe;
3840
3831
  return await d.call({
3841
- abi: c,
3832
+ abi: m,
3842
3833
  contractAddress: a || (await f(this, V).call(this, r)).router,
3843
3834
  funcName: "depositWithExpiry",
3844
3835
  funcParams: [
3845
3836
  n,
3846
- u({ chain: r, symbol: o, ticker: p }, r),
3837
+ l({ chain: r, symbol: o, ticker: p }, r),
3847
3838
  t.getBaseValue("string"),
3848
- l.memo,
3839
+ u.memo,
3849
3840
  s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
3850
3841
  ],
3851
3842
  txOverrides: {
3852
- from: l.from,
3843
+ from: u.from,
3853
3844
  value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
3854
3845
  }
3855
3846
  });
3856
3847
  }
3857
3848
  default:
3858
- return await d.transfer(l);
3849
+ return await d.transfer(u);
3859
3850
  }
3860
- } catch (u) {
3861
- const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"), A = c == null ? void 0 : c.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : A ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
3862
- throw new m(E, u);
3851
+ } catch (l) {
3852
+ const m = ((l == null ? void 0 : l.message) || (l == null ? void 0 : l.toString())).toLowerCase(), _ = m == null ? void 0 : m.includes("insufficient funds"), b = m == null ? void 0 : m.includes("gas"), A = m == null ? void 0 : m.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : A ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
3853
+ throw new c(E, l);
3863
3854
  }
3864
3855
  });
3865
3856
  /**
@@ -3870,7 +3861,7 @@ class Vn {
3870
3861
  assetValue: n
3871
3862
  }) => {
3872
3863
  if (t.lte(0) || n.lte(0))
3873
- throw new m("core_transaction_create_liquidity_invalid_params");
3864
+ throw new c("core_transaction_create_liquidity_invalid_params");
3874
3865
  let a = "", s = "";
3875
3866
  try {
3876
3867
  a = await f(this, v).call(this, {
@@ -3881,7 +3872,7 @@ class Vn {
3881
3872
  })
3882
3873
  });
3883
3874
  } catch (r) {
3884
- throw new m("core_transaction_create_liquidity_rune_error", r);
3875
+ throw new c("core_transaction_create_liquidity_rune_error", r);
3885
3876
  }
3886
3877
  try {
3887
3878
  s = await f(this, v).call(this, {
@@ -3892,7 +3883,7 @@ class Vn {
3892
3883
  })
3893
3884
  });
3894
3885
  } catch (r) {
3895
- throw new m("core_transaction_create_liquidity_asset_error", r);
3886
+ throw new c("core_transaction_create_liquidity_asset_error", r);
3896
3887
  }
3897
3888
  return { runeTx: a, assetTx: s };
3898
3889
  });
@@ -3904,29 +3895,29 @@ class Vn {
3904
3895
  isPendingSymmAsset: r,
3905
3896
  mode: o = "sym"
3906
3897
  }) => {
3907
- const { chain: p, symbol: d } = n, l = o === "sym", u = (t == null ? void 0 : t.gt(0)) && (l || o === "rune"), c = (n == null ? void 0 : n.gt(0)) && (l || o === "asset"), _ = r || u, b = _ ? a || this.getAddress(i.THORChain) : "", A = l || o === "asset" ? s || this.getAddress(p) : "";
3908
- if (!u && !c)
3909
- throw new m("core_transaction_add_liquidity_invalid_params");
3898
+ const { chain: p, symbol: d } = n, u = o === "sym", l = (t == null ? void 0 : t.gt(0)) && (u || o === "rune"), m = (n == null ? void 0 : n.gt(0)) && (u || o === "asset"), _ = r || l, b = _ ? a || this.getAddress(i.THORChain) : "", A = u || o === "asset" ? s || this.getAddress(p) : "";
3899
+ if (!l && !m)
3900
+ throw new c("core_transaction_add_liquidity_invalid_params");
3910
3901
  if (_ && !b)
3911
- throw new m("core_transaction_add_liquidity_no_rune_address");
3902
+ throw new c("core_transaction_add_liquidity_no_rune_address");
3912
3903
  let E, O;
3913
- if (u && t)
3904
+ if (l && t)
3914
3905
  try {
3915
3906
  E = await f(this, v).call(this, {
3916
3907
  assetValue: t,
3917
3908
  memo: N(h.DEPOSIT, { chain: p, symbol: d, address: A })
3918
3909
  });
3919
3910
  } catch (S) {
3920
- throw new m("core_transaction_add_liquidity_rune_error", S);
3911
+ throw new c("core_transaction_add_liquidity_rune_error", S);
3921
3912
  }
3922
- if (c && n)
3913
+ if (m && n)
3923
3914
  try {
3924
3915
  O = await f(this, v).call(this, {
3925
3916
  assetValue: n,
3926
3917
  memo: N(h.DEPOSIT, { chain: p, symbol: d, address: b })
3927
3918
  });
3928
3919
  } catch (S) {
3929
- throw new m("core_transaction_add_liquidity_asset_error", S);
3920
+ throw new c("core_transaction_add_liquidity_asset_error", S);
3930
3921
  }
3931
3922
  return { runeTx: E, assetTx: O };
3932
3923
  });
@@ -3937,7 +3928,7 @@ class Vn {
3937
3928
  symmetric: s
3938
3929
  }) => {
3939
3930
  if (s && !a)
3940
- throw new m("core_transaction_add_liquidity_invalid_params");
3931
+ throw new c("core_transaction_add_liquidity_invalid_params");
3941
3932
  const r = s && a || "";
3942
3933
  return f(this, v).call(this, { assetValue: t, memo: `+:${n}:${r}:t:0` });
3943
3934
  });
@@ -4015,7 +4006,7 @@ class Vn {
4015
4006
  });
4016
4007
  });
4017
4008
  } catch (r) {
4018
- throw new m("core_extend_error", r);
4009
+ throw new c("core_extend_error", r);
4019
4010
  }
4020
4011
  });
4021
4012
  T(this, "estimateMaxSendableAmount", async ({
@@ -4051,35 +4042,35 @@ class Vn {
4051
4042
  });
4052
4043
  }
4053
4044
  default:
4054
- throw new m("core_estimated_max_spendable_chain_not_supported");
4045
+ throw new c("core_estimated_max_spendable_chain_not_supported");
4055
4046
  }
4056
4047
  });
4057
4048
  /**
4058
4049
  * Wallet connection methods
4059
4050
  */
4060
4051
  T(this, "connectXDEFI", async (t) => {
4061
- throw new m("core_wallet_xdefi_not_installed");
4052
+ throw new c("core_wallet_xdefi_not_installed");
4062
4053
  });
4063
4054
  T(this, "connectEVMWallet", async (t, n) => {
4064
- throw new m("core_wallet_evmwallet_not_installed");
4055
+ throw new c("core_wallet_evmwallet_not_installed");
4065
4056
  });
4066
4057
  T(this, "connectWalletconnect", async (t, n) => {
4067
- throw new m("core_wallet_walletconnect_not_installed");
4058
+ throw new c("core_wallet_walletconnect_not_installed");
4068
4059
  });
4069
4060
  T(this, "connectKeystore", async (t, n) => {
4070
- throw new m("core_wallet_keystore_not_installed");
4061
+ throw new c("core_wallet_keystore_not_installed");
4071
4062
  });
4072
4063
  T(this, "connectLedger", async (t, n) => {
4073
- throw new m("core_wallet_ledger_not_installed");
4064
+ throw new c("core_wallet_ledger_not_installed");
4074
4065
  });
4075
4066
  T(this, "connectTrezor", async (t, n) => {
4076
- throw new m("core_wallet_trezor_not_installed");
4067
+ throw new c("core_wallet_trezor_not_installed");
4077
4068
  });
4078
4069
  T(this, "connectKeplr", async (t) => {
4079
- throw new m("core_wallet_keplr_not_installed");
4070
+ throw new c("core_wallet_keplr_not_installed");
4080
4071
  });
4081
4072
  T(this, "connectOkx", async (t) => {
4082
- throw new m("core_wallet_okx_not_installed");
4073
+ throw new c("core_wallet_okx_not_installed");
4083
4074
  });
4084
4075
  T(this, "disconnectChain", (t) => {
4085
4076
  this.connectedChains[t] = null, this.connectedWallets[t] = null;
@@ -4095,9 +4086,9 @@ class Vn {
4095
4086
  };
4096
4087
  const a = (await Tn(this.stagenet)).find((s) => s.chain === t);
4097
4088
  if (!a)
4098
- throw new m("core_inbound_data_not_found");
4089
+ throw new c("core_inbound_data_not_found");
4099
4090
  if (a != null && a.halted)
4100
- throw new m("core_chain_halted");
4091
+ throw new c("core_chain_halted");
4101
4092
  return a;
4102
4093
  });
4103
4094
  P(this, ne, ({ chain: t, wallet: n, walletMethods: a }) => {
@@ -4111,14 +4102,14 @@ class Vn {
4111
4102
  const { address: s, chain: r, isGasAsset: o, isSynthetic: p } = t, d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(r);
4112
4103
  if (d && o || !d || p)
4113
4104
  return !0;
4114
- const u = this.connectedWallets[r], c = n === "checkOnly" ? u == null ? void 0 : u.isApproved : u == null ? void 0 : u.approve;
4115
- if (!c)
4116
- throw new m("core_wallet_connection_not_found");
4105
+ const l = this.connectedWallets[r], m = n === "checkOnly" ? l == null ? void 0 : l.isApproved : l == null ? void 0 : l.approve;
4106
+ if (!m)
4107
+ throw new c("core_wallet_connection_not_found");
4117
4108
  const _ = this.getAddress(r);
4118
4109
  if (!s || !_)
4119
- throw new m("core_approve_asset_address_or_from_not_found");
4110
+ throw new c("core_approve_asset_address_or_from_not_found");
4120
4111
  const b = a || (await f(this, V).call(this, r)).router;
4121
- return c({
4112
+ return m({
4122
4113
  amount: t.getBaseValue("bigint"),
4123
4114
  assetAddress: s,
4124
4115
  from: _,
@@ -4146,7 +4137,7 @@ class Vn {
4146
4137
  P(this, K, async ({ memo: t, assetValue: n }) => {
4147
4138
  const a = await hn(this.stagenet);
4148
4139
  if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
4149
- throw new m("core_chain_halted");
4140
+ throw new c("core_chain_halted");
4150
4141
  return this.deposit({ assetValue: n, recipient: "", memo: t });
4151
4142
  });
4152
4143
  P(this, Y, ({ assetValue: t, ...n }) => ({
@@ -4190,7 +4181,7 @@ export {
4190
4181
  et as SWAP_IN,
4191
4182
  tt as SWAP_OUT,
4192
4183
  Vn as SwapKitCore,
4193
- m as SwapKitError,
4184
+ c as SwapKitError,
4194
4185
  x as SwapKitNumber,
4195
4186
  Je as TCAvalancheDepositABI,
4196
4187
  Qe as TCBscDepositABI,