@swapkit/core 1.0.0-rc.3 → 1.0.0-rc.6
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.d.ts +4 -2
- package/dist/index.es.js +237 -228
- package/package.json +13 -13
- package/src/client/explorerUrls.ts +2 -0
- package/src/client/index.ts +2 -2
- package/src/client/types.ts +2 -0
package/dist/index.es.js
CHANGED
|
@@ -10,7 +10,7 @@ var A = (e, t, n) => (De(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 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
|
|
13
|
+
const Lt = [
|
|
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 Ut = class we extends Error {
|
|
686
686
|
constructor({
|
|
687
687
|
status: t,
|
|
688
688
|
revision: n,
|
|
@@ -690,7 +690,7 @@ let Ht = class we extends Error {
|
|
|
690
690
|
code: i,
|
|
691
691
|
message: r,
|
|
692
692
|
type: p,
|
|
693
|
-
options: { shouldLog: d, shouldThrow: l, shouldTrace:
|
|
693
|
+
options: { shouldLog: d, shouldThrow: l, shouldTrace: c } = {
|
|
694
694
|
shouldLog: !0,
|
|
695
695
|
shouldThrow: !0,
|
|
696
696
|
shouldTrace: !0
|
|
@@ -700,7 +700,7 @@ let Ht = class we extends Error {
|
|
|
700
700
|
const u = r || ae(i, y || []) || "";
|
|
701
701
|
super(u), C(this, "status"), C(this, "revision"), C(this, "type"), C(this, "module"), C(this, "code"), C(this, "message"), C(this, "display"), C(this, "stack"), C(this, "options"), C(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = u, this.display = ae(i, y || []), this.code = i, this.type = p || Ae.UNHANDLED_ERROR, this.options = {
|
|
702
702
|
shouldLog: d || !0,
|
|
703
|
-
shouldTrace:
|
|
703
|
+
shouldTrace: c || !0,
|
|
704
704
|
shouldThrow: l || !1
|
|
705
705
|
}, this.displayMessageParams = y || [], this.options.shouldTrace && Error.captureStackTrace(this);
|
|
706
706
|
}
|
|
@@ -724,8 +724,8 @@ let Ht = class we extends Error {
|
|
|
724
724
|
return this.toErrorInfo();
|
|
725
725
|
}
|
|
726
726
|
};
|
|
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
|
|
728
|
-
const
|
|
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.Kujira = "KUJI", 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.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))(qe || {});
|
|
728
|
+
const Ht = {
|
|
729
729
|
ARB: [44, 60, 0, 0, 0],
|
|
730
730
|
AVAX: [44, 60, 0, 0, 0],
|
|
731
731
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -735,6 +735,7 @@ const $t = {
|
|
|
735
735
|
DOGE: [44, 3, 0, 0, 0],
|
|
736
736
|
ETH: [44, 60, 0, 0, 0],
|
|
737
737
|
GAIA: [44, 118, 0, 0, 0],
|
|
738
|
+
KUJI: [44, 118, 0, 0, 0],
|
|
738
739
|
LTC: [84, 2, 0, 0, 0],
|
|
739
740
|
MATIC: [44, 60, 0, 0, 0],
|
|
740
741
|
MAYA: [44, 931, 0, 0, 0],
|
|
@@ -742,7 +743,7 @@ const $t = {
|
|
|
742
743
|
THOR: [44, 931, 0, 0, 0]
|
|
743
744
|
};
|
|
744
745
|
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
|
|
746
|
+
const $t = [
|
|
746
747
|
"ETH",
|
|
747
748
|
"AVAX",
|
|
748
749
|
"BSC",
|
|
@@ -750,38 +751,38 @@ const kt = [
|
|
|
750
751
|
"OP",
|
|
751
752
|
"MATIC"
|
|
752
753
|
/* Polygon */
|
|
753
|
-
],
|
|
754
|
+
], kt = [
|
|
754
755
|
"BTC",
|
|
755
756
|
"BCH",
|
|
756
757
|
"DOGE",
|
|
757
758
|
"LTC"
|
|
758
759
|
/* Litecoin */
|
|
759
|
-
],
|
|
760
|
+
], Ft = [
|
|
760
761
|
"GAIA",
|
|
761
762
|
"THOR",
|
|
762
763
|
"BNB"
|
|
763
764
|
/* Binance */
|
|
764
765
|
];
|
|
765
|
-
var
|
|
766
|
-
const te = Object.values(s),
|
|
766
|
+
var ce = /* @__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))(ce || {}), Ee = /* @__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))(Ee || {}), 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 || {});
|
|
767
|
+
const te = Object.values(s), Ke = Object.keys(s), me = te.reduce(
|
|
767
768
|
(e, t) => {
|
|
768
|
-
const n =
|
|
769
|
+
const n = Ke.find((a) => s[a] === t);
|
|
769
770
|
return n && (e[t] = n), e;
|
|
770
771
|
},
|
|
771
772
|
{}
|
|
772
|
-
),
|
|
773
|
-
(e, t) => (e[t] = me[
|
|
773
|
+
), Ye = te.reduce(
|
|
774
|
+
(e, t) => (e[t] = ce[me[t]], e),
|
|
774
775
|
{}
|
|
775
|
-
),
|
|
776
|
-
(e, t) => (e[t] = Ee[
|
|
776
|
+
), Xe = te.reduce(
|
|
777
|
+
(e, t) => (e[t] = Ee[me[t]], e),
|
|
777
778
|
{}
|
|
778
|
-
),
|
|
779
|
+
), Gt = te.reduce(
|
|
779
780
|
(e, t) => {
|
|
780
|
-
const n = `${
|
|
781
|
-
return e[t] =
|
|
781
|
+
const n = `${me[t]}Hex`;
|
|
782
|
+
return e[t] = ce[n], e;
|
|
782
783
|
},
|
|
783
784
|
{}
|
|
784
|
-
),
|
|
785
|
+
), Wt = {
|
|
785
786
|
"0xa4b1": "ARB",
|
|
786
787
|
42161: "ARB",
|
|
787
788
|
"0xa86a": "AVAX",
|
|
@@ -794,6 +795,7 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
794
795
|
"cosmoshub-4": "GAIA",
|
|
795
796
|
dogecoin: "DOGE",
|
|
796
797
|
"0x1": "ETH",
|
|
798
|
+
"kaiyo-1": "KUJI",
|
|
797
799
|
1: "ETH",
|
|
798
800
|
litecoin: "LTC",
|
|
799
801
|
"mayachain-stagenet-v1": "MAYA",
|
|
@@ -814,6 +816,7 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
814
816
|
BTC: "https://blockstream.info",
|
|
815
817
|
GAIA: "https://cosmos.bigdipper.live",
|
|
816
818
|
DOGE: "https://blockchair.com/dogecoin",
|
|
819
|
+
KUJI: "https://finder.kujira.network/kaiyo-1",
|
|
817
820
|
ETH: "https://etherscan.io",
|
|
818
821
|
LTC: "https://ltc.bitaps.com",
|
|
819
822
|
MAYA: "https://www.mayascan.org",
|
|
@@ -821,24 +824,24 @@ const te = Object.values(s), Xe = Object.keys(s), ce = te.reduce(
|
|
|
821
824
|
MATIC: "https://polygonscan.com",
|
|
822
825
|
THOR: "https://viewblock.io/thorchain"
|
|
823
826
|
};
|
|
824
|
-
var
|
|
827
|
+
var je = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(je || {}), f = /* @__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))(f || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), Je = /* @__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))(Je || {}), Qe = Object.defineProperty, ze = (e, t, n) => t in e ? Qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, N = (e, t, n) => (ze(e, typeof t != "symbol" ? t + "" : t, n), n), Ze = (e, t, n) => {
|
|
825
828
|
if (!t.has(e))
|
|
826
829
|
throw TypeError("Cannot " + n);
|
|
827
830
|
}, B = (e, t, n) => {
|
|
828
831
|
if (t.has(e))
|
|
829
832
|
throw TypeError("Cannot add the same private member more than once");
|
|
830
833
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
831
|
-
}, R = (e, t, n) => (
|
|
832
|
-
const
|
|
834
|
+
}, R = (e, t, n) => (Ze(e, t, "access private method"), n);
|
|
835
|
+
const qt = (e) => {
|
|
833
836
|
if (e < 0)
|
|
834
837
|
throw new Error("Invalid number of year");
|
|
835
838
|
return 10 + e;
|
|
836
|
-
},
|
|
839
|
+
}, Kt = (e) => {
|
|
837
840
|
if (e.length > 30)
|
|
838
841
|
return !1;
|
|
839
842
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
840
843
|
return !!e.match(t);
|
|
841
|
-
},
|
|
844
|
+
}, Yt = ([e, t, n, a, i]) => `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`, Oe = async (e, t) => {
|
|
842
845
|
const n = Object.entries(t || {}).reduce(
|
|
843
846
|
(a, [i, r]) => (r && (a[i] = r), a),
|
|
844
847
|
{}
|
|
@@ -847,7 +850,7 @@ const Yt = (e) => {
|
|
|
847
850
|
`${e}${t ? `?${new URLSearchParams(n).toString()}` : ""}`,
|
|
848
851
|
{ method: "GET", mode: "cors", credentials: "omit", referrer: "https://sk.thorswap.net" }
|
|
849
852
|
)).json();
|
|
850
|
-
},
|
|
853
|
+
}, et = async (e, t, n, a = !1) => {
|
|
851
854
|
const i = await fetch(`${e}`, {
|
|
852
855
|
body: t,
|
|
853
856
|
headers: n,
|
|
@@ -855,13 +858,13 @@ const Yt = (e) => {
|
|
|
855
858
|
referrer: "https://sk.thorswap.net"
|
|
856
859
|
});
|
|
857
860
|
return a ? i.text() : i.json();
|
|
858
|
-
},
|
|
861
|
+
}, tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
|
|
859
862
|
try {
|
|
860
|
-
const n = await
|
|
861
|
-
|
|
863
|
+
const n = await et(
|
|
864
|
+
Xe[e],
|
|
862
865
|
JSON.stringify({
|
|
863
866
|
method: "eth_call",
|
|
864
|
-
params: [{ to: t.toLowerCase(), data:
|
|
867
|
+
params: [{ to: t.toLowerCase(), data: tt }, "latest"],
|
|
865
868
|
id: 44,
|
|
866
869
|
jsonrpc: "2.0"
|
|
867
870
|
}),
|
|
@@ -872,30 +875,30 @@ const Yt = (e) => {
|
|
|
872
875
|
} catch (n) {
|
|
873
876
|
return console.error(n), E[e];
|
|
874
877
|
}
|
|
875
|
-
},
|
|
878
|
+
}, nt = async (e) => {
|
|
876
879
|
if (e === s.Ethereum)
|
|
877
880
|
return E.ETH;
|
|
878
881
|
const [, t] = e.split("-");
|
|
879
882
|
return t != null && t.startsWith("0x") ? Ie({ chain: s.Ethereum, to: t }) : E.ETH;
|
|
880
|
-
},
|
|
883
|
+
}, at = async (e) => {
|
|
881
884
|
const [, t] = e.split("-");
|
|
882
885
|
return t != null && t.startsWith("0x") ? Ie({ chain: s.Avalanche, to: t.toLowerCase() }) : E.AVAX;
|
|
883
|
-
},
|
|
886
|
+
}, st = async (e) => (e === s.BinanceSmartChain, E.BSC), Se = async ({ chain: e, symbol: t }) => {
|
|
884
887
|
switch (e) {
|
|
885
888
|
case s.Ethereum:
|
|
886
|
-
return
|
|
889
|
+
return nt(t);
|
|
887
890
|
case s.Avalanche:
|
|
888
|
-
return
|
|
891
|
+
return at(t);
|
|
889
892
|
case s.BinanceSmartChain:
|
|
890
|
-
return
|
|
893
|
+
return st(t);
|
|
891
894
|
default:
|
|
892
895
|
return E[e];
|
|
893
896
|
}
|
|
894
|
-
},
|
|
897
|
+
}, it = {
|
|
895
898
|
[F.Average]: 1.2,
|
|
896
899
|
[F.Fast]: 1.5,
|
|
897
900
|
[F.Fastest]: 2
|
|
898
|
-
},
|
|
901
|
+
}, rt = ({ chain: e, symbol: t }) => {
|
|
899
902
|
switch (e) {
|
|
900
903
|
case s.Bitcoin:
|
|
901
904
|
case s.BitcoinCash:
|
|
@@ -910,6 +913,8 @@ const Yt = (e) => {
|
|
|
910
913
|
return t === "ETH";
|
|
911
914
|
case s.Maya:
|
|
912
915
|
return t === "CACAO";
|
|
916
|
+
case s.Kujira:
|
|
917
|
+
return t === "KUJI";
|
|
913
918
|
case s.Cosmos:
|
|
914
919
|
return t === "ATOM";
|
|
915
920
|
case s.Polygon:
|
|
@@ -919,7 +924,7 @@ const Yt = (e) => {
|
|
|
919
924
|
case s.THORChain:
|
|
920
925
|
return t === "RUNE";
|
|
921
926
|
}
|
|
922
|
-
},
|
|
927
|
+
}, pt = (e) => {
|
|
923
928
|
switch (e) {
|
|
924
929
|
case "ETH.THOR":
|
|
925
930
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
@@ -935,6 +940,7 @@ const Yt = (e) => {
|
|
|
935
940
|
return { identifier: "MAYA.CACAO", decimal: E.MAYA };
|
|
936
941
|
case "MAYA.MAYA":
|
|
937
942
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
943
|
+
case s.Kujira:
|
|
938
944
|
case s.Arbitrum:
|
|
939
945
|
case s.Optimism:
|
|
940
946
|
case s.BitcoinCash:
|
|
@@ -947,7 +953,7 @@ const Yt = (e) => {
|
|
|
947
953
|
case s.Ethereum:
|
|
948
954
|
return { identifier: `${e}.${e}`, decimal: E[e] };
|
|
949
955
|
}
|
|
950
|
-
},
|
|
956
|
+
}, ot = ({ chain: e, symbol: t }) => {
|
|
951
957
|
if (t.includes("/"))
|
|
952
958
|
return "Synth";
|
|
953
959
|
switch (e) {
|
|
@@ -960,6 +966,8 @@ const Yt = (e) => {
|
|
|
960
966
|
return "Native";
|
|
961
967
|
case s.Cosmos:
|
|
962
968
|
return t === "ATOM" ? "Native" : "GAIA";
|
|
969
|
+
case s.Kujira:
|
|
970
|
+
return t === "KUJI" ? "Native" : "KUJI";
|
|
963
971
|
case s.Binance:
|
|
964
972
|
return t === s.Binance ? "Native" : "BEP2";
|
|
965
973
|
case s.BinanceSmartChain:
|
|
@@ -975,35 +983,35 @@ const Yt = (e) => {
|
|
|
975
983
|
case s.Optimism:
|
|
976
984
|
return [s.Ethereum, s.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
977
985
|
}
|
|
978
|
-
},
|
|
986
|
+
}, Xt = (e) => {
|
|
979
987
|
var t;
|
|
980
988
|
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
989
|
return { chain: n, symbol: r, ticker: p, synth: i };
|
|
982
|
-
},
|
|
990
|
+
}, dt = ({
|
|
983
991
|
liquidityUnits: e,
|
|
984
992
|
poolUnits: t,
|
|
985
993
|
runeDepth: n
|
|
986
994
|
}) => {
|
|
987
|
-
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),
|
|
988
|
-
return p.mul(d.sub(l).add(
|
|
989
|
-
},
|
|
995
|
+
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), c = a.mul(a), y = i.mul(i).mul(i);
|
|
996
|
+
return p.mul(d.sub(l).add(c)).div(y);
|
|
997
|
+
}, ut = ({
|
|
990
998
|
liquidityUnits: e,
|
|
991
999
|
poolUnits: t,
|
|
992
1000
|
assetDepth: n
|
|
993
1001
|
}) => {
|
|
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),
|
|
1002
|
+
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), c = a.mul(a), y = p.mul(d.sub(l).add(c)), u = i.mul(i).mul(i);
|
|
995
1003
|
return y.div(u);
|
|
996
|
-
},
|
|
1004
|
+
}, jt = ({
|
|
997
1005
|
percent: e,
|
|
998
1006
|
runeDepth: t,
|
|
999
1007
|
liquidityUnits: n,
|
|
1000
1008
|
poolUnits: a
|
|
1001
|
-
}) =>
|
|
1009
|
+
}) => dt({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), Jt = ({
|
|
1002
1010
|
percent: e,
|
|
1003
1011
|
assetDepth: t,
|
|
1004
1012
|
liquidityUnits: n,
|
|
1005
1013
|
poolUnits: a
|
|
1006
|
-
}) =>
|
|
1014
|
+
}) => ut({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), w = (e) => new le({ value: e, decimal: E.THOR }), yt = ({
|
|
1007
1015
|
liquidityUnits: e,
|
|
1008
1016
|
poolUnits: t,
|
|
1009
1017
|
runeDepth: n,
|
|
@@ -1011,17 +1019,17 @@ const Yt = (e) => {
|
|
|
1011
1019
|
}) => ({
|
|
1012
1020
|
assetAmount: w(a).mul(e).div(t),
|
|
1013
1021
|
runeAmount: w(n).mul(e).div(t)
|
|
1014
|
-
}),
|
|
1022
|
+
}), Qt = ({
|
|
1015
1023
|
liquidityUnits: e,
|
|
1016
1024
|
poolUnits: t,
|
|
1017
1025
|
runeDepth: n,
|
|
1018
1026
|
assetDepth: a,
|
|
1019
1027
|
percent: i
|
|
1020
1028
|
}) => Object.fromEntries(
|
|
1021
|
-
Object.entries(
|
|
1029
|
+
Object.entries(yt({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1022
1030
|
([r, p]) => [r, p.mul(i)]
|
|
1023
1031
|
)
|
|
1024
|
-
),
|
|
1032
|
+
), zt = ({
|
|
1025
1033
|
runeDepth: e,
|
|
1026
1034
|
poolUnits: t,
|
|
1027
1035
|
assetDepth: n,
|
|
@@ -1029,20 +1037,20 @@ const Yt = (e) => {
|
|
|
1029
1037
|
runeAmount: i,
|
|
1030
1038
|
assetAmount: r
|
|
1031
1039
|
}) => {
|
|
1032
|
-
const p = w(e), d = w(n), l = w(t),
|
|
1040
|
+
const p = w(e), d = w(n), l = w(t), c = w(i), y = w(r), u = c.mul(d), h = y.mul(p), _ = c.mul(y), O = p.mul(d), I = l.mul(u.add(h.add(_.mul(2)))), g = u.add(h.add(O.mul(2))), S = I.div(g), b = w(a).add(S);
|
|
1033
1041
|
if (S.baseValueNumber === 0)
|
|
1034
1042
|
return b.div(l).baseValueNumber;
|
|
1035
1043
|
const M = l.add(b);
|
|
1036
1044
|
return b.div(M).baseValueNumber;
|
|
1037
|
-
},
|
|
1045
|
+
}, Zt = ({
|
|
1038
1046
|
runeAmount: e,
|
|
1039
1047
|
assetAmount: t,
|
|
1040
1048
|
runeDepth: n,
|
|
1041
1049
|
assetDepth: a
|
|
1042
1050
|
}) => {
|
|
1043
|
-
const i = w(n), r = w(a), p = w(t), d = w(e), l = p.mul(i).sub(r.mul(d)),
|
|
1044
|
-
return Math.abs(l.div(
|
|
1045
|
-
},
|
|
1051
|
+
const i = w(n), r = w(a), p = w(t), d = w(e), l = p.mul(i).sub(r.mul(d)), c = r.mul(d).add(i.mul(r));
|
|
1052
|
+
return Math.abs(l.div(c).baseValueNumber);
|
|
1053
|
+
}, lt = ({
|
|
1046
1054
|
symbol: e,
|
|
1047
1055
|
ticker: t,
|
|
1048
1056
|
chain: n
|
|
@@ -1066,8 +1074,8 @@ const Yt = (e) => {
|
|
|
1066
1074
|
return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${i || ""}:t:0`;
|
|
1067
1075
|
}
|
|
1068
1076
|
case f.WITHDRAW: {
|
|
1069
|
-
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: d } = t, l = !d && p ? `:${p}` : "",
|
|
1070
|
-
return `${e}:${n}${d ? "/" : "."}${
|
|
1077
|
+
const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: d } = t, l = !d && p ? `:${p}` : "", c = lt({ chain: n, symbol: i, ticker: a });
|
|
1078
|
+
return `${e}:${n}${d ? "/" : "."}${c}:${r}${l}`;
|
|
1071
1079
|
}
|
|
1072
1080
|
case f.OPEN_LOAN:
|
|
1073
1081
|
case f.CLOSE_LOAN: {
|
|
@@ -1077,10 +1085,10 @@ const Yt = (e) => {
|
|
|
1077
1085
|
default:
|
|
1078
1086
|
return "";
|
|
1079
1087
|
}
|
|
1080
|
-
},
|
|
1088
|
+
}, K = 8, ge = ({
|
|
1081
1089
|
value: e,
|
|
1082
|
-
bigIntDecimal: t =
|
|
1083
|
-
decimal: n =
|
|
1090
|
+
bigIntDecimal: t = K,
|
|
1091
|
+
decimal: n = K
|
|
1084
1092
|
}) => {
|
|
1085
1093
|
const a = e < 0n;
|
|
1086
1094
|
let i = e.toString().substring(a ? 1 : 0);
|
|
@@ -1103,17 +1111,17 @@ const Yt = (e) => {
|
|
|
1103
1111
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1104
1112
|
);
|
|
1105
1113
|
}, U = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
|
|
1106
|
-
var L, $, ie, ve, re, _e,
|
|
1107
|
-
const
|
|
1114
|
+
var L, $, ie, ve, re, _e, z, pe, H, W, Z, oe, k, J;
|
|
1115
|
+
const mt = class Q {
|
|
1108
1116
|
constructor(t) {
|
|
1109
|
-
B(this, L), B(this, ie), B(this, re), B(this,
|
|
1117
|
+
B(this, L), B(this, ie), B(this, re), B(this, z), B(this, H), B(this, Z), B(this, k), N(this, "decimalMultiplier", 10n ** 8n), N(this, "bigIntValue", 0n), N(this, "decimal");
|
|
1110
1118
|
const n = typeof t == "object", a = n ? t.value : t;
|
|
1111
1119
|
this.decimal = n ? t.decimal : void 0, this.decimalMultiplier = U(
|
|
1112
1120
|
Math.max(R(this, Z, oe).call(this, R(this, H, W).call(this, a)), this.decimal || 0)
|
|
1113
1121
|
), R(this, ie, ve).call(this, a);
|
|
1114
1122
|
}
|
|
1115
1123
|
static fromBigInt(t, n) {
|
|
1116
|
-
return new
|
|
1124
|
+
return new Q({
|
|
1117
1125
|
decimal: n,
|
|
1118
1126
|
value: ge({ value: t, bigIntDecimal: n, decimal: n })
|
|
1119
1127
|
});
|
|
@@ -1123,8 +1131,8 @@ const Tt = class z {
|
|
|
1123
1131
|
from: n,
|
|
1124
1132
|
to: a
|
|
1125
1133
|
}) {
|
|
1126
|
-
return
|
|
1127
|
-
new
|
|
1134
|
+
return Q.fromBigInt(
|
|
1135
|
+
new Q(t).bigIntValue * U(a) / U(n),
|
|
1128
1136
|
a
|
|
1129
1137
|
);
|
|
1130
1138
|
}
|
|
@@ -1132,13 +1140,13 @@ const Tt = class z {
|
|
|
1132
1140
|
return parseFloat((this.bigIntValue / this.decimalMultiplier).toString());
|
|
1133
1141
|
}
|
|
1134
1142
|
get baseValue() {
|
|
1135
|
-
return R(this, k,
|
|
1143
|
+
return R(this, k, J).call(this, "string");
|
|
1136
1144
|
}
|
|
1137
1145
|
get baseValueNumber() {
|
|
1138
|
-
return R(this, k,
|
|
1146
|
+
return R(this, k, J).call(this, "number");
|
|
1139
1147
|
}
|
|
1140
1148
|
get baseValueBigInt() {
|
|
1141
|
-
return R(this, k,
|
|
1149
|
+
return R(this, k, J).call(this, "number");
|
|
1142
1150
|
}
|
|
1143
1151
|
get value() {
|
|
1144
1152
|
return this.formatBigIntToSafeValue(
|
|
@@ -1174,10 +1182,10 @@ const Tt = class z {
|
|
|
1174
1182
|
return this.bigIntValue === this.getBigIntValue(t);
|
|
1175
1183
|
}
|
|
1176
1184
|
getBigIntValue(t, n) {
|
|
1177
|
-
return !n && typeof t == "object" ? t.bigIntValue : (t = typeof t == "object" ? t.value : t, R(this,
|
|
1185
|
+
return !n && typeof t == "object" ? t.bigIntValue : (t = typeof t == "object" ? t.value : t, R(this, z, pe).call(this, R(this, H, W).call(this, t), n));
|
|
1178
1186
|
}
|
|
1179
1187
|
formatBigIntToSafeValue(t, n) {
|
|
1180
|
-
const a = n || this.decimal ||
|
|
1188
|
+
const a = n || this.decimal || K, i = Math.max(
|
|
1181
1189
|
a,
|
|
1182
1190
|
G(this.decimalMultiplier)
|
|
1183
1191
|
), r = t < 0n;
|
|
@@ -1185,8 +1193,8 @@ const Tt = class z {
|
|
|
1185
1193
|
const d = i - (p.length - 1);
|
|
1186
1194
|
d > 0 && (p = "0".repeat(d) + p);
|
|
1187
1195
|
const l = p.length - i;
|
|
1188
|
-
let
|
|
1189
|
-
return parseInt(
|
|
1196
|
+
let c = p.slice(-i);
|
|
1197
|
+
return parseInt(c[a]) >= 5 ? c = `${c.substring(0, a - 1)}${(parseInt(c[a - 1]) + 1).toString()}` : c = c.substring(0, a), `${r ? "-" : ""}${p.slice(0, l)}.${c}`.replace(
|
|
1190
1198
|
/\.?0*$/,
|
|
1191
1199
|
""
|
|
1192
1200
|
);
|
|
@@ -1217,13 +1225,13 @@ L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
|
|
|
1217
1225
|
return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
|
|
1218
1226
|
}, ie = /* @__PURE__ */ new WeakSet(), ve = function(e, t) {
|
|
1219
1227
|
const n = R(this, H, W).call(this, e) || "0";
|
|
1220
|
-
this.bigIntValue = t || R(this,
|
|
1228
|
+
this.bigIntValue = t || R(this, z, pe).call(this, n);
|
|
1221
1229
|
}, re = /* @__PURE__ */ new WeakSet(), _e = function(...e) {
|
|
1222
1230
|
const t = e.map(
|
|
1223
1231
|
(n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : R(this, Z, oe).call(this, R(this, H, W).call(this, n))
|
|
1224
1232
|
).filter(Boolean);
|
|
1225
|
-
return Math.max(...t,
|
|
1226
|
-
},
|
|
1233
|
+
return Math.max(...t, K);
|
|
1234
|
+
}, z = /* @__PURE__ */ new WeakSet(), pe = function(e, t) {
|
|
1227
1235
|
const n = t ? U(t) : this.decimalMultiplier, a = G(n), [i, r = ""] = e.split(".");
|
|
1228
1236
|
return BigInt(`${i}${r.padEnd(a, "0")}`);
|
|
1229
1237
|
}, H = /* @__PURE__ */ new WeakSet(), W = function(e) {
|
|
@@ -1235,8 +1243,8 @@ L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
|
|
|
1235
1243
|
}, Z = /* @__PURE__ */ new WeakSet(), oe = function(e) {
|
|
1236
1244
|
var t;
|
|
1237
1245
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1238
|
-
return Math.max(n,
|
|
1239
|
-
}, k = /* @__PURE__ */ new WeakSet(),
|
|
1246
|
+
return Math.max(n, K);
|
|
1247
|
+
}, k = /* @__PURE__ */ new WeakSet(), J = function(e) {
|
|
1240
1248
|
const t = this.decimalMultiplier / U(this.decimal || 0), n = this.bigIntValue / t;
|
|
1241
1249
|
switch (e) {
|
|
1242
1250
|
case "number":
|
|
@@ -1247,7 +1255,7 @@ L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
|
|
|
1247
1255
|
return n;
|
|
1248
1256
|
}
|
|
1249
1257
|
};
|
|
1250
|
-
let de =
|
|
1258
|
+
let de = mt, ue;
|
|
1251
1259
|
const se = (e) => {
|
|
1252
1260
|
if (!ue)
|
|
1253
1261
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
@@ -1263,7 +1271,7 @@ class v extends de {
|
|
|
1263
1271
|
t.value instanceof de ? t.value : { decimal: t.decimal, value: t.value }
|
|
1264
1272
|
), N(this, "address"), N(this, "chain"), N(this, "isSynthetic", !1), N(this, "isGasAsset", !1), N(this, "symbol"), N(this, "ticker"), N(this, "type");
|
|
1265
1273
|
const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = ye(n);
|
|
1266
|
-
this.type =
|
|
1274
|
+
this.type = ot(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;
|
|
1267
1275
|
}
|
|
1268
1276
|
static async fromString(t, n = 0) {
|
|
1269
1277
|
return he(t, n);
|
|
@@ -1282,7 +1290,7 @@ class v extends de {
|
|
|
1282
1290
|
return new v({ decimal: a, identifier: i, value: n });
|
|
1283
1291
|
}
|
|
1284
1292
|
static fromChainOrSignature(t, n = 0) {
|
|
1285
|
-
const { decimal: a, identifier: i } =
|
|
1293
|
+
const { decimal: a, identifier: i } = pt(t);
|
|
1286
1294
|
return new v({ value: n, decimal: a, identifier: i });
|
|
1287
1295
|
}
|
|
1288
1296
|
static async fromTCQuote(t, n = 0) {
|
|
@@ -1309,8 +1317,8 @@ class v extends de {
|
|
|
1309
1317
|
...r
|
|
1310
1318
|
} = await import("@swapkit/tokens");
|
|
1311
1319
|
ue = [i, ...Object.values(r)].reduce(
|
|
1312
|
-
(p, { tokens: d }) => (d.forEach(({ identifier: l, chain:
|
|
1313
|
-
const u = "decimals" in y ? y.decimals : E[
|
|
1320
|
+
(p, { tokens: d }) => (d.forEach(({ identifier: l, chain: c, ...y }) => {
|
|
1321
|
+
const u = "decimals" in y ? y.decimals : E[c];
|
|
1314
1322
|
p.set(l, { identifier: l, decimal: u });
|
|
1315
1323
|
}), p),
|
|
1316
1324
|
/* @__PURE__ */ new Map()
|
|
@@ -1358,12 +1366,12 @@ const fe = (e) => {
|
|
|
1358
1366
|
return {
|
|
1359
1367
|
address: p == null ? void 0 : p.toLowerCase(),
|
|
1360
1368
|
chain: a,
|
|
1361
|
-
isGasAsset:
|
|
1369
|
+
isGasAsset: rt({ chain: a, symbol: i }),
|
|
1362
1370
|
isSynthetic: t,
|
|
1363
1371
|
symbol: p ? `${r}-${(p == null ? void 0 : p.toLowerCase()) ?? ""}` : i,
|
|
1364
1372
|
ticker: t ? i : r
|
|
1365
1373
|
};
|
|
1366
|
-
},
|
|
1374
|
+
}, Tt = {
|
|
1367
1375
|
/**
|
|
1368
1376
|
* Core
|
|
1369
1377
|
*/
|
|
@@ -1420,9 +1428,9 @@ const fe = (e) => {
|
|
|
1420
1428
|
*/
|
|
1421
1429
|
helpers_number_different_decimals: 99101
|
|
1422
1430
|
};
|
|
1423
|
-
class
|
|
1431
|
+
class m extends Error {
|
|
1424
1432
|
constructor(t, n) {
|
|
1425
|
-
console.error(n), super(t, { cause: { code:
|
|
1433
|
+
console.error(n), super(t, { cause: { code: Tt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
|
|
1426
1434
|
}
|
|
1427
1435
|
}
|
|
1428
1436
|
class le extends de {
|
|
@@ -1433,7 +1441,7 @@ class le extends de {
|
|
|
1433
1441
|
return this.value;
|
|
1434
1442
|
}
|
|
1435
1443
|
}
|
|
1436
|
-
const
|
|
1444
|
+
const _t = [
|
|
1437
1445
|
{
|
|
1438
1446
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1439
1447
|
stateMutability: "nonpayable",
|
|
@@ -1524,7 +1532,7 @@ const ht = [
|
|
|
1524
1532
|
type: "function"
|
|
1525
1533
|
},
|
|
1526
1534
|
{ stateMutability: "payable", type: "receive" }
|
|
1527
|
-
],
|
|
1535
|
+
], ht = [
|
|
1528
1536
|
{
|
|
1529
1537
|
inputs: [
|
|
1530
1538
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -1668,7 +1676,7 @@ const ht = [
|
|
|
1668
1676
|
type: "function"
|
|
1669
1677
|
},
|
|
1670
1678
|
{ stateMutability: "payable", type: "receive" }
|
|
1671
|
-
],
|
|
1679
|
+
], ft = [
|
|
1672
1680
|
{
|
|
1673
1681
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1674
1682
|
stateMutability: "nonpayable",
|
|
@@ -1773,7 +1781,7 @@ const ht = [
|
|
|
1773
1781
|
type: "function"
|
|
1774
1782
|
},
|
|
1775
1783
|
{ stateMutability: "payable", type: "receive" }
|
|
1776
|
-
],
|
|
1784
|
+
], bt = [
|
|
1777
1785
|
{
|
|
1778
1786
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
1779
1787
|
stateMutability: "nonpayable",
|
|
@@ -1864,7 +1872,7 @@ const ht = [
|
|
|
1864
1872
|
type: "function"
|
|
1865
1873
|
},
|
|
1866
1874
|
{ stateMutability: "payable", type: "receive" }
|
|
1867
|
-
],
|
|
1875
|
+
], At = [
|
|
1868
1876
|
{
|
|
1869
1877
|
inputs: [
|
|
1870
1878
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2008,7 +2016,7 @@ const ht = [
|
|
|
2008
2016
|
type: "function"
|
|
2009
2017
|
},
|
|
2010
2018
|
{ stateMutability: "payable", type: "receive" }
|
|
2011
|
-
],
|
|
2019
|
+
], wt = [
|
|
2012
2020
|
{
|
|
2013
2021
|
inputs: [
|
|
2014
2022
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2127,7 +2135,7 @@ const ht = [
|
|
|
2127
2135
|
type: "function"
|
|
2128
2136
|
},
|
|
2129
2137
|
{ stateMutability: "payable", type: "receive" }
|
|
2130
|
-
],
|
|
2138
|
+
], Et = [
|
|
2131
2139
|
{
|
|
2132
2140
|
inputs: [
|
|
2133
2141
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2246,7 +2254,7 @@ const ht = [
|
|
|
2246
2254
|
type: "function"
|
|
2247
2255
|
},
|
|
2248
2256
|
{ stateMutability: "payable", type: "receive" }
|
|
2249
|
-
],
|
|
2257
|
+
], Rt = [
|
|
2250
2258
|
{
|
|
2251
2259
|
inputs: [
|
|
2252
2260
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2365,7 +2373,7 @@ const ht = [
|
|
|
2365
2373
|
type: "function"
|
|
2366
2374
|
},
|
|
2367
2375
|
{ stateMutability: "payable", type: "receive" }
|
|
2368
|
-
],
|
|
2376
|
+
], Ot = [
|
|
2369
2377
|
{
|
|
2370
2378
|
inputs: [
|
|
2371
2379
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2484,7 +2492,7 @@ const ht = [
|
|
|
2484
2492
|
type: "function"
|
|
2485
2493
|
},
|
|
2486
2494
|
{ stateMutability: "payable", type: "receive" }
|
|
2487
|
-
],
|
|
2495
|
+
], It = [
|
|
2488
2496
|
{
|
|
2489
2497
|
inputs: [
|
|
2490
2498
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2611,7 +2619,7 @@ const ht = [
|
|
|
2611
2619
|
type: "function"
|
|
2612
2620
|
},
|
|
2613
2621
|
{ stateMutability: "payable", type: "receive" }
|
|
2614
|
-
],
|
|
2622
|
+
], St = [
|
|
2615
2623
|
{
|
|
2616
2624
|
inputs: [
|
|
2617
2625
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2738,7 +2746,7 @@ const ht = [
|
|
|
2738
2746
|
type: "function"
|
|
2739
2747
|
},
|
|
2740
2748
|
{ stateMutability: "payable", type: "receive" }
|
|
2741
|
-
],
|
|
2749
|
+
], gt = [
|
|
2742
2750
|
{
|
|
2743
2751
|
inputs: [
|
|
2744
2752
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2865,7 +2873,7 @@ const ht = [
|
|
|
2865
2873
|
type: "function"
|
|
2866
2874
|
},
|
|
2867
2875
|
{ stateMutability: "payable", type: "receive" }
|
|
2868
|
-
],
|
|
2876
|
+
], vt = [
|
|
2869
2877
|
{
|
|
2870
2878
|
inputs: [
|
|
2871
2879
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2992,7 +3000,7 @@ const ht = [
|
|
|
2992
3000
|
type: "function"
|
|
2993
3001
|
},
|
|
2994
3002
|
{ stateMutability: "payable", type: "receive" }
|
|
2995
|
-
],
|
|
3003
|
+
], Mt = [
|
|
2996
3004
|
{
|
|
2997
3005
|
inputs: [
|
|
2998
3006
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -3120,26 +3128,26 @@ const ht = [
|
|
|
3120
3128
|
},
|
|
3121
3129
|
{ stateMutability: "payable", type: "receive" }
|
|
3122
3130
|
], Me = {
|
|
3123
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
3124
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
3125
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
3126
|
-
},
|
|
3131
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: _t,
|
|
3132
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: ft,
|
|
3133
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: bt
|
|
3134
|
+
}, Ct = {
|
|
3127
3135
|
...Me,
|
|
3128
3136
|
// AVAX
|
|
3129
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
3130
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
3131
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
3137
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: wt,
|
|
3138
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: ht,
|
|
3139
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: Rt,
|
|
3132
3140
|
// BSC
|
|
3133
|
-
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]:
|
|
3141
|
+
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: At,
|
|
3134
3142
|
// ETH
|
|
3135
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
3136
|
-
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]:
|
|
3137
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
3138
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
3139
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
3140
|
-
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]:
|
|
3141
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
3142
|
-
},
|
|
3143
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Et,
|
|
3144
|
+
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: Ot,
|
|
3145
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: It,
|
|
3146
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: St,
|
|
3147
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: gt,
|
|
3148
|
+
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: vt,
|
|
3149
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: Mt
|
|
3150
|
+
}, Nt = ({
|
|
3143
3151
|
streamSwap: e,
|
|
3144
3152
|
contractAddress: t,
|
|
3145
3153
|
recipient: n,
|
|
@@ -3150,7 +3158,7 @@ const ht = [
|
|
|
3150
3158
|
data: p = "",
|
|
3151
3159
|
deadline: d,
|
|
3152
3160
|
memo: l,
|
|
3153
|
-
router:
|
|
3161
|
+
router: c,
|
|
3154
3162
|
memoStreamingSwap: y,
|
|
3155
3163
|
tcMemo: u,
|
|
3156
3164
|
tcRouter: h,
|
|
@@ -3160,12 +3168,12 @@ const ht = [
|
|
|
3160
3168
|
}
|
|
3161
3169
|
}) => {
|
|
3162
3170
|
const g = !!Me[t.toLowerCase()];
|
|
3163
|
-
if (g && !
|
|
3171
|
+
if (g && !c)
|
|
3164
3172
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
3165
3173
|
const S = u || l, b = e && y || S;
|
|
3166
3174
|
if (!_ && !O)
|
|
3167
3175
|
throw new Error("TC Vault is required on calldata");
|
|
3168
|
-
if (!h && !
|
|
3176
|
+
if (!h && !c)
|
|
3169
3177
|
throw new Error("TC Router is required on calldata");
|
|
3170
3178
|
if (!b)
|
|
3171
3179
|
throw new Error("TC Memo is required on calldata");
|
|
@@ -3173,20 +3181,21 @@ const ht = [
|
|
|
3173
3181
|
throw new Error("Token is required on calldata");
|
|
3174
3182
|
const M = [
|
|
3175
3183
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
3176
|
-
a(h ||
|
|
3184
|
+
a(h || c),
|
|
3177
3185
|
a(_ || O),
|
|
3178
3186
|
b.replace("{recipientAddress}", n),
|
|
3179
3187
|
a(I),
|
|
3180
3188
|
i
|
|
3181
|
-
], ne = g ? [a(
|
|
3189
|
+
], ne = g ? [a(c), p, d] : [r, d];
|
|
3182
3190
|
return [...M, ...ne];
|
|
3183
|
-
},
|
|
3191
|
+
}, Dt = ({ chain: e, txHash: t }) => {
|
|
3184
3192
|
const n = Re[e];
|
|
3185
3193
|
switch (e) {
|
|
3186
3194
|
case s.Binance:
|
|
3187
3195
|
case s.Bitcoin:
|
|
3188
3196
|
case s.BitcoinCash:
|
|
3189
3197
|
case s.Maya:
|
|
3198
|
+
case s.Kujira:
|
|
3190
3199
|
case s.THORChain:
|
|
3191
3200
|
return `${n}/tx/${t}`;
|
|
3192
3201
|
case s.Arbitrum:
|
|
@@ -3205,7 +3214,7 @@ const ht = [
|
|
|
3205
3214
|
default:
|
|
3206
3215
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3207
3216
|
}
|
|
3208
|
-
},
|
|
3217
|
+
}, xt = ({ chain: e, address: t }) => {
|
|
3209
3218
|
const n = Re[e];
|
|
3210
3219
|
switch (e) {
|
|
3211
3220
|
case s.Arbitrum:
|
|
@@ -3219,6 +3228,7 @@ const ht = [
|
|
|
3219
3228
|
case s.Maya:
|
|
3220
3229
|
case s.Optimism:
|
|
3221
3230
|
case s.Polygon:
|
|
3231
|
+
case s.Kujira:
|
|
3222
3232
|
case s.THORChain:
|
|
3223
3233
|
return `${n}/address/${t}`;
|
|
3224
3234
|
case s.Cosmos:
|
|
@@ -3228,18 +3238,18 @@ const ht = [
|
|
|
3228
3238
|
default:
|
|
3229
3239
|
throw new Error(`Unsupported chain: ${e}`);
|
|
3230
3240
|
}
|
|
3231
|
-
},
|
|
3241
|
+
}, Pt = (e) => {
|
|
3232
3242
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3233
3243
|
return Oe(`${t}/thorchain/inbound_addresses`);
|
|
3234
|
-
},
|
|
3244
|
+
}, Bt = (e) => {
|
|
3235
3245
|
const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
|
|
3236
3246
|
return Oe(`${t}/thorchain/mimir`);
|
|
3237
3247
|
}, be = () => Object.values(s).reduce(
|
|
3238
3248
|
(e, t) => (e[t] = null, e),
|
|
3239
3249
|
{}
|
|
3240
3250
|
);
|
|
3241
|
-
var V, ee,
|
|
3242
|
-
class
|
|
3251
|
+
var V, ee, Y, D, X, j;
|
|
3252
|
+
class en {
|
|
3243
3253
|
constructor({ stagenet: t } = {}) {
|
|
3244
3254
|
T(this, "connectedChains", be());
|
|
3245
3255
|
T(this, "connectedWallets", be());
|
|
@@ -3248,9 +3258,9 @@ class tn {
|
|
|
3248
3258
|
var n;
|
|
3249
3259
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
3250
3260
|
});
|
|
3251
|
-
T(this, "getExplorerTxUrl", (t, n) =>
|
|
3261
|
+
T(this, "getExplorerTxUrl", (t, n) => Dt({ chain: t, txHash: n }));
|
|
3252
3262
|
T(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
3253
|
-
T(this, "getExplorerAddressUrl", (t, n) =>
|
|
3263
|
+
T(this, "getExplorerAddressUrl", (t, n) => xt({ chain: t, address: n }));
|
|
3254
3264
|
T(this, "getBalance", async (t, n) => {
|
|
3255
3265
|
var i;
|
|
3256
3266
|
if (!n)
|
|
@@ -3259,22 +3269,22 @@ class tn {
|
|
|
3259
3269
|
return (a == null ? void 0 : a.balance) || [];
|
|
3260
3270
|
});
|
|
3261
3271
|
T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: i }) => {
|
|
3262
|
-
var d, l,
|
|
3272
|
+
var d, l, c, y;
|
|
3263
3273
|
const { quoteMode: r } = a.meta, p = r.startsWith("ERC20-") ? s.Ethereum : r.startsWith("ARC20-") ? s.Avalanche : s.BinanceSmartChain;
|
|
3264
3274
|
if (!a.complete)
|
|
3265
|
-
throw new
|
|
3275
|
+
throw new m("core_swap_route_not_complete");
|
|
3266
3276
|
try {
|
|
3267
3277
|
if (He.includes(r)) {
|
|
3268
3278
|
const u = this.connectedWallets[p];
|
|
3269
3279
|
if (!(u != null && u.sendTransaction))
|
|
3270
|
-
throw new
|
|
3280
|
+
throw new m("core_wallet_connection_not_found");
|
|
3271
3281
|
if (!(t ? (d = a == null ? void 0 : a.streamingSwap) == null ? void 0 : d.transaction : a == null ? void 0 : a.transaction))
|
|
3272
|
-
throw new
|
|
3282
|
+
throw new m("core_swap_route_transaction_not_found");
|
|
3273
3283
|
const { isHexString: _, parseUnits: O } = await import("./index-cf1865cd.js"), { data: I, from: g, to: S, value: b } = a.transaction, M = {
|
|
3274
3284
|
data: I,
|
|
3275
3285
|
from: g,
|
|
3276
3286
|
to: S.toLowerCase(),
|
|
3277
|
-
chainId: BigInt(
|
|
3287
|
+
chainId: BigInt(Ye[p]),
|
|
3278
3288
|
value: b ? new le({
|
|
3279
3289
|
value: _(b) ? b : O(b, "wei").toString(16)
|
|
3280
3290
|
}).baseValueBigInt : 0n
|
|
@@ -3283,10 +3293,10 @@ class tn {
|
|
|
3283
3293
|
}
|
|
3284
3294
|
if (ke.includes(r)) {
|
|
3285
3295
|
if (!a.calldata.fromAsset)
|
|
3286
|
-
throw new
|
|
3296
|
+
throw new m("core_swap_asset_not_recognized");
|
|
3287
3297
|
const u = await v.fromString(a.calldata.fromAsset);
|
|
3288
3298
|
if (!u)
|
|
3289
|
-
throw new
|
|
3299
|
+
throw new m("core_swap_asset_not_recognized");
|
|
3290
3300
|
const { address: h } = await A(this, V).call(this, u.chain), {
|
|
3291
3301
|
contract: _,
|
|
3292
3302
|
calldata: { amountIn: O, memo: I, memoStreamingSwap: g }
|
|
@@ -3296,16 +3306,16 @@ class tn {
|
|
|
3296
3306
|
if ($e.includes(r)) {
|
|
3297
3307
|
const { calldata: u, contract: h } = a;
|
|
3298
3308
|
if (!h)
|
|
3299
|
-
throw new
|
|
3309
|
+
throw new m("core_swap_contract_not_found");
|
|
3300
3310
|
const _ = this.connectedWallets[p], O = this.getAddress(p);
|
|
3301
3311
|
if (!(_ != null && _.sendTransaction) || !O)
|
|
3302
|
-
throw new
|
|
3303
|
-
const { getProvider: I, toChecksumAddress: g } = await import("@swapkit/toolbox-evm"), S = I(p), b =
|
|
3312
|
+
throw new m("core_wallet_connection_not_found");
|
|
3313
|
+
const { getProvider: I, toChecksumAddress: g } = await import("@swapkit/toolbox-evm"), S = I(p), b = Ct[h.toLowerCase()];
|
|
3304
3314
|
if (!b)
|
|
3305
|
-
throw new
|
|
3306
|
-
const ne = await ((y = (
|
|
3307
|
-
|
|
3308
|
-
...
|
|
3315
|
+
throw new m("core_swap_contract_not_supported", { contractAddress: h });
|
|
3316
|
+
const ne = await ((y = (c = (await ((l = _.createContract) == null ? void 0 : l.call(_, h, b, S))).populateTransaction).swapIn) == null ? void 0 : y.call(
|
|
3317
|
+
c,
|
|
3318
|
+
...Nt({
|
|
3309
3319
|
streamSwap: t,
|
|
3310
3320
|
toChecksumAddress: g,
|
|
3311
3321
|
contractAddress: h,
|
|
@@ -3316,9 +3326,9 @@ class tn {
|
|
|
3316
3326
|
));
|
|
3317
3327
|
return _.sendTransaction(ne, i);
|
|
3318
3328
|
}
|
|
3319
|
-
throw new
|
|
3329
|
+
throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
|
|
3320
3330
|
} catch (u) {
|
|
3321
|
-
throw new
|
|
3331
|
+
throw new m("core_swap_transaction_error", u);
|
|
3322
3332
|
}
|
|
3323
3333
|
});
|
|
3324
3334
|
T(this, "getWalletByChain", async (t) => {
|
|
@@ -3335,8 +3345,8 @@ class tn {
|
|
|
3335
3345
|
walletType: (r = this.connectedChains[t]) == null ? void 0 : r.walletType
|
|
3336
3346
|
}, { ...this.connectedChains[t] };
|
|
3337
3347
|
});
|
|
3338
|
-
T(this, "approveAssetValue", (t, n) => A(this,
|
|
3339
|
-
T(this, "isAssetValueApproved", (t, n) => A(this,
|
|
3348
|
+
T(this, "approveAssetValue", (t, n) => A(this, Y).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
3349
|
+
T(this, "isAssetValueApproved", (t, n) => A(this, Y).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
3340
3350
|
T(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
3341
3351
|
var a, i;
|
|
3342
3352
|
return (i = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : i.call(a, t);
|
|
@@ -3344,11 +3354,11 @@ class tn {
|
|
|
3344
3354
|
T(this, "transfer", async (t) => {
|
|
3345
3355
|
const n = this.connectedWallets[t.assetValue.chain];
|
|
3346
3356
|
if (!n)
|
|
3347
|
-
throw new
|
|
3357
|
+
throw new m("core_wallet_connection_not_found");
|
|
3348
3358
|
try {
|
|
3349
3359
|
return await n.transfer(A(this, j).call(this, t));
|
|
3350
3360
|
} catch (a) {
|
|
3351
|
-
throw new
|
|
3361
|
+
throw new m("core_swap_transaction_error", a);
|
|
3352
3362
|
}
|
|
3353
3363
|
});
|
|
3354
3364
|
T(this, "deposit", async ({
|
|
@@ -3359,13 +3369,13 @@ class tn {
|
|
|
3359
3369
|
}) => {
|
|
3360
3370
|
const { chain: r, symbol: p, ticker: d } = t, l = this.connectedWallets[r];
|
|
3361
3371
|
if (!l)
|
|
3362
|
-
throw new
|
|
3363
|
-
const
|
|
3372
|
+
throw new m("core_wallet_connection_not_found");
|
|
3373
|
+
const c = A(this, j).call(this, { assetValue: t, recipient: n, router: a, ...i });
|
|
3364
3374
|
try {
|
|
3365
3375
|
switch (r) {
|
|
3366
3376
|
case s.THORChain: {
|
|
3367
3377
|
const y = l;
|
|
3368
|
-
return await (n === "" ? y.deposit(
|
|
3378
|
+
return await (n === "" ? y.deposit(c) : y.transfer(c));
|
|
3369
3379
|
}
|
|
3370
3380
|
case s.Ethereum:
|
|
3371
3381
|
case s.BinanceSmartChain:
|
|
@@ -3380,18 +3390,18 @@ class tn {
|
|
|
3380
3390
|
y({ chain: r, symbol: p, ticker: d }, r),
|
|
3381
3391
|
// TODO: (@Towan) Re-Check on that conversion 🙏
|
|
3382
3392
|
t.baseValueBigInt.toString(),
|
|
3383
|
-
|
|
3393
|
+
c.memo,
|
|
3384
3394
|
i.expiration
|
|
3385
3395
|
],
|
|
3386
|
-
txOverrides: { from:
|
|
3396
|
+
txOverrides: { from: c.from, value: t.baseValueBigInt }
|
|
3387
3397
|
});
|
|
3388
3398
|
}
|
|
3389
3399
|
default:
|
|
3390
|
-
return await l.transfer(
|
|
3400
|
+
return await l.transfer(c);
|
|
3391
3401
|
}
|
|
3392
3402
|
} catch (y) {
|
|
3393
3403
|
const u = ((y == null ? void 0 : y.message) || (y == null ? void 0 : y.toString())).toLowerCase(), h = u == null ? void 0 : u.includes("insufficient funds"), _ = u == null ? void 0 : u.includes("gas"), O = u == null ? void 0 : u.includes("server"), I = h ? "core_transaction_deposit_insufficient_funds_error" : _ ? "core_transaction_deposit_gas_error" : O ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
3394
|
-
throw new
|
|
3404
|
+
throw new m(I, y);
|
|
3395
3405
|
}
|
|
3396
3406
|
});
|
|
3397
3407
|
/**
|
|
@@ -3402,7 +3412,7 @@ class tn {
|
|
|
3402
3412
|
assetValue: n
|
|
3403
3413
|
}) => {
|
|
3404
3414
|
if (t.lte(0) || n.lte(0))
|
|
3405
|
-
throw new
|
|
3415
|
+
throw new m("core_transaction_create_liquidity_invalid_params");
|
|
3406
3416
|
let a = "", i = "";
|
|
3407
3417
|
try {
|
|
3408
3418
|
a = await A(this, D).call(this, {
|
|
@@ -3413,7 +3423,7 @@ class tn {
|
|
|
3413
3423
|
})
|
|
3414
3424
|
});
|
|
3415
3425
|
} catch (r) {
|
|
3416
|
-
throw new
|
|
3426
|
+
throw new m("core_transaction_create_liquidity_rune_error", r);
|
|
3417
3427
|
}
|
|
3418
3428
|
try {
|
|
3419
3429
|
i = await A(this, D).call(this, {
|
|
@@ -3424,7 +3434,7 @@ class tn {
|
|
|
3424
3434
|
})
|
|
3425
3435
|
});
|
|
3426
3436
|
} catch (r) {
|
|
3427
|
-
throw new
|
|
3437
|
+
throw new m("core_transaction_create_liquidity_asset_error", r);
|
|
3428
3438
|
}
|
|
3429
3439
|
return { runeTx: a, assetTx: i };
|
|
3430
3440
|
});
|
|
@@ -3437,13 +3447,13 @@ class tn {
|
|
|
3437
3447
|
isPendingSymmAsset: p,
|
|
3438
3448
|
mode: d = "sym"
|
|
3439
3449
|
}) => {
|
|
3440
|
-
const [l, ...
|
|
3450
|
+
const [l, ...c] = t.split("."), y = d === "sym", u = (n == null ? void 0 : n.gt(0)) && (y || d === "rune"), h = (a == null ? void 0 : a.gt(0)) && (y || d === "asset"), _ = p || u, O = _ ? i || this.getAddress(s.THORChain) : "", I = y || d === "asset" ? r || this.getAddress(l) : "";
|
|
3441
3451
|
if (!u && !h)
|
|
3442
|
-
throw new
|
|
3452
|
+
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
3443
3453
|
if (_ && !O)
|
|
3444
|
-
throw new
|
|
3454
|
+
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
3445
3455
|
let g, S;
|
|
3446
|
-
const b = { chain: l, symbol:
|
|
3456
|
+
const b = { chain: l, symbol: c.join(".") };
|
|
3447
3457
|
if (u && n)
|
|
3448
3458
|
try {
|
|
3449
3459
|
g = await A(this, D).call(this, {
|
|
@@ -3451,7 +3461,7 @@ class tn {
|
|
|
3451
3461
|
memo: x(f.DEPOSIT, { ...b, address: I })
|
|
3452
3462
|
});
|
|
3453
3463
|
} catch (M) {
|
|
3454
|
-
throw new
|
|
3464
|
+
throw new m("core_transaction_add_liquidity_rune_error", M);
|
|
3455
3465
|
}
|
|
3456
3466
|
if (h && a)
|
|
3457
3467
|
try {
|
|
@@ -3460,7 +3470,7 @@ class tn {
|
|
|
3460
3470
|
memo: x(f.DEPOSIT, { ...b, address: O })
|
|
3461
3471
|
});
|
|
3462
3472
|
} catch (M) {
|
|
3463
|
-
throw new
|
|
3473
|
+
throw new m("core_transaction_add_liquidity_asset_error", M);
|
|
3464
3474
|
}
|
|
3465
3475
|
return { runeTx: g, assetTx: S };
|
|
3466
3476
|
});
|
|
@@ -3485,7 +3495,7 @@ class tn {
|
|
|
3485
3495
|
})
|
|
3486
3496
|
});
|
|
3487
3497
|
} catch (d) {
|
|
3488
|
-
throw new
|
|
3498
|
+
throw new m("core_transaction_withdraw_error", d);
|
|
3489
3499
|
}
|
|
3490
3500
|
});
|
|
3491
3501
|
T(this, "savings", async ({
|
|
@@ -3525,7 +3535,7 @@ class tn {
|
|
|
3525
3535
|
address: a,
|
|
3526
3536
|
unbondAmount: t === "unbond" ? n.baseValueNumber : void 0
|
|
3527
3537
|
});
|
|
3528
|
-
return A(this,
|
|
3538
|
+
return A(this, X).call(this, {
|
|
3529
3539
|
memo: r,
|
|
3530
3540
|
assetValue: t === "bond" ? n : fe(s.THORChain)
|
|
3531
3541
|
});
|
|
@@ -3533,7 +3543,7 @@ class tn {
|
|
|
3533
3543
|
T(this, "registerThorname", ({
|
|
3534
3544
|
assetValue: t,
|
|
3535
3545
|
...n
|
|
3536
|
-
}) => A(this,
|
|
3546
|
+
}) => A(this, X).call(this, { assetValue: t, memo: x(f.THORNAME_REGISTER, n) }));
|
|
3537
3547
|
T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: i = {} }) => {
|
|
3538
3548
|
try {
|
|
3539
3549
|
t.forEach((r) => {
|
|
@@ -3545,7 +3555,7 @@ class tn {
|
|
|
3545
3555
|
});
|
|
3546
3556
|
});
|
|
3547
3557
|
} catch (r) {
|
|
3548
|
-
throw new
|
|
3558
|
+
throw new m("core_extend_error", r);
|
|
3549
3559
|
}
|
|
3550
3560
|
});
|
|
3551
3561
|
T(this, "estimateMaxSendableAmount", async ({
|
|
@@ -3581,35 +3591,35 @@ class tn {
|
|
|
3581
3591
|
});
|
|
3582
3592
|
}
|
|
3583
3593
|
default:
|
|
3584
|
-
throw new
|
|
3594
|
+
throw new m("core_estimated_max_spendable_chain_not_supported");
|
|
3585
3595
|
}
|
|
3586
3596
|
});
|
|
3587
3597
|
/**
|
|
3588
3598
|
* Wallet connection methods
|
|
3589
3599
|
*/
|
|
3590
3600
|
T(this, "connectXDEFI", async (t) => {
|
|
3591
|
-
throw new
|
|
3601
|
+
throw new m("core_wallet_xdefi_not_installed");
|
|
3592
3602
|
});
|
|
3593
3603
|
T(this, "connectEVMWallet", async (t, n) => {
|
|
3594
|
-
throw new
|
|
3604
|
+
throw new m("core_wallet_evmwallet_not_installed");
|
|
3595
3605
|
});
|
|
3596
3606
|
T(this, "connectWalletconnect", async (t, n) => {
|
|
3597
|
-
throw new
|
|
3607
|
+
throw new m("core_wallet_walletconnect_not_installed");
|
|
3598
3608
|
});
|
|
3599
3609
|
T(this, "connectKeystore", async (t, n) => {
|
|
3600
|
-
throw new
|
|
3610
|
+
throw new m("core_wallet_keystore_not_installed");
|
|
3601
3611
|
});
|
|
3602
3612
|
T(this, "connectLedger", async (t, n) => {
|
|
3603
|
-
throw new
|
|
3613
|
+
throw new m("core_wallet_ledger_not_installed");
|
|
3604
3614
|
});
|
|
3605
3615
|
T(this, "connectTrezor", async (t, n) => {
|
|
3606
|
-
throw new
|
|
3616
|
+
throw new m("core_wallet_trezor_not_installed");
|
|
3607
3617
|
});
|
|
3608
|
-
T(this, "connectKeplr", async () => {
|
|
3609
|
-
throw new
|
|
3618
|
+
T(this, "connectKeplr", async (t) => {
|
|
3619
|
+
throw new m("core_wallet_keplr_not_installed");
|
|
3610
3620
|
});
|
|
3611
3621
|
T(this, "connectOkx", async (t) => {
|
|
3612
|
-
throw new
|
|
3622
|
+
throw new m("core_wallet_okx_not_installed");
|
|
3613
3623
|
});
|
|
3614
3624
|
T(this, "disconnectChain", (t) => {
|
|
3615
3625
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
@@ -3623,17 +3633,17 @@ class tn {
|
|
|
3623
3633
|
halted: !1,
|
|
3624
3634
|
chain: s.THORChain
|
|
3625
3635
|
};
|
|
3626
|
-
const a = (await
|
|
3636
|
+
const a = (await Pt(this.stagenet)).find((i) => i.chain === t);
|
|
3627
3637
|
if (!a)
|
|
3628
|
-
throw new
|
|
3638
|
+
throw new m("core_inbound_data_not_found");
|
|
3629
3639
|
if (a != null && a.halted)
|
|
3630
|
-
throw new
|
|
3640
|
+
throw new m("core_chain_halted");
|
|
3631
3641
|
return a;
|
|
3632
3642
|
});
|
|
3633
3643
|
P(this, ee, ({ chain: t, wallet: n, walletMethods: a }) => {
|
|
3634
3644
|
this.connectedChains[t] = n, this.connectedWallets[t] = a;
|
|
3635
3645
|
});
|
|
3636
|
-
P(this,
|
|
3646
|
+
P(this, Y, async ({
|
|
3637
3647
|
assetValue: { baseValueBigInt: t, address: n, chain: a, isGasAsset: i, isSynthetic: r },
|
|
3638
3648
|
type: p = "checkOnly",
|
|
3639
3649
|
contractAddress: d
|
|
@@ -3643,10 +3653,10 @@ class tn {
|
|
|
3643
3653
|
return !0;
|
|
3644
3654
|
const y = this.connectedWallets[a], u = p === "checkOnly" ? y == null ? void 0 : y.isApproved : y == null ? void 0 : y.approve;
|
|
3645
3655
|
if (!u)
|
|
3646
|
-
throw new
|
|
3656
|
+
throw new m("core_wallet_connection_not_found");
|
|
3647
3657
|
const h = this.getAddress(a);
|
|
3648
3658
|
if (!n || !h)
|
|
3649
|
-
throw new
|
|
3659
|
+
throw new m("core_approve_asset_address_or_from_not_found");
|
|
3650
3660
|
const _ = d || (await A(this, V).call(this, a)).router;
|
|
3651
3661
|
return u({
|
|
3652
3662
|
amount: t,
|
|
@@ -3664,7 +3674,7 @@ class tn {
|
|
|
3664
3674
|
gas_rate: i,
|
|
3665
3675
|
router: r,
|
|
3666
3676
|
address: p
|
|
3667
|
-
} = await A(this, V).call(this, t.chain), d = (parseInt(i) || 0) *
|
|
3677
|
+
} = await A(this, V).call(this, t.chain), d = (parseInt(i) || 0) * it[a];
|
|
3668
3678
|
return this.deposit({
|
|
3669
3679
|
assetValue: t,
|
|
3670
3680
|
recipient: p,
|
|
@@ -3673,10 +3683,10 @@ class tn {
|
|
|
3673
3683
|
feeRate: d
|
|
3674
3684
|
});
|
|
3675
3685
|
});
|
|
3676
|
-
P(this,
|
|
3677
|
-
const a = await
|
|
3686
|
+
P(this, X, async ({ memo: t, assetValue: n }) => {
|
|
3687
|
+
const a = await Bt(this.stagenet);
|
|
3678
3688
|
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
3679
|
-
throw new
|
|
3689
|
+
throw new m("core_chain_halted");
|
|
3680
3690
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
3681
3691
|
});
|
|
3682
3692
|
P(this, j, ({ assetValue: t, ...n }) => ({
|
|
@@ -3688,66 +3698,65 @@ class tn {
|
|
|
3688
3698
|
this.stagenet = !!t;
|
|
3689
3699
|
}
|
|
3690
3700
|
}
|
|
3691
|
-
V = new WeakMap(), ee = new WeakMap(),
|
|
3701
|
+
V = new WeakMap(), ee = new WeakMap(), Y = new WeakMap(), D = new WeakMap(), X = new WeakMap(), j = new WeakMap();
|
|
3692
3702
|
export {
|
|
3693
3703
|
He as AGG_SWAP,
|
|
3694
|
-
|
|
3704
|
+
Ut as ApiError,
|
|
3695
3705
|
q as ApiUrl,
|
|
3696
3706
|
v as AssetValue,
|
|
3697
3707
|
E as BaseDecimal,
|
|
3698
3708
|
s as Chain,
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3709
|
+
ce as ChainId,
|
|
3710
|
+
Wt as ChainIdToChain,
|
|
3711
|
+
Ye as ChainToChainId,
|
|
3702
3712
|
Re as ChainToExplorerUrl,
|
|
3703
|
-
|
|
3704
|
-
|
|
3713
|
+
Gt as ChainToHexChainId,
|
|
3714
|
+
Xe as ChainToRPC,
|
|
3705
3715
|
We as ContractAddress,
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3716
|
+
Ft as CosmosChainList,
|
|
3717
|
+
K as DEFAULT_DECIMAL,
|
|
3718
|
+
qe as DerivationPath,
|
|
3709
3719
|
o as ERROR_CODE,
|
|
3710
3720
|
Fe as ERROR_MODULE,
|
|
3711
3721
|
Ae as ERROR_TYPE,
|
|
3712
|
-
|
|
3713
|
-
|
|
3722
|
+
$t as EVMChainList,
|
|
3723
|
+
je as ErrorCode,
|
|
3714
3724
|
F as FeeOption,
|
|
3715
3725
|
f as MemoType,
|
|
3716
|
-
|
|
3717
|
-
qe as NetworkId,
|
|
3726
|
+
Ht as NetworkDerivationPath,
|
|
3718
3727
|
Ue as QuoteMode,
|
|
3719
3728
|
Ee as RPCUrl,
|
|
3720
3729
|
$e as SWAP_IN,
|
|
3721
3730
|
ke as SWAP_OUT,
|
|
3722
|
-
|
|
3723
|
-
|
|
3731
|
+
en as SwapKitCore,
|
|
3732
|
+
m as SwapKitError,
|
|
3724
3733
|
le as SwapKitNumber,
|
|
3725
3734
|
Ve as TCAvalancheDepositABI,
|
|
3726
3735
|
Le as TCBscDepositABI,
|
|
3727
3736
|
Be as TCEthereumVaultAbi,
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3737
|
+
kt as UTXOChainList,
|
|
3738
|
+
Je as WalletOption,
|
|
3739
|
+
Xt as assetFromString,
|
|
3740
|
+
Yt as derivationPathToString,
|
|
3741
|
+
Lt as erc20ABI,
|
|
3733
3742
|
ge as formatBigIntToSafeValue,
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3743
|
+
it as gasFeeMultiplier,
|
|
3744
|
+
ot as getAssetType,
|
|
3745
|
+
ut as getAsymmetricAssetShare,
|
|
3746
|
+
Jt as getAsymmetricAssetWithdrawAmount,
|
|
3747
|
+
dt as getAsymmetricRuneShare,
|
|
3748
|
+
jt as getAsymmetricRuneWithdrawAmount,
|
|
3749
|
+
pt as getCommonAssetInfo,
|
|
3741
3750
|
Se as getDecimal,
|
|
3742
|
-
|
|
3743
|
-
|
|
3751
|
+
zt as getEstimatedPoolShare,
|
|
3752
|
+
Zt as getLiquiditySlippage,
|
|
3744
3753
|
x as getMemoFor,
|
|
3745
3754
|
fe as getMinAmountByChain,
|
|
3746
3755
|
Oe as getRequest,
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3756
|
+
yt as getSymmetricPoolShare,
|
|
3757
|
+
Qt as getSymmetricWithdraw,
|
|
3758
|
+
qt as getTHORNameCost,
|
|
3759
|
+
rt as isGasAsset,
|
|
3760
|
+
et as postRequest,
|
|
3761
|
+
Kt as validateTHORName
|
|
3753
3762
|
};
|