@swapkit/core 1.0.0-rc.0 → 1.0.0-rc.2
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 +124 -114
- package/package.json +13 -7
- package/dist/index.es-320ea117.js +0 -13836
- package/dist/index.es-66e7d15a.js +0 -11436
- package/dist/index.es-8503fb04-8503fb04.js +0 -34669
- package/dist/index.es-8503fb04-903b9173.cjs +0 -1
- package/dist/index.es-c82b553a.cjs +0 -14
- package/dist/index.es-e22f22e9.cjs +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var Ce = Object.defineProperty;
|
|
2
2
|
var Ne = (e, t, n) => t in e ? Ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
-
var T = (e, t, n) => (Ne(e, typeof t != "symbol" ? t + "" : t, n), n),
|
|
3
|
+
var T = (e, t, n) => (Ne(e, typeof t != "symbol" ? t + "" : t, n), n), De = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var A = (e, t, n) => (
|
|
7
|
+
var A = (e, t, n) => (De(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (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);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
const
|
|
12
|
+
var xe = Object.defineProperty, Pe = (e, t, n) => t in e ? xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (Pe(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
|
+
const Ut = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
16
16
|
anonymous: !1,
|
|
@@ -682,7 +682,7 @@ const Ge = {
|
|
|
682
682
|
n = n.replace(`{${a}}`, t[a]);
|
|
683
683
|
return t.length === 0 ? n.replace("{0}", "") : n;
|
|
684
684
|
};
|
|
685
|
-
let
|
|
685
|
+
let Ht = class we extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -725,7 +725,7 @@ let Ut = class we extends Error {
|
|
|
725
725
|
}
|
|
726
726
|
};
|
|
727
727
|
var s = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(s || {}), We = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(We || {}), qe = /* @__PURE__ */ ((e) => (e[e.Ethereum = 60] = "Ethereum", e[e.Binance = 714] = "Binance", e[e.THORChain = 931] = "THORChain", e))(qe || {}), Ye = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(Ye || {});
|
|
728
|
-
const
|
|
728
|
+
const $t = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
731
731
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -742,7 +742,7 @@ const Ht = {
|
|
|
742
742
|
THOR: [44, 931, 0, 0, 0]
|
|
743
743
|
};
|
|
744
744
|
var E = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.ETH = 18] = "ETH", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e))(E || {});
|
|
745
|
-
const
|
|
745
|
+
const kt = [
|
|
746
746
|
"ETH",
|
|
747
747
|
"AVAX",
|
|
748
748
|
"BSC",
|
|
@@ -750,13 +750,13 @@ const $t = [
|
|
|
750
750
|
"OP",
|
|
751
751
|
"MATIC"
|
|
752
752
|
/* Polygon */
|
|
753
|
-
],
|
|
753
|
+
], Ft = [
|
|
754
754
|
"BTC",
|
|
755
755
|
"BCH",
|
|
756
756
|
"DOGE",
|
|
757
757
|
"LTC"
|
|
758
758
|
/* Litecoin */
|
|
759
|
-
],
|
|
759
|
+
], Gt = [
|
|
760
760
|
"GAIA",
|
|
761
761
|
"THOR",
|
|
762
762
|
"BNB"
|
|
@@ -775,13 +775,13 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
775
775
|
), je = te.reduce(
|
|
776
776
|
(e, t) => (e[t] = Ee[ce[t]], e),
|
|
777
777
|
{}
|
|
778
|
-
),
|
|
778
|
+
), Wt = te.reduce(
|
|
779
779
|
(e, t) => {
|
|
780
780
|
const n = `${ce[t]}Hex`;
|
|
781
781
|
return e[t] = me[n], e;
|
|
782
782
|
},
|
|
783
783
|
{}
|
|
784
|
-
),
|
|
784
|
+
), qt = {
|
|
785
785
|
"0xa4b1": "ARB",
|
|
786
786
|
42161: "ARB",
|
|
787
787
|
"0xa86a": "AVAX",
|
|
@@ -816,7 +816,7 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
816
816
|
DOGE: "https://blockchair.com/dogecoin",
|
|
817
817
|
ETH: "https://etherscan.io",
|
|
818
818
|
LTC: "https://ltc.bitaps.com",
|
|
819
|
-
MAYA: "https://
|
|
819
|
+
MAYA: "https://www.mayascan.org",
|
|
820
820
|
OP: "https://optimistic.etherscan.io",
|
|
821
821
|
MATIC: "https://polygonscan.com",
|
|
822
822
|
THOR: "https://viewblock.io/thorchain"
|
|
@@ -829,16 +829,16 @@ var Qe = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(Qe || {}
|
|
|
829
829
|
throw TypeError("Cannot add the same private member more than once");
|
|
830
830
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
831
831
|
}, R = (e, t, n) => (et(e, t, "access private method"), n);
|
|
832
|
-
const
|
|
832
|
+
const Yt = (e) => {
|
|
833
833
|
if (e < 0)
|
|
834
834
|
throw new Error("Invalid number of year");
|
|
835
835
|
return 10 + e;
|
|
836
|
-
},
|
|
836
|
+
}, Xt = (e) => {
|
|
837
837
|
if (e.length > 30)
|
|
838
838
|
return !1;
|
|
839
839
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
840
840
|
return !!e.match(t);
|
|
841
|
-
},
|
|
841
|
+
}, Kt = ([e, t, n, a, i]) => `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`, Oe = async (e, t) => {
|
|
842
842
|
const n = Object.entries(t || {}).reduce(
|
|
843
843
|
(a, [i, r]) => (r && (a[i] = r), a),
|
|
844
844
|
{}
|
|
@@ -975,7 +975,7 @@ const qt = (e) => {
|
|
|
975
975
|
case s.Optimism:
|
|
976
976
|
return [s.Ethereum, s.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
977
977
|
}
|
|
978
|
-
},
|
|
978
|
+
}, jt = (e) => {
|
|
979
979
|
var t;
|
|
980
980
|
const [n, ...a] = e.split("."), i = e.includes("/"), r = a.join("."), p = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
|
|
981
981
|
return { chain: n, symbol: r, ticker: p, synth: i };
|
|
@@ -993,26 +993,35 @@ const qt = (e) => {
|
|
|
993
993
|
}) => {
|
|
994
994
|
const a = w(e), i = w(t), r = w(n), p = a.mul(r), d = i.mul(i).mul(2), l = i.mul(a).mul(2), m = a.mul(a), y = p.mul(d.sub(l).add(m)), u = i.mul(i).mul(i);
|
|
995
995
|
return y.div(u);
|
|
996
|
-
},
|
|
996
|
+
}, Qt = ({
|
|
997
997
|
percent: e,
|
|
998
998
|
runeDepth: t,
|
|
999
999
|
liquidityUnits: n,
|
|
1000
1000
|
poolUnits: a
|
|
1001
|
-
}) => ut({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e),
|
|
1001
|
+
}) => ut({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), zt = ({
|
|
1002
1002
|
percent: e,
|
|
1003
1003
|
assetDepth: t,
|
|
1004
1004
|
liquidityUnits: n,
|
|
1005
1005
|
poolUnits: a
|
|
1006
|
-
}) => yt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), w = (e) => new le({ value: e, decimal: E.THOR }),
|
|
1006
|
+
}) => yt({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), w = (e) => new le({ value: e, decimal: E.THOR }), lt = ({
|
|
1007
1007
|
liquidityUnits: e,
|
|
1008
1008
|
poolUnits: t,
|
|
1009
1009
|
runeDepth: n,
|
|
1010
|
-
assetDepth: a
|
|
1011
|
-
percent: i
|
|
1010
|
+
assetDepth: a
|
|
1012
1011
|
}) => ({
|
|
1013
|
-
assetAmount: w(a).mul(e).div(t)
|
|
1014
|
-
runeAmount: w(n).mul(e).div(t)
|
|
1012
|
+
assetAmount: w(a).mul(e).div(t),
|
|
1013
|
+
runeAmount: w(n).mul(e).div(t)
|
|
1015
1014
|
}), Jt = ({
|
|
1015
|
+
liquidityUnits: e,
|
|
1016
|
+
poolUnits: t,
|
|
1017
|
+
runeDepth: n,
|
|
1018
|
+
assetDepth: a,
|
|
1019
|
+
percent: i
|
|
1020
|
+
}) => Object.fromEntries(
|
|
1021
|
+
Object.entries(lt({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1022
|
+
([r, p]) => [r, p.mul(i)]
|
|
1023
|
+
)
|
|
1024
|
+
), Zt = ({
|
|
1016
1025
|
runeDepth: e,
|
|
1017
1026
|
poolUnits: t,
|
|
1018
1027
|
assetDepth: n,
|
|
@@ -1025,7 +1034,7 @@ const qt = (e) => {
|
|
|
1025
1034
|
return b.div(l).baseValueNumber;
|
|
1026
1035
|
const M = l.add(b);
|
|
1027
1036
|
return b.div(M).baseValueNumber;
|
|
1028
|
-
},
|
|
1037
|
+
}, en = ({
|
|
1029
1038
|
runeAmount: e,
|
|
1030
1039
|
assetAmount: t,
|
|
1031
1040
|
runeDepth: n,
|
|
@@ -1033,11 +1042,11 @@ const qt = (e) => {
|
|
|
1033
1042
|
}) => {
|
|
1034
1043
|
const i = w(n), r = w(a), p = w(t), d = w(e), l = p.mul(i).sub(r.mul(d)), m = r.mul(d).add(i.mul(r));
|
|
1035
1044
|
return Math.abs(l.div(m).baseValueNumber);
|
|
1036
|
-
},
|
|
1045
|
+
}, mt = ({
|
|
1037
1046
|
symbol: e,
|
|
1038
1047
|
ticker: t,
|
|
1039
1048
|
chain: n
|
|
1040
|
-
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e,
|
|
1049
|
+
}) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, x = (e, t) => {
|
|
1041
1050
|
switch (e) {
|
|
1042
1051
|
case f.LEAVE:
|
|
1043
1052
|
case f.BOND: {
|
|
@@ -1057,7 +1066,7 @@ const qt = (e) => {
|
|
|
1057
1066
|
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${i || ""}:t:0`;
|
|
1058
1067
|
}
|
|
1059
1068
|
case f.WITHDRAW: {
|
|
1060
|
-
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: d } = t, l = !d && p ? `:${p}` : "", m =
|
|
1069
|
+
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: d } = t, l = !d && p ? `:${p}` : "", m = mt({ chain: n, symbol: i, ticker: a });
|
|
1061
1070
|
return `${e}:${n}${d ? "/" : "."}${m}:${r}${l}`;
|
|
1062
1071
|
}
|
|
1063
1072
|
case f.OPEN_LOAN:
|
|
@@ -1083,7 +1092,7 @@ const qt = (e) => {
|
|
|
1083
1092
|
/\.?0*$/,
|
|
1084
1093
|
""
|
|
1085
1094
|
);
|
|
1086
|
-
}, Te = Object.values(s),
|
|
1095
|
+
}, Te = Object.values(s), ct = (e = "") => {
|
|
1087
1096
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1088
1097
|
if (Te.includes(n))
|
|
1089
1098
|
return !0;
|
|
@@ -1095,7 +1104,7 @@ const qt = (e) => {
|
|
|
1095
1104
|
);
|
|
1096
1105
|
}, U = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
|
|
1097
1106
|
var L, $, ie, ve, re, _e, J, pe, H, W, Z, oe, k, Q;
|
|
1098
|
-
const
|
|
1107
|
+
const Tt = class z {
|
|
1099
1108
|
constructor(t) {
|
|
1100
1109
|
B(this, L), B(this, ie), B(this, re), B(this, J), B(this, H), B(this, Z), B(this, k), N(this, "decimalMultiplier", 10n ** 8n), N(this, "bigIntValue", 0n), N(this, "decimal");
|
|
1101
1110
|
const n = typeof t == "object", a = n ? t.value : t;
|
|
@@ -1238,13 +1247,13 @@ L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
|
|
|
1238
1247
|
return n;
|
|
1239
1248
|
}
|
|
1240
1249
|
};
|
|
1241
|
-
let de =
|
|
1250
|
+
let de = Tt, ue;
|
|
1242
1251
|
const se = (e) => {
|
|
1243
1252
|
if (!ue)
|
|
1244
1253
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1245
1254
|
return ue.get(e.toUpperCase()) || { decimal: E.THOR, identifier: "" };
|
|
1246
1255
|
}, he = async (e, t = 0) => {
|
|
1247
|
-
|
|
1256
|
+
ct(e);
|
|
1248
1257
|
const n = await Se(ye(e));
|
|
1249
1258
|
return new v({ decimal: n, value: t, identifier: e });
|
|
1250
1259
|
};
|
|
@@ -1298,7 +1307,7 @@ class v extends de {
|
|
|
1298
1307
|
ThorchainList: a,
|
|
1299
1308
|
NativeList: i,
|
|
1300
1309
|
...r
|
|
1301
|
-
} = await import("
|
|
1310
|
+
} = await import("@swapkit/tokens");
|
|
1302
1311
|
ue = [i, ...Object.values(r)].reduce(
|
|
1303
1312
|
(p, { tokens: d }) => (d.forEach(({ identifier: l, chain: m, ...y }) => {
|
|
1304
1313
|
const u = "decimals" in y ? y.decimals : E[m];
|
|
@@ -1354,7 +1363,7 @@ const fe = (e) => {
|
|
|
1354
1363
|
symbol: p ? `${r}-${(p == null ? void 0 : p.toLowerCase()) ?? ""}` : i,
|
|
1355
1364
|
ticker: t ? i : r
|
|
1356
1365
|
};
|
|
1357
|
-
},
|
|
1366
|
+
}, _t = {
|
|
1358
1367
|
/**
|
|
1359
1368
|
* Core
|
|
1360
1369
|
*/
|
|
@@ -1413,7 +1422,7 @@ const fe = (e) => {
|
|
|
1413
1422
|
};
|
|
1414
1423
|
class c extends Error {
|
|
1415
1424
|
constructor(t, n) {
|
|
1416
|
-
console.error(n), super(t, { cause: { code:
|
|
1425
|
+
console.error(n), super(t, { cause: { code: _t[t], message: t } }), Object.setPrototypeOf(this, c.prototype);
|
|
1417
1426
|
}
|
|
1418
1427
|
}
|
|
1419
1428
|
class le extends de {
|
|
@@ -1424,7 +1433,7 @@ class le extends de {
|
|
|
1424
1433
|
return this.value;
|
|
1425
1434
|
}
|
|
1426
1435
|
}
|
|
1427
|
-
const
|
|
1436
|
+
const ht = [
|
|
1428
1437
|
{
|
|
1429
1438
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1430
1439
|
stateMutability: "nonpayable",
|
|
@@ -1515,7 +1524,7 @@ const _t = [
|
|
|
1515
1524
|
type: "function"
|
|
1516
1525
|
},
|
|
1517
1526
|
{ stateMutability: "payable", type: "receive" }
|
|
1518
|
-
],
|
|
1527
|
+
], ft = [
|
|
1519
1528
|
{
|
|
1520
1529
|
inputs: [
|
|
1521
1530
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -1659,7 +1668,7 @@ const _t = [
|
|
|
1659
1668
|
type: "function"
|
|
1660
1669
|
},
|
|
1661
1670
|
{ stateMutability: "payable", type: "receive" }
|
|
1662
|
-
],
|
|
1671
|
+
], bt = [
|
|
1663
1672
|
{
|
|
1664
1673
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1665
1674
|
stateMutability: "nonpayable",
|
|
@@ -1764,7 +1773,7 @@ const _t = [
|
|
|
1764
1773
|
type: "function"
|
|
1765
1774
|
},
|
|
1766
1775
|
{ stateMutability: "payable", type: "receive" }
|
|
1767
|
-
],
|
|
1776
|
+
], At = [
|
|
1768
1777
|
{
|
|
1769
1778
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1770
1779
|
stateMutability: "nonpayable",
|
|
@@ -1855,7 +1864,7 @@ const _t = [
|
|
|
1855
1864
|
type: "function"
|
|
1856
1865
|
},
|
|
1857
1866
|
{ stateMutability: "payable", type: "receive" }
|
|
1858
|
-
],
|
|
1867
|
+
], wt = [
|
|
1859
1868
|
{
|
|
1860
1869
|
inputs: [
|
|
1861
1870
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -1999,7 +2008,7 @@ const _t = [
|
|
|
1999
2008
|
type: "function"
|
|
2000
2009
|
},
|
|
2001
2010
|
{ stateMutability: "payable", type: "receive" }
|
|
2002
|
-
],
|
|
2011
|
+
], Et = [
|
|
2003
2012
|
{
|
|
2004
2013
|
inputs: [
|
|
2005
2014
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2118,7 +2127,7 @@ const _t = [
|
|
|
2118
2127
|
type: "function"
|
|
2119
2128
|
},
|
|
2120
2129
|
{ stateMutability: "payable", type: "receive" }
|
|
2121
|
-
],
|
|
2130
|
+
], Rt = [
|
|
2122
2131
|
{
|
|
2123
2132
|
inputs: [
|
|
2124
2133
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2237,7 +2246,7 @@ const _t = [
|
|
|
2237
2246
|
type: "function"
|
|
2238
2247
|
},
|
|
2239
2248
|
{ stateMutability: "payable", type: "receive" }
|
|
2240
|
-
],
|
|
2249
|
+
], Ot = [
|
|
2241
2250
|
{
|
|
2242
2251
|
inputs: [
|
|
2243
2252
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2356,7 +2365,7 @@ const _t = [
|
|
|
2356
2365
|
type: "function"
|
|
2357
2366
|
},
|
|
2358
2367
|
{ stateMutability: "payable", type: "receive" }
|
|
2359
|
-
],
|
|
2368
|
+
], It = [
|
|
2360
2369
|
{
|
|
2361
2370
|
inputs: [
|
|
2362
2371
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2475,7 +2484,7 @@ const _t = [
|
|
|
2475
2484
|
type: "function"
|
|
2476
2485
|
},
|
|
2477
2486
|
{ stateMutability: "payable", type: "receive" }
|
|
2478
|
-
],
|
|
2487
|
+
], St = [
|
|
2479
2488
|
{
|
|
2480
2489
|
inputs: [
|
|
2481
2490
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2602,7 +2611,7 @@ const _t = [
|
|
|
2602
2611
|
type: "function"
|
|
2603
2612
|
},
|
|
2604
2613
|
{ stateMutability: "payable", type: "receive" }
|
|
2605
|
-
],
|
|
2614
|
+
], gt = [
|
|
2606
2615
|
{
|
|
2607
2616
|
inputs: [
|
|
2608
2617
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2729,7 +2738,7 @@ const _t = [
|
|
|
2729
2738
|
type: "function"
|
|
2730
2739
|
},
|
|
2731
2740
|
{ stateMutability: "payable", type: "receive" }
|
|
2732
|
-
],
|
|
2741
|
+
], vt = [
|
|
2733
2742
|
{
|
|
2734
2743
|
inputs: [
|
|
2735
2744
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2856,7 +2865,7 @@ const _t = [
|
|
|
2856
2865
|
type: "function"
|
|
2857
2866
|
},
|
|
2858
2867
|
{ stateMutability: "payable", type: "receive" }
|
|
2859
|
-
],
|
|
2868
|
+
], Mt = [
|
|
2860
2869
|
{
|
|
2861
2870
|
inputs: [
|
|
2862
2871
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2983,7 +2992,7 @@ const _t = [
|
|
|
2983
2992
|
type: "function"
|
|
2984
2993
|
},
|
|
2985
2994
|
{ stateMutability: "payable", type: "receive" }
|
|
2986
|
-
],
|
|
2995
|
+
], Ct = [
|
|
2987
2996
|
{
|
|
2988
2997
|
inputs: [
|
|
2989
2998
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3111,26 +3120,26 @@ const _t = [
|
|
|
3111
3120
|
},
|
|
3112
3121
|
{ stateMutability: "payable", type: "receive" }
|
|
3113
3122
|
], Me = {
|
|
3114
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3115
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3116
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3117
|
-
},
|
|
3123
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: ht,
|
|
3124
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: bt,
|
|
3125
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: At
|
|
3126
|
+
}, Nt = {
|
|
3118
3127
|
...Me,
|
|
3119
3128
|
// AVAX
|
|
3120
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3121
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3122
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3129
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: Et,
|
|
3130
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: ft,
|
|
3131
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: Ot,
|
|
3123
3132
|
// BSC
|
|
3124
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3133
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: wt,
|
|
3125
3134
|
// ETH
|
|
3126
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3127
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3128
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3129
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3130
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3131
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3132
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3133
|
-
},
|
|
3135
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Rt,
|
|
3136
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: It,
|
|
3137
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: St,
|
|
3138
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: gt,
|
|
3139
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: vt,
|
|
3140
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: Mt,
|
|
3141
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: Ct
|
|
3142
|
+
}, Dt = ({
|
|
3134
3143
|
streamSwap: e,
|
|
3135
3144
|
contractAddress: t,
|
|
3136
3145
|
recipient: n,
|
|
@@ -3196,7 +3205,7 @@ const _t = [
|
|
|
3196
3205
|
default:
|
|
3197
3206
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3198
3207
|
}
|
|
3199
|
-
},
|
|
3208
|
+
}, Pt = ({ chain: e, address: t }) => {
|
|
3200
3209
|
const n = Re[e];
|
|
3201
3210
|
switch (e) {
|
|
3202
3211
|
case s.Arbitrum:
|
|
@@ -3219,18 +3228,18 @@ const _t = [
|
|
|
3219
3228
|
default:
|
|
3220
3229
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3221
3230
|
}
|
|
3222
|
-
},
|
|
3231
|
+
}, Bt = (e) => {
|
|
3223
3232
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3224
3233
|
return Oe(`${t}/thorchain/inbound_addresses`);
|
|
3225
|
-
},
|
|
3234
|
+
}, Vt = (e) => {
|
|
3226
3235
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3227
3236
|
return Oe(`${t}/thorchain/mimir`);
|
|
3228
3237
|
}, be = () => Object.values(s).reduce(
|
|
3229
3238
|
(e, t) => (e[t] = null, e),
|
|
3230
3239
|
{}
|
|
3231
3240
|
);
|
|
3232
|
-
var V, ee, X,
|
|
3233
|
-
class
|
|
3241
|
+
var V, ee, X, D, K, j;
|
|
3242
|
+
class tn {
|
|
3234
3243
|
constructor({ stagenet: t } = {}) {
|
|
3235
3244
|
T(this, "connectedChains", be());
|
|
3236
3245
|
T(this, "connectedWallets", be());
|
|
@@ -3241,7 +3250,7 @@ class en {
|
|
|
3241
3250
|
});
|
|
3242
3251
|
T(this, "getExplorerTxUrl", (t, n) => xt({ chain: t, txHash: n }));
|
|
3243
3252
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3244
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3253
|
+
T(this, "getExplorerAddressUrl", (t, n) => Pt({ chain: t, address: n }));
|
|
3245
3254
|
T(this, "getBalance", async (t, n) => {
|
|
3246
3255
|
var i;
|
|
3247
3256
|
if (!n)
|
|
@@ -3291,12 +3300,12 @@ class en {
|
|
|
3291
3300
|
const _ = this.connectedWallets[p], O = this.getAddress(p);
|
|
3292
3301
|
if (!(_ != null && _.sendTransaction) || !O)
|
|
3293
3302
|
throw new c("core_wallet_connection_not_found");
|
|
3294
|
-
const { getProvider: I, toChecksumAddress: g } = await import("
|
|
3303
|
+
const { getProvider: I, toChecksumAddress: g } = await import("@swapkit/toolbox-evm"), S = I(p), b = Nt[h.toLowerCase()];
|
|
3295
3304
|
if (!b)
|
|
3296
3305
|
throw new c("core_swap_contract_not_supported", { contractAddress: h });
|
|
3297
3306
|
const ne = await ((y = (m = (await ((l = _.createContract) == null ? void 0 : l.call(_, h, b, S))).populateTransaction).swapIn) == null ? void 0 : y.call(
|
|
3298
3307
|
m,
|
|
3299
|
-
...
|
|
3308
|
+
...Dt({
|
|
3300
3309
|
streamSwap: t,
|
|
3301
3310
|
toChecksumAddress: g,
|
|
3302
3311
|
contractAddress: h,
|
|
@@ -3361,7 +3370,7 @@ class en {
|
|
|
3361
3370
|
case s.Ethereum:
|
|
3362
3371
|
case s.BinanceSmartChain:
|
|
3363
3372
|
case s.Avalanche: {
|
|
3364
|
-
const { getChecksumAddressFromAsset: y } = await import("
|
|
3373
|
+
const { getChecksumAddressFromAsset: y } = await import("@swapkit/toolbox-evm"), u = r === s.Avalanche ? Ve : r === s.BinanceSmartChain ? Le : Be;
|
|
3365
3374
|
return await l.call({
|
|
3366
3375
|
abi: u,
|
|
3367
3376
|
contractAddress: a || (await A(this, V).call(this, r)).router,
|
|
@@ -3396,9 +3405,9 @@ class en {
|
|
|
3396
3405
|
throw new c("core_transaction_create_liquidity_invalid_params");
|
|
3397
3406
|
let a = "", i = "";
|
|
3398
3407
|
try {
|
|
3399
|
-
a = await A(this,
|
|
3408
|
+
a = await A(this, D).call(this, {
|
|
3400
3409
|
assetValue: t,
|
|
3401
|
-
memo:
|
|
3410
|
+
memo: x(f.DEPOSIT, {
|
|
3402
3411
|
...n,
|
|
3403
3412
|
address: this.getAddress(n.chain)
|
|
3404
3413
|
})
|
|
@@ -3407,9 +3416,9 @@ class en {
|
|
|
3407
3416
|
throw new c("core_transaction_create_liquidity_rune_error", r);
|
|
3408
3417
|
}
|
|
3409
3418
|
try {
|
|
3410
|
-
i = await A(this,
|
|
3419
|
+
i = await A(this, D).call(this, {
|
|
3411
3420
|
assetValue: n,
|
|
3412
|
-
memo:
|
|
3421
|
+
memo: x(f.DEPOSIT, {
|
|
3413
3422
|
...n,
|
|
3414
3423
|
address: this.getAddress(s.THORChain)
|
|
3415
3424
|
})
|
|
@@ -3437,18 +3446,18 @@ class en {
|
|
|
3437
3446
|
const b = { chain: l, symbol: m.join(".") };
|
|
3438
3447
|
if (u && n)
|
|
3439
3448
|
try {
|
|
3440
|
-
g = await A(this,
|
|
3449
|
+
g = await A(this, D).call(this, {
|
|
3441
3450
|
assetValue: n,
|
|
3442
|
-
memo:
|
|
3451
|
+
memo: x(f.DEPOSIT, { ...b, address: I })
|
|
3443
3452
|
});
|
|
3444
3453
|
} catch (M) {
|
|
3445
3454
|
throw new c("core_transaction_add_liquidity_rune_error", M);
|
|
3446
3455
|
}
|
|
3447
3456
|
if (h && a)
|
|
3448
3457
|
try {
|
|
3449
|
-
S = await A(this,
|
|
3458
|
+
S = await A(this, D).call(this, {
|
|
3450
3459
|
assetValue: a,
|
|
3451
|
-
memo:
|
|
3460
|
+
memo: x(f.DEPOSIT, { ...b, address: O })
|
|
3452
3461
|
});
|
|
3453
3462
|
} catch (M) {
|
|
3454
3463
|
throw new c("core_transaction_add_liquidity_asset_error", M);
|
|
@@ -3464,9 +3473,9 @@ class en {
|
|
|
3464
3473
|
}) => {
|
|
3465
3474
|
const p = r === "rune" ? v.fromChainOrSignature(s.THORChain) : i === "sym" && r === "sym" || i === "rune" || i === "asset" ? void 0 : n;
|
|
3466
3475
|
try {
|
|
3467
|
-
return await A(this,
|
|
3476
|
+
return await A(this, D).call(this, {
|
|
3468
3477
|
assetValue: fe(i === "asset" ? n.chain : s.THORChain),
|
|
3469
|
-
memo: t ||
|
|
3478
|
+
memo: t || x(f.WITHDRAW, {
|
|
3470
3479
|
symbol: n.symbol,
|
|
3471
3480
|
chain: n.chain,
|
|
3472
3481
|
ticker: n.ticker,
|
|
@@ -3485,23 +3494,23 @@ class en {
|
|
|
3485
3494
|
percent: a,
|
|
3486
3495
|
type: i
|
|
3487
3496
|
}) => {
|
|
3488
|
-
const r = i === "add" ? f.DEPOSIT : f.WITHDRAW, p = n ||
|
|
3497
|
+
const r = i === "add" ? f.DEPOSIT : f.WITHDRAW, p = n || x(r, {
|
|
3489
3498
|
ticker: t.ticker,
|
|
3490
3499
|
symbol: t.symbol,
|
|
3491
3500
|
chain: t.chain,
|
|
3492
3501
|
singleSide: !0,
|
|
3493
3502
|
basisPoints: a ? Math.max(1e4, Math.round(a * 100)) : void 0
|
|
3494
3503
|
});
|
|
3495
|
-
return A(this,
|
|
3504
|
+
return A(this, D).call(this, { assetValue: t, memo: p });
|
|
3496
3505
|
});
|
|
3497
3506
|
T(this, "loan", ({
|
|
3498
3507
|
assetValue: t,
|
|
3499
3508
|
memo: n,
|
|
3500
3509
|
minAmount: a,
|
|
3501
3510
|
type: i
|
|
3502
|
-
}) => A(this,
|
|
3511
|
+
}) => A(this, D).call(this, {
|
|
3503
3512
|
assetValue: t,
|
|
3504
|
-
memo: n ||
|
|
3513
|
+
memo: n || x(i === "open" ? f.OPEN_LOAN : f.CLOSE_LOAN, {
|
|
3505
3514
|
asset: t.toString(),
|
|
3506
3515
|
minAmount: a.toString(),
|
|
3507
3516
|
address: this.getAddress(t.chain)
|
|
@@ -3512,7 +3521,7 @@ class en {
|
|
|
3512
3521
|
assetValue: n,
|
|
3513
3522
|
address: a
|
|
3514
3523
|
}) => {
|
|
3515
|
-
const i = t === "bond" ? f.BOND : t === "unbond" ? f.UNBOND : f.LEAVE, r =
|
|
3524
|
+
const i = t === "bond" ? f.BOND : t === "unbond" ? f.UNBOND : f.LEAVE, r = x(i, {
|
|
3516
3525
|
address: a,
|
|
3517
3526
|
unbondAmount: t === "unbond" ? n.baseValueNumber : void 0
|
|
3518
3527
|
});
|
|
@@ -3524,7 +3533,7 @@ class en {
|
|
|
3524
3533
|
T(this, "registerThorname", ({
|
|
3525
3534
|
assetValue: t,
|
|
3526
3535
|
...n
|
|
3527
|
-
}) => A(this, K).call(this, { assetValue: t, memo:
|
|
3536
|
+
}) => A(this, K).call(this, { assetValue: t, memo: x(f.THORNAME_REGISTER, n) }));
|
|
3528
3537
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: i = {} }) => {
|
|
3529
3538
|
try {
|
|
3530
3539
|
t.forEach((r) => {
|
|
@@ -3551,7 +3560,7 @@ class en {
|
|
|
3551
3560
|
case s.Ethereum:
|
|
3552
3561
|
case s.Optimism:
|
|
3553
3562
|
case s.Polygon: {
|
|
3554
|
-
const { estimateMaxSendableAmount: i } = await import("
|
|
3563
|
+
const { estimateMaxSendableAmount: i } = await import("@swapkit/toolbox-evm");
|
|
3555
3564
|
return i({
|
|
3556
3565
|
...n,
|
|
3557
3566
|
toolbox: a
|
|
@@ -3565,7 +3574,7 @@ class en {
|
|
|
3565
3574
|
case s.Binance:
|
|
3566
3575
|
case s.THORChain:
|
|
3567
3576
|
case s.Cosmos: {
|
|
3568
|
-
const { estimateMaxSendableAmount: i } = await import("
|
|
3577
|
+
const { estimateMaxSendableAmount: i } = await import("@swapkit/toolbox-cosmos");
|
|
3569
3578
|
return i({
|
|
3570
3579
|
...n,
|
|
3571
3580
|
toolbox: a
|
|
@@ -3614,7 +3623,7 @@ class en {
|
|
|
3614
3623
|
halted: !1,
|
|
3615
3624
|
chain: s.THORChain
|
|
3616
3625
|
};
|
|
3617
|
-
const a = (await
|
|
3626
|
+
const a = (await Bt(this.stagenet)).find((i) => i.chain === t);
|
|
3618
3627
|
if (!a)
|
|
3619
3628
|
throw new c("core_inbound_data_not_found");
|
|
3620
3629
|
if (a != null && a.halted)
|
|
@@ -3646,7 +3655,7 @@ class en {
|
|
|
3646
3655
|
spenderAddress: _
|
|
3647
3656
|
});
|
|
3648
3657
|
});
|
|
3649
|
-
P(this,
|
|
3658
|
+
P(this, D, async ({
|
|
3650
3659
|
assetValue: t,
|
|
3651
3660
|
memo: n,
|
|
3652
3661
|
feeOptionKey: a = F.Fast
|
|
@@ -3665,7 +3674,7 @@ class en {
|
|
|
3665
3674
|
});
|
|
3666
3675
|
});
|
|
3667
3676
|
P(this, K, async ({ memo: t, assetValue: n }) => {
|
|
3668
|
-
const a = await
|
|
3677
|
+
const a = await Vt(this.stagenet);
|
|
3669
3678
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
3670
3679
|
throw new c("core_chain_halted");
|
|
3671
3680
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
@@ -3679,65 +3688,66 @@ class en {
|
|
|
3679
3688
|
this.stagenet = !!t;
|
|
3680
3689
|
}
|
|
3681
3690
|
}
|
|
3682
|
-
V = new WeakMap(), ee = new WeakMap(), X = new WeakMap(),
|
|
3691
|
+
V = new WeakMap(), ee = new WeakMap(), X = new WeakMap(), D = new WeakMap(), K = new WeakMap(), j = new WeakMap();
|
|
3683
3692
|
export {
|
|
3684
3693
|
He as AGG_SWAP,
|
|
3685
|
-
|
|
3694
|
+
Ht as ApiError,
|
|
3686
3695
|
q as ApiUrl,
|
|
3687
3696
|
v as AssetValue,
|
|
3688
3697
|
E as BaseDecimal,
|
|
3689
3698
|
s as Chain,
|
|
3690
3699
|
me as ChainId,
|
|
3691
|
-
|
|
3700
|
+
qt as ChainIdToChain,
|
|
3692
3701
|
Ke as ChainToChainId,
|
|
3693
3702
|
Re as ChainToExplorerUrl,
|
|
3694
|
-
|
|
3703
|
+
Wt as ChainToHexChainId,
|
|
3695
3704
|
je as ChainToRPC,
|
|
3696
3705
|
We as ContractAddress,
|
|
3697
|
-
|
|
3706
|
+
Gt as CosmosChainList,
|
|
3698
3707
|
Y as DEFAULT_DECIMAL,
|
|
3699
3708
|
Ye as DerivationPath,
|
|
3700
3709
|
o as ERROR_CODE,
|
|
3701
3710
|
Fe as ERROR_MODULE,
|
|
3702
3711
|
Ae as ERROR_TYPE,
|
|
3703
|
-
|
|
3712
|
+
kt as EVMChainList,
|
|
3704
3713
|
Qe as ErrorCode,
|
|
3705
3714
|
F as FeeOption,
|
|
3706
3715
|
f as MemoType,
|
|
3707
|
-
|
|
3716
|
+
$t as NetworkDerivationPath,
|
|
3708
3717
|
qe as NetworkId,
|
|
3709
3718
|
Ue as QuoteMode,
|
|
3710
3719
|
Ee as RPCUrl,
|
|
3711
3720
|
$e as SWAP_IN,
|
|
3712
3721
|
ke as SWAP_OUT,
|
|
3713
|
-
|
|
3722
|
+
tn as SwapKitCore,
|
|
3714
3723
|
c as SwapKitError,
|
|
3715
3724
|
le as SwapKitNumber,
|
|
3716
3725
|
Ve as TCAvalancheDepositABI,
|
|
3717
3726
|
Le as TCBscDepositABI,
|
|
3718
3727
|
Be as TCEthereumVaultAbi,
|
|
3719
|
-
|
|
3728
|
+
Ft as UTXOChainList,
|
|
3720
3729
|
ze as WalletOption,
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3730
|
+
jt as assetFromString,
|
|
3731
|
+
Kt as derivationPathToString,
|
|
3732
|
+
Ut as erc20ABI,
|
|
3724
3733
|
ge as formatBigIntToSafeValue,
|
|
3725
3734
|
rt as gasFeeMultiplier,
|
|
3726
3735
|
dt as getAssetType,
|
|
3727
3736
|
yt as getAsymmetricAssetShare,
|
|
3728
|
-
|
|
3737
|
+
zt as getAsymmetricAssetWithdrawAmount,
|
|
3729
3738
|
ut as getAsymmetricRuneShare,
|
|
3730
|
-
|
|
3739
|
+
Qt as getAsymmetricRuneWithdrawAmount,
|
|
3731
3740
|
ot as getCommonAssetInfo,
|
|
3732
3741
|
Se as getDecimal,
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3742
|
+
Zt as getEstimatedPoolShare,
|
|
3743
|
+
en as getLiquiditySlippage,
|
|
3744
|
+
x as getMemoFor,
|
|
3736
3745
|
fe as getMinAmountByChain,
|
|
3737
3746
|
Oe as getRequest,
|
|
3738
|
-
|
|
3739
|
-
|
|
3747
|
+
lt as getSymmetricPoolShare,
|
|
3748
|
+
Jt as getSymmetricWithdraw,
|
|
3749
|
+
Yt as getTHORNameCost,
|
|
3740
3750
|
pt as isGasAsset,
|
|
3741
3751
|
tt as postRequest,
|
|
3742
|
-
|
|
3752
|
+
Xt as validateTHORName
|
|
3743
3753
|
};
|