@swapkit/core 1.0.0-rc.27 → 1.0.0-rc.29
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 +174 -183
- package/package.json +8 -8
package/dist/index.es.js
CHANGED
|
@@ -10,7 +10,7 @@ var f = (e, t, n) => (qe(e, t, "read from private field"), n ? n.call(e) : t.get
|
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
12
|
var je = Object.defineProperty, Ke = (e, t, n) => t in e ? je(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (Ke(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
13
|
-
const
|
|
13
|
+
const _n = [
|
|
14
14
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
15
15
|
{
|
|
16
16
|
anonymous: !1,
|
|
@@ -682,7 +682,7 @@ const nt = {
|
|
|
682
682
|
n = n.replace(`{${a}}`, t[a]);
|
|
683
683
|
return t.length === 0 ? n.replace("{0}", "") : n;
|
|
684
684
|
};
|
|
685
|
-
let
|
|
685
|
+
let fn = class Me extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -725,7 +725,7 @@ let hn = class Me extends Error {
|
|
|
725
725
|
}
|
|
726
726
|
};
|
|
727
727
|
var i = /* @__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.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), at = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(at || {}), st = /* @__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.KUJI = "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))(st || {});
|
|
728
|
-
const
|
|
728
|
+
const bn = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
731
731
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -743,7 +743,7 @@ const _n = {
|
|
|
743
743
|
THOR: [44, 931, 0, 0, 0]
|
|
744
744
|
};
|
|
745
745
|
var A = /* @__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))(A || {});
|
|
746
|
-
const
|
|
746
|
+
const it = [
|
|
747
747
|
"ETH",
|
|
748
748
|
"AVAX",
|
|
749
749
|
"BSC",
|
|
@@ -751,18 +751,18 @@ const fn = [
|
|
|
751
751
|
"OP",
|
|
752
752
|
"MATIC"
|
|
753
753
|
/* Polygon */
|
|
754
|
-
],
|
|
754
|
+
], wn = [
|
|
755
755
|
"BTC",
|
|
756
756
|
"BCH",
|
|
757
757
|
"DOGE",
|
|
758
758
|
"LTC"
|
|
759
759
|
/* Litecoin */
|
|
760
|
-
],
|
|
760
|
+
], An = [
|
|
761
761
|
"GAIA",
|
|
762
762
|
"THOR",
|
|
763
763
|
"BNB"
|
|
764
764
|
/* Binance */
|
|
765
|
-
],
|
|
765
|
+
], En = [
|
|
766
766
|
"AVAX",
|
|
767
767
|
"BNB",
|
|
768
768
|
"BSC",
|
|
@@ -776,25 +776,25 @@ const fn = [
|
|
|
776
776
|
/* THORChain */
|
|
777
777
|
];
|
|
778
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),
|
|
779
|
+
const ae = Object.values(i), rt = Object.keys(i), fe = ae.reduce(
|
|
780
780
|
(e, t) => {
|
|
781
|
-
const n =
|
|
781
|
+
const n = rt.find((a) => i[a] === t);
|
|
782
782
|
return n && (e[t] = n), e;
|
|
783
783
|
},
|
|
784
784
|
{}
|
|
785
|
-
),
|
|
785
|
+
), ot = ae.reduce(
|
|
786
786
|
(e, t) => (e[t] = _e[fe[t]], e),
|
|
787
787
|
{}
|
|
788
|
-
),
|
|
788
|
+
), pt = ae.reduce(
|
|
789
789
|
(e, t) => (e[t] = Ne[fe[t]], e),
|
|
790
790
|
{}
|
|
791
|
-
),
|
|
791
|
+
), Rn = ae.reduce(
|
|
792
792
|
(e, t) => {
|
|
793
793
|
const n = `${fe[t]}Hex`;
|
|
794
794
|
return e[t] = _e[n], e;
|
|
795
795
|
},
|
|
796
796
|
{}
|
|
797
|
-
),
|
|
797
|
+
), gn = {
|
|
798
798
|
"0xa4b1": "ARB",
|
|
799
799
|
42161: "ARB",
|
|
800
800
|
"0xa86a": "AVAX",
|
|
@@ -836,17 +836,17 @@ const ae = Object.values(i), it = Object.keys(i), fe = ae.reduce(
|
|
|
836
836
|
MATIC: "https://polygonscan.com",
|
|
837
837
|
THOR: "https://viewblock.io/thorchain"
|
|
838
838
|
};
|
|
839
|
-
var
|
|
839
|
+
var dt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(dt || {}), 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 || {}), ut = /* @__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))(ut || {}), lt = Object.defineProperty, yt = (e, t, n) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (yt(e, typeof t != "symbol" ? t + "" : t, n), n), ct = (e, t, n) => {
|
|
840
840
|
if (!t.has(e))
|
|
841
841
|
throw TypeError("Cannot " + n);
|
|
842
|
-
},
|
|
842
|
+
}, V = (e, t, n) => {
|
|
843
843
|
if (t.has(e))
|
|
844
844
|
throw TypeError("Cannot add the same private member more than once");
|
|
845
845
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
846
|
-
}, R = (e, t, n) => (
|
|
847
|
-
const
|
|
846
|
+
}, R = (e, t, n) => (ct(e, t, "access private method"), n);
|
|
847
|
+
const mt = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
848
848
|
try {
|
|
849
|
-
const { result: n } = await we.post(
|
|
849
|
+
const { result: n } = await we.post(pt[e], {
|
|
850
850
|
headers: {
|
|
851
851
|
accept: "*/*",
|
|
852
852
|
"content-type": "application/json",
|
|
@@ -856,37 +856,37 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
856
856
|
id: 44,
|
|
857
857
|
jsonrpc: "2.0",
|
|
858
858
|
method: "eth_call",
|
|
859
|
-
params: [{ to: t.toLowerCase(), data:
|
|
859
|
+
params: [{ to: t.toLowerCase(), data: mt }, "latest"]
|
|
860
860
|
})
|
|
861
861
|
});
|
|
862
862
|
return parseInt(BigInt(n).toString());
|
|
863
863
|
} catch (n) {
|
|
864
864
|
return console.error(n), A[e];
|
|
865
865
|
}
|
|
866
|
-
},
|
|
866
|
+
}, Tt = async (e) => {
|
|
867
867
|
if (e === i.Ethereum)
|
|
868
868
|
return A.ETH;
|
|
869
869
|
const [, t] = e.split("-");
|
|
870
870
|
return t != null && t.startsWith("0x") ? De({ chain: i.Ethereum, to: t }) : A.ETH;
|
|
871
|
-
},
|
|
871
|
+
}, ht = async (e) => {
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
873
|
return t != null && t.startsWith("0x") ? De({ chain: i.Avalanche, to: t.toLowerCase() }) : A.AVAX;
|
|
874
|
-
},
|
|
874
|
+
}, _t = async (e) => (e === i.BinanceSmartChain, A.BSC), ft = async ({ chain: e, symbol: t }) => {
|
|
875
875
|
switch (e) {
|
|
876
876
|
case i.Ethereum:
|
|
877
|
-
return mt(t);
|
|
878
|
-
case i.Avalanche:
|
|
879
877
|
return Tt(t);
|
|
880
|
-
case i.
|
|
878
|
+
case i.Avalanche:
|
|
881
879
|
return ht(t);
|
|
880
|
+
case i.BinanceSmartChain:
|
|
881
|
+
return _t(t);
|
|
882
882
|
default:
|
|
883
883
|
return A[e];
|
|
884
884
|
}
|
|
885
|
-
},
|
|
885
|
+
}, bt = {
|
|
886
886
|
[F.Average]: 1.2,
|
|
887
887
|
[F.Fast]: 1.5,
|
|
888
888
|
[F.Fastest]: 2
|
|
889
|
-
},
|
|
889
|
+
}, wt = ({ chain: e, symbol: t }) => {
|
|
890
890
|
switch (e) {
|
|
891
891
|
case i.Bitcoin:
|
|
892
892
|
case i.BitcoinCash:
|
|
@@ -912,7 +912,7 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
912
912
|
case i.THORChain:
|
|
913
913
|
return t === "RUNE";
|
|
914
914
|
}
|
|
915
|
-
},
|
|
915
|
+
}, At = (e) => {
|
|
916
916
|
switch (e) {
|
|
917
917
|
case "ETH.THOR":
|
|
918
918
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
@@ -941,7 +941,7 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
941
941
|
case i.Ethereum:
|
|
942
942
|
return { identifier: `${e}.${e}`, decimal: A[e] };
|
|
943
943
|
}
|
|
944
|
-
},
|
|
944
|
+
}, Et = ({ chain: e, symbol: t }) => {
|
|
945
945
|
if (t.includes("/"))
|
|
946
946
|
return "Synth";
|
|
947
947
|
switch (e) {
|
|
@@ -971,40 +971,40 @@ const ct = "0x313ce567", De = 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
|
+
}, On = (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 };
|
|
978
|
-
},
|
|
978
|
+
}, Rt = new RegExp(
|
|
979
979
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
980
980
|
"gmi"
|
|
981
|
-
),
|
|
982
|
-
(t) => !
|
|
983
|
-
),
|
|
981
|
+
), gt = (e) => it.includes(e.chain) ? !e.isGasAsset && e.address && !Number.isNaN(e.decimal) : !0, In = (e) => e.filter(
|
|
982
|
+
(t) => !t.toString().includes("undefined") && !Rt.test(t.toString()) && gt(t)
|
|
983
|
+
), Ot = ({
|
|
984
984
|
liquidityUnits: e,
|
|
985
985
|
poolUnits: t,
|
|
986
986
|
runeDepth: n
|
|
987
987
|
}) => {
|
|
988
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
|
+
}, It = ({
|
|
991
991
|
liquidityUnits: e,
|
|
992
992
|
poolUnits: t,
|
|
993
993
|
assetDepth: n
|
|
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), 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
|
+
}, Sn = ({
|
|
998
998
|
percent: e,
|
|
999
999
|
runeDepth: t,
|
|
1000
1000
|
liquidityUnits: n,
|
|
1001
1001
|
poolUnits: a
|
|
1002
|
-
}) =>
|
|
1002
|
+
}) => Ot({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), vn = ({
|
|
1003
1003
|
percent: e,
|
|
1004
1004
|
assetDepth: t,
|
|
1005
1005
|
liquidityUnits: n,
|
|
1006
1006
|
poolUnits: a
|
|
1007
|
-
}) =>
|
|
1007
|
+
}) => It({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), g = (e) => D.fromBigInt(BigInt(e), A.THOR), St = ({
|
|
1008
1008
|
liquidityUnits: e,
|
|
1009
1009
|
poolUnits: t,
|
|
1010
1010
|
runeDepth: n,
|
|
@@ -1012,17 +1012,17 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1012
1012
|
}) => ({
|
|
1013
1013
|
assetAmount: g(a).mul(e).div(t),
|
|
1014
1014
|
runeAmount: g(n).mul(e).div(t)
|
|
1015
|
-
}),
|
|
1015
|
+
}), Cn = ({
|
|
1016
1016
|
liquidityUnits: e,
|
|
1017
1017
|
poolUnits: t,
|
|
1018
1018
|
runeDepth: n,
|
|
1019
1019
|
assetDepth: a,
|
|
1020
1020
|
percent: s
|
|
1021
1021
|
}) => Object.fromEntries(
|
|
1022
|
-
Object.entries(
|
|
1022
|
+
Object.entries(St({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1023
1023
|
([r, o]) => [r, o.mul(s)]
|
|
1024
1024
|
)
|
|
1025
|
-
),
|
|
1025
|
+
), Mn = ({
|
|
1026
1026
|
runeDepth: e,
|
|
1027
1027
|
poolUnits: t,
|
|
1028
1028
|
assetDepth: n,
|
|
@@ -1035,7 +1035,7 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1035
1035
|
return S.div(d).getBaseValue("number");
|
|
1036
1036
|
const P = d.add(S);
|
|
1037
1037
|
return S.div(P).getBaseValue("number");
|
|
1038
|
-
},
|
|
1038
|
+
}, Nn = ({
|
|
1039
1039
|
runeAmount: e,
|
|
1040
1040
|
assetAmount: t,
|
|
1041
1041
|
runeDepth: n,
|
|
@@ -1045,7 +1045,7 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1045
1045
|
return 0;
|
|
1046
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
|
+
}, vt = ({
|
|
1049
1049
|
symbol: e,
|
|
1050
1050
|
ticker: t,
|
|
1051
1051
|
chain: n
|
|
@@ -1069,7 +1069,7 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1069
1069
|
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${s || ""}:t:0`;
|
|
1070
1070
|
}
|
|
1071
1071
|
case h.WITHDRAW: {
|
|
1072
|
-
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", y =
|
|
1072
|
+
const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", y = vt({ chain: n, symbol: s, ticker: a });
|
|
1073
1073
|
return `${e}:${n}${p ? "/" : "."}${y}:${r}${d}`;
|
|
1074
1074
|
}
|
|
1075
1075
|
case h.OPEN_LOAN:
|
|
@@ -1080,16 +1080,16 @@ const ct = "0x313ce567", De = async ({ chain: e, to: t }) => {
|
|
|
1080
1080
|
default:
|
|
1081
1081
|
return "";
|
|
1082
1082
|
}
|
|
1083
|
-
},
|
|
1083
|
+
}, xn = (e) => {
|
|
1084
1084
|
if (e < 0)
|
|
1085
1085
|
throw new Error("Invalid number of year");
|
|
1086
1086
|
return 10 + e;
|
|
1087
|
-
},
|
|
1087
|
+
}, Dn = (e) => {
|
|
1088
1088
|
if (e.length > 30)
|
|
1089
1089
|
return !1;
|
|
1090
1090
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1091
1091
|
return !!e.match(t);
|
|
1092
|
-
},
|
|
1092
|
+
}, Pn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
|
|
1093
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";
|
|
@@ -1142,7 +1142,7 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1142
1142
|
Q(a.headers) && (n = Be(n, a.headers), t.headers = n);
|
|
1143
1143
|
}
|
|
1144
1144
|
return t;
|
|
1145
|
-
},
|
|
1145
|
+
}, Ct = (() => {
|
|
1146
1146
|
let e = !1, t = !1;
|
|
1147
1147
|
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
1148
1148
|
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
@@ -1153,13 +1153,13 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1153
1153
|
return e = !0, "half";
|
|
1154
1154
|
}
|
|
1155
1155
|
}).headers.has("Content-Type")), e && !t;
|
|
1156
|
-
})(),
|
|
1156
|
+
})(), Mt = typeof globalThis.AbortController == "function", Nt = typeof globalThis.ReadableStream == "function", xt = typeof globalThis.FormData == "function", Le = ["get", "post", "put", "patch", "head", "delete"], Dt = {
|
|
1157
1157
|
json: "application/json",
|
|
1158
1158
|
text: "text/*",
|
|
1159
1159
|
formData: "multipart/form-data",
|
|
1160
1160
|
arrayBuffer: "*/*",
|
|
1161
1161
|
blob: "*/*"
|
|
1162
|
-
}, re = 2147483647,
|
|
1162
|
+
}, re = 2147483647, Ve = Symbol("stop"), Pt = {
|
|
1163
1163
|
json: !0,
|
|
1164
1164
|
parseJson: !0,
|
|
1165
1165
|
searchParams: !0,
|
|
@@ -1170,7 +1170,7 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1170
1170
|
throwHttpErrors: !0,
|
|
1171
1171
|
onDownloadProgress: !0,
|
|
1172
1172
|
fetch: !0
|
|
1173
|
-
},
|
|
1173
|
+
}, Bt = {
|
|
1174
1174
|
method: !0,
|
|
1175
1175
|
headers: !0,
|
|
1176
1176
|
body: !0,
|
|
@@ -1186,15 +1186,15 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1186
1186
|
window: !0,
|
|
1187
1187
|
dispatcher: !0,
|
|
1188
1188
|
duplex: !0
|
|
1189
|
-
},
|
|
1189
|
+
}, Lt = (e) => Le.includes(e) ? e.toUpperCase() : e, Vt = ["get", "put", "head", "delete", "options", "trace"], Ut = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503], Ee = {
|
|
1190
1190
|
limit: 2,
|
|
1191
|
-
methods:
|
|
1192
|
-
statusCodes:
|
|
1191
|
+
methods: Vt,
|
|
1192
|
+
statusCodes: Ut,
|
|
1193
1193
|
afterStatusCodes: Ue,
|
|
1194
1194
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
1195
1195
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
1196
1196
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
1197
|
-
},
|
|
1197
|
+
}, Ht = (e = {}) => {
|
|
1198
1198
|
if (typeof e == "number")
|
|
1199
1199
|
return {
|
|
1200
1200
|
...Ee,
|
|
@@ -1210,7 +1210,7 @@ const Q = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1210
1210
|
afterStatusCodes: Ue
|
|
1211
1211
|
};
|
|
1212
1212
|
};
|
|
1213
|
-
async function
|
|
1213
|
+
async function $t(e, t, n, a) {
|
|
1214
1214
|
return new Promise((s, r) => {
|
|
1215
1215
|
const o = setTimeout(() => {
|
|
1216
1216
|
n && n.abort(), r(new Pe(e));
|
|
@@ -1220,7 +1220,7 @@ async function Ut(e, t, n, a) {
|
|
|
1220
1220
|
});
|
|
1221
1221
|
});
|
|
1222
1222
|
}
|
|
1223
|
-
async function
|
|
1223
|
+
async function kt(e, { signal: t }) {
|
|
1224
1224
|
return new Promise((n, a) => {
|
|
1225
1225
|
t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
|
|
1226
1226
|
function s() {
|
|
@@ -1231,10 +1231,10 @@ async function Ht(e, { signal: t }) {
|
|
|
1231
1231
|
}, e);
|
|
1232
1232
|
});
|
|
1233
1233
|
}
|
|
1234
|
-
const
|
|
1234
|
+
const Ft = (e, t) => {
|
|
1235
1235
|
const n = {};
|
|
1236
1236
|
for (const a in t)
|
|
1237
|
-
!(a in
|
|
1237
|
+
!(a in Bt) && !(a in Pt) && !(a in e) && (n[a] = t[a]);
|
|
1238
1238
|
return n;
|
|
1239
1239
|
};
|
|
1240
1240
|
class Z {
|
|
@@ -1257,13 +1257,13 @@ class Z {
|
|
|
1257
1257
|
if (a._options.onDownloadProgress) {
|
|
1258
1258
|
if (typeof a._options.onDownloadProgress != "function")
|
|
1259
1259
|
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
1260
|
-
if (!
|
|
1260
|
+
if (!Nt)
|
|
1261
1261
|
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1262
1262
|
return a._stream(o.clone(), a._options.onDownloadProgress);
|
|
1263
1263
|
}
|
|
1264
1264
|
return o;
|
|
1265
1265
|
}, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(s) : s();
|
|
1266
|
-
for (const [o, p] of Object.entries(
|
|
1266
|
+
for (const [o, p] of Object.entries(Dt))
|
|
1267
1267
|
r[o] = async () => {
|
|
1268
1268
|
a.request.headers.set("accept", a.request.headers.get("accept") || p);
|
|
1269
1269
|
const d = (await r).clone();
|
|
@@ -1315,10 +1315,10 @@ class Z {
|
|
|
1315
1315
|
beforeError: [],
|
|
1316
1316
|
afterResponse: []
|
|
1317
1317
|
}, n.hooks),
|
|
1318
|
-
method:
|
|
1318
|
+
method: Lt(n.method ?? this._input.method),
|
|
1319
1319
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1320
1320
|
prefixUrl: String(n.prefixUrl || ""),
|
|
1321
|
-
retry:
|
|
1321
|
+
retry: Ht(n.retry),
|
|
1322
1322
|
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1323
1323
|
timeout: n.timeout ?? 1e4,
|
|
1324
1324
|
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
@@ -1329,7 +1329,7 @@ class Z {
|
|
|
1329
1329
|
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1330
1330
|
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1331
1331
|
}
|
|
1332
|
-
if (
|
|
1332
|
+
if (Mt) {
|
|
1333
1333
|
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1334
1334
|
const a = this._options.signal;
|
|
1335
1335
|
this._options.signal.addEventListener("abort", () => {
|
|
@@ -1338,9 +1338,9 @@ class Z {
|
|
|
1338
1338
|
}
|
|
1339
1339
|
this._options.signal = this.abortController.signal;
|
|
1340
1340
|
}
|
|
1341
|
-
if (
|
|
1341
|
+
if (Ct && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1342
1342
|
const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
|
|
1343
|
-
(
|
|
1343
|
+
(xt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
|
|
1344
1344
|
}
|
|
1345
1345
|
this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
|
|
1346
1346
|
}
|
|
@@ -1371,14 +1371,14 @@ class Z {
|
|
|
1371
1371
|
} catch (n) {
|
|
1372
1372
|
const a = Math.min(this._calculateRetryDelay(n), re);
|
|
1373
1373
|
if (a !== 0 && this._retryCount > 0) {
|
|
1374
|
-
await
|
|
1374
|
+
await kt(a, { signal: this._options.signal });
|
|
1375
1375
|
for (const s of this._options.hooks.beforeRetry)
|
|
1376
1376
|
if (await s({
|
|
1377
1377
|
request: this.request,
|
|
1378
1378
|
options: this._options,
|
|
1379
1379
|
error: n,
|
|
1380
1380
|
retryCount: this._retryCount
|
|
1381
|
-
}) ===
|
|
1381
|
+
}) === Ve)
|
|
1382
1382
|
return;
|
|
1383
1383
|
return this._retry(t);
|
|
1384
1384
|
}
|
|
@@ -1395,8 +1395,8 @@ class Z {
|
|
|
1395
1395
|
if (a instanceof Response)
|
|
1396
1396
|
return a;
|
|
1397
1397
|
}
|
|
1398
|
-
const t =
|
|
1399
|
-
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) :
|
|
1398
|
+
const t = Ft(this.request, this._options);
|
|
1399
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : $t(this.request.clone(), t, this.abortController, this._options);
|
|
1400
1400
|
}
|
|
1401
1401
|
/* istanbul ignore next */
|
|
1402
1402
|
_stream(t, n) {
|
|
@@ -1435,13 +1435,13 @@ class Z {
|
|
|
1435
1435
|
/*! MIT License © Sindre Sorhus */
|
|
1436
1436
|
const pe = (e) => {
|
|
1437
1437
|
const t = (n, a) => Z.create(n, J(e, a));
|
|
1438
|
-
for (const n of
|
|
1438
|
+
for (const n of Le)
|
|
1439
1439
|
t[n] = (a, s) => Z.create(a, J(e, s, { method: n }));
|
|
1440
|
-
return t.create = (n) => pe(J(n)), t.extend = (n) => pe(J(e, n)), t.stop =
|
|
1441
|
-
},
|
|
1440
|
+
return t.create = (n) => pe(J(n)), t.extend = (n) => pe(J(e, n)), t.stop = Ve, t;
|
|
1441
|
+
}, Gt = pe(), Wt = Gt, qt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Re = Wt.create({ headers: qt }), we = {
|
|
1442
1442
|
get: (e, t) => Re.get(e, t).json(),
|
|
1443
1443
|
post: (e, t) => Re.post(e, t).json()
|
|
1444
|
-
}, ge = Object.values(i),
|
|
1444
|
+
}, ge = Object.values(i), jt = (e = "") => {
|
|
1445
1445
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1446
1446
|
if (ge.includes(n))
|
|
1447
1447
|
return !0;
|
|
@@ -1469,9 +1469,9 @@ function se({
|
|
|
1469
1469
|
);
|
|
1470
1470
|
}
|
|
1471
1471
|
var U, k, de, He, ue, Oe, ee, le, $, W, te, ye;
|
|
1472
|
-
const
|
|
1472
|
+
const Kt = class $e {
|
|
1473
1473
|
constructor(t) {
|
|
1474
|
-
|
|
1474
|
+
V(this, U), V(this, de), V(this, ue), V(this, ee), V(this, $), V(this, te), C(this, "decimalMultiplier", 10n ** 8n), C(this, "bigIntValue", 0n), C(this, "decimal");
|
|
1475
1475
|
const n = me(t);
|
|
1476
1476
|
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = H(
|
|
1477
1477
|
Math.max(R(this, te, ye).call(this, R(this, $, W).call(this, n)), this.decimal || 0)
|
|
@@ -1493,24 +1493,6 @@ const qt = class $e {
|
|
|
1493
1493
|
a
|
|
1494
1494
|
);
|
|
1495
1495
|
}
|
|
1496
|
-
/**
|
|
1497
|
-
* @deprecated Use `getBaseValue('string')` instead
|
|
1498
|
-
*/
|
|
1499
|
-
get baseValue() {
|
|
1500
|
-
return this.getBaseValue("string");
|
|
1501
|
-
}
|
|
1502
|
-
/**
|
|
1503
|
-
* @deprecated Use `getBaseValue('number')` instead
|
|
1504
|
-
*/
|
|
1505
|
-
get baseValueNumber() {
|
|
1506
|
-
return this.getBaseValue("number");
|
|
1507
|
-
}
|
|
1508
|
-
/**
|
|
1509
|
-
* @deprecated Use `getBaseValue('bigint')` instead
|
|
1510
|
-
*/
|
|
1511
|
-
get baseValueBigInt() {
|
|
1512
|
-
return this.getBaseValue("bigint");
|
|
1513
|
-
}
|
|
1514
1496
|
set(t) {
|
|
1515
1497
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1516
1498
|
}
|
|
@@ -1617,6 +1599,15 @@ const qt = class $e {
|
|
|
1617
1599
|
const o = 10 ** (s * 3);
|
|
1618
1600
|
return `${(n / o).toFixed(t)}${r}`;
|
|
1619
1601
|
}
|
|
1602
|
+
toCurrency(t = "$", {
|
|
1603
|
+
currencyPosition: n = "start",
|
|
1604
|
+
decimal: a = 2,
|
|
1605
|
+
decimalSeparator: s = ".",
|
|
1606
|
+
thousandSeparator: r = ","
|
|
1607
|
+
} = {}) {
|
|
1608
|
+
const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."), y = p.replace(/\B(?=(\d{3})+(?!\d))/g, r), u = !p && !d ? "0.00" : p === "0" ? `${parseFloat(`0.${d}`)}`.replace(".", s) : `${y}${d ? `${s}${d.slice(0, a)}` : ""}`;
|
|
1609
|
+
return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
|
|
1610
|
+
}
|
|
1620
1611
|
};
|
|
1621
1612
|
U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
1622
1613
|
const n = R(this, ue, Oe).call(this, this, ...t), a = H(n), s = t.reduce(
|
|
@@ -1668,7 +1659,7 @@ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
|
|
|
1668
1659
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1669
1660
|
return Math.max(n, j);
|
|
1670
1661
|
};
|
|
1671
|
-
let ce =
|
|
1662
|
+
let ce = Kt;
|
|
1672
1663
|
function me(e) {
|
|
1673
1664
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1674
1665
|
}
|
|
@@ -1679,8 +1670,8 @@ const Ie = (e) => {
|
|
|
1679
1670
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
1680
1671
|
return Te.get(e.toUpperCase()) || { decimal: A.THOR, identifier: "" };
|
|
1681
1672
|
}, Se = async (e, t = 0) => {
|
|
1682
|
-
|
|
1683
|
-
const n = await
|
|
1673
|
+
jt(e);
|
|
1674
|
+
const n = await ft(he(e)), a = z(t, n);
|
|
1684
1675
|
return new N({ decimal: n, value: a, identifier: e });
|
|
1685
1676
|
};
|
|
1686
1677
|
class N extends ce {
|
|
@@ -1689,7 +1680,7 @@ class N extends ce {
|
|
|
1689
1680
|
t.value instanceof ce ? t.value : { decimal: t.decimal, value: t.value }
|
|
1690
1681
|
), C(this, "address"), C(this, "chain"), C(this, "isSynthetic", !1), C(this, "isGasAsset", !1), C(this, "symbol"), C(this, "ticker"), C(this, "type");
|
|
1691
1682
|
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = he(n);
|
|
1692
|
-
this.type =
|
|
1683
|
+
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;
|
|
1693
1684
|
}
|
|
1694
1685
|
get assetValue() {
|
|
1695
1686
|
return `${this.getValue("string")} ${this.ticker}`;
|
|
@@ -1721,7 +1712,7 @@ class N extends ce {
|
|
|
1721
1712
|
return new N({ decimal: a, identifier: s, value: r });
|
|
1722
1713
|
}
|
|
1723
1714
|
static fromChainOrSignature(t, n = 0) {
|
|
1724
|
-
const { decimal: a, identifier: s } =
|
|
1715
|
+
const { decimal: a, identifier: s } = At(t), r = z(n, a);
|
|
1725
1716
|
return new N({ value: r, decimal: a, identifier: s });
|
|
1726
1717
|
}
|
|
1727
1718
|
static async loadStaticAssets() {
|
|
@@ -1776,12 +1767,12 @@ const oe = (e) => {
|
|
|
1776
1767
|
return {
|
|
1777
1768
|
address: d == null ? void 0 : d.toLowerCase(),
|
|
1778
1769
|
chain: r,
|
|
1779
|
-
isGasAsset:
|
|
1770
|
+
isGasAsset: wt({ chain: r, symbol: o }),
|
|
1780
1771
|
isSynthetic: t,
|
|
1781
1772
|
symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
|
|
1782
1773
|
ticker: p
|
|
1783
1774
|
};
|
|
1784
|
-
},
|
|
1775
|
+
}, Yt = {
|
|
1785
1776
|
/**
|
|
1786
1777
|
* Core
|
|
1787
1778
|
*/
|
|
@@ -1840,7 +1831,7 @@ const oe = (e) => {
|
|
|
1840
1831
|
};
|
|
1841
1832
|
class m extends Error {
|
|
1842
1833
|
constructor(t, n) {
|
|
1843
|
-
console.error(n), super(t, { cause: { code:
|
|
1834
|
+
console.error(n), super(t, { cause: { code: Yt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1844
1835
|
}
|
|
1845
1836
|
}
|
|
1846
1837
|
class D extends ce {
|
|
@@ -1854,7 +1845,7 @@ class D extends ce {
|
|
|
1854
1845
|
});
|
|
1855
1846
|
}
|
|
1856
1847
|
}
|
|
1857
|
-
const
|
|
1848
|
+
const Xt = [
|
|
1858
1849
|
{
|
|
1859
1850
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1860
1851
|
stateMutability: "nonpayable",
|
|
@@ -1945,7 +1936,7 @@ const Kt = [
|
|
|
1945
1936
|
type: "function"
|
|
1946
1937
|
},
|
|
1947
1938
|
{ stateMutability: "payable", type: "receive" }
|
|
1948
|
-
],
|
|
1939
|
+
], Jt = [
|
|
1949
1940
|
{
|
|
1950
1941
|
inputs: [
|
|
1951
1942
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2089,7 +2080,7 @@ const Kt = [
|
|
|
2089
2080
|
type: "function"
|
|
2090
2081
|
},
|
|
2091
2082
|
{ stateMutability: "payable", type: "receive" }
|
|
2092
|
-
],
|
|
2083
|
+
], Qt = [
|
|
2093
2084
|
{
|
|
2094
2085
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2095
2086
|
stateMutability: "nonpayable",
|
|
@@ -2194,7 +2185,7 @@ const Kt = [
|
|
|
2194
2185
|
type: "function"
|
|
2195
2186
|
},
|
|
2196
2187
|
{ stateMutability: "payable", type: "receive" }
|
|
2197
|
-
],
|
|
2188
|
+
], zt = [
|
|
2198
2189
|
{
|
|
2199
2190
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2200
2191
|
stateMutability: "nonpayable",
|
|
@@ -2285,7 +2276,7 @@ const Kt = [
|
|
|
2285
2276
|
type: "function"
|
|
2286
2277
|
},
|
|
2287
2278
|
{ stateMutability: "payable", type: "receive" }
|
|
2288
|
-
],
|
|
2279
|
+
], Zt = [
|
|
2289
2280
|
{
|
|
2290
2281
|
inputs: [
|
|
2291
2282
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2429,7 +2420,7 @@ const Kt = [
|
|
|
2429
2420
|
type: "function"
|
|
2430
2421
|
},
|
|
2431
2422
|
{ stateMutability: "payable", type: "receive" }
|
|
2432
|
-
],
|
|
2423
|
+
], en = [
|
|
2433
2424
|
{
|
|
2434
2425
|
inputs: [
|
|
2435
2426
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2548,7 +2539,7 @@ const Kt = [
|
|
|
2548
2539
|
type: "function"
|
|
2549
2540
|
},
|
|
2550
2541
|
{ stateMutability: "payable", type: "receive" }
|
|
2551
|
-
],
|
|
2542
|
+
], tn = [
|
|
2552
2543
|
{
|
|
2553
2544
|
inputs: [
|
|
2554
2545
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2667,7 +2658,7 @@ const Kt = [
|
|
|
2667
2658
|
type: "function"
|
|
2668
2659
|
},
|
|
2669
2660
|
{ stateMutability: "payable", type: "receive" }
|
|
2670
|
-
],
|
|
2661
|
+
], nn = [
|
|
2671
2662
|
{
|
|
2672
2663
|
inputs: [
|
|
2673
2664
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2786,7 +2777,7 @@ const Kt = [
|
|
|
2786
2777
|
type: "function"
|
|
2787
2778
|
},
|
|
2788
2779
|
{ stateMutability: "payable", type: "receive" }
|
|
2789
|
-
],
|
|
2780
|
+
], an = [
|
|
2790
2781
|
{
|
|
2791
2782
|
inputs: [
|
|
2792
2783
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2905,7 +2896,7 @@ const Kt = [
|
|
|
2905
2896
|
type: "function"
|
|
2906
2897
|
},
|
|
2907
2898
|
{ stateMutability: "payable", type: "receive" }
|
|
2908
|
-
],
|
|
2899
|
+
], sn = [
|
|
2909
2900
|
{
|
|
2910
2901
|
inputs: [
|
|
2911
2902
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3032,7 +3023,7 @@ const Kt = [
|
|
|
3032
3023
|
type: "function"
|
|
3033
3024
|
},
|
|
3034
3025
|
{ stateMutability: "payable", type: "receive" }
|
|
3035
|
-
],
|
|
3026
|
+
], rn = [
|
|
3036
3027
|
{
|
|
3037
3028
|
inputs: [
|
|
3038
3029
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3159,7 +3150,7 @@ const Kt = [
|
|
|
3159
3150
|
type: "function"
|
|
3160
3151
|
},
|
|
3161
3152
|
{ stateMutability: "payable", type: "receive" }
|
|
3162
|
-
],
|
|
3153
|
+
], on = [
|
|
3163
3154
|
{
|
|
3164
3155
|
inputs: [
|
|
3165
3156
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3286,7 +3277,7 @@ const Kt = [
|
|
|
3286
3277
|
type: "function"
|
|
3287
3278
|
},
|
|
3288
3279
|
{ stateMutability: "payable", type: "receive" }
|
|
3289
|
-
],
|
|
3280
|
+
], pn = [
|
|
3290
3281
|
{
|
|
3291
3282
|
inputs: [
|
|
3292
3283
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3413,7 +3404,7 @@ const Kt = [
|
|
|
3413
3404
|
type: "function"
|
|
3414
3405
|
},
|
|
3415
3406
|
{ stateMutability: "payable", type: "receive" }
|
|
3416
|
-
],
|
|
3407
|
+
], dn = [
|
|
3417
3408
|
{
|
|
3418
3409
|
inputs: [
|
|
3419
3410
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3541,26 +3532,26 @@ const Kt = [
|
|
|
3541
3532
|
},
|
|
3542
3533
|
{ stateMutability: "payable", type: "receive" }
|
|
3543
3534
|
], ke = {
|
|
3544
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3545
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3546
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3547
|
-
},
|
|
3535
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Xt,
|
|
3536
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: Qt,
|
|
3537
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: zt
|
|
3538
|
+
}, un = {
|
|
3548
3539
|
...ke,
|
|
3549
3540
|
// AVAX
|
|
3550
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3551
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3552
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3541
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: en,
|
|
3542
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Jt,
|
|
3543
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: nn,
|
|
3553
3544
|
// BSC
|
|
3554
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3545
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: Zt,
|
|
3555
3546
|
// ETH
|
|
3556
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3557
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3558
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3559
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3560
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3561
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3562
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3563
|
-
},
|
|
3547
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: tn,
|
|
3548
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: an,
|
|
3549
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: sn,
|
|
3550
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: rn,
|
|
3551
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: on,
|
|
3552
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: pn,
|
|
3553
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: dn
|
|
3554
|
+
}, ln = ({
|
|
3564
3555
|
streamSwap: e,
|
|
3565
3556
|
contractAddress: t,
|
|
3566
3557
|
recipient: n,
|
|
@@ -3601,7 +3592,7 @@ const Kt = [
|
|
|
3601
3592
|
s
|
|
3602
3593
|
], Fe = O ? [a(y), o, p] : [r, p];
|
|
3603
3594
|
return [...P, ...Fe];
|
|
3604
|
-
},
|
|
3595
|
+
}, yn = ({ chain: e, txHash: t }) => {
|
|
3605
3596
|
const n = xe[e];
|
|
3606
3597
|
switch (e) {
|
|
3607
3598
|
case i.Binance:
|
|
@@ -3627,7 +3618,7 @@ const Kt = [
|
|
|
3627
3618
|
default:
|
|
3628
3619
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3629
3620
|
}
|
|
3630
|
-
},
|
|
3621
|
+
}, cn = ({ chain: e, address: t }) => {
|
|
3631
3622
|
const n = xe[e];
|
|
3632
3623
|
switch (e) {
|
|
3633
3624
|
case i.Arbitrum:
|
|
@@ -3651,18 +3642,18 @@ const Kt = [
|
|
|
3651
3642
|
default:
|
|
3652
3643
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3653
3644
|
}
|
|
3654
|
-
},
|
|
3645
|
+
}, mn = (e) => {
|
|
3655
3646
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3656
3647
|
return we.get(`${t}/thorchain/inbound_addresses`);
|
|
3657
|
-
},
|
|
3648
|
+
}, Tn = (e) => {
|
|
3658
3649
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3659
3650
|
return we.get(`${t}/thorchain/mimir`);
|
|
3660
3651
|
}, ve = () => Object.values(i).reduce(
|
|
3661
3652
|
(e, t) => (e[t] = null, e),
|
|
3662
3653
|
{}
|
|
3663
3654
|
);
|
|
3664
|
-
var
|
|
3665
|
-
class
|
|
3655
|
+
var L, ne, K, M, Y, X;
|
|
3656
|
+
class Bn {
|
|
3666
3657
|
constructor({ stagenet: t } = {}) {
|
|
3667
3658
|
T(this, "connectedChains", ve());
|
|
3668
3659
|
T(this, "connectedWallets", ve());
|
|
@@ -3671,9 +3662,9 @@ class Pn {
|
|
|
3671
3662
|
var n;
|
|
3672
3663
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3673
3664
|
});
|
|
3674
|
-
T(this, "getExplorerTxUrl", (t, n) =>
|
|
3665
|
+
T(this, "getExplorerTxUrl", (t, n) => yn({ chain: t, txHash: n }));
|
|
3675
3666
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3676
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3667
|
+
T(this, "getExplorerAddressUrl", (t, n) => cn({ chain: t, address: n }));
|
|
3677
3668
|
T(this, "getBalance", async (t, n) => {
|
|
3678
3669
|
const a = await this.getWalletByChain(t, n);
|
|
3679
3670
|
return (a == null ? void 0 : a.balance) || [];
|
|
@@ -3694,7 +3685,7 @@ class Pn {
|
|
|
3694
3685
|
data: c,
|
|
3695
3686
|
from: _,
|
|
3696
3687
|
to: b.toLowerCase(),
|
|
3697
|
-
chainId: BigInt(
|
|
3688
|
+
chainId: BigInt(ot[o]),
|
|
3698
3689
|
value: w ? BigInt(w) : 0n
|
|
3699
3690
|
};
|
|
3700
3691
|
return y.sendTransaction(E, s);
|
|
@@ -3705,7 +3696,7 @@ class Pn {
|
|
|
3705
3696
|
const y = await N.fromString(a.calldata.fromAsset);
|
|
3706
3697
|
if (!y)
|
|
3707
3698
|
throw new m("core_swap_asset_not_recognized");
|
|
3708
|
-
const { address: u } = await f(this,
|
|
3699
|
+
const { address: u } = await f(this, L).call(this, y.chain), {
|
|
3709
3700
|
contract: c,
|
|
3710
3701
|
calldata: { expiration: _, amountIn: b, memo: w, memoStreamingSwap: E }
|
|
3711
3702
|
} = a, O = y.add(D.fromBigInt(BigInt(b), y.decimal)), I = t && E || w;
|
|
@@ -3725,11 +3716,11 @@ class Pn {
|
|
|
3725
3716
|
const c = this.connectedWallets[o], _ = this.getAddress(o);
|
|
3726
3717
|
if (!(c != null && c.sendTransaction) || !_)
|
|
3727
3718
|
throw new m("core_wallet_connection_not_found");
|
|
3728
|
-
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), E = b(o), O =
|
|
3719
|
+
const { getProvider: b, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), E = b(o), O = un[u.toLowerCase()];
|
|
3729
3720
|
if (!O)
|
|
3730
3721
|
throw new m("core_swap_contract_not_supported", { contractAddress: u });
|
|
3731
3722
|
const S = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, O, E))).getFunction("swapIn").populateTransaction(
|
|
3732
|
-
...
|
|
3723
|
+
...ln({
|
|
3733
3724
|
streamSwap: t,
|
|
3734
3725
|
toChecksumAddress: w,
|
|
3735
3726
|
contractAddress: u,
|
|
@@ -3800,7 +3791,7 @@ class Pn {
|
|
|
3800
3791
|
const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Xe : r === i.BinanceSmartChain ? Je : Ye;
|
|
3801
3792
|
return await d.call({
|
|
3802
3793
|
abi: c,
|
|
3803
|
-
contractAddress: a || (await f(this,
|
|
3794
|
+
contractAddress: a || (await f(this, L).call(this, r)).router,
|
|
3804
3795
|
funcName: "depositWithExpiry",
|
|
3805
3796
|
funcParams: [
|
|
3806
3797
|
n,
|
|
@@ -4036,7 +4027,7 @@ class Pn {
|
|
|
4036
4027
|
T(this, "disconnectChain", (t) => {
|
|
4037
4028
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
4038
4029
|
});
|
|
4039
|
-
B(this,
|
|
4030
|
+
B(this, L, async (t) => {
|
|
4040
4031
|
if (t === i.THORChain)
|
|
4041
4032
|
return {
|
|
4042
4033
|
gas_rate: "0",
|
|
@@ -4045,7 +4036,7 @@ class Pn {
|
|
|
4045
4036
|
halted: !1,
|
|
4046
4037
|
chain: i.THORChain
|
|
4047
4038
|
};
|
|
4048
|
-
const a = (await
|
|
4039
|
+
const a = (await mn(this.stagenet)).find((s) => s.chain === t);
|
|
4049
4040
|
if (!a)
|
|
4050
4041
|
throw new m("core_inbound_data_not_found");
|
|
4051
4042
|
if (a != null && a.halted)
|
|
@@ -4069,7 +4060,7 @@ class Pn {
|
|
|
4069
4060
|
const _ = this.getAddress(r);
|
|
4070
4061
|
if (!s || !_)
|
|
4071
4062
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
4072
|
-
const b = a || (await f(this,
|
|
4063
|
+
const b = a || (await f(this, L).call(this, r)).router;
|
|
4073
4064
|
return c({
|
|
4074
4065
|
amount: t.getBaseValue("bigint"),
|
|
4075
4066
|
assetAddress: s,
|
|
@@ -4086,7 +4077,7 @@ class Pn {
|
|
|
4086
4077
|
gas_rate: s,
|
|
4087
4078
|
router: r,
|
|
4088
4079
|
address: o
|
|
4089
|
-
} = await f(this,
|
|
4080
|
+
} = await f(this, L).call(this, t.chain), p = (parseInt(s) || 0) * bt[a];
|
|
4090
4081
|
return this.deposit({
|
|
4091
4082
|
assetValue: t,
|
|
4092
4083
|
recipient: o,
|
|
@@ -4096,7 +4087,7 @@ class Pn {
|
|
|
4096
4087
|
});
|
|
4097
4088
|
});
|
|
4098
4089
|
B(this, Y, async ({ memo: t, assetValue: n }) => {
|
|
4099
|
-
const a = await
|
|
4090
|
+
const a = await Tn(this.stagenet);
|
|
4100
4091
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
4101
4092
|
throw new m("core_chain_halted");
|
|
4102
4093
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
@@ -4110,66 +4101,66 @@ class Pn {
|
|
|
4110
4101
|
this.stagenet = !!t;
|
|
4111
4102
|
}
|
|
4112
4103
|
}
|
|
4113
|
-
|
|
4104
|
+
L = new WeakMap(), ne = new WeakMap(), K = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), X = new WeakMap();
|
|
4114
4105
|
export {
|
|
4115
4106
|
ze as AGG_SWAP,
|
|
4116
|
-
|
|
4107
|
+
fn as ApiError,
|
|
4117
4108
|
q as ApiUrl,
|
|
4118
4109
|
N as AssetValue,
|
|
4119
4110
|
A as BaseDecimal,
|
|
4120
4111
|
ce as BigIntArithmetics,
|
|
4121
4112
|
i as Chain,
|
|
4122
4113
|
_e as ChainId,
|
|
4123
|
-
|
|
4124
|
-
|
|
4114
|
+
gn as ChainIdToChain,
|
|
4115
|
+
ot as ChainToChainId,
|
|
4125
4116
|
xe as ChainToExplorerUrl,
|
|
4126
|
-
|
|
4127
|
-
|
|
4117
|
+
Rn as ChainToHexChainId,
|
|
4118
|
+
pt as ChainToRPC,
|
|
4128
4119
|
at as ContractAddress,
|
|
4129
|
-
|
|
4120
|
+
An as CosmosChainList,
|
|
4130
4121
|
st as DerivationPath,
|
|
4131
4122
|
l as ERROR_CODE,
|
|
4132
4123
|
tt as ERROR_MODULE,
|
|
4133
4124
|
Ce as ERROR_TYPE,
|
|
4134
|
-
|
|
4135
|
-
|
|
4125
|
+
it as EVMChainList,
|
|
4126
|
+
dt as ErrorCode,
|
|
4136
4127
|
F as FeeOption,
|
|
4137
4128
|
h as MemoType,
|
|
4138
|
-
|
|
4129
|
+
bn as NetworkDerivationPath,
|
|
4139
4130
|
Qe as QuoteMode,
|
|
4140
4131
|
Ne as RPCUrl,
|
|
4141
4132
|
we as RequestClient,
|
|
4142
4133
|
Ze as SWAP_IN,
|
|
4143
4134
|
et as SWAP_OUT,
|
|
4144
|
-
|
|
4135
|
+
Bn as SwapKitCore,
|
|
4145
4136
|
m as SwapKitError,
|
|
4146
4137
|
D as SwapKitNumber,
|
|
4147
4138
|
Xe as TCAvalancheDepositABI,
|
|
4148
4139
|
Je as TCBscDepositABI,
|
|
4149
4140
|
Ye as TCEthereumVaultAbi,
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4141
|
+
En as TCSupportedChainList,
|
|
4142
|
+
wn as UTXOChainList,
|
|
4143
|
+
ut as WalletOption,
|
|
4144
|
+
On as assetFromString,
|
|
4145
|
+
Pn as derivationPathToString,
|
|
4146
|
+
_n as erc20ABI,
|
|
4147
|
+
In as filterAssets,
|
|
4157
4148
|
se as formatBigIntToSafeValue,
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4149
|
+
bt as gasFeeMultiplier,
|
|
4150
|
+
Et as getAssetType,
|
|
4151
|
+
It as getAsymmetricAssetShare,
|
|
4152
|
+
vn as getAsymmetricAssetWithdrawAmount,
|
|
4153
|
+
Ot as getAsymmetricRuneShare,
|
|
4154
|
+
Sn as getAsymmetricRuneWithdrawAmount,
|
|
4155
|
+
At as getCommonAssetInfo,
|
|
4156
|
+
ft as getDecimal,
|
|
4157
|
+
Mn as getEstimatedPoolShare,
|
|
4158
|
+
Nn as getLiquiditySlippage,
|
|
4168
4159
|
x as getMemoFor,
|
|
4169
4160
|
oe as getMinAmountByChain,
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4161
|
+
St as getSymmetricPoolShare,
|
|
4162
|
+
Cn as getSymmetricWithdraw,
|
|
4163
|
+
xn as getTHORNameCost,
|
|
4164
|
+
wt as isGasAsset,
|
|
4165
|
+
Dn as validateTHORName
|
|
4175
4166
|
};
|