@swapkit/core 1.0.0-rc.66 → 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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +27 -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");
|
|
@@ -1489,7 +1489,7 @@ function se({
|
|
|
1489
1489
|
var U, k, B, H, ye, He, Q, pe, ee, ce;
|
|
1490
1490
|
const Kt = class $e {
|
|
1491
1491
|
constructor(t) {
|
|
1492
|
-
$(this, U), $(this, B), $(this, ye), $(this, Q), $(this, ee),
|
|
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
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
|
}
|
|
@@ -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
|
|
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
|
-
),
|
|
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
|
-
} =
|
|
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 } =
|
|
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
|
|
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)
|
|
@@ -3690,7 +3690,7 @@ const Jt = [
|
|
|
3690
3690
|
}, hn = (e) => {
|
|
3691
3691
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3692
3692
|
return Ae.get(`${t}/thorchain/mimir`);
|
|
3693
|
-
},
|
|
3693
|
+
}, Se = () => Object.values(i).reduce(
|
|
3694
3694
|
(e, t) => (e[t] = null, e),
|
|
3695
3695
|
{}
|
|
3696
3696
|
), _n = async ({ chain: e, address: t }) => {
|
|
@@ -3706,8 +3706,8 @@ const Jt = [
|
|
|
3706
3706
|
var V, ne, j, v, K, Y;
|
|
3707
3707
|
class Vn {
|
|
3708
3708
|
constructor({ stagenet: t } = {}) {
|
|
3709
|
-
T(this, "connectedChains",
|
|
3710
|
-
T(this, "connectedWallets",
|
|
3709
|
+
T(this, "connectedChains", Se());
|
|
3710
|
+
T(this, "connectedWallets", Se());
|
|
3711
3711
|
T(this, "stagenet", !1);
|
|
3712
3712
|
T(this, "getAddress", (t) => {
|
|
3713
3713
|
var n;
|
|
@@ -3750,11 +3750,11 @@ class Vn {
|
|
|
3750
3750
|
const { address: l } = await f(this, V).call(this, u.chain), {
|
|
3751
3751
|
contract: m,
|
|
3752
3752
|
calldata: { expiration: _, amountIn: b, memo: A, memoStreamingSwap: E }
|
|
3753
|
-
} = a, O = u.add(x.fromBigInt(BigInt(b), u.decimal)),
|
|
3753
|
+
} = a, O = u.add(x.fromBigInt(BigInt(b), u.decimal)), I = t && E || A;
|
|
3754
3754
|
return this.deposit({
|
|
3755
3755
|
expiration: _,
|
|
3756
3756
|
assetValue: O,
|
|
3757
|
-
memo:
|
|
3757
|
+
memo: I,
|
|
3758
3758
|
feeOptionKey: s,
|
|
3759
3759
|
router: m,
|
|
3760
3760
|
recipient: l
|
|
@@ -3921,8 +3921,8 @@ class Vn {
|
|
|
3921
3921
|
assetValue: t,
|
|
3922
3922
|
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: A })
|
|
3923
3923
|
});
|
|
3924
|
-
} catch (
|
|
3925
|
-
throw new c("core_transaction_add_liquidity_rune_error",
|
|
3924
|
+
} catch (I) {
|
|
3925
|
+
throw new c("core_transaction_add_liquidity_rune_error", I);
|
|
3926
3926
|
}
|
|
3927
3927
|
if (m && n)
|
|
3928
3928
|
try {
|
|
@@ -3930,8 +3930,8 @@ class Vn {
|
|
|
3930
3930
|
assetValue: n,
|
|
3931
3931
|
memo: M(h.DEPOSIT, { chain: p, symbol: d, address: b })
|
|
3932
3932
|
});
|
|
3933
|
-
} catch (
|
|
3934
|
-
throw new c("core_transaction_add_liquidity_asset_error",
|
|
3933
|
+
} catch (I) {
|
|
3934
|
+
throw new c("core_transaction_add_liquidity_asset_error", I);
|
|
3935
3935
|
}
|
|
3936
3936
|
return { runeTx: E, assetTx: O };
|
|
3937
3937
|
});
|
|
@@ -4177,7 +4177,7 @@ export {
|
|
|
4177
4177
|
me as BigIntArithmetics,
|
|
4178
4178
|
i as Chain,
|
|
4179
4179
|
fe as ChainId,
|
|
4180
|
-
|
|
4180
|
+
In as ChainIdToChain,
|
|
4181
4181
|
pt as ChainToChainId,
|
|
4182
4182
|
Ne as ChainToExplorerUrl,
|
|
4183
4183
|
On as ChainToHexChainId,
|
|
@@ -4207,14 +4207,14 @@ export {
|
|
|
4207
4207
|
gn as TCSupportedChainList,
|
|
4208
4208
|
En as UTXOChainList,
|
|
4209
4209
|
lt as WalletOption,
|
|
4210
|
-
|
|
4210
|
+
Sn as assetFromString,
|
|
4211
4211
|
Ln as derivationPathToString,
|
|
4212
4212
|
bn as erc20ABI,
|
|
4213
4213
|
vn as filterAssets,
|
|
4214
4214
|
se as formatBigIntToSafeValue,
|
|
4215
4215
|
wt as gasFeeMultiplier,
|
|
4216
4216
|
Et as getAssetType,
|
|
4217
|
-
|
|
4217
|
+
It as getAsymmetricAssetShare,
|
|
4218
4218
|
Mn as getAsymmetricAssetWithdrawAmount,
|
|
4219
4219
|
Ot as getAsymmetricRuneShare,
|
|
4220
4220
|
Cn as getAsymmetricRuneWithdrawAmount,
|
|
@@ -4224,7 +4224,7 @@ export {
|
|
|
4224
4224
|
Dn as getLiquiditySlippage,
|
|
4225
4225
|
M as getMemoFor,
|
|
4226
4226
|
ue as getMinAmountByChain,
|
|
4227
|
-
|
|
4227
|
+
St as getSymmetricPoolShare,
|
|
4228
4228
|
Nn as getSymmetricWithdraw,
|
|
4229
4229
|
Pn as getTHORNameCost,
|
|
4230
4230
|
De as isGasAsset,
|