bridge_ui: added avax nft tvl stats
This commit is contained in:
parent
1d3ae6938b
commit
94a15d37a9
|
@ -9,6 +9,7 @@ import numeral from "numeral";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import useNFTTVL from "../../hooks/useNFTTVL";
|
import useNFTTVL from "../../hooks/useNFTTVL";
|
||||||
import {
|
import {
|
||||||
|
BETA_CHAINS,
|
||||||
CHAINS_WITH_NFT_SUPPORT,
|
CHAINS_WITH_NFT_SUPPORT,
|
||||||
getNFTBridgeAddressForChain,
|
getNFTBridgeAddressForChain,
|
||||||
} from "../../utils/consts";
|
} from "../../utils/consts";
|
||||||
|
@ -134,7 +135,9 @@ const NFTStats: React.FC<any> = () => {
|
||||||
const data = useMemo(() => {
|
const data = useMemo(() => {
|
||||||
const output: any[] = [];
|
const output: any[] = [];
|
||||||
if (nftTVL.data && !nftTVL.isFetching) {
|
if (nftTVL.data && !nftTVL.isFetching) {
|
||||||
CHAINS_WITH_NFT_SUPPORT.forEach((chain) => {
|
CHAINS_WITH_NFT_SUPPORT.filter(
|
||||||
|
(chain) => !BETA_CHAINS.find((x) => x === chain.id)
|
||||||
|
).forEach((chain) => {
|
||||||
output.push({
|
output.push({
|
||||||
nfts: nftTVL?.data?.filter((x) => x.chainId === chain.id),
|
nfts: nftTVL?.data?.filter((x) => x.chainId === chain.id),
|
||||||
chainName: chain.name,
|
chainName: chain.name,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
ChainId,
|
ChainId,
|
||||||
|
CHAIN_ID_AVAX,
|
||||||
CHAIN_ID_BSC,
|
CHAIN_ID_BSC,
|
||||||
CHAIN_ID_ETH,
|
CHAIN_ID_ETH,
|
||||||
CHAIN_ID_POLYGON,
|
CHAIN_ID_POLYGON,
|
||||||
|
@ -129,6 +130,10 @@ const useNFTTVL = (): DataWrapper<NFTTVL[]> => {
|
||||||
useState(false);
|
useState(false);
|
||||||
const [polygonCovalentError, setPolygonCovalentError] = useState("");
|
const [polygonCovalentError, setPolygonCovalentError] = useState("");
|
||||||
|
|
||||||
|
const [avaxCovalentData, setAvaxCovalentData] = useState(undefined);
|
||||||
|
const [avaxCovalentIsLoading, setAvaxCovalentIsLoading] = useState(false);
|
||||||
|
const [avaxCovalentError, setAvaxCovalentError] = useState("");
|
||||||
|
|
||||||
const [solanaCustodyTokens, setSolanaCustodyTokens] = useState<
|
const [solanaCustodyTokens, setSolanaCustodyTokens] = useState<
|
||||||
{ pubkey: PublicKey; account: AccountInfo<ParsedAccountData> }[] | undefined
|
{ pubkey: PublicKey; account: AccountInfo<ParsedAccountData> }[] | undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
|
@ -166,6 +171,11 @@ const useNFTTVL = (): DataWrapper<NFTTVL[]> => {
|
||||||
[polygonCovalentData]
|
[polygonCovalentData]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const avaxTVL = useMemo(
|
||||||
|
() => calcEvmTVL(avaxCovalentData, CHAIN_ID_AVAX),
|
||||||
|
[avaxCovalentData]
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
setEthCovalentIsLoading(true);
|
setEthCovalentIsLoading(true);
|
||||||
|
@ -250,6 +260,34 @@ const useNFTTVL = (): DataWrapper<NFTTVL[]> => {
|
||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
setAvaxCovalentIsLoading(true);
|
||||||
|
axios
|
||||||
|
.get(
|
||||||
|
COVALENT_GET_TOKENS_URL(
|
||||||
|
CHAIN_ID_AVAX,
|
||||||
|
getNFTBridgeAddressForChain(CHAIN_ID_AVAX),
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
(results) => {
|
||||||
|
if (!cancelled) {
|
||||||
|
setAvaxCovalentData(results.data);
|
||||||
|
setAvaxCovalentIsLoading(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
if (!cancelled) {
|
||||||
|
setAvaxCovalentError("Unable to retrieve Polygon TVL.");
|
||||||
|
setAvaxCovalentIsLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
const connection = new Connection(SOLANA_HOST, "confirmed");
|
const connection = new Connection(SOLANA_HOST, "confirmed");
|
||||||
|
@ -277,18 +315,26 @@ const useNFTTVL = (): DataWrapper<NFTTVL[]> => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
const tvlArray = [...ethTVL, ...bscTVL, ...polygonTVL, ...solanaTVL];
|
const tvlArray = [
|
||||||
|
...ethTVL,
|
||||||
|
...bscTVL,
|
||||||
|
...polygonTVL,
|
||||||
|
...avaxTVL,
|
||||||
|
...solanaTVL,
|
||||||
|
];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isFetching:
|
isFetching:
|
||||||
ethCovalentIsLoading ||
|
ethCovalentIsLoading ||
|
||||||
bscCovalentIsLoading ||
|
bscCovalentIsLoading ||
|
||||||
polygonCovalentIsLoading ||
|
polygonCovalentIsLoading ||
|
||||||
|
avaxCovalentIsLoading ||
|
||||||
solanaCustodyTokensLoading,
|
solanaCustodyTokensLoading,
|
||||||
error:
|
error:
|
||||||
ethCovalentError ||
|
ethCovalentError ||
|
||||||
bscCovalentError ||
|
bscCovalentError ||
|
||||||
polygonCovalentError ||
|
polygonCovalentError ||
|
||||||
|
avaxCovalentError ||
|
||||||
solanaCustodyTokensError,
|
solanaCustodyTokensError,
|
||||||
receivedAt: null,
|
receivedAt: null,
|
||||||
data: tvlArray,
|
data: tvlArray,
|
||||||
|
@ -306,6 +352,9 @@ const useNFTTVL = (): DataWrapper<NFTTVL[]> => {
|
||||||
solanaTVL,
|
solanaTVL,
|
||||||
solanaCustodyTokensError,
|
solanaCustodyTokensError,
|
||||||
solanaCustodyTokensLoading,
|
solanaCustodyTokensLoading,
|
||||||
|
avaxTVL,
|
||||||
|
avaxCovalentIsLoading,
|
||||||
|
avaxCovalentError,
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue