Skip to content

Commit

Permalink
fix(home): Fix tvl data (#5089)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjojoex authored Oct 26, 2022
1 parent 877117a commit 7b5dd29
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apps/web/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7b5dd29

Please sign in to comment.