@swapkit/core 1.0.0-rc.65 → 1.0.0-rc.67

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
@@ -794,7 +794,7 @@ const ae = Object.values(i), ot = Object.keys(i), be = ae.reduce(
794
794
  return e[t] = fe[n], e;
795
795
  },
796
796
  {}
797
- ), Sn = {
797
+ ), In = {
798
798
  "0xa4b1": "ARB",
799
799
  42161: "ARB",
800
800
  "0xa86a": "AVAX",
@@ -824,22 +824,22 @@ const ae = Object.values(i), ot = Object.keys(i), be = ae.reduce(
824
824
  AVAX: "https://snowtrace.io",
825
825
  BSC: "https://bscscan.com",
826
826
  BNB: "https://explorer.binance.org",
827
- BCH: "https://www.blockchain.com/bch",
828
- BTC: "https://blockstream.info",
827
+ BCH: "https://www.blockchair.com/bitcoin-cash",
828
+ BTC: "https://blockchair.com/bitcoin",
829
829
  GAIA: "https://cosmos.bigdipper.live",
830
830
  DOGE: "https://blockchair.com/dogecoin",
831
831
  KUJI: "https://finder.kujira.network/kaiyo-1",
832
832
  ETH: "https://etherscan.io",
833
- LTC: "https://ltc.bitaps.com",
833
+ LTC: "https://blockchair.com/litecoin",
834
834
  MAYA: "https://www.mayascan.org",
835
835
  OP: "https://optimistic.etherscan.io",
836
836
  MATIC: "https://polygonscan.com",
837
837
  THOR: "https://runescan.io"
838
838
  };
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) => {
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.OKX_MOBILE = "OKX_MOBILE", 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, S = (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
- }, H = (e, t, n) => {
842
+ }, $ = (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);
@@ -971,7 +971,7 @@ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
971
971
  case i.Optimism:
972
972
  return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
973
973
  }
974
- }, In = (e) => {
974
+ }, Sn = (e) => {
975
975
  var t;
976
976
  const [n, ...a] = e.split("."), s = e.includes("/"), r = a.join("."), o = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
977
977
  return { chain: n, symbol: r, ticker: o, synth: s };
@@ -994,7 +994,7 @@ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
994
994
  }) => {
995
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
996
  return o.mul(p.sub(d).add(u)).div(l);
997
- }, St = ({
997
+ }, It = ({
998
998
  liquidityUnits: e,
999
999
  poolUnits: t,
1000
1000
  assetDepth: n
@@ -1011,7 +1011,7 @@ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
1011
1011
  assetDepth: t,
1012
1012
  liquidityUnits: n,
1013
1013
  poolUnits: a
1014
- }) => St({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), g = (e) => x.fromBigInt(BigInt(e), w.THOR), It = ({
1014
+ }) => It({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), g = (e) => x.fromBigInt(BigInt(e), w.THOR), St = ({
1015
1015
  liquidityUnits: e,
1016
1016
  poolUnits: t,
1017
1017
  runeDepth: n,
@@ -1026,7 +1026,7 @@ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
1026
1026
  assetDepth: a,
1027
1027
  percent: s
1028
1028
  }) => Object.fromEntries(
1029
- Object.entries(It({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
1029
+ Object.entries(St({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
1030
1030
  ([r, o]) => [r, o.mul(s)]
1031
1031
  )
1032
1032
  ), xn = ({
@@ -1037,8 +1037,8 @@ 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 }), 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
- if (S.getBaseValue("number") === 0)
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))), I = E.div(O), D = g(a).add(I);
1041
+ if (I.getBaseValue("number") === 0)
1042
1042
  return D.div(d).getBaseValue("number");
1043
1043
  const ie = d.add(D);
1044
1044
  return D.div(ie).getBaseValue("number");
@@ -1212,7 +1212,7 @@ const J = (e) => e !== null && typeof e == "object", X = (...e) => {
1212
1212
  maxRetryAfter: Number.POSITIVE_INFINITY,
1213
1213
  backoffLimit: Number.POSITIVE_INFINITY,
1214
1214
  delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
1215
- }, $t = (e = {}) => {
1215
+ }, Ht = (e = {}) => {
1216
1216
  if (typeof e == "number")
1217
1217
  return {
1218
1218
  ...Re,
@@ -1228,7 +1228,7 @@ const J = (e) => e !== null && typeof e == "object", X = (...e) => {
1228
1228
  afterStatusCodes: Ue
1229
1229
  };
1230
1230
  };
1231
- async function Ht(e, t, n, a) {
1231
+ async function $t(e, t, n, a) {
1232
1232
  return new Promise((s, r) => {
1233
1233
  const o = setTimeout(() => {
1234
1234
  n && n.abort(), r(new Pe(e));
@@ -1336,7 +1336,7 @@ class Z {
1336
1336
  method: Lt(n.method ?? this._input.method),
1337
1337
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
1338
1338
  prefixUrl: String(n.prefixUrl || ""),
1339
- retry: $t(n.retry),
1339
+ retry: Ht(n.retry),
1340
1340
  throwHttpErrors: n.throwHttpErrors !== !1,
1341
1341
  timeout: n.timeout ?? 1e4,
1342
1342
  fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
@@ -1414,7 +1414,7 @@ class Z {
1414
1414
  return a;
1415
1415
  }
1416
1416
  const t = Ft(this.request, this._options);
1417
- return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Ht(this.request.clone(), t, this.abortController, this._options);
1417
+ return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : $t(this.request.clone(), t, this.abortController, this._options);
1418
1418
  }
1419
1419
  /* istanbul ignore next */
1420
1420
  _stream(t, n) {
@@ -1486,15 +1486,15 @@ function se({
1486
1486
  ""
1487
1487
  );
1488
1488
  }
1489
- var U, k, B, $, ye, $e, Q, pe, ee, ce;
1490
- const Kt = class He {
1489
+ var U, k, B, H, ye, He, Q, pe, ee, ce;
1490
+ const Kt = class $e {
1491
1491
  constructor(t) {
1492
- H(this, U), H(this, B), H(this, ye), H(this, Q), H(this, ee), I(this, "decimalMultiplier", 10n ** 8n), I(this, "bigIntValue", 0n), I(this, "decimal");
1492
+ $(this, U), $(this, B), $(this, ye), $(this, Q), $(this, ee), S(this, "decimalMultiplier", 10n ** 8n), S(this, "bigIntValue", 0n), S(this, "decimal");
1493
1493
  const n = Te(t), a = typeof t == "object";
1494
- 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, ye, $e).call(this, n);
1494
+ 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, ye, He).call(this, n);
1495
1495
  }
1496
1496
  static fromBigInt(t, n) {
1497
- return new He({
1497
+ return new $e({
1498
1498
  decimal: n,
1499
1499
  value: se({ value: t, bigIntDecimal: n, decimal: n })
1500
1500
  });
@@ -1525,19 +1525,19 @@ const Kt = class He {
1525
1525
  return R(this, U, k).call(this, "div", ...t);
1526
1526
  }
1527
1527
  gt(t) {
1528
- return R(this, B, $).call(this, "gt", t);
1528
+ return R(this, B, H).call(this, "gt", t);
1529
1529
  }
1530
1530
  gte(t) {
1531
- return R(this, B, $).call(this, "gte", t);
1531
+ return R(this, B, H).call(this, "gte", t);
1532
1532
  }
1533
1533
  lt(t) {
1534
- return R(this, B, $).call(this, "lt", t);
1534
+ return R(this, B, H).call(this, "lt", t);
1535
1535
  }
1536
1536
  lte(t) {
1537
- return R(this, B, $).call(this, "lte", t);
1537
+ return R(this, B, H).call(this, "lte", t);
1538
1538
  }
1539
1539
  eqValue(t) {
1540
- return R(this, B, $).call(this, "eqValue", t);
1540
+ return R(this, B, H).call(this, "eqValue", t);
1541
1541
  }
1542
1542
  // @ts-expect-error False positive
1543
1543
  getValue(t) {
@@ -1660,7 +1660,7 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1660
1660
  value: o,
1661
1661
  identifier: this.toString()
1662
1662
  });
1663
- }, B = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
1663
+ }, B = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
1664
1664
  const n = R(this, Q, pe).call(this, this, ...t), a = this.getBigIntValue(t[0], n), s = this.getBigIntValue(this, n);
1665
1665
  switch (e) {
1666
1666
  case "gt":
@@ -1674,7 +1674,7 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1674
1674
  case "eqValue":
1675
1675
  return s === a;
1676
1676
  }
1677
- }, ye = /* @__PURE__ */ new WeakSet(), $e = function(e) {
1677
+ }, ye = /* @__PURE__ */ new WeakSet(), He = function(e) {
1678
1678
  const t = te(e) || "0";
1679
1679
  this.bigIntValue = R(this, ee, ce).call(this, t);
1680
1680
  }, Q = /* @__PURE__ */ new WeakSet(), pe = function(...e) {
@@ -1703,7 +1703,7 @@ function Te(e) {
1703
1703
  }
1704
1704
  const z = (e, t) => typeof e == "bigint" ? se({ value: e, bigIntDecimal: t, decimal: t }) : e;
1705
1705
  let he;
1706
- const Se = (e) => {
1706
+ const Ie = (e) => {
1707
1707
  if (!he)
1708
1708
  throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
1709
1709
  return he.get(e.toUpperCase()) || { decimal: w.THOR, identifier: "" };
@@ -1717,7 +1717,7 @@ class N extends me {
1717
1717
  const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`;
1718
1718
  super(
1719
1719
  t.value instanceof me ? t.value : { decimal: t.decimal, value: t.value }
1720
- ), I(this, "address"), I(this, "chain"), I(this, "isGasAsset", !1), I(this, "isSynthetic", !1), I(this, "symbol"), I(this, "tax"), I(this, "ticker"), I(this, "type");
1720
+ ), S(this, "address"), S(this, "chain"), S(this, "isGasAsset", !1), S(this, "isSynthetic", !1), S(this, "symbol"), S(this, "tax"), S(this, "ticker"), S(this, "type");
1721
1721
  const a = _e(n);
1722
1722
  this.type = Et(a), this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset, this.tax = t.tax;
1723
1723
  }
@@ -1748,14 +1748,14 @@ class N extends me {
1748
1748
  tax: s,
1749
1749
  decimal: r,
1750
1750
  identifier: o
1751
- } = Se(t), p = z(n, r);
1751
+ } = Ie(t), p = z(n, r);
1752
1752
  return o ? new N({ tax: s, decimal: r, identifier: o, value: p }) : a ? new N({ tax: s, decimal: 8, identifier: t, value: p }) : void 0;
1753
1753
  }
1754
1754
  static fromIdentifier(t, n = 0) {
1755
1755
  return de(t, n);
1756
1756
  }
1757
1757
  static fromIdentifierSync(t, n = 0) {
1758
- const { decimal: a, identifier: s } = Se(t), r = z(n, a);
1758
+ const { decimal: a, identifier: s } = Ie(t), r = z(n, a);
1759
1759
  return new N({ decimal: a, identifier: s, value: r });
1760
1760
  }
1761
1761
  static fromChainOrSignature(t, n = 0) {
@@ -3618,7 +3618,7 @@ const Jt = [
3618
3618
  const O = !!Fe[t.toLowerCase()];
3619
3619
  if (O && !u)
3620
3620
  throw new Error("Router is required on calldata for swapIn with GenericContract");
3621
- const S = m || d, D = e && l || S;
3621
+ const I = m || d, D = e && l || I;
3622
3622
  if (!b && !A)
3623
3623
  throw new Error("TC Vault is required on calldata");
3624
3624
  if (!_ && !u)
@@ -3640,8 +3640,6 @@ const Jt = [
3640
3640
  const n = Ne[e];
3641
3641
  switch (e) {
3642
3642
  case i.Binance:
3643
- case i.Bitcoin:
3644
- case i.BitcoinCash:
3645
3643
  case i.Maya:
3646
3644
  case i.Kujira:
3647
3645
  case i.THORChain:
@@ -3655,10 +3653,11 @@ const Jt = [
3655
3653
  return `${n}/tx/${t.startsWith("0x") ? t : `0x${t}`}`;
3656
3654
  case i.Cosmos:
3657
3655
  return `${n}/transactions/${t}`;
3656
+ case i.Litecoin:
3657
+ case i.Bitcoin:
3658
+ case i.BitcoinCash:
3658
3659
  case i.Dogecoin:
3659
3660
  return `${n}/transaction/${t.toLowerCase()}`;
3660
- case i.Litecoin:
3661
- return `${n}/${t}`;
3662
3661
  default:
3663
3662
  throw new Error(`Unsupported chain: ${e}`);
3664
3663
  }
@@ -3673,16 +3672,15 @@ const Jt = [
3673
3672
  case i.BitcoinCash:
3674
3673
  case i.Dogecoin:
3675
3674
  case i.Ethereum:
3675
+ case i.Kujira:
3676
+ case i.Litecoin:
3676
3677
  case i.Maya:
3677
3678
  case i.Optimism:
3678
3679
  case i.Polygon:
3679
- case i.Kujira:
3680
3680
  case i.THORChain:
3681
3681
  return `${n}/address/${t}`;
3682
3682
  case i.Cosmos:
3683
3683
  return `${n}/account/${t}`;
3684
- case i.Litecoin:
3685
- return `${n}/${t}`;
3686
3684
  default:
3687
3685
  throw new Error(`Unsupported chain: ${e}`);
3688
3686
  }
@@ -3692,7 +3690,7 @@ const Jt = [
3692
3690
  }, hn = (e) => {
3693
3691
  const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
3694
3692
  return Ae.get(`${t}/thorchain/mimir`);
3695
- }, Ie = () => Object.values(i).reduce(
3693
+ }, Se = () => Object.values(i).reduce(
3696
3694
  (e, t) => (e[t] = null, e),
3697
3695
  {}
3698
3696
  ), _n = async ({ chain: e, address: t }) => {
@@ -3708,8 +3706,8 @@ const Jt = [
3708
3706
  var V, ne, j, v, K, Y;
3709
3707
  class Vn {
3710
3708
  constructor({ stagenet: t } = {}) {
3711
- T(this, "connectedChains", Ie());
3712
- T(this, "connectedWallets", Ie());
3709
+ T(this, "connectedChains", Se());
3710
+ T(this, "connectedWallets", Se());
3713
3711
  T(this, "stagenet", !1);
3714
3712
  T(this, "getAddress", (t) => {
3715
3713
  var n;
@@ -3752,11 +3750,11 @@ class Vn {
3752
3750
  const { address: l } = await f(this, V).call(this, u.chain), {
3753
3751
  contract: m,
3754
3752
  calldata: { expiration: _, amountIn: b, memo: A, memoStreamingSwap: E }
3755
- } = a, O = u.add(x.fromBigInt(BigInt(b), u.decimal)), S = t && E || A;
3753
+ } = a, O = u.add(x.fromBigInt(BigInt(b), u.decimal)), I = t && E || A;
3756
3754
  return this.deposit({
3757
3755
  expiration: _,
3758
3756
  assetValue: O,
3759
- memo: S,
3757
+ memo: I,
3760
3758
  feeOptionKey: s,
3761
3759
  router: m,
3762
3760
  recipient: l
@@ -3923,8 +3921,8 @@ class Vn {
3923
3921
  assetValue: t,
3924
3922
  memo: M(h.DEPOSIT, { chain: p, symbol: d, address: A })
3925
3923
  });
3926
- } catch (S) {
3927
- throw new c("core_transaction_add_liquidity_rune_error", S);
3924
+ } catch (I) {
3925
+ throw new c("core_transaction_add_liquidity_rune_error", I);
3928
3926
  }
3929
3927
  if (m && n)
3930
3928
  try {
@@ -3932,8 +3930,8 @@ class Vn {
3932
3930
  assetValue: n,
3933
3931
  memo: M(h.DEPOSIT, { chain: p, symbol: d, address: b })
3934
3932
  });
3935
- } catch (S) {
3936
- throw new c("core_transaction_add_liquidity_asset_error", S);
3933
+ } catch (I) {
3934
+ throw new c("core_transaction_add_liquidity_asset_error", I);
3937
3935
  }
3938
3936
  return { runeTx: E, assetTx: O };
3939
3937
  });
@@ -4179,7 +4177,7 @@ export {
4179
4177
  me as BigIntArithmetics,
4180
4178
  i as Chain,
4181
4179
  fe as ChainId,
4182
- Sn as ChainIdToChain,
4180
+ In as ChainIdToChain,
4183
4181
  pt as ChainToChainId,
4184
4182
  Ne as ChainToExplorerUrl,
4185
4183
  On as ChainToHexChainId,
@@ -4209,14 +4207,14 @@ export {
4209
4207
  gn as TCSupportedChainList,
4210
4208
  En as UTXOChainList,
4211
4209
  lt as WalletOption,
4212
- In as assetFromString,
4210
+ Sn as assetFromString,
4213
4211
  Ln as derivationPathToString,
4214
4212
  bn as erc20ABI,
4215
4213
  vn as filterAssets,
4216
4214
  se as formatBigIntToSafeValue,
4217
4215
  wt as gasFeeMultiplier,
4218
4216
  Et as getAssetType,
4219
- St as getAsymmetricAssetShare,
4217
+ It as getAsymmetricAssetShare,
4220
4218
  Mn as getAsymmetricAssetWithdrawAmount,
4221
4219
  Ot as getAsymmetricRuneShare,
4222
4220
  Cn as getAsymmetricRuneWithdrawAmount,
@@ -4226,9 +4224,10 @@ export {
4226
4224
  Dn as getLiquiditySlippage,
4227
4225
  M as getMemoFor,
4228
4226
  ue as getMinAmountByChain,
4229
- It as getSymmetricPoolShare,
4227
+ St as getSymmetricPoolShare,
4230
4228
  Nn as getSymmetricWithdraw,
4231
4229
  Pn as getTHORNameCost,
4232
4230
  De as isGasAsset,
4233
4231
  Bn as validateTHORName
4234
4232
  };
4233
+ //# sourceMappingURL=index.es.js.map