@swapkit/core 1.0.0-rc.110 → 1.0.0-rc.112
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/LICENSE +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.es.js +624 -592
- package/dist/index.es.js.map +1 -1
- package/package.json +14 -14
- package/src/client/index.ts +27 -29
- package/src/client/old.ts +44 -15
- package/src/helpers/mayanode.ts +31 -0
- package/src/helpers/thornode.ts +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var bt = Object.defineProperty;
|
|
2
|
+
var ft = (e, t, n) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var m = (e, t, n) => (ft(e, typeof t != "symbol" ? t + "" : t, n), n), ht = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var A = (e, t, n) => (ht(e, t, "read from private field"), n ? n.call(e) : t.get(e)), V = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
const
|
|
12
|
+
const Jn = [
|
|
13
13
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
14
14
|
{
|
|
15
15
|
anonymous: !1,
|
|
@@ -107,7 +107,7 @@ const Qn = [
|
|
|
107
107
|
stateMutability: "nonpayable",
|
|
108
108
|
type: "function"
|
|
109
109
|
}
|
|
110
|
-
],
|
|
110
|
+
], wt = [
|
|
111
111
|
{
|
|
112
112
|
inputs: [{ internalType: "address", name: "rune", type: "address" }],
|
|
113
113
|
stateMutability: "nonpayable",
|
|
@@ -282,7 +282,7 @@ const Qn = [
|
|
|
282
282
|
stateMutability: "view",
|
|
283
283
|
type: "function"
|
|
284
284
|
}
|
|
285
|
-
],
|
|
285
|
+
], At = [
|
|
286
286
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
287
287
|
{
|
|
288
288
|
anonymous: !1,
|
|
@@ -446,7 +446,7 @@ const Qn = [
|
|
|
446
446
|
stateMutability: "view",
|
|
447
447
|
type: "function"
|
|
448
448
|
}
|
|
449
|
-
],
|
|
449
|
+
], gt = [
|
|
450
450
|
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
451
451
|
{
|
|
452
452
|
anonymous: !1,
|
|
@@ -599,13 +599,13 @@ const Qn = [
|
|
|
599
599
|
type: "function"
|
|
600
600
|
}
|
|
601
601
|
];
|
|
602
|
-
var
|
|
603
|
-
const
|
|
602
|
+
var _t = /* @__PURE__ */ ((e) => (e.TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC", e.TC_SUPPORTED_TO_ETH = "TC-ERC20", e.TC_SUPPORTED_TO_AVAX = "TC-ARC20", e.TC_SUPPORTED_TO_BSC = "TC-BEP20", e.ETH_TO_TC_SUPPORTED = "ERC20-TC", e.ETH_TO_ETH = "ERC20-ERC20", e.ETH_TO_AVAX = "ERC20-ARC20", e.ETH_TO_BSC = "ERC20-BEP20", e.AVAX_TO_TC_SUPPORTED = "ARC20-TC", e.AVAX_TO_ETH = "ARC20-ERC20", e.AVAX_TO_AVAX = "ARC20-ARC20", e.AVAX_TO_BSC = "ARC20-BEP20", e.BSC_TO_TC_SUPPORTED = "BEP20-TC", e.BSC_TO_ETH = "BEP20-ERC20", e.BSC_TO_AVAX = "BEP20-ARC20", e.BSC_TO_BSC = "BEP20-BEP20", e))(_t || {});
|
|
603
|
+
const Mt = [
|
|
604
604
|
"ERC20-ERC20",
|
|
605
605
|
"ARC20-ARC20",
|
|
606
606
|
"BEP20-BEP20"
|
|
607
607
|
/* BSC_TO_BSC */
|
|
608
|
-
],
|
|
608
|
+
], vt = [
|
|
609
609
|
"ERC20-TC",
|
|
610
610
|
"ERC20-ARC20",
|
|
611
611
|
"ERC20-BEP20",
|
|
@@ -616,15 +616,15 @@ const _t = [
|
|
|
616
616
|
"BEP20-ERC20",
|
|
617
617
|
"BEP20-ARC20"
|
|
618
618
|
/* BSC_TO_AVAX */
|
|
619
|
-
],
|
|
619
|
+
], Ct = [
|
|
620
620
|
"TC-TC",
|
|
621
621
|
"TC-ERC20",
|
|
622
622
|
"TC-ARC20",
|
|
623
623
|
"TC-BEP20"
|
|
624
624
|
/* TC_SUPPORTED_TO_BSC */
|
|
625
625
|
];
|
|
626
|
-
var r = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(r || {}), Et = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(Et || {}),
|
|
627
|
-
const
|
|
626
|
+
var r = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(r || {}), Et = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(Et || {}), Ot = /* @__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.DASH = "m/44'/5'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.DOT = "////", e.ETH = "m/44'/60'/0'/0", e.FLIP = "////", 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))(Ot || {});
|
|
627
|
+
const Zn = {
|
|
628
628
|
ARB: [44, 60, 0, 0, 0],
|
|
629
629
|
AVAX: [44, 60, 0, 0, 0],
|
|
630
630
|
BCH: [44, 145, 0, 0, 0],
|
|
@@ -645,8 +645,8 @@ const Yn = {
|
|
|
645
645
|
DOT: [0, 0, 0, 0, 0],
|
|
646
646
|
FLIP: [0, 0, 0, 0, 0]
|
|
647
647
|
};
|
|
648
|
-
var
|
|
649
|
-
const
|
|
648
|
+
var g = /* @__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.DOT = 10] = "DOT", e[e.ETH = 18] = "ETH", e[e.FLIP = 18] = "FLIP", 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.ZEC = 8] = "ZEC", e))(g || {});
|
|
649
|
+
const zn = [
|
|
650
650
|
"DOT",
|
|
651
651
|
"FLIP"
|
|
652
652
|
/* Chainflip */
|
|
@@ -658,19 +658,21 @@ const Jn = [
|
|
|
658
658
|
"OP",
|
|
659
659
|
"MATIC"
|
|
660
660
|
/* Polygon */
|
|
661
|
-
],
|
|
661
|
+
], ea = je, xt = [
|
|
662
662
|
"BTC",
|
|
663
663
|
"BCH",
|
|
664
664
|
"DASH",
|
|
665
665
|
"DOGE",
|
|
666
666
|
"LTC"
|
|
667
667
|
/* Litecoin */
|
|
668
|
-
],
|
|
668
|
+
], ta = xt, kt = [
|
|
669
669
|
"GAIA",
|
|
670
670
|
"THOR",
|
|
671
|
-
"BNB"
|
|
672
|
-
|
|
673
|
-
|
|
671
|
+
"BNB",
|
|
672
|
+
"MAYA",
|
|
673
|
+
"KUJI"
|
|
674
|
+
/* Kujira */
|
|
675
|
+
], na = kt, St = [
|
|
674
676
|
"AVAX",
|
|
675
677
|
"BNB",
|
|
676
678
|
"BSC",
|
|
@@ -682,27 +684,27 @@ const Jn = [
|
|
|
682
684
|
"LTC",
|
|
683
685
|
"THOR"
|
|
684
686
|
/* THORChain */
|
|
685
|
-
],
|
|
686
|
-
var
|
|
687
|
-
const
|
|
687
|
+
], aa = St;
|
|
688
|
+
var Re = /* @__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.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dash = "dash", 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.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(Re || {}), Ke = /* @__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.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dash = "https://node-router.thorswap.net/dash", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Kujira = "https://rpc-kujira.synergynodes.com/", 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.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Ke || {}), U = /* @__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.net", e.ThorswapStatic = "https://static.thorswap.net", e))(U || {});
|
|
689
|
+
const ce = Object.values(r), Rt = Object.keys(r), Ie = ce.reduce(
|
|
688
690
|
(e, t) => {
|
|
689
|
-
const n =
|
|
691
|
+
const n = Rt.find((a) => r[a] === t);
|
|
690
692
|
return n && (e[t] = n), e;
|
|
691
693
|
},
|
|
692
694
|
{}
|
|
693
|
-
),
|
|
694
|
-
(e, t) => (e[t] =
|
|
695
|
+
), Qe = ce.reduce(
|
|
696
|
+
(e, t) => (e[t] = Re[Ie[t]], e),
|
|
695
697
|
{}
|
|
696
|
-
),
|
|
697
|
-
(e, t) => (e[t] =
|
|
698
|
+
), It = ce.reduce(
|
|
699
|
+
(e, t) => (e[t] = Ke[Ie[t]], e),
|
|
698
700
|
{}
|
|
699
|
-
),
|
|
701
|
+
), ia = ce.reduce(
|
|
700
702
|
(e, t) => {
|
|
701
|
-
const n = `${
|
|
702
|
-
return e[t] =
|
|
703
|
+
const n = `${Ie[t]}Hex`;
|
|
704
|
+
return e[t] = Re[n], e;
|
|
703
705
|
},
|
|
704
706
|
{}
|
|
705
|
-
),
|
|
707
|
+
), sa = {
|
|
706
708
|
"0xa4b1": "ARB",
|
|
707
709
|
42161: "ARB",
|
|
708
710
|
"0xa86a": "AVAX",
|
|
@@ -730,7 +732,7 @@ const Te = Object.values(r), St = Object.keys(r), Re = Te.reduce(
|
|
|
730
732
|
"thorchain-stagenet-v2": "THOR",
|
|
731
733
|
"thorchain-mainnet-v1": "THOR"
|
|
732
734
|
/* THORChain */
|
|
733
|
-
},
|
|
735
|
+
}, Ye = {
|
|
734
736
|
ARB: "https://arbiscan.io",
|
|
735
737
|
AVAX: "https://snowtrace.io",
|
|
736
738
|
BSC: "https://bscscan.com",
|
|
@@ -750,37 +752,37 @@ const Te = Object.values(r), St = Object.keys(r), Re = Te.reduce(
|
|
|
750
752
|
MATIC: "https://polygonscan.com",
|
|
751
753
|
THOR: "https://runescan.io"
|
|
752
754
|
};
|
|
753
|
-
var w = /* @__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))(w || {}),
|
|
755
|
+
var w = /* @__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))(w || {}), Y = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(Y || {}), Bt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.KEEPKEY = "KEEPKEY", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.OKX_MOBILE = "OKX_MOBILE", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(Bt || {}), Pt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e[e.LockedDevice = 21781] = "LockedDevice", e[e.TC_NotFound = 65535] = "TC_NotFound", e))(Pt || {}), Ht = Object.defineProperty, Dt = (e, t, n) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, P = (e, t, n) => (Dt(e, typeof t != "symbol" ? t + "" : t, n), n), Ft = (e, t, n) => {
|
|
754
756
|
if (!t.has(e))
|
|
755
757
|
throw TypeError("Cannot " + n);
|
|
756
|
-
},
|
|
758
|
+
}, Z = (e, t, n) => {
|
|
757
759
|
if (t.has(e))
|
|
758
760
|
throw TypeError("Cannot add the same private member more than once");
|
|
759
761
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
760
|
-
},
|
|
761
|
-
const
|
|
762
|
+
}, E = (e, t, n) => (Ft(e, t, "access private method"), n), be = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polkadot = "DOT", e.Chainflip = "FLIP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(be || {}), Be = /* @__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.Chainflip = "chainflip", e.Cosmos = "cosmoshub-4", e.Dash = "dash", 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.Polkadot = "polkadot", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(Be || {}), Je = /* @__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.Chainflip = "wss://mainnet-archive.chainflip.io", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dash = "https://node-router.thorswap.net/dash", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Kujira = "https://rpc-kujira.synergynodes.com/", 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.Polkadot = "wss://rpc.polkadot.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Je || {}), N = /* @__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.net", e.ThorswapStatic = "https://static.thorswap.net", e))(N || {});
|
|
763
|
+
const fe = Object.values(be), Lt = Object.keys(be), Pe = fe.reduce(
|
|
762
764
|
(e, t) => {
|
|
763
|
-
const n =
|
|
765
|
+
const n = Lt.find((a) => be[a] === t);
|
|
764
766
|
return n && (e[t] = n), e;
|
|
765
767
|
},
|
|
766
768
|
{}
|
|
767
769
|
);
|
|
768
|
-
|
|
769
|
-
(e, t) => (e[t] = Be[
|
|
770
|
+
fe.reduce(
|
|
771
|
+
(e, t) => (e[t] = Be[Pe[t]], e),
|
|
770
772
|
{}
|
|
771
773
|
);
|
|
772
|
-
|
|
773
|
-
(e, t) => (e[t] =
|
|
774
|
+
fe.reduce(
|
|
775
|
+
(e, t) => (e[t] = Je[Pe[t]], e),
|
|
774
776
|
{}
|
|
775
777
|
);
|
|
776
|
-
|
|
778
|
+
fe.reduce(
|
|
777
779
|
(e, t) => {
|
|
778
|
-
const n = `${
|
|
780
|
+
const n = `${Pe[t]}Hex`;
|
|
779
781
|
return e[t] = Be[n], e;
|
|
780
782
|
},
|
|
781
783
|
{}
|
|
782
784
|
);
|
|
783
|
-
class
|
|
785
|
+
class Ve extends Error {
|
|
784
786
|
constructor(t, n, a) {
|
|
785
787
|
const i = t.status || t.status === 0 ? t.status : "", s = t.statusText || "", p = `${i} ${s}`.trim(), u = p ? `status code ${p}` : "an unknown error";
|
|
786
788
|
super(`Request failed with ${u}`), Object.defineProperty(this, "response", {
|
|
@@ -801,7 +803,7 @@ class Le extends Error {
|
|
|
801
803
|
}), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
|
|
802
804
|
}
|
|
803
805
|
}
|
|
804
|
-
class
|
|
806
|
+
class Ze extends Error {
|
|
805
807
|
constructor(t) {
|
|
806
808
|
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
807
809
|
enumerable: !0,
|
|
@@ -815,24 +817,24 @@ const pe = (e) => e !== null && typeof e == "object", re = (...e) => {
|
|
|
815
817
|
for (const t of e)
|
|
816
818
|
if ((!pe(t) || Array.isArray(t)) && t !== void 0)
|
|
817
819
|
throw new TypeError("The `options` argument must be an object");
|
|
818
|
-
return
|
|
819
|
-
},
|
|
820
|
+
return He({}, ...e);
|
|
821
|
+
}, ze = (e = {}, t = {}) => {
|
|
820
822
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, i = new globalThis.Headers(t);
|
|
821
823
|
for (const [s, p] of i.entries())
|
|
822
824
|
a && p === "undefined" || p === void 0 ? n.delete(s) : n.set(s, p);
|
|
823
825
|
return n;
|
|
824
|
-
},
|
|
826
|
+
}, He = (...e) => {
|
|
825
827
|
let t = {}, n = {};
|
|
826
828
|
for (const a of e)
|
|
827
829
|
if (Array.isArray(a))
|
|
828
830
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
829
831
|
else if (pe(a)) {
|
|
830
832
|
for (let [i, s] of Object.entries(a))
|
|
831
|
-
pe(s) && i in t && (s =
|
|
832
|
-
pe(a.headers) && (n =
|
|
833
|
+
pe(s) && i in t && (s = He(t[i], s)), t = { ...t, [i]: s };
|
|
834
|
+
pe(a.headers) && (n = ze(n, a.headers), t.headers = n);
|
|
833
835
|
}
|
|
834
836
|
return t;
|
|
835
|
-
},
|
|
837
|
+
}, Vt = (() => {
|
|
836
838
|
let e = !1, t = !1;
|
|
837
839
|
const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
|
|
838
840
|
return n && a && (t = new globalThis.Request("https://empty.invalid", {
|
|
@@ -843,13 +845,13 @@ const pe = (e) => e !== null && typeof e == "object", re = (...e) => {
|
|
|
843
845
|
return e = !0, "half";
|
|
844
846
|
}
|
|
845
847
|
}).headers.has("Content-Type")), e && !t;
|
|
846
|
-
})(),
|
|
848
|
+
})(), Nt = typeof globalThis.AbortController == "function", qt = typeof globalThis.ReadableStream == "function", Wt = typeof globalThis.FormData == "function", et = ["get", "post", "put", "patch", "head", "delete"], $t = {
|
|
847
849
|
json: "application/json",
|
|
848
850
|
text: "text/*",
|
|
849
851
|
formData: "multipart/form-data",
|
|
850
852
|
arrayBuffer: "*/*",
|
|
851
853
|
blob: "*/*"
|
|
852
|
-
},
|
|
854
|
+
}, Ae = 2147483647, tt = Symbol("stop"), Ut = {
|
|
853
855
|
json: !0,
|
|
854
856
|
parseJson: !0,
|
|
855
857
|
searchParams: !0,
|
|
@@ -860,7 +862,7 @@ const pe = (e) => e !== null && typeof e == "object", re = (...e) => {
|
|
|
860
862
|
throwHttpErrors: !0,
|
|
861
863
|
onDownloadProgress: !0,
|
|
862
864
|
fetch: !0
|
|
863
|
-
},
|
|
865
|
+
}, Xt = {
|
|
864
866
|
method: !0,
|
|
865
867
|
headers: !0,
|
|
866
868
|
body: !0,
|
|
@@ -876,18 +878,18 @@ const pe = (e) => e !== null && typeof e == "object", re = (...e) => {
|
|
|
876
878
|
window: !0,
|
|
877
879
|
dispatcher: !0,
|
|
878
880
|
duplex: !0
|
|
879
|
-
},
|
|
881
|
+
}, Gt = (e) => et.includes(e) ? e.toUpperCase() : e, jt = ["get", "put", "head", "delete", "options", "trace"], Kt = [408, 413, 429, 500, 502, 503, 504], nt = [413, 429, 503], Ne = {
|
|
880
882
|
limit: 2,
|
|
881
883
|
methods: jt,
|
|
882
|
-
statusCodes:
|
|
883
|
-
afterStatusCodes:
|
|
884
|
+
statusCodes: Kt,
|
|
885
|
+
afterStatusCodes: nt,
|
|
884
886
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
885
887
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
886
888
|
delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
|
|
887
|
-
},
|
|
889
|
+
}, Qt = (e = {}) => {
|
|
888
890
|
if (typeof e == "number")
|
|
889
891
|
return {
|
|
890
|
-
...
|
|
892
|
+
...Ne,
|
|
891
893
|
limit: e
|
|
892
894
|
};
|
|
893
895
|
if (e.methods && !Array.isArray(e.methods))
|
|
@@ -895,22 +897,22 @@ const pe = (e) => e !== null && typeof e == "object", re = (...e) => {
|
|
|
895
897
|
if (e.statusCodes && !Array.isArray(e.statusCodes))
|
|
896
898
|
throw new Error("retry.statusCodes must be an array");
|
|
897
899
|
return {
|
|
898
|
-
...
|
|
900
|
+
...Ne,
|
|
899
901
|
...e,
|
|
900
|
-
afterStatusCodes:
|
|
902
|
+
afterStatusCodes: nt
|
|
901
903
|
};
|
|
902
904
|
};
|
|
903
|
-
async function
|
|
905
|
+
async function Yt(e, t, n, a) {
|
|
904
906
|
return new Promise((i, s) => {
|
|
905
907
|
const p = setTimeout(() => {
|
|
906
|
-
n && n.abort(), s(new
|
|
908
|
+
n && n.abort(), s(new Ze(e));
|
|
907
909
|
}, a.timeout);
|
|
908
910
|
a.fetch(e, t).then(i).catch(s).then(() => {
|
|
909
911
|
clearTimeout(p);
|
|
910
912
|
});
|
|
911
913
|
});
|
|
912
914
|
}
|
|
913
|
-
async function
|
|
915
|
+
async function Jt(e, { signal: t }) {
|
|
914
916
|
return new Promise((n, a) => {
|
|
915
917
|
t && (t.throwIfAborted(), t.addEventListener("abort", i, { once: !0 }));
|
|
916
918
|
function i() {
|
|
@@ -921,17 +923,17 @@ async function Yt(e, { signal: t }) {
|
|
|
921
923
|
}, e);
|
|
922
924
|
});
|
|
923
925
|
}
|
|
924
|
-
const
|
|
926
|
+
const Zt = (e, t) => {
|
|
925
927
|
const n = {};
|
|
926
928
|
for (const a in t)
|
|
927
|
-
!(a in
|
|
929
|
+
!(a in Xt) && !(a in Ut) && !(a in e) && (n[a] = t[a]);
|
|
928
930
|
return n;
|
|
929
931
|
};
|
|
930
932
|
class oe {
|
|
931
933
|
static create(t, n) {
|
|
932
934
|
const a = new oe(t, n), i = async () => {
|
|
933
|
-
if (typeof a._options.timeout == "number" && a._options.timeout >
|
|
934
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
935
|
+
if (typeof a._options.timeout == "number" && a._options.timeout > Ae)
|
|
936
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${Ae}`);
|
|
935
937
|
await Promise.resolve();
|
|
936
938
|
let p = await a._fetch();
|
|
937
939
|
for (const u of a._options.hooks.afterResponse) {
|
|
@@ -939,7 +941,7 @@ class oe {
|
|
|
939
941
|
y instanceof globalThis.Response && (p = y);
|
|
940
942
|
}
|
|
941
943
|
if (a._decorateResponse(p), !p.ok && a._options.throwHttpErrors) {
|
|
942
|
-
let u = new
|
|
944
|
+
let u = new Ve(p, a.request, a._options);
|
|
943
945
|
for (const y of a._options.hooks.beforeError)
|
|
944
946
|
u = await y(u);
|
|
945
947
|
throw u;
|
|
@@ -953,7 +955,7 @@ class oe {
|
|
|
953
955
|
}
|
|
954
956
|
return p;
|
|
955
957
|
}, s = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(i) : i();
|
|
956
|
-
for (const [p, u] of Object.entries(
|
|
958
|
+
for (const [p, u] of Object.entries($t))
|
|
957
959
|
s[p] = async () => {
|
|
958
960
|
a.request.headers.set("accept", a.request.headers.get("accept") || u);
|
|
959
961
|
const y = (await s).clone();
|
|
@@ -969,7 +971,7 @@ class oe {
|
|
|
969
971
|
}
|
|
970
972
|
// eslint-disable-next-line complexity
|
|
971
973
|
constructor(t, n = {}) {
|
|
972
|
-
|
|
974
|
+
Object.defineProperty(this, "request", {
|
|
973
975
|
enumerable: !0,
|
|
974
976
|
configurable: !0,
|
|
975
977
|
writable: !0,
|
|
@@ -994,21 +996,22 @@ class oe {
|
|
|
994
996
|
configurable: !0,
|
|
995
997
|
writable: !0,
|
|
996
998
|
value: void 0
|
|
997
|
-
}), this._input = t
|
|
998
|
-
|
|
999
|
-
|
|
999
|
+
}), this._input = t;
|
|
1000
|
+
const a = "credentials" in Request.prototype;
|
|
1001
|
+
if (this._options = {
|
|
1002
|
+
credentials: a ? this._input.credentials : void 0,
|
|
1000
1003
|
...n,
|
|
1001
|
-
headers:
|
|
1002
|
-
hooks:
|
|
1004
|
+
headers: ze(this._input.headers, n.headers),
|
|
1005
|
+
hooks: He({
|
|
1003
1006
|
beforeRequest: [],
|
|
1004
1007
|
beforeRetry: [],
|
|
1005
1008
|
beforeError: [],
|
|
1006
1009
|
afterResponse: []
|
|
1007
1010
|
}, n.hooks),
|
|
1008
|
-
method:
|
|
1011
|
+
method: Gt(n.method ?? this._input.method),
|
|
1009
1012
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1010
1013
|
prefixUrl: String(n.prefixUrl || ""),
|
|
1011
|
-
retry:
|
|
1014
|
+
retry: Qt(n.retry),
|
|
1012
1015
|
throwHttpErrors: n.throwHttpErrors !== !1,
|
|
1013
1016
|
timeout: n.timeout ?? 1e4,
|
|
1014
1017
|
fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
|
|
@@ -1019,24 +1022,24 @@ class oe {
|
|
|
1019
1022
|
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1020
1023
|
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
1021
1024
|
}
|
|
1022
|
-
if (
|
|
1025
|
+
if (Nt) {
|
|
1023
1026
|
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
1024
|
-
const
|
|
1027
|
+
const i = this._options.signal;
|
|
1025
1028
|
this._options.signal.addEventListener("abort", () => {
|
|
1026
|
-
this.abortController.abort(
|
|
1029
|
+
this.abortController.abort(i.reason);
|
|
1027
1030
|
});
|
|
1028
1031
|
}
|
|
1029
1032
|
this._options.signal = this.abortController.signal;
|
|
1030
1033
|
}
|
|
1031
|
-
if (
|
|
1032
|
-
const
|
|
1033
|
-
(Wt && 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(
|
|
1034
|
+
if (Vt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
1035
|
+
const i = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i);
|
|
1036
|
+
(Wt && 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);
|
|
1034
1037
|
}
|
|
1035
1038
|
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 }));
|
|
1036
1039
|
}
|
|
1037
1040
|
_calculateRetryDelay(t) {
|
|
1038
|
-
if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof
|
|
1039
|
-
if (t instanceof
|
|
1041
|
+
if (this._retryCount++, this._retryCount <= this._options.retry.limit && !(t instanceof Ze)) {
|
|
1042
|
+
if (t instanceof Ve) {
|
|
1040
1043
|
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
1041
1044
|
return 0;
|
|
1042
1045
|
const a = t.response.headers.get("Retry-After");
|
|
@@ -1059,16 +1062,16 @@ class oe {
|
|
|
1059
1062
|
try {
|
|
1060
1063
|
return await t();
|
|
1061
1064
|
} catch (n) {
|
|
1062
|
-
const a = Math.min(this._calculateRetryDelay(n),
|
|
1065
|
+
const a = Math.min(this._calculateRetryDelay(n), Ae);
|
|
1063
1066
|
if (a !== 0 && this._retryCount > 0) {
|
|
1064
|
-
await
|
|
1067
|
+
await Jt(a, { signal: this._options.signal });
|
|
1065
1068
|
for (const i of this._options.hooks.beforeRetry)
|
|
1066
1069
|
if (await i({
|
|
1067
1070
|
request: this.request,
|
|
1068
1071
|
options: this._options,
|
|
1069
1072
|
error: n,
|
|
1070
1073
|
retryCount: this._retryCount
|
|
1071
|
-
}) ===
|
|
1074
|
+
}) === tt)
|
|
1072
1075
|
return;
|
|
1073
1076
|
return this._retry(t);
|
|
1074
1077
|
}
|
|
@@ -1085,8 +1088,8 @@ class oe {
|
|
|
1085
1088
|
if (a instanceof Response)
|
|
1086
1089
|
return a;
|
|
1087
1090
|
}
|
|
1088
|
-
const t =
|
|
1089
|
-
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) :
|
|
1091
|
+
const t = Zt(this.request, this._options);
|
|
1092
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Yt(this.request.clone(), t, this.abortController, this._options);
|
|
1090
1093
|
}
|
|
1091
1094
|
/* istanbul ignore next */
|
|
1092
1095
|
_stream(t, n) {
|
|
@@ -1123,54 +1126,54 @@ class oe {
|
|
|
1123
1126
|
}
|
|
1124
1127
|
}
|
|
1125
1128
|
/*! MIT License © Sindre Sorhus */
|
|
1126
|
-
const
|
|
1129
|
+
const Ce = (e) => {
|
|
1127
1130
|
const t = (n, a) => oe.create(n, re(e, a));
|
|
1128
|
-
for (const n of
|
|
1131
|
+
for (const n of et)
|
|
1129
1132
|
t[n] = (a, i) => oe.create(a, re(e, i, { method: n }));
|
|
1130
|
-
return t.create = (n) =>
|
|
1131
|
-
},
|
|
1133
|
+
return t.create = (n) => Ce(re(n)), t.extend = (n) => Ce(re(e, n)), t.stop = tt, t;
|
|
1134
|
+
}, at = Ce();
|
|
1132
1135
|
let ue;
|
|
1133
1136
|
const L = {
|
|
1134
|
-
CachedPrices: `${
|
|
1135
|
-
GasRates: `${
|
|
1136
|
-
Quote: `${
|
|
1137
|
-
Txn: `${
|
|
1138
|
-
TokenlistProviders: `${
|
|
1139
|
-
TokenList: `${
|
|
1140
|
-
Thorname: `${
|
|
1141
|
-
},
|
|
1142
|
-
ue =
|
|
1137
|
+
CachedPrices: `${N.ThorswapApi}/tokenlist/cached-price`,
|
|
1138
|
+
GasRates: `${N.ThorswapApi}/resource-worker/gasPrice/getAll`,
|
|
1139
|
+
Quote: `${N.ThorswapApi}/aggregator/tokens/quote`,
|
|
1140
|
+
Txn: `${N.ThorswapApi}/apiusage/v2/txn`,
|
|
1141
|
+
TokenlistProviders: `${N.ThorswapApi}/tokenlist/providers`,
|
|
1142
|
+
TokenList: `${N.ThorswapStatic}/token-list`,
|
|
1143
|
+
Thorname: `${N.ThorswapApi}/thorname`
|
|
1144
|
+
}, it = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, qe = () => ue || (ue = at.create({ headers: it }), ue), ra = ({ apiKey: e, ...t }) => {
|
|
1145
|
+
ue = at.create({
|
|
1143
1146
|
...t,
|
|
1144
|
-
headers: { ...
|
|
1147
|
+
headers: { ...it, ...t.headers, "x-api-key": e }
|
|
1145
1148
|
});
|
|
1146
|
-
},
|
|
1149
|
+
}, x = {
|
|
1147
1150
|
get: (e, t) => qe().get(e, t).json(),
|
|
1148
1151
|
post: (e, t) => qe().post(e, t).json()
|
|
1149
|
-
},
|
|
1152
|
+
}, zt = ({ tokens: e, ...t }) => {
|
|
1150
1153
|
const n = new URLSearchParams(), a = e.filter(
|
|
1151
1154
|
(i, s, p) => p.findIndex((u) => u === i) === s
|
|
1152
1155
|
);
|
|
1153
1156
|
for (const i of a)
|
|
1154
1157
|
n.append("tokens", JSON.stringify(i));
|
|
1155
|
-
return t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"),
|
|
1158
|
+
return t.metadata && n.append("metadata", "true"), t.lookup && n.append("lookup", "true"), t.sparkline && n.append("sparkline", "true"), x.post(L.CachedPrices, {
|
|
1156
1159
|
body: n.toString(),
|
|
1157
1160
|
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
1158
1161
|
});
|
|
1159
|
-
},
|
|
1160
|
-
getCachedPrices:
|
|
1161
|
-
getQuote: (e) =>
|
|
1162
|
-
getGasRates: () =>
|
|
1163
|
-
getTxnDetails: (e) =>
|
|
1164
|
-
getTokenlistProviders: () =>
|
|
1165
|
-
getTokenList: (e) =>
|
|
1166
|
-
getThornameAddresses: (e) =>
|
|
1167
|
-
getThornameRegisteredChains: (e) =>
|
|
1168
|
-
getThornameRlookup: (e, t) =>
|
|
1162
|
+
}, pa = {
|
|
1163
|
+
getCachedPrices: zt,
|
|
1164
|
+
getQuote: (e) => x.get(L.Quote, { searchParams: e }),
|
|
1165
|
+
getGasRates: () => x.get(L.GasRates),
|
|
1166
|
+
getTxnDetails: (e) => x.get(L.Txn, { searchParams: e }),
|
|
1167
|
+
getTokenlistProviders: () => x.get(L.TokenlistProviders),
|
|
1168
|
+
getTokenList: (e) => x.get(`${L.TokenList}/${e}.json`),
|
|
1169
|
+
getThornameAddresses: (e) => x.get(`${L.Thorname}/${e}`),
|
|
1170
|
+
getThornameRegisteredChains: (e) => x.get(`${L.Thorname}/chains/${e}`),
|
|
1171
|
+
getThornameRlookup: (e, t) => x.get(`${L.Thorname}/rlookup`, { searchParams: { address: e, chain: t } })
|
|
1169
1172
|
};
|
|
1170
|
-
var
|
|
1171
|
-
const
|
|
1173
|
+
var en = /* @__PURE__ */ ((e) => (e.SWAP_TC_TO_TC = "SWAP:TC-TC", e.SWAP_ETH_TO_TC = "SWAP:ERC20-TC", e.SWAP_TC_TO_ETH = "SWAP:TC-ERC20", e.SWAP_ETH_TO_ETH = "SWAP:ERC20-ERC20", e.SWAP_AVAX_TO_TC = "SWAP:AVAX-TC", e.SWAP_TC_TO_AVAX = "SWAP:TC-AVAX", e.SWAP_AVAX_TO_AVAX = "SWAP:AVAX-AVAX", e.SWAP_ETH_TO_AVAX = "SWAP:ETH-AVAX", e.SWAP_AVAX_TO_ETH = "SWAP:AVAX-ETH", e.SWAP_TC_TO_GAIA = "SWAP:TC-GAIA", e.SWAP_GAIA_TO_TC = "SWAP:GAIA-TC", e.SWAP_TC_TO_BNB = "SWAP:TC-BNB", e.SWAP_BNB_TO_TC = "SWAP:BNB-TC", e.SWAP_TC_TO_BTC = "SWAP:TC-BTC", e.SWAP_BTC_TO_TC = "SWAP:BTC-TC", e.SWAP_TC_TO_BCH = "SWAP:TC-BCH", e.SWAP_BCH_TO_TC = "SWAP:BCH-TC", e.SWAP_TC_TO_LTC = "SWAP:TC-LTC", e.SWAP_LTC_TO_TC = "SWAP:LTC-TC", e.SWAP_TC_TO_DOGE = "SWAP:TC-DOGE", e.SWAP_DOGE_TO_TC = "SWAP:DOGE-TC", e.TC_STATUS = "TC:STATUS", e.TC_TRANSFER = "TC:TRANSFER", e.TC_DEPOSIT = "TC:DEPOSIT", e.TC_SEND = "TC:SEND", e.TC_SWITCH = "TC:SWITCH", e.TC_LP_ADD = "TC:ADDLIQUIDITY", e.TC_LP_WITHDRAW = "TC:WITHDRAW", e.TC_TNS_CREATE = "TC:TNS-CREATE", e.TC_TNS_EXTEND = "TC:TNS-EXTEND", e.TC_TNS_UPDATE = "TC:TNS-UPDATE", e.TC_SAVINGS_ADD = "TC:ADDSAVINGS", e.TC_SAVINGS_WITHDRAW = "TC:WITHDRAWSAVINGS", e.TC_LENDING_OPEN = "TC:LENDINGOPEN", e.TC_LENDING_CLOSE = "TC:LENDINGCLOSE", e.ETH_APPROVAL = "ETH:APPROVAL", e.ETH_STATUS = "ETH:STATUS", e.ETH_TRANSFER_TO_TC = "ETH:TRANSFER:IN", e.ETH_TRANSFER_FROM_TC = "ETH:TRANSFER:OUT", e.AVAX_APPROVAL = "AVAX:APPROVAL", e.AVAX_STATUS = "AVAX:STATUS", e.AVAX_TRANSFER_TO_TC = "AVAX:TRANSFER:IN", e.AVAX_TRANSFER_FROM_TC = "AVAX:TRANSFER:OUT", e.BSC_APPROVAL = "BSC:APPROVAL", e.BSC_STATUS = "BSC:STATUS", e.BSC_TRANSFER_TO_TC = "BSC:TRANSFER:IN", e.BSC_TRANSFER_FROM_TC = "BSC:TRANSFER:OUT", e.APPROVAL = "APPROVAL", e.STATUS = "STATUS", e.TRANSFER_TO_TC = "TRANSFER:IN", e.TRANSFER_FROM_TC = "TRANSFER:OUT", e.UNSUPPORTED = "UNSUPPORTED", e.TC_LENDING = "TC:LENDING", e))(en || {}), tn = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.SUCCESS = "success", e.CANCELLED = "cancelled", e.REFUNDED = "refunded", e.REPLACED = "replaced", e.ERROR = "error", e.UNKNOWN = "unknown", e.NOT_STARTED = "not_started", e.NOT_FOUND = "not_found", e.RETRIES_EXCEEDED = "retries_exceeded", e.STREAMING = "streaming", e))(tn || {}), nn = /* @__PURE__ */ ((e) => (e[e.NOT_STARTED = 0] = "NOT_STARTED", e[e.SUCCESS = 1] = "SUCCESS", e[e.REFUNDED = 2] = "REFUNDED", e))(nn || {});
|
|
1174
|
+
const an = "0x313ce567", st = async ({ chain: e, to: t }) => {
|
|
1172
1175
|
try {
|
|
1173
|
-
const { result: n } = await
|
|
1176
|
+
const { result: n } = await x.post(It[e], {
|
|
1174
1177
|
headers: {
|
|
1175
1178
|
accept: "*/*",
|
|
1176
1179
|
"content-type": "application/json",
|
|
@@ -1180,37 +1183,37 @@ const nn = "0x313ce567", it = async ({ chain: e, to: t }) => {
|
|
|
1180
1183
|
id: 44,
|
|
1181
1184
|
jsonrpc: "2.0",
|
|
1182
1185
|
method: "eth_call",
|
|
1183
|
-
params: [{ to: t.toLowerCase(), data:
|
|
1186
|
+
params: [{ to: t.toLowerCase(), data: an }, "latest"]
|
|
1184
1187
|
})
|
|
1185
1188
|
});
|
|
1186
|
-
return parseInt(BigInt(n).toString());
|
|
1189
|
+
return Number.parseInt(BigInt(n).toString());
|
|
1187
1190
|
} catch (n) {
|
|
1188
|
-
return console.error(n),
|
|
1191
|
+
return console.error(n), g[e];
|
|
1189
1192
|
}
|
|
1190
|
-
},
|
|
1193
|
+
}, sn = (e) => {
|
|
1191
1194
|
if (e === r.Ethereum)
|
|
1192
|
-
return
|
|
1195
|
+
return g.ETH;
|
|
1193
1196
|
const [, t] = e.split("-");
|
|
1194
|
-
return t != null && t.startsWith("0x") ?
|
|
1195
|
-
},
|
|
1197
|
+
return t != null && t.startsWith("0x") ? st({ chain: r.Ethereum, to: t }) : g.ETH;
|
|
1198
|
+
}, rn = (e) => {
|
|
1196
1199
|
const [, t] = e.split("-");
|
|
1197
|
-
return t != null && t.startsWith("0x") ?
|
|
1198
|
-
},
|
|
1200
|
+
return t != null && t.startsWith("0x") ? st({ chain: r.Avalanche, to: t.toLowerCase() }) : g.AVAX;
|
|
1201
|
+
}, pn = (e) => (e === r.BinanceSmartChain, g.BSC), un = ({ chain: e, symbol: t }) => {
|
|
1199
1202
|
switch (e) {
|
|
1200
1203
|
case r.Ethereum:
|
|
1201
|
-
return an(t);
|
|
1202
|
-
case r.Avalanche:
|
|
1203
1204
|
return sn(t);
|
|
1204
|
-
case r.
|
|
1205
|
+
case r.Avalanche:
|
|
1205
1206
|
return rn(t);
|
|
1207
|
+
case r.BinanceSmartChain:
|
|
1208
|
+
return pn(t);
|
|
1206
1209
|
default:
|
|
1207
|
-
return
|
|
1210
|
+
return g[e];
|
|
1208
1211
|
}
|
|
1209
|
-
},
|
|
1210
|
-
[
|
|
1211
|
-
[
|
|
1212
|
-
[
|
|
1213
|
-
},
|
|
1212
|
+
}, yn = {
|
|
1213
|
+
[Y.Average]: 1.2,
|
|
1214
|
+
[Y.Fast]: 1.5,
|
|
1215
|
+
[Y.Fastest]: 2
|
|
1216
|
+
}, rt = ({ chain: e, symbol: t }) => {
|
|
1214
1217
|
switch (e) {
|
|
1215
1218
|
case r.Arbitrum:
|
|
1216
1219
|
case r.Optimism:
|
|
@@ -1230,28 +1233,28 @@ const nn = "0x313ce567", it = async ({ chain: e, to: t }) => {
|
|
|
1230
1233
|
default:
|
|
1231
1234
|
return t === e;
|
|
1232
1235
|
}
|
|
1233
|
-
},
|
|
1236
|
+
}, on = (e) => {
|
|
1234
1237
|
switch (e) {
|
|
1235
1238
|
case `${r.Ethereum}.THOR`:
|
|
1236
1239
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
1237
1240
|
case `${r.Ethereum}.vTHOR`:
|
|
1238
1241
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
1239
1242
|
case r.Cosmos:
|
|
1240
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
1243
|
+
return { identifier: "GAIA.ATOM", decimal: g[e] };
|
|
1241
1244
|
case r.THORChain:
|
|
1242
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
1245
|
+
return { identifier: "THOR.RUNE", decimal: g[e] };
|
|
1243
1246
|
case r.BinanceSmartChain:
|
|
1244
|
-
return { identifier: "BSC.BNB", decimal:
|
|
1247
|
+
return { identifier: "BSC.BNB", decimal: g[e] };
|
|
1245
1248
|
case r.Maya:
|
|
1246
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
1249
|
+
return { identifier: "MAYA.CACAO", decimal: g.MAYA };
|
|
1247
1250
|
case `${r.Maya}.MAYA`:
|
|
1248
1251
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
1249
1252
|
case `${r.Kujira}.USK`:
|
|
1250
1253
|
return { identifier: `${r.Kujira}.USK`, decimal: 6 };
|
|
1251
1254
|
default:
|
|
1252
|
-
return { identifier: `${e}.${e}`, decimal:
|
|
1255
|
+
return { identifier: `${e}.${e}`, decimal: g[e] };
|
|
1253
1256
|
}
|
|
1254
|
-
},
|
|
1257
|
+
}, dn = ({ chain: e, symbol: t }) => {
|
|
1255
1258
|
if (t.includes("/"))
|
|
1256
1259
|
return "Synth";
|
|
1257
1260
|
switch (e) {
|
|
@@ -1276,70 +1279,70 @@ const nn = "0x313ce567", it = async ({ chain: e, to: t }) => {
|
|
|
1276
1279
|
default:
|
|
1277
1280
|
return "Native";
|
|
1278
1281
|
}
|
|
1279
|
-
},
|
|
1282
|
+
}, ua = (e) => {
|
|
1280
1283
|
var t;
|
|
1281
1284
|
const [n, ...a] = e.split("."), i = e.includes("/"), s = a.join("."), p = (t = s == null ? void 0 : s.split("-")) == null ? void 0 : t[0];
|
|
1282
1285
|
return { chain: n, symbol: s, ticker: p, synth: i };
|
|
1283
|
-
},
|
|
1286
|
+
}, ln = new RegExp(
|
|
1284
1287
|
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
1285
1288
|
"gmi"
|
|
1286
|
-
),
|
|
1289
|
+
), mn = (e) => {
|
|
1287
1290
|
const [t, n] = e.split(".");
|
|
1288
1291
|
if (!je.includes(t))
|
|
1289
1292
|
return !0;
|
|
1290
1293
|
const [, a] = n.split("-");
|
|
1291
|
-
return
|
|
1292
|
-
},
|
|
1294
|
+
return rt({ chain: t, symbol: n }) || !!a;
|
|
1295
|
+
}, ya = (e) => e.filter(({ chain: t, value: n, symbol: a }) => {
|
|
1293
1296
|
const i = `${t}.${a}`;
|
|
1294
|
-
return !
|
|
1297
|
+
return !ln.test(i) && mn(i) && n !== "0";
|
|
1295
1298
|
});
|
|
1296
|
-
function
|
|
1299
|
+
function Tn({
|
|
1297
1300
|
liquidityUnits: e,
|
|
1298
1301
|
poolUnits: t,
|
|
1299
1302
|
runeDepth: n
|
|
1300
1303
|
}) {
|
|
1301
|
-
const a =
|
|
1304
|
+
const a = S(e), i = S(t), s = S(n), p = a.mul(s), u = i.mul(i).mul(2), y = i.mul(a).mul(2), o = a.mul(a), l = i.mul(i).mul(i);
|
|
1302
1305
|
return p.mul(u.sub(y).add(o)).div(l);
|
|
1303
1306
|
}
|
|
1304
|
-
function
|
|
1307
|
+
function cn({
|
|
1305
1308
|
liquidityUnits: e,
|
|
1306
1309
|
poolUnits: t,
|
|
1307
1310
|
assetDepth: n
|
|
1308
1311
|
}) {
|
|
1309
|
-
const a =
|
|
1312
|
+
const a = S(e), i = S(t), s = S(n), p = a.mul(s), u = i.mul(i).mul(2), y = i.mul(a).mul(2), o = a.mul(a), l = p.mul(u.sub(y).add(o)), b = i.mul(i).mul(i);
|
|
1310
1313
|
return l.div(b);
|
|
1311
1314
|
}
|
|
1312
|
-
function
|
|
1315
|
+
function oa({
|
|
1313
1316
|
percent: e,
|
|
1314
1317
|
runeDepth: t,
|
|
1315
1318
|
liquidityUnits: n,
|
|
1316
1319
|
poolUnits: a
|
|
1317
1320
|
}) {
|
|
1318
|
-
return
|
|
1321
|
+
return Tn({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1319
1322
|
}
|
|
1320
|
-
function
|
|
1323
|
+
function da({
|
|
1321
1324
|
percent: e,
|
|
1322
1325
|
assetDepth: t,
|
|
1323
1326
|
liquidityUnits: n,
|
|
1324
1327
|
poolUnits: a
|
|
1325
1328
|
}) {
|
|
1326
|
-
return
|
|
1329
|
+
return cn({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1327
1330
|
}
|
|
1328
|
-
function
|
|
1329
|
-
return
|
|
1331
|
+
function S(e) {
|
|
1332
|
+
return F.fromBigInt(BigInt(e), g.THOR);
|
|
1330
1333
|
}
|
|
1331
|
-
function
|
|
1334
|
+
function bn({
|
|
1332
1335
|
liquidityUnits: e,
|
|
1333
1336
|
poolUnits: t,
|
|
1334
1337
|
runeDepth: n,
|
|
1335
1338
|
assetDepth: a
|
|
1336
1339
|
}) {
|
|
1337
1340
|
return {
|
|
1338
|
-
assetAmount:
|
|
1339
|
-
runeAmount:
|
|
1341
|
+
assetAmount: S(a).mul(e).div(t),
|
|
1342
|
+
runeAmount: S(n).mul(e).div(t)
|
|
1340
1343
|
};
|
|
1341
1344
|
}
|
|
1342
|
-
function
|
|
1345
|
+
function la({
|
|
1343
1346
|
liquidityUnits: e,
|
|
1344
1347
|
poolUnits: t,
|
|
1345
1348
|
runeDepth: n,
|
|
@@ -1347,12 +1350,12 @@ function oa({
|
|
|
1347
1350
|
percent: i
|
|
1348
1351
|
}) {
|
|
1349
1352
|
return Object.fromEntries(
|
|
1350
|
-
Object.entries(
|
|
1353
|
+
Object.entries(bn({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
|
|
1351
1354
|
([s, p]) => [s, p.mul(i)]
|
|
1352
1355
|
)
|
|
1353
1356
|
);
|
|
1354
1357
|
}
|
|
1355
|
-
function
|
|
1358
|
+
function ma({
|
|
1356
1359
|
runeDepth: e,
|
|
1357
1360
|
poolUnits: t,
|
|
1358
1361
|
assetDepth: n,
|
|
@@ -1360,13 +1363,13 @@ function da({
|
|
|
1360
1363
|
runeAmount: i,
|
|
1361
1364
|
assetAmount: s
|
|
1362
1365
|
}) {
|
|
1363
|
-
const p = new
|
|
1364
|
-
if (
|
|
1365
|
-
return
|
|
1366
|
-
const
|
|
1367
|
-
return
|
|
1366
|
+
const p = new F({ value: e, decimal: 8 }), u = new F({ value: n, decimal: 8 }), y = new F({ value: t, decimal: 8 }), o = new F({ value: i, decimal: 8 }), l = new F({ value: s, decimal: 8 }), b = o.mul(u), T = l.mul(p), f = o.mul(l), _ = p.mul(u), M = y.mul(b.add(T.add(f.mul(2)))), v = b.add(T.add(_.mul(2))), C = M.div(v), R = S(a).add(C);
|
|
1367
|
+
if (C.getBaseValue("number") === 0)
|
|
1368
|
+
return R.div(y).getBaseValue("number");
|
|
1369
|
+
const J = y.add(R);
|
|
1370
|
+
return R.div(J).getBaseValue("number");
|
|
1368
1371
|
}
|
|
1369
|
-
function
|
|
1372
|
+
function Ta({
|
|
1370
1373
|
runeAmount: e,
|
|
1371
1374
|
assetAmount: t,
|
|
1372
1375
|
runeDepth: n,
|
|
@@ -1374,10 +1377,10 @@ function la({
|
|
|
1374
1377
|
}) {
|
|
1375
1378
|
if (e === "0" || t === "0" || n === "0" || a === "0")
|
|
1376
1379
|
return 0;
|
|
1377
|
-
const i =
|
|
1380
|
+
const i = S(n), s = S(a), p = S(t), u = S(e), y = p.mul(i).sub(s.mul(u)), o = s.mul(u).add(i.mul(s));
|
|
1378
1381
|
return Math.abs(y.div(o).getBaseValue("number"));
|
|
1379
1382
|
}
|
|
1380
|
-
const
|
|
1383
|
+
const B = (e, t) => {
|
|
1381
1384
|
switch (e) {
|
|
1382
1385
|
case w.LEAVE:
|
|
1383
1386
|
case w.BOND: {
|
|
@@ -1420,22 +1423,33 @@ const F = (e, t) => {
|
|
|
1420
1423
|
return "";
|
|
1421
1424
|
}
|
|
1422
1425
|
};
|
|
1423
|
-
function
|
|
1426
|
+
function ca(e) {
|
|
1424
1427
|
if (e < 0)
|
|
1425
1428
|
throw new Error("Invalid number of year");
|
|
1426
1429
|
return 10 + e;
|
|
1427
1430
|
}
|
|
1428
|
-
function
|
|
1431
|
+
function ba(e) {
|
|
1432
|
+
if (e < 0)
|
|
1433
|
+
throw new Error("Invalid number of year");
|
|
1434
|
+
return Math.round((10 + e * 1.0512) * 1e10) / 1e10;
|
|
1435
|
+
}
|
|
1436
|
+
function fa(e) {
|
|
1429
1437
|
if (e.length > 30)
|
|
1430
1438
|
return !1;
|
|
1431
1439
|
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1432
1440
|
return !!e.match(t);
|
|
1433
1441
|
}
|
|
1434
|
-
function
|
|
1442
|
+
function ha(e) {
|
|
1443
|
+
if (e.length > 30)
|
|
1444
|
+
return !1;
|
|
1445
|
+
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
1446
|
+
return !!e.match(t);
|
|
1447
|
+
}
|
|
1448
|
+
function wa([e, t, n, a, i]) {
|
|
1435
1449
|
return `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`;
|
|
1436
1450
|
}
|
|
1437
1451
|
const We = [...Object.values(r), "TERRA"];
|
|
1438
|
-
function
|
|
1452
|
+
function fn(e = "") {
|
|
1439
1453
|
const t = e.toUpperCase(), [n] = t.split(".");
|
|
1440
1454
|
if (We.includes(n))
|
|
1441
1455
|
return !0;
|
|
@@ -1446,8 +1460,8 @@ function bn(e = "") {
|
|
|
1446
1460
|
`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
1447
1461
|
);
|
|
1448
1462
|
}
|
|
1449
|
-
const ne = 8,
|
|
1450
|
-
function
|
|
1463
|
+
const ne = 8, W = (e) => 10n ** BigInt(e), te = (e) => Math.log10(Number.parseFloat(e.toString()));
|
|
1464
|
+
function he({
|
|
1451
1465
|
value: e,
|
|
1452
1466
|
bigIntDecimal: t = ne,
|
|
1453
1467
|
decimal: n = ne
|
|
@@ -1460,22 +1474,22 @@ function fe({
|
|
|
1460
1474
|
s > 0 && (i = "0".repeat(s) + i);
|
|
1461
1475
|
const p = i.length - n;
|
|
1462
1476
|
let u = i.slice(-n);
|
|
1463
|
-
return parseInt(u[t]) >= 5 ? u = `${u.substring(0, t - 1)}${(parseInt(u[t - 1]) + 1).toString()}` : u = u.substring(0, t), `${a ? "-" : ""}${i.slice(0, p)}.${u}`.replace(
|
|
1477
|
+
return Number.parseInt(u[t]) >= 5 ? u = `${u.substring(0, t - 1)}${(Number.parseInt(u[t - 1]) + 1).toString()}` : u = u.substring(0, t), `${a ? "-" : ""}${i.slice(0, p)}.${u}`.replace(
|
|
1464
1478
|
/\.?0*$/,
|
|
1465
1479
|
""
|
|
1466
1480
|
);
|
|
1467
1481
|
}
|
|
1468
|
-
var
|
|
1469
|
-
const
|
|
1482
|
+
var G, z, q, j, Ee, pt, ye, ge, de, Oe;
|
|
1483
|
+
const hn = class xe {
|
|
1470
1484
|
constructor(t) {
|
|
1471
|
-
|
|
1472
|
-
const n =
|
|
1473
|
-
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier :
|
|
1485
|
+
Z(this, G), Z(this, q), Z(this, Ee), Z(this, ye), Z(this, de), P(this, "decimalMultiplier", 10n ** 8n), P(this, "bigIntValue", 0n), P(this, "decimal");
|
|
1486
|
+
const n = Se(t), a = typeof t == "object";
|
|
1487
|
+
this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : W(Math.max(ut(le(n)), this.decimal || 0)), E(this, Ee, pt).call(this, n);
|
|
1474
1488
|
}
|
|
1475
1489
|
static fromBigInt(t, n) {
|
|
1476
|
-
return new
|
|
1490
|
+
return new xe({
|
|
1477
1491
|
decimal: n,
|
|
1478
|
-
value:
|
|
1492
|
+
value: he({ value: t, bigIntDecimal: n, decimal: n })
|
|
1479
1493
|
});
|
|
1480
1494
|
}
|
|
1481
1495
|
static shiftDecimals({
|
|
@@ -1483,8 +1497,8 @@ const fn = class Oe {
|
|
|
1483
1497
|
from: n,
|
|
1484
1498
|
to: a
|
|
1485
1499
|
}) {
|
|
1486
|
-
return
|
|
1487
|
-
t.getBaseValue("bigint") *
|
|
1500
|
+
return xe.fromBigInt(
|
|
1501
|
+
t.getBaseValue("bigint") * W(a) / W(n),
|
|
1488
1502
|
a
|
|
1489
1503
|
);
|
|
1490
1504
|
}
|
|
@@ -1492,37 +1506,37 @@ const fn = class Oe {
|
|
|
1492
1506
|
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
1493
1507
|
}
|
|
1494
1508
|
add(...t) {
|
|
1495
|
-
return
|
|
1509
|
+
return E(this, G, z).call(this, "add", ...t);
|
|
1496
1510
|
}
|
|
1497
1511
|
sub(...t) {
|
|
1498
|
-
return
|
|
1512
|
+
return E(this, G, z).call(this, "sub", ...t);
|
|
1499
1513
|
}
|
|
1500
1514
|
mul(...t) {
|
|
1501
|
-
return
|
|
1515
|
+
return E(this, G, z).call(this, "mul", ...t);
|
|
1502
1516
|
}
|
|
1503
1517
|
div(...t) {
|
|
1504
|
-
return
|
|
1518
|
+
return E(this, G, z).call(this, "div", ...t);
|
|
1505
1519
|
}
|
|
1506
1520
|
gt(t) {
|
|
1507
|
-
return
|
|
1521
|
+
return E(this, q, j).call(this, "gt", t);
|
|
1508
1522
|
}
|
|
1509
1523
|
gte(t) {
|
|
1510
|
-
return
|
|
1524
|
+
return E(this, q, j).call(this, "gte", t);
|
|
1511
1525
|
}
|
|
1512
1526
|
lt(t) {
|
|
1513
|
-
return
|
|
1527
|
+
return E(this, q, j).call(this, "lt", t);
|
|
1514
1528
|
}
|
|
1515
1529
|
lte(t) {
|
|
1516
|
-
return
|
|
1530
|
+
return E(this, q, j).call(this, "lte", t);
|
|
1517
1531
|
}
|
|
1518
1532
|
eqValue(t) {
|
|
1519
|
-
return
|
|
1533
|
+
return E(this, q, j).call(this, "eqValue", t);
|
|
1520
1534
|
}
|
|
1521
1535
|
// @ts-expect-error False positive
|
|
1522
1536
|
getValue(t) {
|
|
1523
1537
|
const n = this.formatBigIntToSafeValue(
|
|
1524
1538
|
this.bigIntValue,
|
|
1525
|
-
this.decimal ||
|
|
1539
|
+
this.decimal || te(this.decimalMultiplier)
|
|
1526
1540
|
);
|
|
1527
1541
|
switch (t) {
|
|
1528
1542
|
case "number":
|
|
@@ -1535,7 +1549,7 @@ const fn = class Oe {
|
|
|
1535
1549
|
}
|
|
1536
1550
|
// @ts-expect-error
|
|
1537
1551
|
getBaseValue(t) {
|
|
1538
|
-
const n = this.decimalMultiplier /
|
|
1552
|
+
const n = this.decimalMultiplier / W(this.decimal || g.THOR), a = this.bigIntValue / n;
|
|
1539
1553
|
switch (t) {
|
|
1540
1554
|
case "number":
|
|
1541
1555
|
return Number(a);
|
|
@@ -1548,21 +1562,21 @@ const fn = class Oe {
|
|
|
1548
1562
|
getBigIntValue(t, n) {
|
|
1549
1563
|
if (!n && typeof t == "object")
|
|
1550
1564
|
return t.bigIntValue;
|
|
1551
|
-
const a =
|
|
1552
|
-
return i === "0" || i === "undefined" ? 0n :
|
|
1565
|
+
const a = Se(t), i = le(a);
|
|
1566
|
+
return i === "0" || i === "undefined" ? 0n : E(this, de, Oe).call(this, i, n);
|
|
1553
1567
|
}
|
|
1554
1568
|
toSignificant(t = 6) {
|
|
1555
1569
|
const [n, a] = this.getValue("string").split("."), i = n || "", s = a || "";
|
|
1556
|
-
if ((parseInt(i) ? i.length + s.length : s.length) <= t)
|
|
1570
|
+
if ((Number.parseInt(i) ? i.length + s.length : s.length) <= t)
|
|
1557
1571
|
return this.getValue("string");
|
|
1558
1572
|
if (i.length >= t)
|
|
1559
1573
|
return i.slice(0, t).padEnd(i.length, "0");
|
|
1560
|
-
if (parseInt(i))
|
|
1574
|
+
if (Number.parseInt(i))
|
|
1561
1575
|
return `${i}.${s.slice(0, t - i.length)}`.padEnd(
|
|
1562
1576
|
t - i.length,
|
|
1563
1577
|
"0"
|
|
1564
1578
|
);
|
|
1565
|
-
const p = parseInt(s), u = `${p}`.slice(0, t);
|
|
1579
|
+
const p = Number.parseInt(s), u = `${p}`.slice(0, t);
|
|
1566
1580
|
return `0.${u.padStart(
|
|
1567
1581
|
s.length - `${p}`.length + u.length,
|
|
1568
1582
|
"0"
|
|
@@ -1570,9 +1584,9 @@ const fn = class Oe {
|
|
|
1570
1584
|
}
|
|
1571
1585
|
toFixed(t = 6) {
|
|
1572
1586
|
const [n, a] = this.getValue("string").split("."), i = n || "", s = a || "";
|
|
1573
|
-
if (parseInt(i))
|
|
1587
|
+
if (Number.parseInt(i))
|
|
1574
1588
|
return `${i}.${s.slice(0, t)}`.padEnd(t, "0");
|
|
1575
|
-
const p = parseInt(s), u = `${p}`.slice(0, t);
|
|
1589
|
+
const p = Number.parseInt(s), u = `${p}`.slice(0, t);
|
|
1576
1590
|
return `0.${u.padStart(
|
|
1577
1591
|
s.length - `${p}`.length + u.length,
|
|
1578
1592
|
"0"
|
|
@@ -1591,23 +1605,23 @@ const fn = class Oe {
|
|
|
1591
1605
|
decimalSeparator: i = ".",
|
|
1592
1606
|
thousandSeparator: s = ","
|
|
1593
1607
|
} = {}) {
|
|
1594
|
-
const p = this.getValue("number"), [u, y = ""] = p.toFixed(6).split("."), o = u.replace(/\B(?=(\d{3})+(?!\d))/g, s), l = u || y ? u === "0" ? `${parseFloat(`0.${y}`)}`.replace(".", i) : `${o}${parseInt(y) ? `${i}${y.slice(0, a)}` : ""}` : "0.00";
|
|
1608
|
+
const p = this.getValue("number"), [u, y = ""] = p.toFixed(6).split("."), o = u.replace(/\B(?=(\d{3})+(?!\d))/g, s), l = u || y ? u === "0" ? `${Number.parseFloat(`0.${y}`)}`.replace(".", i) : `${o}${Number.parseInt(y) ? `${i}${y.slice(0, a)}` : ""}` : "0.00";
|
|
1595
1609
|
return `${n === "start" ? t : ""}${l}${n === "end" ? t : ""}`;
|
|
1596
1610
|
}
|
|
1597
1611
|
formatBigIntToSafeValue(t, n) {
|
|
1598
1612
|
const a = n || this.decimal || ne, i = Math.max(
|
|
1599
1613
|
a,
|
|
1600
|
-
|
|
1614
|
+
te(this.decimalMultiplier)
|
|
1601
1615
|
), s = t < 0n, p = t.toString().substring(s ? 1 : 0), u = i - (p.length - 1), y = u > 0 ? "0".repeat(u) + p : p, o = y.length - i;
|
|
1602
1616
|
let l = y.slice(-i);
|
|
1603
|
-
return parseInt(l[a]) >= 5 ? l = `${l.substring(0, a - 1)}${(parseInt(l[a - 1]) + 1).toString()}` : l = l.substring(0, a), `${s ? "-" : ""}${y.slice(
|
|
1617
|
+
return Number.parseInt(l[a]) >= 5 ? l = `${l.substring(0, a - 1)}${(Number.parseInt(l[a - 1]) + 1).toString()}` : l = l.substring(0, a), `${s ? "-" : ""}${y.slice(
|
|
1604
1618
|
0,
|
|
1605
1619
|
o
|
|
1606
1620
|
)}.${l}`.replace(/\.?0*$/, "");
|
|
1607
1621
|
}
|
|
1608
1622
|
};
|
|
1609
|
-
|
|
1610
|
-
const n =
|
|
1623
|
+
G = /* @__PURE__ */ new WeakSet(), z = function(e, ...t) {
|
|
1624
|
+
const n = E(this, ye, ge).call(this, this, ...t), a = Math.max(n, te(this.decimalMultiplier)), i = W(a), s = t.reduce(
|
|
1611
1625
|
(u, y) => {
|
|
1612
1626
|
const o = this.getBigIntValue(y, a);
|
|
1613
1627
|
switch (e) {
|
|
@@ -1628,19 +1642,19 @@ X = /* @__PURE__ */ new WeakSet(), Z = function(e, ...t) {
|
|
|
1628
1642
|
},
|
|
1629
1643
|
//normalize is to precision multiplier base
|
|
1630
1644
|
this.bigIntValue * i / this.decimalMultiplier
|
|
1631
|
-
), p =
|
|
1645
|
+
), p = he({
|
|
1632
1646
|
bigIntDecimal: a,
|
|
1633
1647
|
decimal: a,
|
|
1634
1648
|
value: s
|
|
1635
1649
|
});
|
|
1636
1650
|
return new this.constructor({
|
|
1637
|
-
decimalMultiplier:
|
|
1651
|
+
decimalMultiplier: W(a),
|
|
1638
1652
|
decimal: this.decimal,
|
|
1639
1653
|
value: p,
|
|
1640
1654
|
identifier: this.toString()
|
|
1641
1655
|
});
|
|
1642
|
-
},
|
|
1643
|
-
const n =
|
|
1656
|
+
}, q = /* @__PURE__ */ new WeakSet(), j = function(e, ...t) {
|
|
1657
|
+
const n = E(this, ye, ge).call(this, this, ...t), a = this.getBigIntValue(t[0], n), i = this.getBigIntValue(this, n);
|
|
1644
1658
|
switch (e) {
|
|
1645
1659
|
case "gt":
|
|
1646
1660
|
return i > a;
|
|
@@ -1653,46 +1667,46 @@ X = /* @__PURE__ */ new WeakSet(), Z = function(e, ...t) {
|
|
|
1653
1667
|
case "eqValue":
|
|
1654
1668
|
return i === a;
|
|
1655
1669
|
}
|
|
1656
|
-
}, Ee = /* @__PURE__ */ new WeakSet(),
|
|
1670
|
+
}, Ee = /* @__PURE__ */ new WeakSet(), pt = function(e) {
|
|
1657
1671
|
const t = le(e) || "0";
|
|
1658
|
-
this.bigIntValue =
|
|
1659
|
-
}, ye = /* @__PURE__ */ new WeakSet(),
|
|
1660
|
-
const t = e.map((n) => typeof n == "object" ? n.decimal ||
|
|
1672
|
+
this.bigIntValue = E(this, de, Oe).call(this, t);
|
|
1673
|
+
}, ye = /* @__PURE__ */ new WeakSet(), ge = function(...e) {
|
|
1674
|
+
const t = e.map((n) => typeof n == "object" ? n.decimal || te(n.decimalMultiplier) : ut(le(n))).filter(Boolean);
|
|
1661
1675
|
return Math.max(...t, ne);
|
|
1662
|
-
}, de = /* @__PURE__ */ new WeakSet(),
|
|
1663
|
-
const n = t ?
|
|
1676
|
+
}, de = /* @__PURE__ */ new WeakSet(), Oe = function(e, t) {
|
|
1677
|
+
const n = t ? W(t) : this.decimalMultiplier, a = te(n), [i = "", s = ""] = e.split(".");
|
|
1664
1678
|
return BigInt(`${i}${s.padEnd(a, "0")}`);
|
|
1665
1679
|
};
|
|
1666
|
-
let
|
|
1667
|
-
const
|
|
1680
|
+
let ke = hn;
|
|
1681
|
+
const wn = Intl.NumberFormat("fullwide", {
|
|
1668
1682
|
useGrouping: !1,
|
|
1669
1683
|
maximumFractionDigits: 20
|
|
1670
1684
|
});
|
|
1671
1685
|
function le(e) {
|
|
1672
|
-
const t = `${typeof e == "number" ?
|
|
1686
|
+
const t = `${typeof e == "number" ? wn.format(e) : Se(e)}`.replaceAll(",", ".").split(".");
|
|
1673
1687
|
return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
|
|
1674
1688
|
}
|
|
1675
|
-
function
|
|
1689
|
+
function ut(e) {
|
|
1676
1690
|
var t;
|
|
1677
1691
|
const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
|
|
1678
1692
|
return Math.max(n, ne);
|
|
1679
1693
|
}
|
|
1680
|
-
function
|
|
1694
|
+
function Se(e) {
|
|
1681
1695
|
return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
|
|
1682
1696
|
}
|
|
1683
|
-
class
|
|
1697
|
+
class F extends ke {
|
|
1684
1698
|
eq(t) {
|
|
1685
1699
|
return this.eqValue(t);
|
|
1686
1700
|
}
|
|
1687
1701
|
static fromBigInt(t, n) {
|
|
1688
|
-
return new
|
|
1702
|
+
return new F({
|
|
1689
1703
|
decimal: n,
|
|
1690
|
-
value:
|
|
1704
|
+
value: he({ value: t, bigIntDecimal: n, decimal: n })
|
|
1691
1705
|
});
|
|
1692
1706
|
}
|
|
1693
1707
|
}
|
|
1694
|
-
const
|
|
1695
|
-
class
|
|
1708
|
+
const K = /* @__PURE__ */ new Map();
|
|
1709
|
+
class k extends ke {
|
|
1696
1710
|
constructor({
|
|
1697
1711
|
value: t,
|
|
1698
1712
|
decimal: n,
|
|
@@ -1701,9 +1715,9 @@ class x extends xe {
|
|
|
1701
1715
|
symbol: s,
|
|
1702
1716
|
identifier: p
|
|
1703
1717
|
}) {
|
|
1704
|
-
super(typeof t == "object" ? t : { decimal: n, value: t }),
|
|
1705
|
-
const u =
|
|
1706
|
-
this.type =
|
|
1718
|
+
super(typeof t == "object" ? t : { decimal: n, value: t }), P(this, "address"), P(this, "chain"), P(this, "isGasAsset", !1), P(this, "isSynthetic", !1), P(this, "symbol"), P(this, "tax"), P(this, "ticker"), P(this, "type");
|
|
1719
|
+
const u = ee(p || `${i}.${s}`);
|
|
1720
|
+
this.type = dn(u), this.tax = a, this.chain = u.chain, this.ticker = u.ticker, this.symbol = u.symbol, this.address = u.address, this.isSynthetic = u.isSynthetic, this.isGasAsset = u.isGasAsset;
|
|
1707
1721
|
}
|
|
1708
1722
|
toString() {
|
|
1709
1723
|
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
@@ -1715,7 +1729,7 @@ class x extends xe {
|
|
|
1715
1729
|
return this.chain === t && this.symbol === n;
|
|
1716
1730
|
}
|
|
1717
1731
|
chainId() {
|
|
1718
|
-
return
|
|
1732
|
+
return Qe[this.chain];
|
|
1719
1733
|
}
|
|
1720
1734
|
// THOR.RUNE
|
|
1721
1735
|
// THOR.ETH.ETH
|
|
@@ -1725,65 +1739,65 @@ class x extends xe {
|
|
|
1725
1739
|
if (!(a && i))
|
|
1726
1740
|
throw new Error("Invalid asset url");
|
|
1727
1741
|
const p = a === r.THORChain && s ? `${a}.${i}/${s}` : t;
|
|
1728
|
-
return
|
|
1742
|
+
return Me(p, n);
|
|
1729
1743
|
}
|
|
1730
1744
|
static fromString(t, n = 0) {
|
|
1731
|
-
return
|
|
1745
|
+
return Me(t, n);
|
|
1732
1746
|
}
|
|
1733
1747
|
static fromIdentifier(t, n = 0) {
|
|
1734
|
-
return
|
|
1748
|
+
return Me(t, n);
|
|
1735
1749
|
}
|
|
1736
1750
|
static fromStringSync(t, n = 0) {
|
|
1737
|
-
const { chain: a, isSynthetic: i } =
|
|
1751
|
+
const { chain: a, isSynthetic: i } = ee(t), s = K.get(t.toUpperCase());
|
|
1738
1752
|
if (i)
|
|
1739
|
-
return
|
|
1753
|
+
return ve(t, n);
|
|
1740
1754
|
const { tax: p, decimal: u, identifier: y } = s || {
|
|
1741
|
-
decimal:
|
|
1755
|
+
decimal: g[a],
|
|
1742
1756
|
identifier: t
|
|
1743
1757
|
};
|
|
1744
|
-
return new
|
|
1758
|
+
return new k({
|
|
1745
1759
|
tax: p,
|
|
1746
|
-
value:
|
|
1760
|
+
value: Q(n, u),
|
|
1747
1761
|
identifier: i ? t : y,
|
|
1748
1762
|
decimal: i ? 8 : u
|
|
1749
1763
|
});
|
|
1750
1764
|
}
|
|
1751
|
-
static async fromStringWithBase(t, n = 0, a =
|
|
1752
|
-
const i =
|
|
1753
|
-
value:
|
|
1765
|
+
static async fromStringWithBase(t, n = 0, a = g.THOR) {
|
|
1766
|
+
const i = ke.shiftDecimals({
|
|
1767
|
+
value: F.fromBigInt(BigInt(n)),
|
|
1754
1768
|
from: 0,
|
|
1755
1769
|
to: a
|
|
1756
1770
|
}).getBaseValue("string");
|
|
1757
|
-
return (await
|
|
1771
|
+
return (await k.fromString(t, n)).set(i);
|
|
1758
1772
|
}
|
|
1759
|
-
static fromStringWithBaseSync(t, n = 0, a =
|
|
1760
|
-
const { chain: i, isSynthetic: s } =
|
|
1773
|
+
static fromStringWithBaseSync(t, n = 0, a = g.THOR) {
|
|
1774
|
+
const { chain: i, isSynthetic: s } = ee(t), p = K.get(t.toUpperCase());
|
|
1761
1775
|
if (s)
|
|
1762
|
-
return
|
|
1776
|
+
return ve(t, n);
|
|
1763
1777
|
const { tax: u, decimal: y, identifier: o } = p || {
|
|
1764
|
-
decimal:
|
|
1778
|
+
decimal: g[i],
|
|
1765
1779
|
identifier: t
|
|
1766
1780
|
};
|
|
1767
|
-
return new
|
|
1781
|
+
return new k({
|
|
1768
1782
|
tax: u,
|
|
1769
|
-
value:
|
|
1783
|
+
value: Q(BigInt(n), a),
|
|
1770
1784
|
identifier: o,
|
|
1771
1785
|
decimal: y
|
|
1772
1786
|
});
|
|
1773
1787
|
}
|
|
1774
1788
|
static fromIdentifierSync(t, n = 0) {
|
|
1775
|
-
const { chain: a, isSynthetic: i } =
|
|
1789
|
+
const { chain: a, isSynthetic: i } = ee(t), s = K.get(t);
|
|
1776
1790
|
if (i)
|
|
1777
|
-
return
|
|
1791
|
+
return ve(t, n);
|
|
1778
1792
|
const { tax: p, decimal: u, identifier: y } = s || {
|
|
1779
|
-
decimal:
|
|
1793
|
+
decimal: g[a],
|
|
1780
1794
|
identifier: t
|
|
1781
1795
|
};
|
|
1782
|
-
return new
|
|
1796
|
+
return new k({ tax: p, decimal: u, identifier: y, value: Q(n, u) });
|
|
1783
1797
|
}
|
|
1784
1798
|
static fromChainOrSignature(t, n = 0) {
|
|
1785
|
-
const { decimal: a, identifier: i } =
|
|
1786
|
-
return new
|
|
1799
|
+
const { decimal: a, identifier: i } = on(t);
|
|
1800
|
+
return new k({ value: Q(n, a), decimal: a, identifier: i });
|
|
1787
1801
|
}
|
|
1788
1802
|
static loadStaticAssets() {
|
|
1789
1803
|
return new Promise(
|
|
@@ -1792,9 +1806,9 @@ class x extends xe {
|
|
|
1792
1806
|
import("@swapkit/tokens").then((a) => {
|
|
1793
1807
|
for (const i of Object.values(a))
|
|
1794
1808
|
for (const { identifier: s, chain: p, ...u } of i.tokens)
|
|
1795
|
-
|
|
1809
|
+
K.set(s.toUpperCase(), {
|
|
1796
1810
|
identifier: s,
|
|
1797
|
-
decimal: "decimals" in u ? u.decimals :
|
|
1811
|
+
decimal: "decimals" in u ? u.decimals : g[p]
|
|
1798
1812
|
});
|
|
1799
1813
|
t({ ok: !0 });
|
|
1800
1814
|
});
|
|
@@ -1809,8 +1823,8 @@ class x extends xe {
|
|
|
1809
1823
|
);
|
|
1810
1824
|
}
|
|
1811
1825
|
}
|
|
1812
|
-
function
|
|
1813
|
-
const t =
|
|
1826
|
+
function _e(e) {
|
|
1827
|
+
const t = k.fromChainOrSignature(e);
|
|
1814
1828
|
switch (e) {
|
|
1815
1829
|
case r.Bitcoin:
|
|
1816
1830
|
case r.Litecoin:
|
|
@@ -1830,25 +1844,25 @@ function ge(e) {
|
|
|
1830
1844
|
return t.set(1e-8);
|
|
1831
1845
|
}
|
|
1832
1846
|
}
|
|
1833
|
-
async function
|
|
1834
|
-
|
|
1835
|
-
const n =
|
|
1836
|
-
return n ||
|
|
1847
|
+
async function Me(e, t = 0) {
|
|
1848
|
+
fn(e);
|
|
1849
|
+
const n = K.get(e.toUpperCase()), a = (n == null ? void 0 : n.decimal) || await un(ee(e));
|
|
1850
|
+
return n || K.set(e.toUpperCase(), { identifier: e, decimal: a }), new k({ decimal: a, value: Q(t, a), identifier: e });
|
|
1837
1851
|
}
|
|
1838
|
-
function
|
|
1852
|
+
function ve(e, t = 0) {
|
|
1839
1853
|
const [n, a] = e.split(".")[0].toUpperCase() === r.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1840
1854
|
if (!(n && a))
|
|
1841
1855
|
throw new Error("Invalid asset identifier");
|
|
1842
|
-
return new
|
|
1856
|
+
return new k({
|
|
1843
1857
|
decimal: 8,
|
|
1844
|
-
value:
|
|
1858
|
+
value: Q(t, 8),
|
|
1845
1859
|
identifier: `${r.THORChain}.${n}/${a}`
|
|
1846
1860
|
});
|
|
1847
1861
|
}
|
|
1848
|
-
function
|
|
1849
|
-
return typeof e == "bigint" ?
|
|
1862
|
+
function Q(e, t) {
|
|
1863
|
+
return typeof e == "bigint" ? he({ value: e, bigIntDecimal: t, decimal: t }) : e;
|
|
1850
1864
|
}
|
|
1851
|
-
function
|
|
1865
|
+
function ee(e) {
|
|
1852
1866
|
const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".")[0].toUpperCase() === r.THORChain ? e.split(".").slice(1).join().split("/") : e.split("/");
|
|
1853
1867
|
if (t && !(n && a))
|
|
1854
1868
|
throw new Error("Invalid asset identifier");
|
|
@@ -1856,13 +1870,13 @@ function z(e) {
|
|
|
1856
1870
|
return {
|
|
1857
1871
|
address: y == null ? void 0 : y.toLowerCase(),
|
|
1858
1872
|
chain: s,
|
|
1859
|
-
isGasAsset:
|
|
1873
|
+
isGasAsset: rt({ chain: s, symbol: o }),
|
|
1860
1874
|
isSynthetic: t,
|
|
1861
1875
|
symbol: (t ? `${n}/` : "") + (y ? `${u}-${(y == null ? void 0 : y.toLowerCase()) ?? ""}` : o),
|
|
1862
1876
|
ticker: u
|
|
1863
1877
|
};
|
|
1864
1878
|
}
|
|
1865
|
-
const
|
|
1879
|
+
const An = {
|
|
1866
1880
|
/**
|
|
1867
1881
|
* Core
|
|
1868
1882
|
*/
|
|
@@ -1871,6 +1885,7 @@ const wn = {
|
|
|
1871
1885
|
core_extend_error: 10003,
|
|
1872
1886
|
core_inbound_data_not_found: 10004,
|
|
1873
1887
|
core_approve_asset_address_or_from_not_found: 10005,
|
|
1888
|
+
core_plugin_not_found: 10006,
|
|
1874
1889
|
core_chain_halted: 10099,
|
|
1875
1890
|
/**
|
|
1876
1891
|
* Core - Wallet Connection
|
|
@@ -1895,7 +1910,6 @@ const wn = {
|
|
|
1895
1910
|
core_swap_contract_not_supported: 10205,
|
|
1896
1911
|
core_swap_transaction_error: 10206,
|
|
1897
1912
|
core_swap_quote_mode_not_supported: 10207,
|
|
1898
|
-
core_swap_provider_not_found: 10208,
|
|
1899
1913
|
/**
|
|
1900
1914
|
* Core - Transaction
|
|
1901
1915
|
*/
|
|
@@ -1941,12 +1955,12 @@ class d extends Error {
|
|
|
1941
1955
|
stack: n == null ? void 0 : n.stack,
|
|
1942
1956
|
message: n == null ? void 0 : n.message
|
|
1943
1957
|
}), super(t, {
|
|
1944
|
-
cause: { code:
|
|
1958
|
+
cause: { code: An[t], message: t }
|
|
1945
1959
|
}), Object.setPrototypeOf(this, d.prototype);
|
|
1946
1960
|
}
|
|
1947
1961
|
}
|
|
1948
|
-
const
|
|
1949
|
-
const n =
|
|
1962
|
+
const yt = ({ chain: e, txHash: t }) => {
|
|
1963
|
+
const n = Ye[e];
|
|
1950
1964
|
switch (e) {
|
|
1951
1965
|
case r.Binance:
|
|
1952
1966
|
case r.Maya:
|
|
@@ -1971,8 +1985,8 @@ const ut = ({ chain: e, txHash: t }) => {
|
|
|
1971
1985
|
default:
|
|
1972
1986
|
throw new Error(`Unsupported chain: ${e}`);
|
|
1973
1987
|
}
|
|
1974
|
-
},
|
|
1975
|
-
const n =
|
|
1988
|
+
}, ot = ({ chain: e, address: t }) => {
|
|
1989
|
+
const n = Ye[e];
|
|
1976
1990
|
switch (e) {
|
|
1977
1991
|
case r.Arbitrum:
|
|
1978
1992
|
case r.Avalanche:
|
|
@@ -1996,127 +2010,124 @@ const ut = ({ chain: e, txHash: t }) => {
|
|
|
1996
2010
|
throw new Error(`Unsupported chain: ${e}`);
|
|
1997
2011
|
}
|
|
1998
2012
|
};
|
|
1999
|
-
var
|
|
2000
|
-
function
|
|
2013
|
+
var gn = /* @__PURE__ */ ((e) => (e.Approve = "approve", e.CheckOnly = "checkOnly", e))(gn || {});
|
|
2014
|
+
function Aa({
|
|
2001
2015
|
stagenet: e,
|
|
2002
2016
|
wallets: t,
|
|
2003
|
-
|
|
2017
|
+
plugins: n,
|
|
2004
2018
|
config: a = {},
|
|
2005
2019
|
apis: i,
|
|
2006
2020
|
rpcUrls: s
|
|
2007
2021
|
}) {
|
|
2008
2022
|
const p = {}, u = {};
|
|
2009
|
-
for (const
|
|
2010
|
-
const { name: h, methods:
|
|
2011
|
-
u[h] =
|
|
2023
|
+
for (const c of n) {
|
|
2024
|
+
const { name: h, methods: I } = c({ wallets: p, stagenet: e });
|
|
2025
|
+
u[h] = I;
|
|
2012
2026
|
}
|
|
2013
|
-
const y = t.reduce((
|
|
2027
|
+
const y = t.reduce((c, h) => (c[h.connectMethodName] = h.connect({
|
|
2014
2028
|
addChain: l,
|
|
2015
2029
|
config: a,
|
|
2016
2030
|
apis: i,
|
|
2017
2031
|
rpcUrls: s
|
|
2018
|
-
}),
|
|
2019
|
-
function o(
|
|
2020
|
-
const h = u[
|
|
2032
|
+
}), c), {});
|
|
2033
|
+
function o(c) {
|
|
2034
|
+
const h = u[c] || Object.values(u)[0];
|
|
2021
2035
|
if (!h)
|
|
2022
|
-
throw new d(
|
|
2023
|
-
"core_swap_provider_not_found",
|
|
2024
|
-
"Could not find the requested provider"
|
|
2025
|
-
);
|
|
2036
|
+
throw new d("core_plugin_not_found", "Could not find the requested plugin");
|
|
2026
2037
|
return h;
|
|
2027
2038
|
}
|
|
2028
|
-
function l(
|
|
2029
|
-
p[
|
|
2039
|
+
function l(c) {
|
|
2040
|
+
p[c.chain] = c;
|
|
2030
2041
|
}
|
|
2031
2042
|
function b({
|
|
2032
|
-
assetValue:
|
|
2043
|
+
assetValue: c,
|
|
2033
2044
|
type: h = "checkOnly",
|
|
2034
|
-
contractAddress:
|
|
2045
|
+
contractAddress: I
|
|
2035
2046
|
}) {
|
|
2036
|
-
const { address: O, chain:
|
|
2037
|
-
if (
|
|
2047
|
+
const { address: O, chain: D, isGasAsset: mt, isSynthetic: Tt } = c, De = [r.Ethereum, r.Avalanche, r.BinanceSmartChain].includes(D);
|
|
2048
|
+
if (De && mt || !De || Tt)
|
|
2038
2049
|
return Promise.resolve(h === "checkOnly" ? !0 : "approved");
|
|
2039
|
-
const
|
|
2050
|
+
const X = p[D], Fe = h === "checkOnly" ? X == null ? void 0 : X.isApproved : X == null ? void 0 : X.approve;
|
|
2040
2051
|
if (!Fe)
|
|
2041
2052
|
throw new d("core_wallet_connection_not_found");
|
|
2042
|
-
const
|
|
2043
|
-
if (!(O &&
|
|
2053
|
+
const Le = f(D);
|
|
2054
|
+
if (!(O && Le))
|
|
2044
2055
|
throw new d("core_approve_asset_address_or_from_not_found");
|
|
2045
|
-
const
|
|
2056
|
+
const ct = I;
|
|
2046
2057
|
return Fe({
|
|
2047
|
-
amount:
|
|
2058
|
+
amount: c.getBaseValue("bigint"),
|
|
2048
2059
|
assetAddress: O,
|
|
2049
|
-
from:
|
|
2050
|
-
spenderAddress:
|
|
2060
|
+
from: Le,
|
|
2061
|
+
spenderAddress: ct
|
|
2051
2062
|
});
|
|
2052
2063
|
}
|
|
2053
|
-
function c
|
|
2054
|
-
return p[
|
|
2064
|
+
function T(c) {
|
|
2065
|
+
return p[c];
|
|
2055
2066
|
}
|
|
2056
|
-
function f(
|
|
2067
|
+
function f(c) {
|
|
2057
2068
|
var h;
|
|
2058
|
-
return ((h = c
|
|
2069
|
+
return ((h = T(c)) == null ? void 0 : h.address) || "";
|
|
2059
2070
|
}
|
|
2060
|
-
function _(
|
|
2071
|
+
function _(c) {
|
|
2061
2072
|
var h;
|
|
2062
|
-
return ((h = c
|
|
2073
|
+
return ((h = T(c)) == null ? void 0 : h.balance) || [];
|
|
2063
2074
|
}
|
|
2064
|
-
function M(
|
|
2065
|
-
return
|
|
2075
|
+
function M(c, h) {
|
|
2076
|
+
return yt({ chain: c, txHash: h });
|
|
2066
2077
|
}
|
|
2067
|
-
function v(
|
|
2068
|
-
return
|
|
2078
|
+
function v(c, h) {
|
|
2079
|
+
return ot({ chain: c, address: h });
|
|
2069
2080
|
}
|
|
2070
|
-
function
|
|
2071
|
-
var
|
|
2072
|
-
return (O = (
|
|
2081
|
+
function C({ address: c, chain: h }) {
|
|
2082
|
+
var I, O;
|
|
2083
|
+
return (O = (I = T(h)) == null ? void 0 : I.validateAddress) == null ? void 0 : O.call(I, c);
|
|
2073
2084
|
}
|
|
2074
|
-
async function
|
|
2075
|
-
const
|
|
2085
|
+
async function R(c, h) {
|
|
2086
|
+
const I = [k.fromChainOrSignature(c)], O = T(c);
|
|
2076
2087
|
try {
|
|
2077
2088
|
if (!O)
|
|
2078
2089
|
throw new d("core_wallet_connection_not_found");
|
|
2079
|
-
const
|
|
2080
|
-
return O.balance =
|
|
2081
|
-
} catch (
|
|
2082
|
-
throw new d("core_wallet_connection_not_found",
|
|
2090
|
+
const D = await (O == null ? void 0 : O.getBalance(O.address, h));
|
|
2091
|
+
return O.balance = D != null && D.length ? D : I, O;
|
|
2092
|
+
} catch (D) {
|
|
2093
|
+
throw new d("core_wallet_connection_not_found", D);
|
|
2083
2094
|
}
|
|
2084
2095
|
}
|
|
2085
|
-
function
|
|
2096
|
+
function J(c, h) {
|
|
2086
2097
|
return b({
|
|
2087
|
-
assetValue:
|
|
2098
|
+
assetValue: c,
|
|
2088
2099
|
contractAddress: h,
|
|
2089
2100
|
type: "approve"
|
|
2090
2101
|
/* Approve */
|
|
2091
2102
|
});
|
|
2092
2103
|
}
|
|
2093
|
-
function
|
|
2104
|
+
function we(c, h) {
|
|
2094
2105
|
return b({
|
|
2095
|
-
assetValue:
|
|
2106
|
+
assetValue: c,
|
|
2096
2107
|
contractAddress: h,
|
|
2097
2108
|
type: "checkOnly"
|
|
2098
2109
|
/* CheckOnly */
|
|
2099
2110
|
});
|
|
2100
2111
|
}
|
|
2101
|
-
function
|
|
2102
|
-
return o(
|
|
2112
|
+
function lt({ provider: c, ...h }) {
|
|
2113
|
+
return o(c == null ? void 0 : c.name).swap({ provider: c, ...h });
|
|
2103
2114
|
}
|
|
2104
2115
|
return {
|
|
2105
2116
|
...u,
|
|
2106
2117
|
...y,
|
|
2107
|
-
approveAssetValue:
|
|
2118
|
+
approveAssetValue: J,
|
|
2108
2119
|
getAddress: f,
|
|
2109
2120
|
getBalance: _,
|
|
2110
2121
|
getExplorerAddressUrl: v,
|
|
2111
2122
|
getExplorerTxUrl: M,
|
|
2112
|
-
getWallet:
|
|
2113
|
-
getWalletWithBalance:
|
|
2114
|
-
isAssetValueApproved:
|
|
2115
|
-
swap:
|
|
2116
|
-
validateAddress:
|
|
2123
|
+
getWallet: T,
|
|
2124
|
+
getWalletWithBalance: R,
|
|
2125
|
+
isAssetValueApproved: we,
|
|
2126
|
+
swap: lt,
|
|
2127
|
+
validateAddress: C
|
|
2117
2128
|
};
|
|
2118
2129
|
}
|
|
2119
|
-
const
|
|
2130
|
+
const _n = [
|
|
2120
2131
|
{
|
|
2121
2132
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2122
2133
|
stateMutability: "nonpayable",
|
|
@@ -2207,7 +2218,7 @@ const gn = [
|
|
|
2207
2218
|
type: "function"
|
|
2208
2219
|
},
|
|
2209
2220
|
{ stateMutability: "payable", type: "receive" }
|
|
2210
|
-
],
|
|
2221
|
+
], Mn = [
|
|
2211
2222
|
{
|
|
2212
2223
|
inputs: [
|
|
2213
2224
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2351,7 +2362,7 @@ const gn = [
|
|
|
2351
2362
|
type: "function"
|
|
2352
2363
|
},
|
|
2353
2364
|
{ stateMutability: "payable", type: "receive" }
|
|
2354
|
-
],
|
|
2365
|
+
], vn = [
|
|
2355
2366
|
{
|
|
2356
2367
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2357
2368
|
stateMutability: "nonpayable",
|
|
@@ -2456,7 +2467,7 @@ const gn = [
|
|
|
2456
2467
|
type: "function"
|
|
2457
2468
|
},
|
|
2458
2469
|
{ stateMutability: "payable", type: "receive" }
|
|
2459
|
-
],
|
|
2470
|
+
], Cn = [
|
|
2460
2471
|
{
|
|
2461
2472
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
2462
2473
|
stateMutability: "nonpayable",
|
|
@@ -2691,7 +2702,7 @@ const gn = [
|
|
|
2691
2702
|
type: "function"
|
|
2692
2703
|
},
|
|
2693
2704
|
{ stateMutability: "payable", type: "receive" }
|
|
2694
|
-
],
|
|
2705
|
+
], On = [
|
|
2695
2706
|
{
|
|
2696
2707
|
inputs: [
|
|
2697
2708
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -2810,7 +2821,7 @@ const gn = [
|
|
|
2810
2821
|
type: "function"
|
|
2811
2822
|
},
|
|
2812
2823
|
{ stateMutability: "payable", type: "receive" }
|
|
2813
|
-
],
|
|
2824
|
+
], $e = [
|
|
2814
2825
|
{
|
|
2815
2826
|
inputs: [{ internalType: "address", name: "_WETH", type: "address" }],
|
|
2816
2827
|
stateMutability: "nonpayable",
|
|
@@ -3211,7 +3222,7 @@ const gn = [
|
|
|
3211
3222
|
type: "function"
|
|
3212
3223
|
},
|
|
3213
3224
|
{ stateMutability: "payable", type: "receive" }
|
|
3214
|
-
],
|
|
3225
|
+
], Ue = [
|
|
3215
3226
|
{
|
|
3216
3227
|
inputs: [
|
|
3217
3228
|
{
|
|
@@ -5398,7 +5409,7 @@ const gn = [
|
|
|
5398
5409
|
stateMutability: "payable",
|
|
5399
5410
|
type: "receive"
|
|
5400
5411
|
}
|
|
5401
|
-
],
|
|
5412
|
+
], Xe = [
|
|
5402
5413
|
{
|
|
5403
5414
|
inputs: [
|
|
5404
5415
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -5737,7 +5748,7 @@ const gn = [
|
|
|
5737
5748
|
type: "function"
|
|
5738
5749
|
},
|
|
5739
5750
|
{ stateMutability: "payable", type: "receive" }
|
|
5740
|
-
],
|
|
5751
|
+
], xn = [
|
|
5741
5752
|
{
|
|
5742
5753
|
inputs: [
|
|
5743
5754
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6076,7 +6087,7 @@ const gn = [
|
|
|
6076
6087
|
type: "function"
|
|
6077
6088
|
},
|
|
6078
6089
|
{ stateMutability: "payable", type: "receive" }
|
|
6079
|
-
],
|
|
6090
|
+
], kn = [
|
|
6080
6091
|
{
|
|
6081
6092
|
inputs: [
|
|
6082
6093
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6415,7 +6426,7 @@ const gn = [
|
|
|
6415
6426
|
type: "function"
|
|
6416
6427
|
},
|
|
6417
6428
|
{ stateMutability: "payable", type: "receive" }
|
|
6418
|
-
],
|
|
6429
|
+
], Sn = [
|
|
6419
6430
|
{
|
|
6420
6431
|
inputs: [
|
|
6421
6432
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -6754,7 +6765,7 @@ const gn = [
|
|
|
6754
6765
|
type: "function"
|
|
6755
6766
|
},
|
|
6756
6767
|
{ stateMutability: "payable", type: "receive" }
|
|
6757
|
-
],
|
|
6768
|
+
], Rn = [
|
|
6758
6769
|
{
|
|
6759
6770
|
inputs: [
|
|
6760
6771
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -7093,7 +7104,7 @@ const gn = [
|
|
|
7093
7104
|
type: "function"
|
|
7094
7105
|
},
|
|
7095
7106
|
{ stateMutability: "payable", type: "receive" }
|
|
7096
|
-
],
|
|
7107
|
+
], In = [
|
|
7097
7108
|
{
|
|
7098
7109
|
inputs: [
|
|
7099
7110
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -7516,23 +7527,23 @@ const gn = [
|
|
|
7516
7527
|
type: "function"
|
|
7517
7528
|
},
|
|
7518
7529
|
{ stateMutability: "payable", type: "receive" }
|
|
7519
|
-
],
|
|
7530
|
+
], Pn = {
|
|
7520
7531
|
// AVAX
|
|
7521
|
-
["0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106".toLowerCase()]:
|
|
7532
|
+
["0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106".toLowerCase()]: xn,
|
|
7522
7533
|
["0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9".toLowerCase()]: Bn,
|
|
7523
|
-
["0x60aE616a2155Ee3d9A68541Ba4544862310933d4".toLowerCase()]:
|
|
7524
|
-
["0x1111111254fb6c44bAC0beD2854e76F90643097d".toLowerCase()]:
|
|
7525
|
-
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]:
|
|
7534
|
+
["0x60aE616a2155Ee3d9A68541Ba4544862310933d4".toLowerCase()]: Sn,
|
|
7535
|
+
["0x1111111254fb6c44bAC0beD2854e76F90643097d".toLowerCase()]: Ue,
|
|
7536
|
+
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]: $e,
|
|
7526
7537
|
// BSC
|
|
7527
|
-
["0x10ED43C718714eb63d5aA57B78B54704E256024E".toLowerCase()]:
|
|
7538
|
+
["0x10ED43C718714eb63d5aA57B78B54704E256024E".toLowerCase()]: Xe,
|
|
7528
7539
|
// ETH
|
|
7529
|
-
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]:
|
|
7530
|
-
["0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f".toLowerCase()]:
|
|
7531
|
-
["0xEfF92A263d31888d860bD50809A8D171709b7b1c".toLowerCase()]:
|
|
7532
|
-
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".toLowerCase()]:
|
|
7533
|
-
["0xE592427A0AEce92De3Edee1F18E0157C05861564".toLowerCase()]:
|
|
7534
|
-
["0x1111111254fb6c44bac0bed2854e76f90643097d".toLowerCase()]:
|
|
7535
|
-
},
|
|
7540
|
+
["0x6131B5fae19EA4f9D964eAc0408E4408b66337b5".toLowerCase()]: $e,
|
|
7541
|
+
["0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f".toLowerCase()]: kn,
|
|
7542
|
+
["0xEfF92A263d31888d860bD50809A8D171709b7b1c".toLowerCase()]: Xe,
|
|
7543
|
+
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".toLowerCase()]: Rn,
|
|
7544
|
+
["0xE592427A0AEce92De3Edee1F18E0157C05861564".toLowerCase()]: In,
|
|
7545
|
+
["0x1111111254fb6c44bac0bed2854e76f90643097d".toLowerCase()]: Ue
|
|
7546
|
+
}, Hn = [
|
|
7536
7547
|
{
|
|
7537
7548
|
inputs: [
|
|
7538
7549
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7651,7 +7662,7 @@ const gn = [
|
|
|
7651
7662
|
type: "function"
|
|
7652
7663
|
},
|
|
7653
7664
|
{ stateMutability: "payable", type: "receive" }
|
|
7654
|
-
],
|
|
7665
|
+
], Dn = [
|
|
7655
7666
|
{
|
|
7656
7667
|
inputs: [
|
|
7657
7668
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -7889,7 +7900,7 @@ const gn = [
|
|
|
7889
7900
|
type: "function"
|
|
7890
7901
|
},
|
|
7891
7902
|
{ stateMutability: "payable", type: "receive" }
|
|
7892
|
-
],
|
|
7903
|
+
], Ln = [
|
|
7893
7904
|
{
|
|
7894
7905
|
inputs: [
|
|
7895
7906
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8016,7 +8027,7 @@ const gn = [
|
|
|
8016
8027
|
type: "function"
|
|
8017
8028
|
},
|
|
8018
8029
|
{ stateMutability: "payable", type: "receive" }
|
|
8019
|
-
],
|
|
8030
|
+
], Vn = [
|
|
8020
8031
|
{
|
|
8021
8032
|
inputs: [
|
|
8022
8033
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8143,7 +8154,7 @@ const gn = [
|
|
|
8143
8154
|
type: "function"
|
|
8144
8155
|
},
|
|
8145
8156
|
{ stateMutability: "payable", type: "receive" }
|
|
8146
|
-
],
|
|
8157
|
+
], Nn = [
|
|
8147
8158
|
{
|
|
8148
8159
|
inputs: [
|
|
8149
8160
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8524,28 +8535,28 @@ const gn = [
|
|
|
8524
8535
|
type: "function"
|
|
8525
8536
|
},
|
|
8526
8537
|
{ stateMutability: "payable", type: "receive" }
|
|
8527
|
-
],
|
|
8528
|
-
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]:
|
|
8529
|
-
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]:
|
|
8530
|
-
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]:
|
|
8531
|
-
},
|
|
8532
|
-
...
|
|
8533
|
-
...
|
|
8538
|
+
], dt = {
|
|
8539
|
+
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: _n,
|
|
8540
|
+
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: vn,
|
|
8541
|
+
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Cn
|
|
8542
|
+
}, $n = {
|
|
8543
|
+
...Pn,
|
|
8544
|
+
...dt,
|
|
8534
8545
|
// AVAX
|
|
8535
|
-
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]:
|
|
8536
|
-
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]:
|
|
8537
|
-
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]:
|
|
8546
|
+
["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: On,
|
|
8547
|
+
["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Mn,
|
|
8548
|
+
["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: Dn,
|
|
8538
8549
|
// BSC
|
|
8539
8550
|
["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: En,
|
|
8540
8551
|
// ETH
|
|
8541
|
-
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]:
|
|
8552
|
+
["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Hn,
|
|
8542
8553
|
["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: Fn,
|
|
8543
|
-
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]:
|
|
8544
|
-
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]:
|
|
8545
|
-
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]:
|
|
8554
|
+
["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: Ln,
|
|
8555
|
+
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: Vn,
|
|
8556
|
+
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: Nn,
|
|
8546
8557
|
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: qn,
|
|
8547
8558
|
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: Wn
|
|
8548
|
-
},
|
|
8559
|
+
}, Un = ({
|
|
8549
8560
|
streamSwap: e,
|
|
8550
8561
|
contractAddress: t,
|
|
8551
8562
|
recipient: n,
|
|
@@ -8559,43 +8570,46 @@ const gn = [
|
|
|
8559
8570
|
router: o,
|
|
8560
8571
|
memoStreamingSwap: l,
|
|
8561
8572
|
tcMemo: b,
|
|
8562
|
-
tcRouter:
|
|
8573
|
+
tcRouter: T,
|
|
8563
8574
|
tcVault: f,
|
|
8564
8575
|
vault: _,
|
|
8565
8576
|
token: M
|
|
8566
8577
|
}
|
|
8567
8578
|
}) => {
|
|
8568
|
-
const v = !!
|
|
8579
|
+
const v = !!dt[t.toLowerCase()];
|
|
8569
8580
|
if (v && !o)
|
|
8570
8581
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
8571
|
-
const
|
|
8582
|
+
const C = b || y, R = e && l || C;
|
|
8572
8583
|
if (!(f || _))
|
|
8573
8584
|
throw new Error("TC Vault is required on calldata");
|
|
8574
|
-
if (!(
|
|
8585
|
+
if (!(T || o))
|
|
8575
8586
|
throw new Error("TC Router is required on calldata");
|
|
8576
|
-
if (!
|
|
8587
|
+
if (!R)
|
|
8577
8588
|
throw new Error("TC Memo is required on calldata");
|
|
8578
8589
|
if (!M)
|
|
8579
8590
|
throw new Error("Token is required on calldata");
|
|
8580
|
-
const
|
|
8591
|
+
const J = [
|
|
8581
8592
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
8582
|
-
a(
|
|
8593
|
+
a(T || o),
|
|
8583
8594
|
a(f || _),
|
|
8584
|
-
|
|
8595
|
+
R.replace("{recipientAddress}", n),
|
|
8585
8596
|
a(M),
|
|
8586
8597
|
i
|
|
8587
|
-
],
|
|
8588
|
-
return [...
|
|
8589
|
-
}, Un = (e) => {
|
|
8590
|
-
const t = e ? te.ThornodeStagenet : te.ThornodeMainnet;
|
|
8591
|
-
return R.get(`${t}/thorchain/inbound_addresses`);
|
|
8598
|
+
], we = v ? [a(o), p, u] : [s, u];
|
|
8599
|
+
return [...J, ...we];
|
|
8592
8600
|
}, Xn = (e) => {
|
|
8593
|
-
const t = e ?
|
|
8594
|
-
return
|
|
8595
|
-
},
|
|
8601
|
+
const t = e ? U.MayanodeStagenet : U.MayanodeMainnet;
|
|
8602
|
+
return x.get(`${t}/mayachain/mimir`);
|
|
8603
|
+
}, Gn = (e) => {
|
|
8604
|
+
const t = e ? U.ThornodeStagenet : U.ThornodeMainnet;
|
|
8605
|
+
return x.get(`${t}/thorchain/inbound_addresses`);
|
|
8606
|
+
}, jn = (e) => {
|
|
8607
|
+
const t = e ? U.ThornodeStagenet : U.ThornodeMainnet;
|
|
8608
|
+
return x.get(`${t}/thorchain/mimir`);
|
|
8609
|
+
}, Ge = () => Object.values(r).reduce(
|
|
8596
8610
|
(e, t) => (e[t] = null, e),
|
|
8597
8611
|
{}
|
|
8598
|
-
),
|
|
8612
|
+
), Kn = ({
|
|
8599
8613
|
chain: e,
|
|
8600
8614
|
address: t
|
|
8601
8615
|
}) => {
|
|
@@ -8608,28 +8622,28 @@ const gn = [
|
|
|
8608
8622
|
return !0;
|
|
8609
8623
|
}
|
|
8610
8624
|
};
|
|
8611
|
-
var $, me, ae,
|
|
8612
|
-
class
|
|
8625
|
+
var $, me, ae, H, ie, Te, se;
|
|
8626
|
+
class ga {
|
|
8613
8627
|
constructor({ stagenet: t } = {}) {
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8628
|
+
m(this, "connectedChains", Ge());
|
|
8629
|
+
m(this, "connectedWallets", Ge());
|
|
8630
|
+
m(this, "stagenet", !1);
|
|
8631
|
+
m(this, "getAddress", (t) => {
|
|
8618
8632
|
var n;
|
|
8619
8633
|
return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
|
|
8620
8634
|
});
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8635
|
+
m(this, "getExplorerTxUrl", (t, n) => yt({ chain: t, txHash: n }));
|
|
8636
|
+
m(this, "getWallet", (t) => this.connectedWallets[t]);
|
|
8637
|
+
m(this, "getExplorerAddressUrl", (t, n) => ot({ chain: t, address: n }));
|
|
8638
|
+
m(this, "getBalance", async (t, n) => {
|
|
8625
8639
|
const a = await this.getWalletByChain(t, n);
|
|
8626
8640
|
return (a == null ? void 0 : a.balance) || [];
|
|
8627
8641
|
});
|
|
8628
|
-
|
|
8642
|
+
m(this, "swap", async ({
|
|
8629
8643
|
streamSwap: t,
|
|
8630
8644
|
recipient: n,
|
|
8631
8645
|
route: a,
|
|
8632
|
-
feeOptionKey: i =
|
|
8646
|
+
feeOptionKey: i = Y.Average
|
|
8633
8647
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
|
|
8634
8648
|
}) => {
|
|
8635
8649
|
var u, y;
|
|
@@ -8639,72 +8653,72 @@ class fa {
|
|
|
8639
8653
|
} = a, p = s.startsWith("ERC20-") ? r.Ethereum : s.startsWith("ARC20-") ? r.Avalanche : s.startsWith("BEP20-") ? r.BinanceSmartChain : void 0;
|
|
8640
8654
|
if (!a.complete)
|
|
8641
8655
|
throw new d("core_swap_route_not_complete");
|
|
8642
|
-
if (
|
|
8656
|
+
if (Mt.includes(s) && p) {
|
|
8643
8657
|
const o = this.connectedWallets[p];
|
|
8644
8658
|
if (!(o != null && o.sendTransaction))
|
|
8645
8659
|
throw new d("core_wallet_connection_not_found");
|
|
8646
8660
|
if (!(t ? (u = a == null ? void 0 : a.streamingSwap) == null ? void 0 : u.transaction : a == null ? void 0 : a.transaction))
|
|
8647
8661
|
throw new d("core_swap_route_transaction_not_found");
|
|
8648
|
-
const { data: b, from:
|
|
8662
|
+
const { data: b, from: T, to: f, value: _ } = a.transaction, M = {
|
|
8649
8663
|
data: b,
|
|
8650
|
-
from:
|
|
8664
|
+
from: T,
|
|
8651
8665
|
to: f.toLowerCase(),
|
|
8652
|
-
chainId: BigInt(
|
|
8666
|
+
chainId: BigInt(Qe[p]),
|
|
8653
8667
|
value: _ ? BigInt(_) : 0n
|
|
8654
8668
|
};
|
|
8655
8669
|
return o.sendTransaction(M, i);
|
|
8656
8670
|
}
|
|
8657
|
-
if (
|
|
8671
|
+
if (Ct.includes(s)) {
|
|
8658
8672
|
if (!a.calldata.fromAsset)
|
|
8659
8673
|
throw new d("core_swap_asset_not_recognized");
|
|
8660
|
-
const o = await
|
|
8674
|
+
const o = await k.fromString(a.calldata.fromAsset);
|
|
8661
8675
|
if (!o)
|
|
8662
8676
|
throw new d("core_swap_asset_not_recognized");
|
|
8663
|
-
const { address: l } = await
|
|
8677
|
+
const { address: l } = await A(this, $).call(this, o.chain), {
|
|
8664
8678
|
contract: b,
|
|
8665
|
-
calldata: { expiration:
|
|
8666
|
-
} = a, v = o.add(
|
|
8679
|
+
calldata: { expiration: T, amountIn: f, memo: _, memoStreamingSwap: M }
|
|
8680
|
+
} = a, v = o.add(F.fromBigInt(BigInt(f), o.decimal)), C = t && M || _;
|
|
8667
8681
|
return this.deposit({
|
|
8668
|
-
expiration:
|
|
8682
|
+
expiration: T,
|
|
8669
8683
|
assetValue: v,
|
|
8670
|
-
memo:
|
|
8684
|
+
memo: C,
|
|
8671
8685
|
feeOptionKey: i,
|
|
8672
8686
|
router: b,
|
|
8673
8687
|
recipient: l
|
|
8674
8688
|
});
|
|
8675
8689
|
}
|
|
8676
|
-
if (
|
|
8690
|
+
if (vt.includes(s) && p) {
|
|
8677
8691
|
const { calldata: o, contract: l } = a;
|
|
8678
8692
|
if (!l)
|
|
8679
8693
|
throw new d("core_swap_contract_not_found");
|
|
8680
|
-
const b = this.connectedWallets[p],
|
|
8681
|
-
if (!(b != null && b.sendTransaction &&
|
|
8694
|
+
const b = this.connectedWallets[p], T = this.getAddress(p);
|
|
8695
|
+
if (!(b != null && b.sendTransaction && T))
|
|
8682
8696
|
throw new d("core_wallet_connection_not_found");
|
|
8683
|
-
const { getProvider: f, toChecksumAddress: _ } = await import("@swapkit/toolbox-evm"), M = f(p), v =
|
|
8697
|
+
const { getProvider: f, toChecksumAddress: _ } = await import("@swapkit/toolbox-evm"), M = f(p), v = $n[l.toLowerCase()];
|
|
8684
8698
|
if (!v)
|
|
8685
8699
|
throw new d("core_swap_contract_not_supported", {
|
|
8686
8700
|
contractAddress: l
|
|
8687
8701
|
});
|
|
8688
|
-
const
|
|
8689
|
-
|
|
8702
|
+
const R = await (await ((y = b.createContract) == null ? void 0 : y.call(b, l, v, M))).getFunction("swapIn").populateTransaction(
|
|
8703
|
+
...Un({
|
|
8690
8704
|
streamSwap: t,
|
|
8691
8705
|
toChecksumAddress: _,
|
|
8692
8706
|
contractAddress: l,
|
|
8693
8707
|
recipient: n,
|
|
8694
8708
|
calldata: o
|
|
8695
8709
|
}),
|
|
8696
|
-
{ from:
|
|
8710
|
+
{ from: T }
|
|
8697
8711
|
);
|
|
8698
|
-
return b.sendTransaction(
|
|
8712
|
+
return b.sendTransaction(R, i);
|
|
8699
8713
|
}
|
|
8700
8714
|
throw new d("core_swap_quote_mode_not_supported", { quoteMode: s });
|
|
8701
8715
|
});
|
|
8702
|
-
|
|
8716
|
+
m(this, "getWalletByChain", async (t, n) => {
|
|
8703
8717
|
var p, u;
|
|
8704
8718
|
const a = this.getAddress(t);
|
|
8705
8719
|
if (!a)
|
|
8706
8720
|
return null;
|
|
8707
|
-
const i = [
|
|
8721
|
+
const i = [k.fromChainOrSignature(t)], s = (p = this.connectedChains[t]) == null ? void 0 : p.walletType;
|
|
8708
8722
|
try {
|
|
8709
8723
|
const y = await ((u = this.getWallet(t)) == null ? void 0 : u.getBalance(a, n));
|
|
8710
8724
|
return this.connectedChains[t] = {
|
|
@@ -8716,37 +8730,37 @@ class fa {
|
|
|
8716
8730
|
return console.error(y), { address: a, balance: i, walletType: s };
|
|
8717
8731
|
}
|
|
8718
8732
|
});
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8733
|
+
m(this, "approveAssetValue", (t, n) => A(this, ae).call(this, { assetValue: t, type: "approve", contractAddress: n }));
|
|
8734
|
+
m(this, "isAssetValueApproved", (t, n) => A(this, ae).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
|
|
8735
|
+
m(this, "validateAddress", ({ address: t, chain: n }) => {
|
|
8722
8736
|
var a, i;
|
|
8723
8737
|
return (i = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : i.call(a, t);
|
|
8724
8738
|
});
|
|
8725
|
-
|
|
8739
|
+
m(this, "transfer", async (t) => {
|
|
8726
8740
|
const n = this.connectedWallets[t.assetValue.chain];
|
|
8727
8741
|
if (!n)
|
|
8728
8742
|
throw new d("core_wallet_connection_not_found");
|
|
8729
8743
|
try {
|
|
8730
|
-
return await n.transfer(
|
|
8744
|
+
return await n.transfer(A(this, se).call(this, t));
|
|
8731
8745
|
} catch (a) {
|
|
8732
8746
|
throw new d("core_swap_transaction_error", a);
|
|
8733
8747
|
}
|
|
8734
8748
|
});
|
|
8735
|
-
|
|
8749
|
+
m(this, "deposit", async ({
|
|
8736
8750
|
assetValue: t,
|
|
8737
8751
|
recipient: n,
|
|
8738
8752
|
router: a,
|
|
8739
8753
|
...i
|
|
8740
8754
|
}) => {
|
|
8741
8755
|
const { chain: s, symbol: p, ticker: u } = t, y = this.connectedWallets[s], o = this.connectedChains[s];
|
|
8742
|
-
if (!await
|
|
8756
|
+
if (!await Kn({
|
|
8743
8757
|
address: o == null ? void 0 : o.address,
|
|
8744
8758
|
chain: s
|
|
8745
8759
|
}))
|
|
8746
8760
|
throw new d("core_transaction_invalid_sender_address");
|
|
8747
8761
|
if (!y)
|
|
8748
8762
|
throw new d("core_wallet_connection_not_found");
|
|
8749
|
-
const b =
|
|
8763
|
+
const b = A(this, se).call(this, {
|
|
8750
8764
|
assetValue: t,
|
|
8751
8765
|
recipient: n,
|
|
8752
8766
|
router: a,
|
|
@@ -8756,23 +8770,23 @@ class fa {
|
|
|
8756
8770
|
switch (s) {
|
|
8757
8771
|
case r.THORChain:
|
|
8758
8772
|
case r.Maya: {
|
|
8759
|
-
const
|
|
8760
|
-
return await (n === "" ?
|
|
8773
|
+
const T = y;
|
|
8774
|
+
return await (n === "" ? T.deposit(b) : T.transfer(b));
|
|
8761
8775
|
}
|
|
8762
8776
|
case r.Ethereum:
|
|
8763
8777
|
case r.BinanceSmartChain:
|
|
8764
8778
|
case r.Avalanche: {
|
|
8765
|
-
const { getChecksumAddressFromAsset:
|
|
8779
|
+
const { getChecksumAddressFromAsset: T } = await import("@swapkit/toolbox-evm"), f = s === r.Avalanche ? At : s === r.BinanceSmartChain ? gt : wt;
|
|
8766
8780
|
return await y.call({
|
|
8767
8781
|
abi: f,
|
|
8768
|
-
contractAddress: a || (await
|
|
8782
|
+
contractAddress: a || (await A(this, $).call(this, s)).router,
|
|
8769
8783
|
funcName: "depositWithExpiry",
|
|
8770
8784
|
funcParams: [
|
|
8771
8785
|
n,
|
|
8772
|
-
|
|
8786
|
+
T({ chain: s, symbol: p, ticker: u }, s),
|
|
8773
8787
|
t.getBaseValue("string"),
|
|
8774
8788
|
b.memo,
|
|
8775
|
-
i.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
8789
|
+
i.expiration || Number.parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
8776
8790
|
],
|
|
8777
8791
|
txOverrides: {
|
|
8778
8792
|
from: b.from,
|
|
@@ -8783,15 +8797,15 @@ class fa {
|
|
|
8783
8797
|
default:
|
|
8784
8798
|
return await y.transfer(b);
|
|
8785
8799
|
}
|
|
8786
|
-
} catch (
|
|
8787
|
-
const f =
|
|
8788
|
-
throw new d(
|
|
8800
|
+
} catch (T) {
|
|
8801
|
+
const f = typeof T == "string" ? T.toLowerCase() : T == null ? void 0 : T.message.toLowerCase(), _ = f == null ? void 0 : f.includes("insufficient funds"), M = f == null ? void 0 : f.includes("gas"), v = f == null ? void 0 : f.includes("server"), C = f == null ? void 0 : f.includes("user rejected"), R = _ ? "core_transaction_deposit_insufficient_funds_error" : M ? "core_transaction_deposit_gas_error" : v ? "core_transaction_deposit_server_error" : C ? "core_transaction_user_rejected" : "core_transaction_deposit_error";
|
|
8802
|
+
throw new d(R, T);
|
|
8789
8803
|
}
|
|
8790
8804
|
});
|
|
8791
8805
|
/**
|
|
8792
8806
|
* TC related Methods
|
|
8793
8807
|
*/
|
|
8794
|
-
|
|
8808
|
+
m(this, "createLiquidity", async ({
|
|
8795
8809
|
runeAssetValue: t,
|
|
8796
8810
|
assetValue: n
|
|
8797
8811
|
}) => {
|
|
@@ -8799,9 +8813,9 @@ class fa {
|
|
|
8799
8813
|
throw new d("core_transaction_create_liquidity_invalid_params");
|
|
8800
8814
|
let a = "", i = "";
|
|
8801
8815
|
try {
|
|
8802
|
-
a = await
|
|
8816
|
+
a = await A(this, H).call(this, {
|
|
8803
8817
|
assetValue: t,
|
|
8804
|
-
memo:
|
|
8818
|
+
memo: B(w.DEPOSIT, {
|
|
8805
8819
|
...n,
|
|
8806
8820
|
address: this.getAddress(n.chain)
|
|
8807
8821
|
})
|
|
@@ -8810,9 +8824,9 @@ class fa {
|
|
|
8810
8824
|
throw new d("core_transaction_create_liquidity_rune_error", s);
|
|
8811
8825
|
}
|
|
8812
8826
|
try {
|
|
8813
|
-
i = await
|
|
8827
|
+
i = await A(this, H).call(this, {
|
|
8814
8828
|
assetValue: n,
|
|
8815
|
-
memo:
|
|
8829
|
+
memo: B(w.DEPOSIT, {
|
|
8816
8830
|
...n,
|
|
8817
8831
|
address: this.getAddress(r.THORChain)
|
|
8818
8832
|
})
|
|
@@ -8822,7 +8836,7 @@ class fa {
|
|
|
8822
8836
|
}
|
|
8823
8837
|
return { runeTx: a, assetTx: i };
|
|
8824
8838
|
});
|
|
8825
|
-
|
|
8839
|
+
m(this, "addLiquidity", async ({
|
|
8826
8840
|
runeAssetValue: t,
|
|
8827
8841
|
assetValue: n,
|
|
8828
8842
|
runeAddr: a,
|
|
@@ -8830,41 +8844,41 @@ class fa {
|
|
|
8830
8844
|
isPendingSymmAsset: s,
|
|
8831
8845
|
mode: p = "sym"
|
|
8832
8846
|
}) => {
|
|
8833
|
-
const { chain: u, symbol: y } = n, o = p === "sym", l = (t == null ? void 0 : t.gt(0)) && (o || p === "rune"), b = (n == null ? void 0 : n.gt(0)) && (o || p === "asset"),
|
|
8847
|
+
const { chain: u, symbol: y } = n, o = p === "sym", l = (t == null ? void 0 : t.gt(0)) && (o || p === "rune"), b = (n == null ? void 0 : n.gt(0)) && (o || p === "asset"), T = s || l, f = T ? a || this.getAddress(r.THORChain) : "", _ = o || p === "asset" ? i || this.getAddress(u) : "";
|
|
8834
8848
|
if (!(l || b))
|
|
8835
8849
|
throw new d("core_transaction_add_liquidity_invalid_params");
|
|
8836
|
-
if (
|
|
8850
|
+
if (T && !f)
|
|
8837
8851
|
throw new d("core_transaction_add_liquidity_no_rune_address");
|
|
8838
8852
|
let M, v;
|
|
8839
8853
|
if (l && t)
|
|
8840
8854
|
try {
|
|
8841
|
-
M = await
|
|
8855
|
+
M = await A(this, H).call(this, {
|
|
8842
8856
|
assetValue: t,
|
|
8843
|
-
memo:
|
|
8857
|
+
memo: B(w.DEPOSIT, {
|
|
8844
8858
|
chain: u,
|
|
8845
8859
|
symbol: y,
|
|
8846
8860
|
address: _
|
|
8847
8861
|
})
|
|
8848
8862
|
});
|
|
8849
|
-
} catch (
|
|
8850
|
-
throw new d("core_transaction_add_liquidity_rune_error",
|
|
8863
|
+
} catch (C) {
|
|
8864
|
+
throw new d("core_transaction_add_liquidity_rune_error", C);
|
|
8851
8865
|
}
|
|
8852
8866
|
if (b && n)
|
|
8853
8867
|
try {
|
|
8854
|
-
v = await
|
|
8868
|
+
v = await A(this, H).call(this, {
|
|
8855
8869
|
assetValue: n,
|
|
8856
|
-
memo:
|
|
8870
|
+
memo: B(w.DEPOSIT, {
|
|
8857
8871
|
chain: u,
|
|
8858
8872
|
symbol: y,
|
|
8859
8873
|
address: f
|
|
8860
8874
|
})
|
|
8861
8875
|
});
|
|
8862
|
-
} catch (
|
|
8863
|
-
throw new d("core_transaction_add_liquidity_asset_error",
|
|
8876
|
+
} catch (C) {
|
|
8877
|
+
throw new d("core_transaction_add_liquidity_asset_error", C);
|
|
8864
8878
|
}
|
|
8865
8879
|
return { runeTx: M, assetTx: v };
|
|
8866
8880
|
});
|
|
8867
|
-
|
|
8881
|
+
m(this, "addLiquidityPart", ({
|
|
8868
8882
|
assetValue: t,
|
|
8869
8883
|
poolAddress: n,
|
|
8870
8884
|
address: a,
|
|
@@ -8872,21 +8886,21 @@ class fa {
|
|
|
8872
8886
|
}) => {
|
|
8873
8887
|
if (i && !a)
|
|
8874
8888
|
throw new d("core_transaction_add_liquidity_invalid_params");
|
|
8875
|
-
const s =
|
|
8889
|
+
const s = B(w.DEPOSIT, {
|
|
8876
8890
|
chain: n.split(".")[0],
|
|
8877
8891
|
symbol: n.split(".")[1],
|
|
8878
8892
|
address: i ? a : ""
|
|
8879
8893
|
});
|
|
8880
|
-
return
|
|
8894
|
+
return A(this, H).call(this, { assetValue: t, memo: s });
|
|
8881
8895
|
});
|
|
8882
|
-
|
|
8896
|
+
m(this, "withdraw", ({
|
|
8883
8897
|
memo: t,
|
|
8884
8898
|
assetValue: n,
|
|
8885
8899
|
percent: a,
|
|
8886
8900
|
from: i,
|
|
8887
8901
|
to: s
|
|
8888
8902
|
}) => {
|
|
8889
|
-
const p = s === "rune" && i !== "rune" ?
|
|
8903
|
+
const p = s === "rune" && i !== "rune" ? k.fromChainOrSignature(r.THORChain) : i === "sym" && s === "sym" || i === "rune" || i === "asset" ? void 0 : n, u = _e(i === "asset" ? n.chain : r.THORChain), y = t || B(w.WITHDRAW, {
|
|
8890
8904
|
symbol: n.symbol,
|
|
8891
8905
|
chain: n.chain,
|
|
8892
8906
|
ticker: n.ticker,
|
|
@@ -8894,62 +8908,69 @@ class fa {
|
|
|
8894
8908
|
targetAssetString: p == null ? void 0 : p.toString(),
|
|
8895
8909
|
singleSide: !1
|
|
8896
8910
|
});
|
|
8897
|
-
return
|
|
8911
|
+
return A(this, H).call(this, { assetValue: u, memo: y });
|
|
8898
8912
|
});
|
|
8899
|
-
|
|
8913
|
+
m(this, "savings", ({
|
|
8900
8914
|
assetValue: t,
|
|
8901
8915
|
memo: n,
|
|
8902
8916
|
percent: a,
|
|
8903
8917
|
type: i
|
|
8904
8918
|
}) => {
|
|
8905
|
-
const s = i === "add" ? w.DEPOSIT : w.WITHDRAW, p = n ||
|
|
8919
|
+
const s = i === "add" ? w.DEPOSIT : w.WITHDRAW, p = n || B(s, {
|
|
8906
8920
|
ticker: t.ticker,
|
|
8907
8921
|
symbol: t.symbol,
|
|
8908
8922
|
chain: t.chain,
|
|
8909
8923
|
singleSide: !0,
|
|
8910
8924
|
basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
|
|
8911
|
-
}), u = s === w.DEPOSIT ? t :
|
|
8912
|
-
return
|
|
8925
|
+
}), u = s === w.DEPOSIT ? t : _e(t.chain);
|
|
8926
|
+
return A(this, H).call(this, { memo: p, assetValue: u });
|
|
8913
8927
|
});
|
|
8914
|
-
|
|
8928
|
+
m(this, "loan", ({
|
|
8915
8929
|
assetValue: t,
|
|
8916
8930
|
memo: n,
|
|
8917
8931
|
minAmount: a,
|
|
8918
8932
|
type: i
|
|
8919
|
-
}) =>
|
|
8933
|
+
}) => A(this, H).call(this, {
|
|
8920
8934
|
assetValue: t,
|
|
8921
|
-
memo: n ||
|
|
8935
|
+
memo: n || B(i === "open" ? w.OPEN_LOAN : w.CLOSE_LOAN, {
|
|
8922
8936
|
asset: t.toString(),
|
|
8923
8937
|
minAmount: a.toString(),
|
|
8924
8938
|
address: this.getAddress(t.chain)
|
|
8925
8939
|
})
|
|
8926
8940
|
}));
|
|
8927
|
-
|
|
8941
|
+
m(this, "nodeAction", ({
|
|
8928
8942
|
type: t,
|
|
8929
8943
|
assetValue: n,
|
|
8930
8944
|
address: a
|
|
8931
8945
|
}) => {
|
|
8932
|
-
const i = t === "bond" ? w.BOND : t === "unbond" ? w.UNBOND : w.LEAVE, s =
|
|
8946
|
+
const i = t === "bond" ? w.BOND : t === "unbond" ? w.UNBOND : w.LEAVE, s = B(i, {
|
|
8933
8947
|
address: a,
|
|
8934
8948
|
unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
|
|
8935
8949
|
});
|
|
8936
|
-
return
|
|
8950
|
+
return A(this, ie).call(this, {
|
|
8937
8951
|
memo: s,
|
|
8938
|
-
assetValue: t === "bond" ? n :
|
|
8952
|
+
assetValue: t === "bond" ? n : _e(r.THORChain)
|
|
8939
8953
|
});
|
|
8940
8954
|
});
|
|
8941
|
-
|
|
8955
|
+
m(this, "registerThorname", ({
|
|
8956
|
+
assetValue: t,
|
|
8957
|
+
...n
|
|
8958
|
+
}) => A(this, ie).call(this, {
|
|
8959
|
+
assetValue: t,
|
|
8960
|
+
memo: B(w.THORNAME_REGISTER, n)
|
|
8961
|
+
}));
|
|
8962
|
+
m(this, "registerMayaname", ({
|
|
8942
8963
|
assetValue: t,
|
|
8943
8964
|
...n
|
|
8944
|
-
}) =>
|
|
8965
|
+
}) => A(this, Te).call(this, {
|
|
8945
8966
|
assetValue: t,
|
|
8946
|
-
memo:
|
|
8967
|
+
memo: B(w.THORNAME_REGISTER, n)
|
|
8947
8968
|
}));
|
|
8948
|
-
|
|
8969
|
+
m(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: i = {} }) => {
|
|
8949
8970
|
try {
|
|
8950
8971
|
for (const s of t)
|
|
8951
8972
|
this[s.connectMethodName] = s.connect({
|
|
8952
|
-
addChain:
|
|
8973
|
+
addChain: A(this, me),
|
|
8953
8974
|
config: n || {},
|
|
8954
8975
|
apis: a,
|
|
8955
8976
|
rpcUrls: i
|
|
@@ -8958,7 +8979,7 @@ class fa {
|
|
|
8958
8979
|
throw new d("core_extend_error", s);
|
|
8959
8980
|
}
|
|
8960
8981
|
});
|
|
8961
|
-
|
|
8982
|
+
m(this, "estimateMaxSendableAmount", async ({
|
|
8962
8983
|
chain: t,
|
|
8963
8984
|
params: n
|
|
8964
8985
|
}) => {
|
|
@@ -8997,52 +9018,52 @@ class fa {
|
|
|
8997
9018
|
/**
|
|
8998
9019
|
* Wallet connection methods
|
|
8999
9020
|
*/
|
|
9000
|
-
// biome-ignore lint/
|
|
9001
|
-
|
|
9021
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9022
|
+
m(this, "connectXDEFI", async (t) => {
|
|
9002
9023
|
throw new d("core_wallet_xdefi_not_installed");
|
|
9003
9024
|
});
|
|
9004
|
-
// biome-ignore lint/
|
|
9005
|
-
|
|
9025
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9026
|
+
m(this, "connectEVMWallet", async (t, n) => {
|
|
9006
9027
|
throw new d("core_wallet_evmwallet_not_installed");
|
|
9007
9028
|
});
|
|
9008
|
-
// biome-ignore lint/
|
|
9009
|
-
|
|
9029
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9030
|
+
m(this, "connectWalletconnect", async (t, n) => {
|
|
9010
9031
|
throw new d("core_wallet_walletconnect_not_installed");
|
|
9011
9032
|
});
|
|
9012
|
-
// biome-ignore lint/
|
|
9013
|
-
|
|
9033
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9034
|
+
m(this, "connectKeepkey", async (t, n) => {
|
|
9014
9035
|
throw new d("core_wallet_keepkey_not_installed");
|
|
9015
9036
|
});
|
|
9016
|
-
// biome-ignore lint/
|
|
9017
|
-
|
|
9037
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9038
|
+
m(this, "connectKeystore", async (t, n) => {
|
|
9018
9039
|
throw new d("core_wallet_keystore_not_installed");
|
|
9019
9040
|
});
|
|
9020
|
-
// biome-ignore lint/
|
|
9021
|
-
|
|
9041
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9042
|
+
m(this, "connectLedger", async (t, n) => {
|
|
9022
9043
|
throw new d("core_wallet_ledger_not_installed");
|
|
9023
9044
|
});
|
|
9024
|
-
// biome-ignore lint/
|
|
9025
|
-
|
|
9045
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9046
|
+
m(this, "connectTrezor", async (t, n) => {
|
|
9026
9047
|
throw new d("core_wallet_trezor_not_installed");
|
|
9027
9048
|
});
|
|
9028
|
-
// biome-ignore lint/
|
|
9029
|
-
|
|
9049
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9050
|
+
m(this, "connectKeplr", async (t) => {
|
|
9030
9051
|
throw new d("core_wallet_keplr_not_installed");
|
|
9031
9052
|
});
|
|
9032
|
-
// biome-ignore lint/
|
|
9033
|
-
|
|
9053
|
+
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
9054
|
+
m(this, "connectOkx", async (t) => {
|
|
9034
9055
|
throw new d("core_wallet_okx_not_installed");
|
|
9035
9056
|
});
|
|
9036
|
-
|
|
9057
|
+
m(this, "disconnectChain", (t) => {
|
|
9037
9058
|
this.connectedChains[t] = null, this.connectedWallets[t] = null;
|
|
9038
9059
|
});
|
|
9039
|
-
|
|
9060
|
+
V(this, $, async (t) => {
|
|
9040
9061
|
switch (t) {
|
|
9041
9062
|
case r.Maya:
|
|
9042
9063
|
case r.THORChain:
|
|
9043
9064
|
return { gas_rate: "0", router: "", address: "", halted: !1, chain: t };
|
|
9044
9065
|
default: {
|
|
9045
|
-
const a = (await
|
|
9066
|
+
const a = (await Gn(this.stagenet)).find((i) => i.chain === t);
|
|
9046
9067
|
if (!a)
|
|
9047
9068
|
throw new d("core_inbound_data_not_found");
|
|
9048
9069
|
if (a != null && a.halted)
|
|
@@ -9051,7 +9072,7 @@ class fa {
|
|
|
9051
9072
|
}
|
|
9052
9073
|
}
|
|
9053
9074
|
});
|
|
9054
|
-
|
|
9075
|
+
V(this, me, ({
|
|
9055
9076
|
chain: t,
|
|
9056
9077
|
address: n,
|
|
9057
9078
|
balance: a,
|
|
@@ -9064,7 +9085,7 @@ class fa {
|
|
|
9064
9085
|
walletType: i || "unknown"
|
|
9065
9086
|
}, this.connectedWallets[t] = { ...s };
|
|
9066
9087
|
});
|
|
9067
|
-
|
|
9088
|
+
V(this, ae, async ({
|
|
9068
9089
|
assetValue: t,
|
|
9069
9090
|
type: n = "checkOnly",
|
|
9070
9091
|
contractAddress: a
|
|
@@ -9075,27 +9096,27 @@ class fa {
|
|
|
9075
9096
|
const l = this.connectedWallets[s], b = n === "checkOnly" ? l == null ? void 0 : l.isApproved : l == null ? void 0 : l.approve;
|
|
9076
9097
|
if (!b)
|
|
9077
9098
|
throw new d("core_wallet_connection_not_found");
|
|
9078
|
-
const
|
|
9079
|
-
if (!(i &&
|
|
9099
|
+
const T = this.getAddress(s);
|
|
9100
|
+
if (!(i && T))
|
|
9080
9101
|
throw new d("core_approve_asset_address_or_from_not_found");
|
|
9081
|
-
const f = a || (await
|
|
9102
|
+
const f = a || (await A(this, $).call(this, s)).router;
|
|
9082
9103
|
return b({
|
|
9083
9104
|
amount: t.getBaseValue("bigint"),
|
|
9084
9105
|
assetAddress: i,
|
|
9085
|
-
from:
|
|
9106
|
+
from: T,
|
|
9086
9107
|
spenderAddress: f
|
|
9087
9108
|
});
|
|
9088
9109
|
});
|
|
9089
|
-
|
|
9110
|
+
V(this, H, async ({
|
|
9090
9111
|
assetValue: t,
|
|
9091
9112
|
memo: n,
|
|
9092
|
-
feeOptionKey: a =
|
|
9113
|
+
feeOptionKey: a = Y.Fast
|
|
9093
9114
|
}) => {
|
|
9094
9115
|
const {
|
|
9095
9116
|
gas_rate: i,
|
|
9096
9117
|
router: s,
|
|
9097
9118
|
address: p
|
|
9098
|
-
} = await
|
|
9119
|
+
} = await A(this, $).call(this, t.chain), u = (Number.parseInt(i) || 0) * yn[a];
|
|
9099
9120
|
return this.deposit({
|
|
9100
9121
|
assetValue: t,
|
|
9101
9122
|
recipient: p,
|
|
@@ -9104,7 +9125,16 @@ class fa {
|
|
|
9104
9125
|
feeRate: u
|
|
9105
9126
|
});
|
|
9106
9127
|
});
|
|
9107
|
-
|
|
9128
|
+
V(this, ie, async ({
|
|
9129
|
+
memo: t,
|
|
9130
|
+
assetValue: n
|
|
9131
|
+
}) => {
|
|
9132
|
+
const a = await jn(this.stagenet);
|
|
9133
|
+
if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
|
|
9134
|
+
throw new d("core_chain_halted");
|
|
9135
|
+
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
9136
|
+
});
|
|
9137
|
+
V(this, Te, async ({
|
|
9108
9138
|
memo: t,
|
|
9109
9139
|
assetValue: n
|
|
9110
9140
|
}) => {
|
|
@@ -9113,7 +9143,7 @@ class fa {
|
|
|
9113
9143
|
throw new d("core_chain_halted");
|
|
9114
9144
|
return this.deposit({ assetValue: n, recipient: "", memo: t });
|
|
9115
9145
|
});
|
|
9116
|
-
|
|
9146
|
+
V(this, se, ({ assetValue: t, ...n }) => ({
|
|
9117
9147
|
...n,
|
|
9118
9148
|
memo: n.memo || "",
|
|
9119
9149
|
from: this.getAddress(t.chain),
|
|
@@ -9122,77 +9152,79 @@ class fa {
|
|
|
9122
9152
|
this.stagenet = !!t;
|
|
9123
9153
|
}
|
|
9124
9154
|
}
|
|
9125
|
-
$ = new WeakMap(), me = new WeakMap(), ae = new WeakMap(),
|
|
9155
|
+
$ = new WeakMap(), me = new WeakMap(), ae = new WeakMap(), H = new WeakMap(), ie = new WeakMap(), Te = new WeakMap(), se = new WeakMap();
|
|
9126
9156
|
export {
|
|
9127
|
-
|
|
9157
|
+
Mt as AGG_SWAP,
|
|
9128
9158
|
L as ApiEndpoints,
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9159
|
+
U as ApiUrl,
|
|
9160
|
+
gn as ApproveMode,
|
|
9161
|
+
k as AssetValue,
|
|
9162
|
+
g as BaseDecimal,
|
|
9163
|
+
ke as BigIntArithmetics,
|
|
9134
9164
|
r as Chain,
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9165
|
+
Re as ChainId,
|
|
9166
|
+
sa as ChainIdToChain,
|
|
9167
|
+
Qe as ChainToChainId,
|
|
9168
|
+
Ye as ChainToExplorerUrl,
|
|
9169
|
+
ia as ChainToHexChainId,
|
|
9170
|
+
It as ChainToRPC,
|
|
9141
9171
|
Et as ContractAddress,
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
|
|
9172
|
+
na as CosmosChainList,
|
|
9173
|
+
kt as CosmosChains,
|
|
9174
|
+
Ot as DerivationPath,
|
|
9175
|
+
ea as EVMChainList,
|
|
9146
9176
|
je as EVMChains,
|
|
9147
|
-
|
|
9148
|
-
|
|
9177
|
+
Y as FeeOption,
|
|
9178
|
+
Pt as LedgerErrorCode,
|
|
9149
9179
|
w as MemoType,
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9180
|
+
Zn as NetworkDerivationPath,
|
|
9181
|
+
_t as QuoteMode,
|
|
9182
|
+
Ke as RPCUrl,
|
|
9183
|
+
x as RequestClient,
|
|
9184
|
+
vt as SWAP_IN,
|
|
9185
|
+
Ct as SWAP_OUT,
|
|
9186
|
+
nn as StreamingSwapProgressStatus,
|
|
9187
|
+
zn as SubstrateChains,
|
|
9188
|
+
Aa as SwapKit,
|
|
9189
|
+
pa as SwapKitApi,
|
|
9190
|
+
ga as SwapKitCore,
|
|
9161
9191
|
d as SwapKitError,
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9192
|
+
F as SwapKitNumber,
|
|
9193
|
+
At as TCAvalancheDepositABI,
|
|
9194
|
+
gt as TCBscDepositABI,
|
|
9195
|
+
wt as TCEthereumVaultAbi,
|
|
9196
|
+
aa as TCSupportedChainList,
|
|
9197
|
+
St as TCSupportedChains,
|
|
9198
|
+
en as TransactionType,
|
|
9199
|
+
tn as TxStatus,
|
|
9200
|
+
ta as UTXOChainList,
|
|
9201
|
+
xt as UTXOChains,
|
|
9172
9202
|
Bt as WalletOption,
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9203
|
+
ua as assetFromString,
|
|
9204
|
+
it as defaultRequestHeaders,
|
|
9205
|
+
wa as derivationPathToString,
|
|
9206
|
+
Jn as erc20ABI,
|
|
9207
|
+
ya as filterAssets,
|
|
9208
|
+
he as formatBigIntToSafeValue,
|
|
9209
|
+
yn as gasFeeMultiplier,
|
|
9210
|
+
dn as getAssetType,
|
|
9211
|
+
cn as getAsymmetricAssetShare,
|
|
9212
|
+
da as getAsymmetricAssetWithdrawAmount,
|
|
9213
|
+
Tn as getAsymmetricRuneShare,
|
|
9214
|
+
oa as getAsymmetricRuneWithdrawAmount,
|
|
9215
|
+
on as getCommonAssetInfo,
|
|
9216
|
+
un as getDecimal,
|
|
9217
|
+
ma as getEstimatedPoolShare,
|
|
9218
|
+
Ta as getLiquiditySlippage,
|
|
9219
|
+
ba as getMAYANameCost,
|
|
9220
|
+
B as getMemoFor,
|
|
9221
|
+
_e as getMinAmountByChain,
|
|
9222
|
+
bn as getSymmetricPoolShare,
|
|
9223
|
+
la as getSymmetricWithdraw,
|
|
9224
|
+
ca as getTHORNameCost,
|
|
9225
|
+
rt as isGasAsset,
|
|
9226
|
+
ra as setRequestClientConfig,
|
|
9227
|
+
ha as validateMAYAName,
|
|
9228
|
+
fa as validateTHORName
|
|
9197
9229
|
};
|
|
9198
9230
|
//# sourceMappingURL=index.es.js.map
|