@swapkit/core 1.0.0-rc.21 → 1.0.0-rc.23

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,10 +1,10 @@
1
- var We = Object.defineProperty;
2
- var qe = (e, t, n) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var T = (e, t, n) => (qe(e, typeof t != "symbol" ? t + "" : t, n), n), je = (e, t, n) => {
1
+ var qe = Object.defineProperty;
2
+ var We = (e, t, n) => t in e ? qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var T = (e, t, n) => (We(e, typeof t != "symbol" ? t + "" : t, n), n), je = (e, t, n) => {
4
4
  if (!t.has(e))
5
5
  throw TypeError("Cannot " + n);
6
6
  };
7
- var f = (e, t, n) => (je(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (e, t, n) => {
7
+ var f = (e, t, n) => (je(e, t, "read from private field"), n ? n.call(e) : t.get(e)), B = (e, t, n) => {
8
8
  if (t.has(e))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
10
  t instanceof WeakSet ? t.add(e) : t.set(e, n);
@@ -836,14 +836,14 @@ const se = Object.values(i), rt = Object.keys(i), be = se.reduce(
836
836
  MATIC: "https://polygonscan.com",
837
837
  THOR: "https://viewblock.io/thorchain"
838
838
  };
839
- var dt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(dt || {}), 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 || {}), k = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(k || {}), ut = /* @__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))(ut || {}), lt = Object.defineProperty, yt = (e, t, n) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, M = (e, t, n) => (yt(e, typeof t != "symbol" ? t + "" : t, n), n), ct = (e, t, n) => {
839
+ var dt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(dt || {}), 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 || {}), ut = /* @__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))(ut || {}), lt = Object.defineProperty, yt = (e, t, n) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, M = (e, t, n) => (yt(e, typeof t != "symbol" ? t + "" : t, n), n), ct = (e, t, n) => {
840
840
  if (!t.has(e))
841
841
  throw TypeError("Cannot " + n);
842
- }, V = (e, t, n) => {
842
+ }, L = (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);
846
- }, O = (e, t, n) => (ct(e, t, "access private method"), n);
846
+ }, g = (e, t, n) => (ct(e, t, "access private method"), n);
847
847
  const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
848
848
  try {
849
849
  const { result: n } = await Ae.post(pt[e], {
@@ -883,9 +883,9 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
883
883
  return b[e];
884
884
  }
885
885
  }, ft = {
886
- [k.Average]: 1.2,
887
- [k.Fast]: 1.5,
888
- [k.Fastest]: 2
886
+ [F.Average]: 1.2,
887
+ [F.Fast]: 1.5,
888
+ [F.Fastest]: 2
889
889
  }, bt = ({ chain: e, symbol: t }) => {
890
890
  switch (e) {
891
891
  case i.Bitcoin:
@@ -985,14 +985,14 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
985
985
  poolUnits: t,
986
986
  runeDepth: n
987
987
  }) => {
988
- const a = w(e), s = w(t), r = w(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = s.mul(s).mul(s);
988
+ const a = I(e), s = I(t), r = I(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = s.mul(s).mul(s);
989
989
  return o.mul(p.sub(d).add(y)).div(u);
990
990
  }, gt = ({
991
991
  liquidityUnits: e,
992
992
  poolUnits: t,
993
993
  assetDepth: n
994
994
  }) => {
995
- const a = w(e), s = w(t), r = w(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = o.mul(p.sub(d).add(y)), c = s.mul(s).mul(s);
995
+ const a = I(e), s = I(t), r = I(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), y = a.mul(a), u = o.mul(p.sub(d).add(y)), c = s.mul(s).mul(s);
996
996
  return u.div(c);
997
997
  }, In = ({
998
998
  percent: e,
@@ -1004,14 +1004,14 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
1004
1004
  assetDepth: t,
1005
1005
  liquidityUnits: n,
1006
1006
  poolUnits: a
1007
- }) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), w = (e) => new j({ value: e, decimal: b.THOR }), Ot = ({
1007
+ }) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), I = (e) => x.fromBigInt(BigInt(e), b.THOR), Ot = ({
1008
1008
  liquidityUnits: e,
1009
1009
  poolUnits: t,
1010
1010
  runeDepth: n,
1011
1011
  assetDepth: a
1012
1012
  }) => ({
1013
- assetAmount: w(a).mul(e).div(t),
1014
- runeAmount: w(n).mul(e).div(t)
1013
+ assetAmount: I(a).mul(e).div(t),
1014
+ runeAmount: I(n).mul(e).div(t)
1015
1015
  }), vn = ({
1016
1016
  liquidityUnits: e,
1017
1017
  poolUnits: t,
@@ -1030,24 +1030,26 @@ const mt = "0x313ce567", Pe = async ({ chain: e, to: t }) => {
1030
1030
  runeAmount: s,
1031
1031
  assetAmount: r
1032
1032
  }) => {
1033
- const o = w(e), p = w(n), d = w(t), y = w(s), u = w(r), c = y.mul(p), _ = u.mul(o), A = y.mul(u), R = o.mul(p), g = d.mul(c.add(_.add(A.mul(2)))), E = c.add(_.add(R.mul(2))), I = g.div(E), v = w(a).add(I);
1034
- if (I.baseValueNumber === 0)
1035
- return v.div(d).baseValueNumber;
1036
- const D = d.add(v);
1037
- return v.div(D).baseValueNumber;
1033
+ const o = new x({ value: e, decimal: 8 }), p = new x({ value: n, decimal: 8 }), d = new x({ value: t, decimal: 8 }), y = new x({ value: s, decimal: 8 }), u = new x({ value: r, decimal: 8 }), c = y.mul(p), _ = u.mul(o), w = y.mul(u), E = o.mul(p), R = d.mul(c.add(_.add(w.mul(2)))), A = c.add(_.add(E.mul(2))), O = R.div(A), v = I(a).add(O);
1034
+ if (O.getBaseValue("number") === 0)
1035
+ return v.div(d).getBaseValue("number");
1036
+ const P = d.add(v);
1037
+ return v.div(P).getBaseValue("number");
1038
1038
  }, Mn = ({
1039
1039
  runeAmount: e,
1040
1040
  assetAmount: t,
1041
1041
  runeDepth: n,
1042
1042
  assetDepth: a
1043
1043
  }) => {
1044
- const s = w(n), r = w(a), o = w(t), p = w(e), d = o.mul(s).sub(r.mul(p)), y = r.mul(p).add(s.mul(r));
1045
- return Math.abs(d.div(y).baseValueNumber);
1044
+ if (e === "0" || t === "0" || n === "0" || a === "0")
1045
+ return 0;
1046
+ const s = I(n), r = I(a), o = I(t), p = I(e), d = o.mul(s).sub(r.mul(p)), y = r.mul(p).add(s.mul(r));
1047
+ return Math.abs(d.div(y).getBaseValue("number"));
1046
1048
  }, It = ({
1047
1049
  symbol: e,
1048
1050
  ticker: t,
1049
1051
  chain: n
1050
- }) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, x = (e, t) => {
1052
+ }) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, D = (e, t) => {
1051
1053
  switch (e) {
1052
1054
  case h.LEAVE:
1053
1055
  case h.BOND: {
@@ -1439,7 +1441,7 @@ const de = (e) => {
1439
1441
  }, kt = de(), Ft = kt, Gt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, ge = Ft.create({ headers: Gt }), Ae = {
1440
1442
  get: (e, t) => ge.get(e, t).json(),
1441
1443
  post: (e, t) => ge.post(e, t).json()
1442
- }, Oe = Object.values(i), Wt = (e = "") => {
1444
+ }, Oe = Object.values(i), qt = (e = "") => {
1443
1445
  const t = e.toUpperCase(), [n] = t.split(".");
1444
1446
  if (Oe.includes(n))
1445
1447
  return !0;
@@ -1449,11 +1451,11 @@ const de = (e) => {
1449
1451
  throw new Error(
1450
1452
  `Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
1451
1453
  );
1452
- }, q = 8, U = (e) => 10n ** BigInt(e), F = (e) => Math.log10(parseFloat(e.toString()));
1454
+ }, j = 8, H = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
1453
1455
  function ie({
1454
1456
  value: e,
1455
- bigIntDecimal: t = q,
1456
- decimal: n = q
1457
+ bigIntDecimal: t = j,
1458
+ decimal: n = j
1457
1459
  }) {
1458
1460
  const a = e < 0n;
1459
1461
  let s = e.toString().substring(a ? 1 : 0);
@@ -1466,14 +1468,14 @@ function ie({
1466
1468
  ""
1467
1469
  );
1468
1470
  }
1469
- var L, $, ue, ke, le, Ie, te, ye, H, G, ne, ce;
1470
- const qt = class me {
1471
+ var U, k, ue, ke, le, Ie, te, ye, $, q, ne, ce;
1472
+ const Wt = class me {
1471
1473
  constructor(t) {
1472
- V(this, L), V(this, ue), V(this, le), V(this, te), V(this, H), V(this, ne), M(this, "decimalMultiplier", 10n ** 8n), M(this, "bigIntValue", 0n), M(this, "decimal");
1474
+ L(this, U), L(this, ue), L(this, le), L(this, te), L(this, $), L(this, ne), M(this, "decimalMultiplier", 10n ** 8n), M(this, "bigIntValue", 0n), M(this, "decimal");
1473
1475
  const n = he(t);
1474
- this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = U(
1475
- Math.max(O(this, ne, ce).call(this, O(this, H, G).call(this, n)), this.decimal || 0)
1476
- ), O(this, ue, ke).call(this, n);
1476
+ this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = H(
1477
+ Math.max(g(this, ne, ce).call(this, g(this, $, q).call(this, n)), this.decimal || 0)
1478
+ ), g(this, ue, ke).call(this, n);
1477
1479
  }
1478
1480
  static fromBigInt(t, n) {
1479
1481
  return new me({
@@ -1487,7 +1489,7 @@ const qt = class me {
1487
1489
  to: a
1488
1490
  }) {
1489
1491
  return this.fromBigInt(
1490
- new me(t).bigIntValue * U(a) / U(n),
1492
+ new me(t).bigIntValue * H(a) / H(n),
1491
1493
  a
1492
1494
  );
1493
1495
  }
@@ -1513,16 +1515,16 @@ const qt = class me {
1513
1515
  return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
1514
1516
  }
1515
1517
  add(...t) {
1516
- return O(this, L, $).call(this, "add", ...t);
1518
+ return g(this, U, k).call(this, "add", ...t);
1517
1519
  }
1518
1520
  sub(...t) {
1519
- return O(this, L, $).call(this, "sub", ...t);
1521
+ return g(this, U, k).call(this, "sub", ...t);
1520
1522
  }
1521
1523
  mul(...t) {
1522
- return O(this, L, $).call(this, "mul", ...t);
1524
+ return g(this, U, k).call(this, "mul", ...t);
1523
1525
  }
1524
1526
  div(...t) {
1525
- return O(this, L, $).call(this, "div", ...t);
1527
+ return g(this, U, k).call(this, "div", ...t);
1526
1528
  }
1527
1529
  gt(t) {
1528
1530
  return this.bigIntValue > this.getBigIntValue(t);
@@ -1542,7 +1544,7 @@ const qt = class me {
1542
1544
  getValue(t) {
1543
1545
  const n = this.formatBigIntToSafeValue(
1544
1546
  this.bigIntValue,
1545
- this.decimal || F(this.decimalMultiplier)
1547
+ this.decimal || G(this.decimalMultiplier)
1546
1548
  );
1547
1549
  switch (t) {
1548
1550
  case "number":
@@ -1554,7 +1556,7 @@ const qt = class me {
1554
1556
  }
1555
1557
  }
1556
1558
  getBaseValue(t) {
1557
- const n = this.decimalMultiplier / U(this.decimal || b.THOR), a = this.bigIntValue / n;
1559
+ const n = this.decimalMultiplier / H(this.decimal || b.THOR), a = this.bigIntValue / n;
1558
1560
  switch (t) {
1559
1561
  case "number":
1560
1562
  return Number(a);
@@ -1567,13 +1569,13 @@ const qt = class me {
1567
1569
  getBigIntValue(t, n) {
1568
1570
  if (!n && typeof t == "object")
1569
1571
  return t.bigIntValue;
1570
- const a = he(t), s = O(this, H, G).call(this, a);
1571
- return s === "0" || s === "undefined" ? 0n : O(this, te, ye).call(this, s, n);
1572
+ const a = he(t), s = g(this, $, q).call(this, a);
1573
+ return s === "0" || s === "undefined" ? 0n : g(this, te, ye).call(this, s, n);
1572
1574
  }
1573
1575
  formatBigIntToSafeValue(t, n) {
1574
- const a = n || this.decimal || q, s = Math.max(
1576
+ const a = n || this.decimal || j, s = Math.max(
1575
1577
  a,
1576
- F(this.decimalMultiplier)
1578
+ G(this.decimalMultiplier)
1577
1579
  ), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, y = d.length - s;
1578
1580
  let u = d.slice(-s);
1579
1581
  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(
@@ -1582,19 +1584,19 @@ const qt = class me {
1582
1584
  )}.${u}`.replace(/\.?0*$/, "");
1583
1585
  }
1584
1586
  toSignificant(t = 6) {
1585
- const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "", o = parseInt(s) ? s.length + r.length : r.length;
1586
- if (o <= t)
1587
+ const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
1588
+ if ((parseInt(s) ? s.length + r.length : r.length) <= t)
1587
1589
  return this.getValue("string");
1588
1590
  if (s.length >= t)
1589
1591
  return s.slice(0, t).padEnd(s.length, "0");
1590
1592
  if (parseInt(s))
1591
1593
  return `${s}.${r.slice(0, t - s.length)}`.padEnd(
1592
- o - t,
1594
+ t - s.length,
1593
1595
  "0"
1594
1596
  );
1595
- const p = parseInt(r), d = `${p}`.slice(0, t);
1596
- return `0.${d.padStart(
1597
- r.length - `${p}`.length + d.length,
1597
+ const o = parseInt(r), p = `${o}`.slice(0, t);
1598
+ return `0.${p.padStart(
1599
+ r.length - `${o}`.length + p.length,
1598
1600
  "0"
1599
1601
  )}`;
1600
1602
  }
@@ -1616,8 +1618,8 @@ const qt = class me {
1616
1618
  return `${(n / o).toFixed(t)}${r}`;
1617
1619
  }
1618
1620
  };
1619
- L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
1620
- const n = O(this, le, Ie).call(this, this, ...t), a = U(n), s = t.reduce(
1621
+ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1622
+ const n = g(this, le, Ie).call(this, this, ...t), a = H(n), s = t.reduce(
1621
1623
  (o, p) => {
1622
1624
  const d = this.getBigIntValue(p, n);
1623
1625
  switch (e) {
@@ -1640,22 +1642,22 @@ L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
1640
1642
  this.bigIntValue * a / this.decimalMultiplier
1641
1643
  ), r = ie({
1642
1644
  bigIntDecimal: n,
1643
- decimal: Math.max(n, F(this.decimalMultiplier)),
1645
+ decimal: Math.max(n, G(this.decimalMultiplier)),
1644
1646
  value: s
1645
1647
  });
1646
1648
  return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
1647
1649
  }, ue = /* @__PURE__ */ new WeakSet(), ke = function(e) {
1648
- const t = O(this, H, G).call(this, e) || "0";
1649
- this.bigIntValue = O(this, te, ye).call(this, t);
1650
+ const t = g(this, $, q).call(this, e) || "0";
1651
+ this.bigIntValue = g(this, te, ye).call(this, t);
1650
1652
  }, le = /* @__PURE__ */ new WeakSet(), Ie = function(...e) {
1651
1653
  const t = e.map(
1652
- (n) => typeof n == "object" ? n.decimal || F(n.decimalMultiplier) : O(this, ne, ce).call(this, O(this, H, G).call(this, n))
1654
+ (n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : g(this, ne, ce).call(this, g(this, $, q).call(this, n))
1653
1655
  ).filter(Boolean);
1654
- return Math.max(...t, q);
1656
+ return Math.max(...t, j);
1655
1657
  }, te = /* @__PURE__ */ new WeakSet(), ye = function(e, t) {
1656
- const n = t ? U(t) : this.decimalMultiplier, a = F(n), [s = "", r = ""] = e.split(".");
1658
+ const n = t ? H(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
1657
1659
  return BigInt(`${s}${r.padEnd(a, "0")}`);
1658
- }, H = /* @__PURE__ */ new WeakSet(), G = function(e) {
1660
+ }, $ = /* @__PURE__ */ new WeakSet(), q = function(e) {
1659
1661
  const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
1660
1662
  useGrouping: !1,
1661
1663
  maximumFractionDigits: 20
@@ -1664,9 +1666,9 @@ L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
1664
1666
  }, ne = /* @__PURE__ */ new WeakSet(), ce = function(e) {
1665
1667
  var t;
1666
1668
  const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
1667
- return Math.max(n, q);
1669
+ return Math.max(n, j);
1668
1670
  };
1669
- let Te = qt;
1671
+ let Te = Wt;
1670
1672
  function he(e) {
1671
1673
  return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
1672
1674
  }
@@ -1677,7 +1679,7 @@ const pe = (e) => {
1677
1679
  throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
1678
1680
  return _e.get(e.toUpperCase()) || { decimal: b.THOR, identifier: "" };
1679
1681
  }, Se = async (e, t = 0) => {
1680
- Wt(e);
1682
+ qt(e);
1681
1683
  const n = await Be(Z(e)), a = z(t, n);
1682
1684
  return new S({ decimal: n, value: a, identifier: e });
1683
1685
  };
@@ -1853,12 +1855,12 @@ class m extends Error {
1853
1855
  console.error(n), super(t, { cause: { code: jt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
1854
1856
  }
1855
1857
  }
1856
- class j extends Te {
1858
+ class x extends Te {
1857
1859
  eq(t) {
1858
1860
  return this.eqValue(t);
1859
1861
  }
1860
1862
  static fromBigInt(t, n) {
1861
- return new j({
1863
+ return new x({
1862
1864
  decimal: n,
1863
1865
  value: ie({ value: t, bigIntDecimal: n, decimal: n })
1864
1866
  });
@@ -3585,32 +3587,32 @@ const Kt = [
3585
3587
  memoStreamingSwap: u,
3586
3588
  tcMemo: c,
3587
3589
  tcRouter: _,
3588
- tcVault: A,
3589
- vault: R,
3590
- token: g
3590
+ tcVault: w,
3591
+ vault: E,
3592
+ token: R
3591
3593
  }
3592
3594
  }) => {
3593
- const E = !!Fe[t.toLowerCase()];
3594
- if (E && !y)
3595
+ const A = !!Fe[t.toLowerCase()];
3596
+ if (A && !y)
3595
3597
  throw new Error("Router is required on calldata for swapIn with GenericContract");
3596
- const I = c || d, v = e && u || I;
3597
- if (!A && !R)
3598
+ const O = c || d, v = e && u || O;
3599
+ if (!w && !E)
3598
3600
  throw new Error("TC Vault is required on calldata");
3599
3601
  if (!_ && !y)
3600
3602
  throw new Error("TC Router is required on calldata");
3601
3603
  if (!v)
3602
3604
  throw new Error("TC Memo is required on calldata");
3603
- if (!g)
3605
+ if (!R)
3604
3606
  throw new Error("Token is required on calldata");
3605
- const D = [
3607
+ const P = [
3606
3608
  // v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
3607
3609
  a(_ || y),
3608
- a(A || R),
3610
+ a(w || E),
3609
3611
  v.replace("{recipientAddress}", n),
3610
- a(g),
3612
+ a(R),
3611
3613
  s
3612
- ], Ge = E ? [a(y), o, p] : [r, p];
3613
- return [...D, ...Ge];
3614
+ ], Ge = A ? [a(y), o, p] : [r, p];
3615
+ return [...P, ...Ge];
3614
3616
  }, un = ({ chain: e, txHash: t }) => {
3615
3617
  const n = De[e];
3616
3618
  switch (e) {
@@ -3671,7 +3673,7 @@ const Kt = [
3671
3673
  (e, t) => (e[t] = null, e),
3672
3674
  {}
3673
3675
  );
3674
- var B, ae, K, N, Y, X;
3676
+ var V, ae, K, N, Y, X;
3675
3677
  class Pn {
3676
3678
  constructor({ stagenet: t } = {}) {
3677
3679
  T(this, "connectedChains", Ce());
@@ -3700,16 +3702,16 @@ class Pn {
3700
3702
  throw new m("core_wallet_connection_not_found");
3701
3703
  if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
3702
3704
  throw new m("core_swap_route_transaction_not_found");
3703
- const { isHexString: c, parseUnits: _ } = await import("./index-cf1865cd.js"), { data: A, from: R, to: g, value: E } = a.transaction, I = {
3704
- data: A,
3705
- from: R,
3706
- to: g.toLowerCase(),
3705
+ const { isHexString: c, parseUnits: _ } = await import("./index-cf1865cd.js"), { data: w, from: E, to: R, value: A } = a.transaction, O = {
3706
+ data: w,
3707
+ from: E,
3708
+ to: R.toLowerCase(),
3707
3709
  chainId: BigInt(ot[o]),
3708
- value: E ? new j({
3709
- value: c(E) ? E : _(E, "wei").toString(16)
3710
- }).baseValueBigInt : 0n
3710
+ value: A ? new x({
3711
+ value: c(A) ? A : _(A, "wei").toString(16)
3712
+ }).getBaseValue("bigint") : 0n
3711
3713
  };
3712
- return y.sendTransaction(I, s);
3714
+ return y.sendTransaction(O, s);
3713
3715
  }
3714
3716
  if (tt.includes(r)) {
3715
3717
  if (!a.calldata.fromAsset)
@@ -3717,14 +3719,14 @@ class Pn {
3717
3719
  const y = await S.fromString(a.calldata.fromAsset);
3718
3720
  if (!y)
3719
3721
  throw new m("core_swap_asset_not_recognized");
3720
- const { address: u } = await f(this, B).call(this, y.chain), {
3722
+ const { address: u } = await f(this, V).call(this, y.chain), {
3721
3723
  contract: c,
3722
- calldata: { expiration: _, amountIn: A, memo: R, memoStreamingSwap: g }
3723
- } = a, E = y.add(j.fromBigInt(BigInt(A), y.decimal)), I = t && g || R;
3724
+ calldata: { expiration: _, amountIn: w, memo: E, memoStreamingSwap: R }
3725
+ } = a, A = y.add(x.fromBigInt(BigInt(w), y.decimal)), O = t && R || E;
3724
3726
  return this.deposit({
3725
3727
  expiration: _,
3726
- assetValue: E,
3727
- memo: I,
3728
+ assetValue: A,
3729
+ memo: O,
3728
3730
  feeOptionKey: s,
3729
3731
  router: c,
3730
3732
  recipient: u
@@ -3737,13 +3739,13 @@ class Pn {
3737
3739
  const c = this.connectedWallets[o], _ = this.getAddress(o);
3738
3740
  if (!(c != null && c.sendTransaction) || !_)
3739
3741
  throw new m("core_wallet_connection_not_found");
3740
- const { getProvider: A, toChecksumAddress: R } = await import("@swapkit/toolbox-evm"), g = A(o), E = pn[u.toLowerCase()];
3741
- if (!E)
3742
+ const { getProvider: w, toChecksumAddress: E } = await import("@swapkit/toolbox-evm"), R = w(o), A = pn[u.toLowerCase()];
3743
+ if (!A)
3742
3744
  throw new m("core_swap_contract_not_supported", { contractAddress: u });
3743
- const v = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, E, g))).getFunction("swapIn").populateTransaction(
3745
+ const v = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, A, R))).getFunction("swapIn").populateTransaction(
3744
3746
  ...dn({
3745
3747
  streamSwap: t,
3746
- toChecksumAddress: R,
3748
+ toChecksumAddress: E,
3747
3749
  contractAddress: u,
3748
3750
  recipient: n,
3749
3751
  calldata: y
@@ -3758,18 +3760,21 @@ class Pn {
3758
3760
  }
3759
3761
  });
3760
3762
  T(this, "getWalletByChain", async (t, n) => {
3761
- var r, o;
3763
+ var o, p;
3762
3764
  const a = this.getAddress(t);
3763
3765
  if (!a)
3764
3766
  return null;
3765
- const s = await ((r = this.getWallet(t)) == null ? void 0 : r.getBalance(a, n)) ?? [
3766
- S.fromChainOrSignature(t)
3767
- ];
3768
- return this.connectedChains[t] = {
3769
- address: a,
3770
- balance: s,
3771
- walletType: (o = this.connectedChains[t]) == null ? void 0 : o.walletType
3772
- }, { ...this.connectedChains[t] };
3767
+ const s = [S.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
3768
+ try {
3769
+ const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
3770
+ return this.connectedChains[t] = {
3771
+ address: a,
3772
+ balance: d != null && d.length ? d : s,
3773
+ walletType: r
3774
+ }, { ...this.connectedChains[t] };
3775
+ } catch (d) {
3776
+ return console.error(d), { address: a, balance: s, walletType: r };
3777
+ }
3773
3778
  });
3774
3779
  T(this, "approveAssetValue", (t, n) => f(this, K).call(this, { assetValue: t, type: "approve", contractAddress: n }));
3775
3780
  T(this, "isAssetValueApproved", (t, n) => f(this, K).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
@@ -3809,7 +3814,7 @@ class Pn {
3809
3814
  const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Je : r === i.BinanceSmartChain ? Qe : Xe;
3810
3815
  return await d.call({
3811
3816
  abi: c,
3812
- contractAddress: a || (await f(this, B).call(this, r)).router,
3817
+ contractAddress: a || (await f(this, V).call(this, r)).router,
3813
3818
  funcName: "depositWithExpiry",
3814
3819
  funcParams: [
3815
3820
  n,
@@ -3829,8 +3834,8 @@ class Pn {
3829
3834
  return await d.transfer(y);
3830
3835
  }
3831
3836
  } catch (u) {
3832
- const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), A = c == null ? void 0 : c.includes("gas"), R = c == null ? void 0 : c.includes("server"), g = _ ? "core_transaction_deposit_insufficient_funds_error" : A ? "core_transaction_deposit_gas_error" : R ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
3833
- throw new m(g, u);
3837
+ const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), w = c == null ? void 0 : c.includes("gas"), E = c == null ? void 0 : c.includes("server"), R = _ ? "core_transaction_deposit_insufficient_funds_error" : w ? "core_transaction_deposit_gas_error" : E ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
3838
+ throw new m(R, u);
3834
3839
  }
3835
3840
  });
3836
3841
  /**
@@ -3846,7 +3851,7 @@ class Pn {
3846
3851
  try {
3847
3852
  a = await f(this, N).call(this, {
3848
3853
  assetValue: t,
3849
- memo: x(h.DEPOSIT, {
3854
+ memo: D(h.DEPOSIT, {
3850
3855
  ...n,
3851
3856
  address: this.getAddress(n.chain)
3852
3857
  })
@@ -3857,7 +3862,7 @@ class Pn {
3857
3862
  try {
3858
3863
  s = await f(this, N).call(this, {
3859
3864
  assetValue: n,
3860
- memo: x(h.DEPOSIT, {
3865
+ memo: D(h.DEPOSIT, {
3861
3866
  ...n,
3862
3867
  address: this.getAddress(i.THORChain)
3863
3868
  })
@@ -3876,32 +3881,32 @@ class Pn {
3876
3881
  isPendingSymmAsset: o,
3877
3882
  mode: p = "sym"
3878
3883
  }) => {
3879
- const [d, ...y] = t.split("."), u = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (u || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (u || p === "asset"), A = o || c, R = A ? s || this.getAddress(i.THORChain) : "", g = u || p === "asset" ? r || this.getAddress(d) : "";
3884
+ const [d, ...y] = t.split("."), u = p === "sym", c = (n == null ? void 0 : n.gt(0)) && (u || p === "rune"), _ = (a == null ? void 0 : a.gt(0)) && (u || p === "asset"), w = o || c, E = w ? s || this.getAddress(i.THORChain) : "", R = u || p === "asset" ? r || this.getAddress(d) : "";
3880
3885
  if (!c && !_)
3881
3886
  throw new m("core_transaction_add_liquidity_invalid_params");
3882
- if (A && !R)
3887
+ if (w && !E)
3883
3888
  throw new m("core_transaction_add_liquidity_no_rune_address");
3884
- let E, I;
3889
+ let A, O;
3885
3890
  const v = { chain: d, symbol: y.join(".") };
3886
3891
  if (c && n)
3887
3892
  try {
3888
- E = await f(this, N).call(this, {
3893
+ A = await f(this, N).call(this, {
3889
3894
  assetValue: n,
3890
- memo: x(h.DEPOSIT, { ...v, address: g })
3895
+ memo: D(h.DEPOSIT, { ...v, address: R })
3891
3896
  });
3892
- } catch (D) {
3893
- throw new m("core_transaction_add_liquidity_rune_error", D);
3897
+ } catch (P) {
3898
+ throw new m("core_transaction_add_liquidity_rune_error", P);
3894
3899
  }
3895
3900
  if (_ && a)
3896
3901
  try {
3897
- I = await f(this, N).call(this, {
3902
+ O = await f(this, N).call(this, {
3898
3903
  assetValue: a,
3899
- memo: x(h.DEPOSIT, { ...v, address: R })
3904
+ memo: D(h.DEPOSIT, { ...v, address: E })
3900
3905
  });
3901
- } catch (D) {
3902
- throw new m("core_transaction_add_liquidity_asset_error", D);
3906
+ } catch (P) {
3907
+ throw new m("core_transaction_add_liquidity_asset_error", P);
3903
3908
  }
3904
- return { runeTx: E, assetTx: I };
3909
+ return { runeTx: A, assetTx: O };
3905
3910
  });
3906
3911
  T(this, "withdraw", async ({
3907
3912
  memo: t,
@@ -3914,7 +3919,7 @@ class Pn {
3914
3919
  try {
3915
3920
  return await f(this, N).call(this, {
3916
3921
  assetValue: ve(s === "asset" ? n.chain : i.THORChain),
3917
- memo: t || x(h.WITHDRAW, {
3922
+ memo: t || D(h.WITHDRAW, {
3918
3923
  symbol: n.symbol,
3919
3924
  chain: n.chain,
3920
3925
  ticker: n.ticker,
@@ -3933,7 +3938,7 @@ class Pn {
3933
3938
  percent: a,
3934
3939
  type: s
3935
3940
  }) => {
3936
- const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || x(r, {
3941
+ const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || D(r, {
3937
3942
  ticker: t.ticker,
3938
3943
  symbol: t.symbol,
3939
3944
  chain: t.chain,
@@ -3949,7 +3954,7 @@ class Pn {
3949
3954
  type: s
3950
3955
  }) => f(this, N).call(this, {
3951
3956
  assetValue: t,
3952
- memo: n || x(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
3957
+ memo: n || D(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
3953
3958
  asset: t.toString(),
3954
3959
  minAmount: a.toString(),
3955
3960
  address: this.getAddress(t.chain)
@@ -3960,9 +3965,9 @@ class Pn {
3960
3965
  assetValue: n,
3961
3966
  address: a
3962
3967
  }) => {
3963
- const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = x(s, {
3968
+ const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = D(s, {
3964
3969
  address: a,
3965
- unbondAmount: t === "unbond" ? n.baseValueNumber : void 0
3970
+ unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
3966
3971
  });
3967
3972
  return f(this, Y).call(this, {
3968
3973
  memo: r,
@@ -3972,7 +3977,7 @@ class Pn {
3972
3977
  T(this, "registerThorname", ({
3973
3978
  assetValue: t,
3974
3979
  ...n
3975
- }) => f(this, Y).call(this, { assetValue: t, memo: x(h.THORNAME_REGISTER, n) }));
3980
+ }) => f(this, Y).call(this, { assetValue: t, memo: D(h.THORNAME_REGISTER, n) }));
3976
3981
  T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
3977
3982
  try {
3978
3983
  t.forEach((r) => {
@@ -4053,7 +4058,7 @@ class Pn {
4053
4058
  T(this, "disconnectChain", (t) => {
4054
4059
  this.connectedChains[t] = null, this.connectedWallets[t] = null;
4055
4060
  });
4056
- P(this, B, async (t) => {
4061
+ B(this, V, async (t) => {
4057
4062
  if (t === i.THORChain)
4058
4063
  return {
4059
4064
  gas_rate: "0",
@@ -4069,11 +4074,11 @@ class Pn {
4069
4074
  throw new m("core_chain_halted");
4070
4075
  return a;
4071
4076
  });
4072
- P(this, ae, ({ chain: t, wallet: n, walletMethods: a }) => {
4077
+ B(this, ae, ({ chain: t, wallet: n, walletMethods: a }) => {
4073
4078
  this.connectedChains[t] = n, this.connectedWallets[t] = a;
4074
4079
  });
4075
- P(this, K, async ({
4076
- assetValue: { baseValueBigInt: t, address: n, chain: a, isGasAsset: s, isSynthetic: r },
4080
+ B(this, K, async ({
4081
+ assetValue: { getBaseValue: t, address: n, chain: a, isGasAsset: s, isSynthetic: r },
4077
4082
  type: o = "checkOnly",
4078
4083
  contractAddress: p
4079
4084
  }) => {
@@ -4086,24 +4091,24 @@ class Pn {
4086
4091
  const _ = this.getAddress(a);
4087
4092
  if (!n || !_)
4088
4093
  throw new m("core_approve_asset_address_or_from_not_found");
4089
- const A = p || (await f(this, B).call(this, a)).router;
4094
+ const w = p || (await f(this, V).call(this, a)).router;
4090
4095
  return c({
4091
- amount: t,
4096
+ amount: t("bigint"),
4092
4097
  assetAddress: n,
4093
4098
  from: _,
4094
- spenderAddress: A
4099
+ spenderAddress: w
4095
4100
  });
4096
4101
  });
4097
- P(this, N, async ({
4102
+ B(this, N, async ({
4098
4103
  assetValue: t,
4099
4104
  memo: n,
4100
- feeOptionKey: a = k.Fast
4105
+ feeOptionKey: a = F.Fast
4101
4106
  }) => {
4102
4107
  const {
4103
4108
  gas_rate: s,
4104
4109
  router: r,
4105
4110
  address: o
4106
- } = await f(this, B).call(this, t.chain), p = (parseInt(s) || 0) * ft[a];
4111
+ } = await f(this, V).call(this, t.chain), p = (parseInt(s) || 0) * ft[a];
4107
4112
  return this.deposit({
4108
4113
  assetValue: t,
4109
4114
  recipient: o,
@@ -4112,13 +4117,13 @@ class Pn {
4112
4117
  feeRate: p
4113
4118
  });
4114
4119
  });
4115
- P(this, Y, async ({ memo: t, assetValue: n }) => {
4120
+ B(this, Y, async ({ memo: t, assetValue: n }) => {
4116
4121
  const a = await cn(this.stagenet);
4117
4122
  if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
4118
4123
  throw new m("core_chain_halted");
4119
4124
  return this.deposit({ assetValue: n, recipient: "", memo: t });
4120
4125
  });
4121
- P(this, X, ({ assetValue: t, ...n }) => ({
4126
+ B(this, X, ({ assetValue: t, ...n }) => ({
4122
4127
  ...n,
4123
4128
  memo: n.memo || "",
4124
4129
  from: this.getAddress(t.chain),
@@ -4127,7 +4132,7 @@ class Pn {
4127
4132
  this.stagenet = !!t;
4128
4133
  }
4129
4134
  }
4130
- B = new WeakMap(), ae = new WeakMap(), K = new WeakMap(), N = new WeakMap(), Y = new WeakMap(), X = new WeakMap();
4135
+ V = new WeakMap(), ae = new WeakMap(), K = new WeakMap(), N = new WeakMap(), Y = new WeakMap(), X = new WeakMap();
4131
4136
  export {
4132
4137
  Ze as AGG_SWAP,
4133
4138
  hn as ApiError,
@@ -4150,7 +4155,7 @@ export {
4150
4155
  Me as ERROR_TYPE,
4151
4156
  fn as EVMChainList,
4152
4157
  dt as ErrorCode,
4153
- k as FeeOption,
4158
+ F as FeeOption,
4154
4159
  h as MemoType,
4155
4160
  _n as NetworkDerivationPath,
4156
4161
  ze as QuoteMode,
@@ -4160,7 +4165,7 @@ export {
4160
4165
  tt as SWAP_OUT,
4161
4166
  Pn as SwapKitCore,
4162
4167
  m as SwapKitError,
4163
- j as SwapKitNumber,
4168
+ x as SwapKitNumber,
4164
4169
  Je as TCAvalancheDepositABI,
4165
4170
  Qe as TCBscDepositABI,
4166
4171
  Xe as TCEthereumVaultAbi,
@@ -4182,7 +4187,7 @@ export {
4182
4187
  Be as getDecimal,
4183
4188
  Cn as getEstimatedPoolShare,
4184
4189
  Mn as getLiquiditySlippage,
4185
- x as getMemoFor,
4190
+ D as getMemoFor,
4186
4191
  ve as getMinAmountByChain,
4187
4192
  Ot as getSymmetricPoolShare,
4188
4193
  vn as getSymmetricWithdraw,