From 7b5dd29371945e480f4db9d6053365da398d8ef8 Mon Sep 17 00:00:00 2001 From: ChefJoJo <94336009+chef-jojo@users.noreply.github.com> Date: Wed, 26 Oct 2022 14:44:28 +0800 Subject: [PATCH] fix(home): Fix tvl data (#5089) --- apps/web/src/pages/index.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/web/src/pages/index.tsx b/apps/web/src/pages/index.tsx index 6b68e08e608e7..180e32ded23a5 100644 --- a/apps/web/src/pages/index.tsx +++ b/apps/web/src/pages/index.tsx @@ -115,16 +115,14 @@ export const getStaticProps: GetStaticProps = async () => { pancakeFactories(first: 1) { totalLiquidityUSD } - token(id: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82") { - derivedUSD - } } `) + const cake = await (await fetch('https://farms.pancake-swap.workers.dev/price/cake')).json() const { totalLiquidityUSD } = result.pancakeFactories[0] const cakeVaultV2 = getCakeVaultAddress() const cakeContract = getCakeContract() const totalCakeInVault = await cakeContract.balanceOf(cakeVaultV2) - results.tvl = parseFloat(formatEther(totalCakeInVault)) * result.token.derivedUSD + parseFloat(totalLiquidityUSD) + results.tvl = parseFloat(formatEther(totalCakeInVault)) * cake.price + parseFloat(totalLiquidityUSD) } catch (error) { if (process.env.NODE_ENV === 'production') { console.error('Error when fetching tvl stats', error)