@swapkit/core 1.0.0-rc.24 → 1.0.0-rc.27
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 +2 -2
- package/dist/index.es.js +162 -172
- package/package.json +14 -14
- package/src/client/index.ts +22 -30
- package/dist/index-9e36735e.cjs +0 -1
- package/dist/index-cf1865cd.js +0 -649
package/dist/index.es.js
CHANGED
|
@@ -775,23 +775,23 @@ const fn = [
|
|
|
775
775
|
"THOR"
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
|
-
var
|
|
779
|
-
const ae = Object.values(i), it = Object.keys(i),
|
|
778
|
+
var _e = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(_e || {}), Ne = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Ne || {}), q = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.finance", e.ThorswapStatic = "https://static.thorswap.net", e))(q || {});
|
|
779
|
+
const ae = Object.values(i), it = Object.keys(i), fe = ae.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
781
|
const n = it.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
785
|
), rt = ae.reduce(
|
|
786
|
-
(e, t) => (e[t] =
|
|
786
|
+
(e, t) => (e[t] = _e[fe[t]], e),
|
|
787
787
|
{}
|
|
788
788
|
), ot = ae.reduce(
|
|
789
|
-
(e, t) => (e[t] = Ne[
|
|
789
|
+
(e, t) => (e[t] = Ne[fe[t]], e),
|
|
790
790
|
{}
|
|
791
791
|
), En = ae.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
|
-
const n = `${
|
|
794
|
-
return e[t] =
|
|
793
|
+
const n = `${fe[t]}Hex`;
|
|
794
|
+
return e[t] = _e[n], e;
|
|
795
795
|
},
|
|
796
796
|
{}
|
|
797
797
|
), Rn = {
|
|
@@ -843,10 +843,10 @@ var pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(pt || {}
|
|
|
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
|
-
},
|
|
846
|
+
}, R = (e, t, n) => (yt(e, t, "access private method"), n);
|
|
847
847
|
const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await
|
|
849
|
+
const { result: n } = await we.post(ot[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -985,14 +985,14 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
985
985
|
poolUnits: t,
|
|
986
986
|
runeDepth: n
|
|
987
987
|
}) => {
|
|
988
|
-
const a =
|
|
988
|
+
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), 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 =
|
|
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), 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 ct = "0x313ce567", De = 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),
|
|
1007
|
+
}) => gt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), g = (e) => D.fromBigInt(BigInt(e), A.THOR), Ot = ({
|
|
1008
1008
|
liquidityUnits: e,
|
|
1009
1009
|
poolUnits: t,
|
|
1010
1010
|
runeDepth: n,
|
|
1011
1011
|
assetDepth: a
|
|
1012
1012
|
}) => ({
|
|
1013
|
-
assetAmount:
|
|
1014
|
-
runeAmount:
|
|
1013
|
+
assetAmount: g(a).mul(e).div(t),
|
|
1014
|
+
runeAmount: g(n).mul(e).div(t)
|
|
1015
1015
|
}), vn = ({
|
|
1016
1016
|
liquidityUnits: e,
|
|
1017
1017
|
poolUnits: t,
|
|
@@ -1030,8 +1030,8 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1030
1030
|
runeAmount: s,
|
|
1031
1031
|
assetAmount: r
|
|
1032
1032
|
}) => {
|
|
1033
|
-
const o = new
|
|
1034
|
-
if (
|
|
1033
|
+
const o = new D({ value: e, decimal: 8 }), p = new D({ value: n, decimal: 8 }), d = new D({ value: t, decimal: 8 }), y = new D({ value: s, decimal: 8 }), u = new D({ value: r, decimal: 8 }), c = y.mul(p), _ = u.mul(o), b = y.mul(u), w = o.mul(p), E = d.mul(c.add(_.add(b.mul(2)))), O = c.add(_.add(w.mul(2))), I = E.div(O), S = g(a).add(I);
|
|
1034
|
+
if (I.getBaseValue("number") === 0)
|
|
1035
1035
|
return S.div(d).getBaseValue("number");
|
|
1036
1036
|
const P = d.add(S);
|
|
1037
1037
|
return S.div(P).getBaseValue("number");
|
|
@@ -1043,13 +1043,13 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1043
1043
|
}) => {
|
|
1044
1044
|
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1045
1045
|
return 0;
|
|
1046
|
-
const s =
|
|
1046
|
+
const s = g(n), r = g(a), o = g(t), p = g(e), d = o.mul(s).sub(r.mul(p)), y = r.mul(p).add(s.mul(r));
|
|
1047
1047
|
return Math.abs(d.div(y).getBaseValue("number"));
|
|
1048
1048
|
}, It = ({
|
|
1049
1049
|
symbol: e,
|
|
1050
1050
|
ticker: t,
|
|
1051
1051
|
chain: n
|
|
1052
|
-
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e,
|
|
1052
|
+
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, x = (e, t) => {
|
|
1053
1053
|
switch (e) {
|
|
1054
1054
|
case h.LEAVE:
|
|
1055
1055
|
case h.BOND: {
|
|
@@ -1090,7 +1090,7 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1090
1090
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1091
1091
|
return !!e.match(t);
|
|
1092
1092
|
}, Dn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1093
|
-
class
|
|
1093
|
+
class Ae extends Error {
|
|
1094
1094
|
constructor(t, n, a) {
|
|
1095
1095
|
const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", o = `${s} ${r}`.trim(), p = o ? `status code ${o}` : "an unknown error";
|
|
1096
1096
|
super(`Request failed with ${p}`), Object.defineProperty(this, "response", {
|
|
@@ -1125,20 +1125,20 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1125
1125
|
for (const t of e)
|
|
1126
1126
|
if ((!Q(t) || Array.isArray(t)) && t !== void 0)
|
|
1127
1127
|
throw new TypeError("The `options` argument must be an object");
|
|
1128
|
-
return
|
|
1128
|
+
return be({}, ...e);
|
|
1129
1129
|
}, Be = (e = {}, t = {}) => {
|
|
1130
1130
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
|
|
1131
1131
|
for (const [r, o] of s.entries())
|
|
1132
1132
|
a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
|
|
1133
1133
|
return n;
|
|
1134
|
-
},
|
|
1134
|
+
}, be = (...e) => {
|
|
1135
1135
|
let t = {}, n = {};
|
|
1136
1136
|
for (const a of e)
|
|
1137
1137
|
if (Array.isArray(a))
|
|
1138
1138
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1139
1139
|
else if (Q(a)) {
|
|
1140
1140
|
for (let [s, r] of Object.entries(a))
|
|
1141
|
-
Q(r) && s in t && (r =
|
|
1141
|
+
Q(r) && s in t && (r = be(t[s], r)), t = { ...t, [s]: r };
|
|
1142
1142
|
Q(a.headers) && (n = Be(n, a.headers), t.headers = n);
|
|
1143
1143
|
}
|
|
1144
1144
|
return t;
|
|
@@ -1186,7 +1186,7 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1186
1186
|
window: !0,
|
|
1187
1187
|
dispatcher: !0,
|
|
1188
1188
|
duplex: !0
|
|
1189
|
-
}, Pt = (e) => Ve.includes(e) ? e.toUpperCase() : e, Bt = ["get", "put", "head", "delete", "options", "trace"], Vt = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503],
|
|
1189
|
+
}, Pt = (e) => Ve.includes(e) ? e.toUpperCase() : e, Bt = ["get", "put", "head", "delete", "options", "trace"], Vt = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503], Ee = {
|
|
1190
1190
|
limit: 2,
|
|
1191
1191
|
methods: Bt,
|
|
1192
1192
|
statusCodes: Vt,
|
|
@@ -1197,7 +1197,7 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1197
1197
|
}, Lt = (e = {}) => {
|
|
1198
1198
|
if (typeof e == "number")
|
|
1199
1199
|
return {
|
|
1200
|
-
...
|
|
1200
|
+
...Ee,
|
|
1201
1201
|
limit: e
|
|
1202
1202
|
};
|
|
1203
1203
|
if (e.methods && !Array.isArray(e.methods))
|
|
@@ -1205,7 +1205,7 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1205
1205
|
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
1206
1206
|
throw new Error("retry.statusCodes must be an array");
|
|
1207
1207
|
return {
|
|
1208
|
-
...
|
|
1208
|
+
...Ee,
|
|
1209
1209
|
...e,
|
|
1210
1210
|
afterStatusCodes: Ue
|
|
1211
1211
|
};
|
|
@@ -1249,7 +1249,7 @@ class Z {
|
|
|
1249
1249
|
d instanceof globalThis.Response && (o = d);
|
|
1250
1250
|
}
|
|
1251
1251
|
if (a._decorateResponse(o), !o.ok && a._options.throwHttpErrors) {
|
|
1252
|
-
let p = new
|
|
1252
|
+
let p = new Ae(o, a.request, a._options);
|
|
1253
1253
|
for (const d of a._options.hooks.beforeError)
|
|
1254
1254
|
p = await d(p);
|
|
1255
1255
|
throw p;
|
|
@@ -1309,7 +1309,7 @@ class Z {
|
|
|
1309
1309
|
credentials: this._input.credentials || "same-origin",
|
|
1310
1310
|
...n,
|
|
1311
1311
|
headers: Be(this._input.headers, n.headers),
|
|
1312
|
-
hooks:
|
|
1312
|
+
hooks: be({
|
|
1313
1313
|
beforeRequest: [],
|
|
1314
1314
|
beforeRetry: [],
|
|
1315
1315
|
beforeError: [],
|
|
@@ -1346,7 +1346,7 @@ class Z {
|
|
|
1346
1346
|
}
|
|
1347
1347
|
_calculateRetryDelay(t) {
|
|
1348
1348
|
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof Pe)) {
|
|
1349
|
-
if (t instanceof
|
|
1349
|
+
if (t instanceof Ae) {
|
|
1350
1350
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1351
1351
|
return 0;
|
|
1352
1352
|
const a = t.response.headers.get("Retry-After");
|
|
@@ -1433,20 +1433,20 @@ class Z {
|
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
1435
|
/*! MIT License © Sindre Sorhus */
|
|
1436
|
-
const
|
|
1436
|
+
const pe = (e) => {
|
|
1437
1437
|
const t = (n, a) => Z.create(n, J(e, a));
|
|
1438
1438
|
for (const n of Ve)
|
|
1439
1439
|
t[n] = (a, s) => Z.create(a, J(e, s, { method: n }));
|
|
1440
|
-
return t.create = (n) =>
|
|
1441
|
-
}, kt =
|
|
1442
|
-
get: (e, t) =>
|
|
1443
|
-
post: (e, t) =>
|
|
1444
|
-
},
|
|
1440
|
+
return t.create = (n) => pe(J(n)), t.extend = (n) => pe(J(e, n)), t.stop = Le, t;
|
|
1441
|
+
}, kt = pe(), Ft = kt, Gt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Re = Ft.create({ headers: Gt }), we = {
|
|
1442
|
+
get: (e, t) => Re.get(e, t).json(),
|
|
1443
|
+
post: (e, t) => Re.post(e, t).json()
|
|
1444
|
+
}, ge = Object.values(i), Wt = (e = "") => {
|
|
1445
1445
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1446
|
-
if (
|
|
1446
|
+
if (ge.includes(n))
|
|
1447
1447
|
return !0;
|
|
1448
1448
|
const [a] = t.split("/");
|
|
1449
|
-
if (
|
|
1449
|
+
if (ge.includes(a))
|
|
1450
1450
|
return !0;
|
|
1451
1451
|
throw new Error(
|
|
1452
1452
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
@@ -1468,14 +1468,14 @@ function se({
|
|
|
1468
1468
|
""
|
|
1469
1469
|
);
|
|
1470
1470
|
}
|
|
1471
|
-
var U, k,
|
|
1471
|
+
var U, k, de, He, ue, Oe, ee, le, $, W, te, ye;
|
|
1472
1472
|
const qt = class $e {
|
|
1473
1473
|
constructor(t) {
|
|
1474
|
-
L(this, U), L(this,
|
|
1475
|
-
const n =
|
|
1474
|
+
L(this, U), L(this, de), L(this, ue), L(this, ee), L(this, $), L(this, te), C(this, "decimalMultiplier", 10n ** 8n), C(this, "bigIntValue", 0n), C(this, "decimal");
|
|
1475
|
+
const n = me(t);
|
|
1476
1476
|
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = H(
|
|
1477
|
-
Math.max(
|
|
1478
|
-
),
|
|
1477
|
+
Math.max(R(this, te, ye).call(this, R(this, $, W).call(this, n)), this.decimal || 0)
|
|
1478
|
+
), R(this, de, He).call(this, n);
|
|
1479
1479
|
}
|
|
1480
1480
|
static fromBigInt(t, n) {
|
|
1481
1481
|
return new $e({
|
|
@@ -1515,16 +1515,16 @@ const qt = class $e {
|
|
|
1515
1515
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1516
1516
|
}
|
|
1517
1517
|
add(...t) {
|
|
1518
|
-
return
|
|
1518
|
+
return R(this, U, k).call(this, "add", ...t);
|
|
1519
1519
|
}
|
|
1520
1520
|
sub(...t) {
|
|
1521
|
-
return
|
|
1521
|
+
return R(this, U, k).call(this, "sub", ...t);
|
|
1522
1522
|
}
|
|
1523
1523
|
mul(...t) {
|
|
1524
|
-
return
|
|
1524
|
+
return R(this, U, k).call(this, "mul", ...t);
|
|
1525
1525
|
}
|
|
1526
1526
|
div(...t) {
|
|
1527
|
-
return
|
|
1527
|
+
return R(this, U, k).call(this, "div", ...t);
|
|
1528
1528
|
}
|
|
1529
1529
|
gt(t) {
|
|
1530
1530
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -1569,8 +1569,8 @@ const qt = class $e {
|
|
|
1569
1569
|
getBigIntValue(t, n) {
|
|
1570
1570
|
if (!n && typeof t == "object")
|
|
1571
1571
|
return t.bigIntValue;
|
|
1572
|
-
const a =
|
|
1573
|
-
return s === "0" || s === "undefined" ? 0n :
|
|
1572
|
+
const a = me(t), s = R(this, $, W).call(this, a);
|
|
1573
|
+
return s === "0" || s === "undefined" ? 0n : R(this, ee, le).call(this, s, n);
|
|
1574
1574
|
}
|
|
1575
1575
|
formatBigIntToSafeValue(t, n) {
|
|
1576
1576
|
const a = n || this.decimal || j, s = Math.max(
|
|
@@ -1619,7 +1619,7 @@ const qt = class $e {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
};
|
|
1621
1621
|
U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
1622
|
-
const n =
|
|
1622
|
+
const n = R(this, ue, Oe).call(this, this, ...t), a = H(n), s = t.reduce(
|
|
1623
1623
|
(o, p) => {
|
|
1624
1624
|
const d = this.getBigIntValue(p, n);
|
|
1625
1625
|
switch (e) {
|
|
@@ -1646,49 +1646,49 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1646
1646
|
value: s
|
|
1647
1647
|
});
|
|
1648
1648
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1649
|
-
},
|
|
1650
|
-
const t =
|
|
1651
|
-
this.bigIntValue =
|
|
1652
|
-
},
|
|
1649
|
+
}, de = /* @__PURE__ */ new WeakSet(), He = function(e) {
|
|
1650
|
+
const t = R(this, $, W).call(this, e) || "0";
|
|
1651
|
+
this.bigIntValue = R(this, ee, le).call(this, t);
|
|
1652
|
+
}, ue = /* @__PURE__ */ new WeakSet(), Oe = function(...e) {
|
|
1653
1653
|
const t = e.map(
|
|
1654
|
-
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) :
|
|
1654
|
+
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : R(this, te, ye).call(this, R(this, $, W).call(this, n))
|
|
1655
1655
|
).filter(Boolean);
|
|
1656
1656
|
return Math.max(...t, j);
|
|
1657
|
-
}, ee = /* @__PURE__ */ new WeakSet(),
|
|
1657
|
+
}, ee = /* @__PURE__ */ new WeakSet(), le = function(e, t) {
|
|
1658
1658
|
const n = t ? H(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
|
|
1659
1659
|
return BigInt(`${s}${r.padEnd(a, "0")}`);
|
|
1660
1660
|
}, $ = /* @__PURE__ */ new WeakSet(), W = function(e) {
|
|
1661
1661
|
const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
|
|
1662
1662
|
useGrouping: !1,
|
|
1663
1663
|
maximumFractionDigits: 20
|
|
1664
|
-
}) :
|
|
1664
|
+
}) : me(e)}`.replaceAll(",", ".").split(".");
|
|
1665
1665
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1666
|
-
}, te = /* @__PURE__ */ new WeakSet(),
|
|
1666
|
+
}, te = /* @__PURE__ */ new WeakSet(), ye = function(e) {
|
|
1667
1667
|
var t;
|
|
1668
1668
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1669
1669
|
return Math.max(n, j);
|
|
1670
1670
|
};
|
|
1671
|
-
let
|
|
1672
|
-
function
|
|
1671
|
+
let ce = qt;
|
|
1672
|
+
function me(e) {
|
|
1673
1673
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1674
1674
|
}
|
|
1675
1675
|
const z = (e, t) => typeof e == "bigint" ? se({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1676
|
-
let
|
|
1677
|
-
const
|
|
1678
|
-
if (!
|
|
1676
|
+
let Te;
|
|
1677
|
+
const Ie = (e) => {
|
|
1678
|
+
if (!Te)
|
|
1679
1679
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1680
|
-
return
|
|
1681
|
-
},
|
|
1680
|
+
return Te.get(e.toUpperCase()) || { decimal: A.THOR, identifier: "" };
|
|
1681
|
+
}, Se = async (e, t = 0) => {
|
|
1682
1682
|
Wt(e);
|
|
1683
|
-
const n = await _t(
|
|
1684
|
-
return new
|
|
1683
|
+
const n = await _t(he(e)), a = z(t, n);
|
|
1684
|
+
return new N({ decimal: n, value: a, identifier: e });
|
|
1685
1685
|
};
|
|
1686
|
-
class
|
|
1686
|
+
class N extends ce {
|
|
1687
1687
|
constructor(t) {
|
|
1688
1688
|
super(
|
|
1689
|
-
t.value instanceof
|
|
1689
|
+
t.value instanceof ce ? t.value : { decimal: t.decimal, value: t.value }
|
|
1690
1690
|
), C(this, "address"), C(this, "chain"), C(this, "isSynthetic", !1), C(this, "isGasAsset", !1), C(this, "symbol"), C(this, "ticker"), C(this, "type");
|
|
1691
|
-
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a =
|
|
1691
|
+
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = he(n);
|
|
1692
1692
|
this.type = At(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;
|
|
1693
1693
|
}
|
|
1694
1694
|
get assetValue() {
|
|
@@ -1705,24 +1705,24 @@ class x extends ye {
|
|
|
1705
1705
|
return this.chain === t && this.symbol === n;
|
|
1706
1706
|
}
|
|
1707
1707
|
static async fromString(t, n = 0) {
|
|
1708
|
-
return
|
|
1708
|
+
return Se(t, n);
|
|
1709
1709
|
}
|
|
1710
1710
|
static fromStringSync(t, n = 0) {
|
|
1711
|
-
const { isSynthetic: a } =
|
|
1711
|
+
const { isSynthetic: a } = he(t), { decimal: s, identifier: r } = Ie(
|
|
1712
1712
|
t
|
|
1713
1713
|
), o = z(n, s);
|
|
1714
|
-
return r ? new
|
|
1714
|
+
return r ? new N({ decimal: s, identifier: r, value: o }) : a ? new N({ decimal: 8, identifier: t, value: o }) : void 0;
|
|
1715
1715
|
}
|
|
1716
1716
|
static async fromIdentifier(t, n = 0) {
|
|
1717
|
-
return
|
|
1717
|
+
return Se(t, n);
|
|
1718
1718
|
}
|
|
1719
1719
|
static fromIdentifierSync(t, n = 0) {
|
|
1720
|
-
const { decimal: a, identifier: s } =
|
|
1721
|
-
return new
|
|
1720
|
+
const { decimal: a, identifier: s } = Ie(t), r = z(n, a);
|
|
1721
|
+
return new N({ decimal: a, identifier: s, value: r });
|
|
1722
1722
|
}
|
|
1723
1723
|
static fromChainOrSignature(t, n = 0) {
|
|
1724
1724
|
const { decimal: a, identifier: s } = wt(t), r = z(n, a);
|
|
1725
|
-
return new
|
|
1725
|
+
return new N({ value: r, decimal: a, identifier: s });
|
|
1726
1726
|
}
|
|
1727
1727
|
static async loadStaticAssets() {
|
|
1728
1728
|
return new Promise(
|
|
@@ -1735,7 +1735,7 @@ class x extends ye {
|
|
|
1735
1735
|
NativeList: s,
|
|
1736
1736
|
...r
|
|
1737
1737
|
} = await import("@swapkit/tokens");
|
|
1738
|
-
|
|
1738
|
+
Te = [s, ...Object.values(r)].reduce(
|
|
1739
1739
|
(o, { tokens: p }) => (p.forEach(({ identifier: d, chain: y, ...u }) => {
|
|
1740
1740
|
const c = "decimals" in u ? u.decimals : A[y];
|
|
1741
1741
|
o.set(d, { identifier: d, decimal: c });
|
|
@@ -1753,25 +1753,25 @@ class x extends ye {
|
|
|
1753
1753
|
);
|
|
1754
1754
|
}
|
|
1755
1755
|
}
|
|
1756
|
-
const
|
|
1757
|
-
const t =
|
|
1756
|
+
const oe = (e) => {
|
|
1757
|
+
const t = N.fromChainOrSignature(e);
|
|
1758
1758
|
switch (e) {
|
|
1759
1759
|
case i.Bitcoin:
|
|
1760
1760
|
case i.Litecoin:
|
|
1761
1761
|
case i.BitcoinCash:
|
|
1762
|
-
return t.
|
|
1762
|
+
return t.set(10001e-8);
|
|
1763
1763
|
case i.Dogecoin:
|
|
1764
|
-
return t.
|
|
1764
|
+
return t.set(1.00000001);
|
|
1765
1765
|
case i.Avalanche:
|
|
1766
1766
|
case i.Ethereum:
|
|
1767
|
-
return t.
|
|
1767
|
+
return t.set(1e-8);
|
|
1768
1768
|
case i.THORChain:
|
|
1769
1769
|
case i.Maya:
|
|
1770
|
-
return t.
|
|
1770
|
+
return t.set(0);
|
|
1771
1771
|
default:
|
|
1772
|
-
return t.
|
|
1772
|
+
return t.set(1e-8);
|
|
1773
1773
|
}
|
|
1774
|
-
},
|
|
1774
|
+
}, he = (e) => {
|
|
1775
1775
|
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".").pop().split("/"), s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, o] = s.split("."), [p, d] = (t ? a : o).split("-");
|
|
1776
1776
|
return {
|
|
1777
1777
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
@@ -1843,12 +1843,12 @@ class m extends Error {
|
|
|
1843
1843
|
console.error(n), super(t, { cause: { code: jt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1844
1844
|
}
|
|
1845
1845
|
}
|
|
1846
|
-
class
|
|
1846
|
+
class D extends ce {
|
|
1847
1847
|
eq(t) {
|
|
1848
1848
|
return this.eqValue(t);
|
|
1849
1849
|
}
|
|
1850
1850
|
static fromBigInt(t, n) {
|
|
1851
|
-
return new
|
|
1851
|
+
return new D({
|
|
1852
1852
|
decimal: n,
|
|
1853
1853
|
value: se({ value: t, bigIntDecimal: n, decimal: n })
|
|
1854
1854
|
});
|
|
@@ -3576,30 +3576,30 @@ const Kt = [
|
|
|
3576
3576
|
tcMemo: c,
|
|
3577
3577
|
tcRouter: _,
|
|
3578
3578
|
tcVault: b,
|
|
3579
|
-
vault:
|
|
3580
|
-
token:
|
|
3579
|
+
vault: w,
|
|
3580
|
+
token: E
|
|
3581
3581
|
}
|
|
3582
3582
|
}) => {
|
|
3583
|
-
const
|
|
3584
|
-
if (
|
|
3583
|
+
const O = !!ke[t.toLowerCase()];
|
|
3584
|
+
if (O && !y)
|
|
3585
3585
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3586
|
-
const
|
|
3587
|
-
if (!b && !
|
|
3586
|
+
const I = c || d, S = e && u || I;
|
|
3587
|
+
if (!b && !w)
|
|
3588
3588
|
throw new Error("TC Vault is required on calldata");
|
|
3589
3589
|
if (!_ && !y)
|
|
3590
3590
|
throw new Error("TC Router is required on calldata");
|
|
3591
3591
|
if (!S)
|
|
3592
3592
|
throw new Error("TC Memo is required on calldata");
|
|
3593
|
-
if (!
|
|
3593
|
+
if (!E)
|
|
3594
3594
|
throw new Error("Token is required on calldata");
|
|
3595
3595
|
const P = [
|
|
3596
3596
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3597
3597
|
a(_ || y),
|
|
3598
|
-
a(b ||
|
|
3598
|
+
a(b || w),
|
|
3599
3599
|
S.replace("{recipientAddress}", n),
|
|
3600
|
-
a(
|
|
3600
|
+
a(E),
|
|
3601
3601
|
s
|
|
3602
|
-
], Fe =
|
|
3602
|
+
], Fe = O ? [a(y), o, p] : [r, p];
|
|
3603
3603
|
return [...P, ...Fe];
|
|
3604
3604
|
}, un = ({ chain: e, txHash: t }) => {
|
|
3605
3605
|
const n = xe[e];
|
|
@@ -3653,10 +3653,10 @@ const Kt = [
|
|
|
3653
3653
|
}
|
|
3654
3654
|
}, yn = (e) => {
|
|
3655
3655
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3656
|
-
return
|
|
3656
|
+
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3657
3657
|
}, cn = (e) => {
|
|
3658
3658
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3659
|
-
return
|
|
3659
|
+
return we.get(`${t}/thorchain/mimir`);
|
|
3660
3660
|
}, ve = () => Object.values(i).reduce(
|
|
3661
3661
|
(e, t) => (e[t] = null, e),
|
|
3662
3662
|
{}
|
|
@@ -3690,31 +3690,29 @@ class Pn {
|
|
|
3690
3690
|
throw new m("core_wallet_connection_not_found");
|
|
3691
3691
|
if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
|
|
3692
3692
|
throw new m("core_swap_route_transaction_not_found");
|
|
3693
|
-
const {
|
|
3694
|
-
data:
|
|
3695
|
-
from:
|
|
3696
|
-
to:
|
|
3693
|
+
const { data: c, from: _, to: b, value: w } = a.transaction, E = {
|
|
3694
|
+
data: c,
|
|
3695
|
+
from: _,
|
|
3696
|
+
to: b.toLowerCase(),
|
|
3697
3697
|
chainId: BigInt(rt[o]),
|
|
3698
|
-
value: w ?
|
|
3699
|
-
value: c(w) ? w : _(w, "wei").toString(16)
|
|
3700
|
-
}).getBaseValue("bigint") : 0n
|
|
3698
|
+
value: w ? BigInt(w) : 0n
|
|
3701
3699
|
};
|
|
3702
|
-
return y.sendTransaction(
|
|
3700
|
+
return y.sendTransaction(E, s);
|
|
3703
3701
|
}
|
|
3704
3702
|
if (et.includes(r)) {
|
|
3705
3703
|
if (!a.calldata.fromAsset)
|
|
3706
3704
|
throw new m("core_swap_asset_not_recognized");
|
|
3707
|
-
const y = await
|
|
3705
|
+
const y = await N.fromString(a.calldata.fromAsset);
|
|
3708
3706
|
if (!y)
|
|
3709
3707
|
throw new m("core_swap_asset_not_recognized");
|
|
3710
3708
|
const { address: u } = await f(this, V).call(this, y.chain), {
|
|
3711
3709
|
contract: c,
|
|
3712
|
-
calldata: { expiration: _, amountIn: b, memo:
|
|
3713
|
-
} = a,
|
|
3710
|
+
calldata: { expiration: _, amountIn: b, memo: w, memoStreamingSwap: E }
|
|
3711
|
+
} = a, O = y.add(D.fromBigInt(BigInt(b), y.decimal)), I = t && E || w;
|
|
3714
3712
|
return this.deposit({
|
|
3715
3713
|
expiration: _,
|
|
3716
|
-
assetValue:
|
|
3717
|
-
memo:
|
|
3714
|
+
assetValue: O,
|
|
3715
|
+
memo: I,
|
|
3718
3716
|
feeOptionKey: s,
|
|
3719
3717
|
router: c,
|
|
3720
3718
|
recipient: u
|
|
@@ -3727,13 +3725,13 @@ class Pn {
|
|
|
3727
3725
|
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3728
3726
|
if (!(c != null && c.sendTransaction) || !_)
|
|
3729
3727
|
throw new m("core_wallet_connection_not_found");
|
|
3730
|
-
const { getProvider: b, toChecksumAddress:
|
|
3731
|
-
if (!
|
|
3728
|
+
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), E = b(o), O = pn[u.toLowerCase()];
|
|
3729
|
+
if (!O)
|
|
3732
3730
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3733
|
-
const S = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u,
|
|
3731
|
+
const S = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, O, E))).getFunction("swapIn").populateTransaction(
|
|
3734
3732
|
...dn({
|
|
3735
3733
|
streamSwap: t,
|
|
3736
|
-
toChecksumAddress:
|
|
3734
|
+
toChecksumAddress: w,
|
|
3737
3735
|
contractAddress: u,
|
|
3738
3736
|
recipient: n,
|
|
3739
3737
|
calldata: y
|
|
@@ -3752,7 +3750,7 @@ class Pn {
|
|
|
3752
3750
|
const a = this.getAddress(t);
|
|
3753
3751
|
if (!a)
|
|
3754
3752
|
return null;
|
|
3755
|
-
const s = [
|
|
3753
|
+
const s = [N.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
|
|
3756
3754
|
try {
|
|
3757
3755
|
const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
|
|
3758
3756
|
return this.connectedChains[t] = {
|
|
@@ -3807,10 +3805,9 @@ class Pn {
|
|
|
3807
3805
|
funcParams: [
|
|
3808
3806
|
n,
|
|
3809
3807
|
u({ chain: r, symbol: o, ticker: p }, r),
|
|
3810
|
-
|
|
3811
|
-
t.getBaseValue("bigint").toString(),
|
|
3808
|
+
t.getBaseValue("string"),
|
|
3812
3809
|
y.memo,
|
|
3813
|
-
s.expiration
|
|
3810
|
+
s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
3814
3811
|
],
|
|
3815
3812
|
txOverrides: {
|
|
3816
3813
|
from: y.from,
|
|
@@ -3822,8 +3819,8 @@ class Pn {
|
|
|
3822
3819
|
return await d.transfer(y);
|
|
3823
3820
|
}
|
|
3824
3821
|
} catch (u) {
|
|
3825
|
-
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"),
|
|
3826
|
-
throw new m(
|
|
3822
|
+
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"), w = c == null ? void 0 : c.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : w ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3823
|
+
throw new m(E, u);
|
|
3827
3824
|
}
|
|
3828
3825
|
});
|
|
3829
3826
|
/**
|
|
@@ -3839,7 +3836,7 @@ class Pn {
|
|
|
3839
3836
|
try {
|
|
3840
3837
|
a = await f(this, M).call(this, {
|
|
3841
3838
|
assetValue: t,
|
|
3842
|
-
memo:
|
|
3839
|
+
memo: x(h.DEPOSIT, {
|
|
3843
3840
|
...n,
|
|
3844
3841
|
address: this.getAddress(n.chain)
|
|
3845
3842
|
})
|
|
@@ -3850,7 +3847,7 @@ class Pn {
|
|
|
3850
3847
|
try {
|
|
3851
3848
|
s = await f(this, M).call(this, {
|
|
3852
3849
|
assetValue: n,
|
|
3853
|
-
memo:
|
|
3850
|
+
memo: x(h.DEPOSIT, {
|
|
3854
3851
|
...n,
|
|
3855
3852
|
address: this.getAddress(i.THORChain)
|
|
3856
3853
|
})
|
|
@@ -3869,32 +3866,32 @@ class Pn {
|
|
|
3869
3866
|
isPendingSymmAsset: o,
|
|
3870
3867
|
mode: p = "sym"
|
|
3871
3868
|
}) => {
|
|
3872
|
-
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"), b = o || c,
|
|
3869
|
+
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"), b = o || c, w = b ? s || this.getAddress(i.THORChain) : "", E = u || p === "asset" ? r || this.getAddress(d) : "";
|
|
3873
3870
|
if (!c && !_)
|
|
3874
3871
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3875
|
-
if (b && !
|
|
3872
|
+
if (b && !w)
|
|
3876
3873
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3877
|
-
let
|
|
3874
|
+
let O, I;
|
|
3878
3875
|
const S = { chain: d, symbol: y.join(".") };
|
|
3879
3876
|
if (c && n)
|
|
3880
3877
|
try {
|
|
3881
|
-
|
|
3878
|
+
O = await f(this, M).call(this, {
|
|
3882
3879
|
assetValue: n,
|
|
3883
|
-
memo:
|
|
3880
|
+
memo: x(h.DEPOSIT, { ...S, address: E })
|
|
3884
3881
|
});
|
|
3885
3882
|
} catch (P) {
|
|
3886
3883
|
throw new m("core_transaction_add_liquidity_rune_error", P);
|
|
3887
3884
|
}
|
|
3888
3885
|
if (_ && a)
|
|
3889
3886
|
try {
|
|
3890
|
-
|
|
3887
|
+
I = await f(this, M).call(this, {
|
|
3891
3888
|
assetValue: a,
|
|
3892
|
-
memo:
|
|
3889
|
+
memo: x(h.DEPOSIT, { ...S, address: w })
|
|
3893
3890
|
});
|
|
3894
3891
|
} catch (P) {
|
|
3895
3892
|
throw new m("core_transaction_add_liquidity_asset_error", P);
|
|
3896
3893
|
}
|
|
3897
|
-
return { runeTx:
|
|
3894
|
+
return { runeTx: O, assetTx: I };
|
|
3898
3895
|
});
|
|
3899
3896
|
T(this, "withdraw", async ({
|
|
3900
3897
|
memo: t,
|
|
@@ -3903,22 +3900,15 @@ class Pn {
|
|
|
3903
3900
|
from: s,
|
|
3904
3901
|
to: r
|
|
3905
3902
|
}) => {
|
|
3906
|
-
const o = r === "rune" ?
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
targetAssetString: o == null ? void 0 : o.toString(),
|
|
3916
|
-
singleSide: !1
|
|
3917
|
-
})
|
|
3918
|
-
});
|
|
3919
|
-
} catch (p) {
|
|
3920
|
-
throw new m("core_transaction_withdraw_error", p);
|
|
3921
|
-
}
|
|
3903
|
+
const o = r === "rune" ? N.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = oe(s === "asset" ? n.chain : i.THORChain), d = t || x(h.WITHDRAW, {
|
|
3904
|
+
symbol: n.symbol,
|
|
3905
|
+
chain: n.chain,
|
|
3906
|
+
ticker: n.ticker,
|
|
3907
|
+
basisPoints: Math.max(1e4, Math.round(a * 100)),
|
|
3908
|
+
targetAssetString: o == null ? void 0 : o.toString(),
|
|
3909
|
+
singleSide: !1
|
|
3910
|
+
});
|
|
3911
|
+
return f(this, M).call(this, { assetValue: p, memo: d });
|
|
3922
3912
|
});
|
|
3923
3913
|
T(this, "savings", async ({
|
|
3924
3914
|
assetValue: t,
|
|
@@ -3926,14 +3916,14 @@ class Pn {
|
|
|
3926
3916
|
percent: a,
|
|
3927
3917
|
type: s
|
|
3928
3918
|
}) => {
|
|
3929
|
-
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n ||
|
|
3919
|
+
const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || x(r, {
|
|
3930
3920
|
ticker: t.ticker,
|
|
3931
3921
|
symbol: t.symbol,
|
|
3932
3922
|
chain: t.chain,
|
|
3933
3923
|
singleSide: !0,
|
|
3934
|
-
basisPoints: a ? Math.
|
|
3935
|
-
});
|
|
3936
|
-
return f(this, M).call(this, {
|
|
3924
|
+
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
3925
|
+
}), p = r === h.DEPOSIT ? t : oe(t.chain);
|
|
3926
|
+
return f(this, M).call(this, { memo: o, assetValue: p });
|
|
3937
3927
|
});
|
|
3938
3928
|
T(this, "loan", ({
|
|
3939
3929
|
assetValue: t,
|
|
@@ -3942,7 +3932,7 @@ class Pn {
|
|
|
3942
3932
|
type: s
|
|
3943
3933
|
}) => f(this, M).call(this, {
|
|
3944
3934
|
assetValue: t,
|
|
3945
|
-
memo: n ||
|
|
3935
|
+
memo: n || x(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
|
|
3946
3936
|
asset: t.toString(),
|
|
3947
3937
|
minAmount: a.toString(),
|
|
3948
3938
|
address: this.getAddress(t.chain)
|
|
@@ -3953,19 +3943,19 @@ class Pn {
|
|
|
3953
3943
|
assetValue: n,
|
|
3954
3944
|
address: a
|
|
3955
3945
|
}) => {
|
|
3956
|
-
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r =
|
|
3946
|
+
const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = x(s, {
|
|
3957
3947
|
address: a,
|
|
3958
3948
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
3959
3949
|
});
|
|
3960
3950
|
return f(this, Y).call(this, {
|
|
3961
3951
|
memo: r,
|
|
3962
|
-
assetValue: t === "bond" ? n :
|
|
3952
|
+
assetValue: t === "bond" ? n : oe(i.THORChain)
|
|
3963
3953
|
});
|
|
3964
3954
|
});
|
|
3965
3955
|
T(this, "registerThorname", ({
|
|
3966
3956
|
assetValue: t,
|
|
3967
3957
|
...n
|
|
3968
|
-
}) => f(this, Y).call(this, { assetValue: t, memo:
|
|
3958
|
+
}) => f(this, Y).call(this, { assetValue: t, memo: x(h.THORNAME_REGISTER, n) }));
|
|
3969
3959
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
|
|
3970
3960
|
try {
|
|
3971
3961
|
t.forEach((r) => {
|
|
@@ -4066,23 +4056,23 @@ class Pn {
|
|
|
4066
4056
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
4067
4057
|
});
|
|
4068
4058
|
B(this, K, async ({
|
|
4069
|
-
assetValue:
|
|
4070
|
-
type:
|
|
4071
|
-
contractAddress:
|
|
4059
|
+
assetValue: t,
|
|
4060
|
+
type: n = "checkOnly",
|
|
4061
|
+
contractAddress: a
|
|
4072
4062
|
}) => {
|
|
4073
|
-
const d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(
|
|
4074
|
-
if (d &&
|
|
4063
|
+
const { address: s, chain: r, isGasAsset: o, isSynthetic: p } = t, d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(r);
|
|
4064
|
+
if (d && o || !d || p)
|
|
4075
4065
|
return !0;
|
|
4076
|
-
const u = this.connectedWallets[
|
|
4066
|
+
const u = this.connectedWallets[r], c = n === "checkOnly" ? u == null ? void 0 : u.isApproved : u == null ? void 0 : u.approve;
|
|
4077
4067
|
if (!c)
|
|
4078
4068
|
throw new m("core_wallet_connection_not_found");
|
|
4079
|
-
const _ = this.getAddress(
|
|
4080
|
-
if (!
|
|
4069
|
+
const _ = this.getAddress(r);
|
|
4070
|
+
if (!s || !_)
|
|
4081
4071
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
4082
|
-
const b =
|
|
4072
|
+
const b = a || (await f(this, V).call(this, r)).router;
|
|
4083
4073
|
return c({
|
|
4084
|
-
amount: t("bigint"),
|
|
4085
|
-
assetAddress:
|
|
4074
|
+
amount: t.getBaseValue("bigint"),
|
|
4075
|
+
assetAddress: s,
|
|
4086
4076
|
from: _,
|
|
4087
4077
|
spenderAddress: b
|
|
4088
4078
|
});
|
|
@@ -4125,11 +4115,11 @@ export {
|
|
|
4125
4115
|
ze as AGG_SWAP,
|
|
4126
4116
|
hn as ApiError,
|
|
4127
4117
|
q as ApiUrl,
|
|
4128
|
-
|
|
4118
|
+
N as AssetValue,
|
|
4129
4119
|
A as BaseDecimal,
|
|
4130
|
-
|
|
4120
|
+
ce as BigIntArithmetics,
|
|
4131
4121
|
i as Chain,
|
|
4132
|
-
|
|
4122
|
+
_e as ChainId,
|
|
4133
4123
|
Rn as ChainIdToChain,
|
|
4134
4124
|
rt as ChainToChainId,
|
|
4135
4125
|
xe as ChainToExplorerUrl,
|
|
@@ -4148,12 +4138,12 @@ export {
|
|
|
4148
4138
|
_n as NetworkDerivationPath,
|
|
4149
4139
|
Qe as QuoteMode,
|
|
4150
4140
|
Ne as RPCUrl,
|
|
4151
|
-
|
|
4141
|
+
we as RequestClient,
|
|
4152
4142
|
Ze as SWAP_IN,
|
|
4153
4143
|
et as SWAP_OUT,
|
|
4154
4144
|
Pn as SwapKitCore,
|
|
4155
4145
|
m as SwapKitError,
|
|
4156
|
-
|
|
4146
|
+
D as SwapKitNumber,
|
|
4157
4147
|
Xe as TCAvalancheDepositABI,
|
|
4158
4148
|
Je as TCBscDepositABI,
|
|
4159
4149
|
Ye as TCEthereumVaultAbi,
|
|
@@ -4175,8 +4165,8 @@ export {
|
|
|
4175
4165
|
_t as getDecimal,
|
|
4176
4166
|
Cn as getEstimatedPoolShare,
|
|
4177
4167
|
Mn as getLiquiditySlippage,
|
|
4178
|
-
|
|
4179
|
-
|
|
4168
|
+
x as getMemoFor,
|
|
4169
|
+
oe as getMinAmountByChain,
|
|
4180
4170
|
Ot as getSymmetricPoolShare,
|
|
4181
4171
|
vn as getSymmetricWithdraw,
|
|
4182
4172
|
Nn as getTHORNameCost,
|