@swapkit/core 1.0.0-rc.66 → 1.0.0-rc.68
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +29 -27
- package/dist/index.es.js.map +1 -1
- package/package.json +11 -11
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
|
-
),
|
|
797
|
+
), In = {
|
|
798
798
|
"0xa4b1": "ARB",
|
|
799
799
|
42161: "ARB",
|
|
800
800
|
"0xa86a": "AVAX",
|
|
@@ -836,7 +836,7 @@ const ae = Object.values(i), ot = Object.keys(i), be = ae.reduce(
|
|
|
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,
|
|
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
842
|
}, $ = (e, t, 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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
}) =>
|
|
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(
|
|
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))),
|
|
1041
|
-
if (
|
|
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");
|
|
@@ -1475,6 +1475,8 @@ function se({
|
|
|
1475
1475
|
bigIntDecimal: t = W,
|
|
1476
1476
|
decimal: n = W
|
|
1477
1477
|
}) {
|
|
1478
|
+
if (n === 0)
|
|
1479
|
+
return e.toString();
|
|
1478
1480
|
const a = e < 0n;
|
|
1479
1481
|
let s = e.toString().substring(a ? 1 : 0);
|
|
1480
1482
|
const r = n - (s.length - 1);
|
|
@@ -1489,7 +1491,7 @@ function se({
|
|
|
1489
1491
|
var U, k, B, H, ye, He, Q, pe, ee, ce;
|
|
1490
1492
|
const Kt = class $e {
|
|
1491
1493
|
constructor(t) {
|
|
1492
|
-
$(this, U), $(this, B), $(this, ye), $(this, Q), $(this, ee),
|
|
1494
|
+
$(this, U), $(this, B), $(this, ye), $(this, Q), $(this, ee), S(this, "decimalMultiplier", 10n ** 8n), S(this, "bigIntValue", 0n), S(this, "decimal");
|
|
1493
1495
|
const n = Te(t), a = typeof t == "object";
|
|
1494
1496
|
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
1497
|
}
|
|
@@ -1703,7 +1705,7 @@ function Te(e) {
|
|
|
1703
1705
|
}
|
|
1704
1706
|
const z = (e, t) => typeof e == "bigint" ? se({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1705
1707
|
let he;
|
|
1706
|
-
const
|
|
1708
|
+
const Ie = (e) => {
|
|
1707
1709
|
if (!he)
|
|
1708
1710
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1709
1711
|
return he.get(e.toUpperCase()) || { decimal: w.THOR, identifier: "" };
|
|
@@ -1717,7 +1719,7 @@ class N extends me {
|
|
|
1717
1719
|
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`;
|
|
1718
1720
|
super(
|
|
1719
1721
|
t.value instanceof me ? t.value : { decimal: t.decimal, value: t.value }
|
|
1720
|
-
),
|
|
1722
|
+
), 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
1723
|
const a = _e(n);
|
|
1722
1724
|
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
1725
|
}
|
|
@@ -1748,14 +1750,14 @@ class N extends me {
|
|
|
1748
1750
|
tax: s,
|
|
1749
1751
|
decimal: r,
|
|
1750
1752
|
identifier: o
|
|
1751
|
-
} =
|
|
1753
|
+
} = Ie(t), p = z(n, r);
|
|
1752
1754
|
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
1755
|
}
|
|
1754
1756
|
static fromIdentifier(t, n = 0) {
|
|
1755
1757
|
return de(t, n);
|
|
1756
1758
|
}
|
|
1757
1759
|
static fromIdentifierSync(t, n = 0) {
|
|
1758
|
-
const { decimal: a, identifier: s } =
|
|
1760
|
+
const { decimal: a, identifier: s } = Ie(t), r = z(n, a);
|
|
1759
1761
|
return new N({ decimal: a, identifier: s, value: r });
|
|
1760
1762
|
}
|
|
1761
1763
|
static fromChainOrSignature(t, n = 0) {
|
|
@@ -3618,7 +3620,7 @@ const Jt = [
|
|
|
3618
3620
|
const O = !!Fe[t.toLowerCase()];
|
|
3619
3621
|
if (O && !u)
|
|
3620
3622
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3621
|
-
const
|
|
3623
|
+
const I = m || d, D = e && l || I;
|
|
3622
3624
|
if (!b && !A)
|
|
3623
3625
|
throw new Error("TC Vault is required on calldata");
|
|
3624
3626
|
if (!_ && !u)
|
|
@@ -3690,7 +3692,7 @@ const Jt = [
|
|
|
3690
3692
|
}, hn = (e) => {
|
|
3691
3693
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3692
3694
|
return Ae.get(`${t}/thorchain/mimir`);
|
|
3693
|
-
},
|
|
3695
|
+
}, Se = () => Object.values(i).reduce(
|
|
3694
3696
|
(e, t) => (e[t] = null, e),
|
|
3695
3697
|
{}
|
|
3696
3698
|
), _n = async ({ chain: e, address: t }) => {
|
|
@@ -3706,8 +3708,8 @@ const Jt = [
|
|
|
3706
3708
|
var V, ne, j, v, K, Y;
|
|
3707
3709
|
class Vn {
|
|
3708
3710
|
constructor({ stagenet: t } = {}) {
|
|
3709
|
-
T(this, "connectedChains",
|
|
3710
|
-
T(this, "connectedWallets",
|
|
3711
|
+
T(this, "connectedChains", Se());
|
|
3712
|
+
T(this, "connectedWallets", Se());
|
|
3711
3713
|
T(this, "stagenet", !1);
|
|
3712
3714
|
T(this, "getAddress", (t) => {
|
|
3713
3715
|
var n;
|
|
@@ -3750,11 +3752,11 @@ class Vn {
|
|
|
3750
3752
|
const { address: l } = await f(this, V).call(this, u.chain), {
|
|
3751
3753
|
contract: m,
|
|
3752
3754
|
calldata: { expiration: _, amountIn: b, memo: A, memoStreamingSwap: E }
|
|
3753
|
-
} = a, O = u.add(x.fromBigInt(BigInt(b), u.decimal)),
|
|
3755
|
+
} = a, O = u.add(x.fromBigInt(BigInt(b), u.decimal)), I = t && E || A;
|
|
3754
3756
|
return this.deposit({
|
|
3755
3757
|
expiration: _,
|
|
3756
3758
|
assetValue: O,
|
|
3757
|
-
memo:
|
|
3759
|
+
memo: I,
|
|
3758
3760
|
feeOptionKey: s,
|
|
3759
3761
|
router: m,
|
|
3760
3762
|
recipient: l
|
|
@@ -3921,8 +3923,8 @@ class Vn {
|
|
|
3921
3923
|
assetValue: t,
|
|
3922
3924
|
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: A })
|
|
3923
3925
|
});
|
|
3924
|
-
} catch (
|
|
3925
|
-
throw new c("core_transaction_add_liquidity_rune_error",
|
|
3926
|
+
} catch (I) {
|
|
3927
|
+
throw new c("core_transaction_add_liquidity_rune_error", I);
|
|
3926
3928
|
}
|
|
3927
3929
|
if (m && n)
|
|
3928
3930
|
try {
|
|
@@ -3930,8 +3932,8 @@ class Vn {
|
|
|
3930
3932
|
assetValue: n,
|
|
3931
3933
|
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: b })
|
|
3932
3934
|
});
|
|
3933
|
-
} catch (
|
|
3934
|
-
throw new c("core_transaction_add_liquidity_asset_error",
|
|
3935
|
+
} catch (I) {
|
|
3936
|
+
throw new c("core_transaction_add_liquidity_asset_error", I);
|
|
3935
3937
|
}
|
|
3936
3938
|
return { runeTx: E, assetTx: O };
|
|
3937
3939
|
});
|
|
@@ -4177,7 +4179,7 @@ export {
|
|
|
4177
4179
|
me as BigIntArithmetics,
|
|
4178
4180
|
i as Chain,
|
|
4179
4181
|
fe as ChainId,
|
|
4180
|
-
|
|
4182
|
+
In as ChainIdToChain,
|
|
4181
4183
|
pt as ChainToChainId,
|
|
4182
4184
|
Ne as ChainToExplorerUrl,
|
|
4183
4185
|
On as ChainToHexChainId,
|
|
@@ -4207,14 +4209,14 @@ export {
|
|
|
4207
4209
|
gn as TCSupportedChainList,
|
|
4208
4210
|
En as UTXOChainList,
|
|
4209
4211
|
lt as WalletOption,
|
|
4210
|
-
|
|
4212
|
+
Sn as assetFromString,
|
|
4211
4213
|
Ln as derivationPathToString,
|
|
4212
4214
|
bn as erc20ABI,
|
|
4213
4215
|
vn as filterAssets,
|
|
4214
4216
|
se as formatBigIntToSafeValue,
|
|
4215
4217
|
wt as gasFeeMultiplier,
|
|
4216
4218
|
Et as getAssetType,
|
|
4217
|
-
|
|
4219
|
+
It as getAsymmetricAssetShare,
|
|
4218
4220
|
Mn as getAsymmetricAssetWithdrawAmount,
|
|
4219
4221
|
Ot as getAsymmetricRuneShare,
|
|
4220
4222
|
Cn as getAsymmetricRuneWithdrawAmount,
|
|
@@ -4224,7 +4226,7 @@ export {
|
|
|
4224
4226
|
Dn as getLiquiditySlippage,
|
|
4225
4227
|
M as getMemoFor,
|
|
4226
4228
|
ue as getMinAmountByChain,
|
|
4227
|
-
|
|
4229
|
+
St as getSymmetricPoolShare,
|
|
4228
4230
|
Nn as getSymmetricWithdraw,
|
|
4229
4231
|
Pn as getTHORNameCost,
|
|
4230
4232
|
De as isGasAsset,
|