diff --git a/apps/hubble-stats/app/pool/[slug]/page.tsx b/apps/hubble-stats/app/pool/[slug]/page.tsx index a2fe841f8b..42c1763231 100644 --- a/apps/hubble-stats/app/pool/[slug]/page.tsx +++ b/apps/hubble-stats/app/pool/[slug]/page.tsx @@ -1,17 +1,16 @@ import { notFound } from 'next/navigation'; - +import { Suspense } from 'react'; +import { VANCHORS_MAP } from '../../../constants'; import { PoolInfoCardContainer, + PoolMetadataTableContainer, PoolOverviewChartsContainer, - PoolWrappingChartsContainer, - PoolTransactionsTableContainer, PoolOverviewTableContainer, + PoolTransactionsTableContainer, + PoolWrappingChartsContainer, PoolWrappingTableContainer, - PoolMetadataTableContainer, } from '../../../containers'; -import { VANCHORS_MAP } from '../../../constants'; import { getDateDataForPage } from '../../../utils'; -import { Suspense } from 'react'; // revalidate every 5 seconds export const revalidate = 5; diff --git a/apps/hubble-stats/containers/HeaderChipsContainer/HeaderChipsContainer.tsx b/apps/hubble-stats/containers/HeaderChipsContainer/HeaderChipsContainer.tsx index 03885b4477..b2e237f0bd 100644 --- a/apps/hubble-stats/containers/HeaderChipsContainer/HeaderChipsContainer.tsx +++ b/apps/hubble-stats/containers/HeaderChipsContainer/HeaderChipsContainer.tsx @@ -3,9 +3,9 @@ import { ArrowRightUp, DatabaseLine } from '@webb-tools/icons'; import { HeaderChipItem } from '../../components'; import { getHeaderChipsTvlData, getHeaderChipsDepositData } from '../../data'; -export default async function HeaderChipsContainer() { +export default function HeaderChipsContainer() { return ( -
+
, vAnchorAddress: string, + tokenSymbol: string, epochNow: number ) => { - const vanchor = VANCHORS_MAP[vAnchorAddress]; - const { fungibleTokenSymbol: tokenSymbol, supportedSubgraphs } = vanchor; - - const deposits24h = await getDepositInTimeRangeByVAnchor( - vAnchorAddress, - epochNow - EPOCH_DAY_INTERVAL, - epochNow, - supportedSubgraphs - ); - - let withdrawals24h: number | undefined; try { const withdrawalVAnchorsByChainsData = await vAnchorClient.Withdrawal.GetVAnchorWithdrawalByChainsAndByToken15MinsInterval( @@ -31,7 +23,7 @@ const getAssetInfoFromVAnchor = async ( getDateFromEpoch(epochNow) ); - withdrawals24h = withdrawalVAnchorsByChainsData.reduce( + return withdrawalVAnchorsByChainsData.reduce( (withdrawal, vAnchorsByChain) => { const withdrawalVAnchorsByChain = vAnchorsByChain.reduce( (withdrawalByChain, vAnchorWithdrawal) => @@ -44,8 +36,31 @@ const getAssetInfoFromVAnchor = async ( 0 ); } catch { - withdrawals24h = undefined; + return; } +}; + +const getAssetInfoFromVAnchor = async ( + vAnchorAddress: string, + epochNow: number +) => { + const vanchor = VANCHORS_MAP[vAnchorAddress]; + const { fungibleTokenSymbol: tokenSymbol, supportedSubgraphs } = vanchor; + + const [deposits24h, withdrawals24h] = await Promise.all([ + getDepositInTimeRangeByVAnchor( + vAnchorAddress, + epochNow - EPOCH_DAY_INTERVAL, + epochNow, + supportedSubgraphs + ), + getWithdrawals24h( + supportedSubgraphs, + vAnchorAddress, + tokenSymbol, + epochNow + ), + ]); return { address: vanchor.fungibleTokenAddress, diff --git a/apps/hubble-stats/data/shieldedTables/getShieldedPoolsTableData.ts b/apps/hubble-stats/data/shieldedTables/getShieldedPoolsTableData.ts index 78518005e1..0ac7dc2b91 100644 --- a/apps/hubble-stats/data/shieldedTables/getShieldedPoolsTableData.ts +++ b/apps/hubble-stats/data/shieldedTables/getShieldedPoolsTableData.ts @@ -12,13 +12,15 @@ const getPoolInfoFromVAnchor = async ( // plus one for fungible token const tokenNum = vAnchor.composition.length + 1; - const deposits24h = await getDepositInTimeRangeByVAnchor( - vAnchorAddress, - epochNow - EPOCH_DAY_INTERVAL, - epochNow, - vAnchor.supportedSubgraphs - ); - const tvl = await getTvlByVAnchor(vAnchorAddress, vAnchor.supportedSubgraphs); + const [deposits24h, tvl] = await Promise.all([ + getDepositInTimeRangeByVAnchor( + vAnchorAddress, + epochNow - EPOCH_DAY_INTERVAL, + epochNow, + vAnchor.supportedSubgraphs + ), + getTvlByVAnchor(vAnchorAddress, vAnchor.supportedSubgraphs), + ]); return { address: vAnchorAddress, diff --git a/package.json b/package.json index bdf51e35ad..7c906fc25d 100644 --- a/package.json +++ b/package.json @@ -211,7 +211,7 @@ "@webb-tools/test-utils": "0.1.4-126", "@webb-tools/tokens": "1.0.8", "@webb-tools/utils": "0.5.39", - "@webb-tools/vanchor-client": "0.1.25", + "@webb-tools/vanchor-client": "0.1.26", "@webb-tools/wasm-utils": "0.1.4-126", "autoprefixer": "10.4.14", "babel-jest": "29.5.0", diff --git a/yarn.lock b/yarn.lock index 5916ef4c39..1ad48ee618 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10945,10 +10945,10 @@ ethers "5.7.0" snarkjs "^0.6.10" -"@webb-tools/vanchor-client@0.1.25": - version "0.1.25" - resolved "https://registry.yarnpkg.com/@webb-tools/vanchor-client/-/vanchor-client-0.1.25.tgz#23d09f39f665231bc6604752d40bdb07a74bd3fd" - integrity sha512-vq6Se8LgO/Tr6XK0pvyn7cCW27GFVn6GNO83WnULjm8uyKAjxeFscb4SONn765g9WDYkE9zEANZJSaVWX1FYrw== +"@webb-tools/vanchor-client@0.1.26": + version "0.1.26" + resolved "https://registry.yarnpkg.com/@webb-tools/vanchor-client/-/vanchor-client-0.1.26.tgz#e03b0c3b33e1e4bab3ce9a47bfad00adc873ed0b" + integrity sha512-XpBJDJLE9JsMoIrlpUH8ExxA0ntaulXh3HhyIOLrVWIkwv3+Eb/O2QfJ7IAeoZ2/wl+qw/8VMtq5Z0oc924uHw== dependencies: "@graphprotocol/client-cli" "3.0.0" ts-node "10.9.1"