From 7ac6e6a4808adb7173541ca490747fe47c8867f3 Mon Sep 17 00:00:00 2001 From: Carlos Fontes Date: Mon, 25 Nov 2024 18:59:32 +0000 Subject: [PATCH] fixed apy bug --- packages/web/src/hooks/vaults/useVaultApy.ts | 4 ++-- .../VaultAssetsSection/components/VaultAsset.tsx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/web/src/hooks/vaults/useVaultApy.ts b/packages/web/src/hooks/vaults/useVaultApy.ts index ff467d26e..2989dd2ad 100644 --- a/packages/web/src/hooks/vaults/useVaultApy.ts +++ b/packages/web/src/hooks/vaults/useVaultApy.ts @@ -56,7 +56,7 @@ export const useVaultApy = (vault?: IVault): IVaultApy[] => { vault.amountsInfo?.depositedAmount ? +vault.amountsInfo.depositedAmount.tokens : 0 ); - apys.push({ rewardController: controller, apy }); + if (!isNaN(apy)) apys.push({ rewardController: controller, apy }); } setVaultApys(apys); @@ -87,7 +87,7 @@ function calculateAPY( // Calculate the APY // Note: vaultTokenStaked should be the total value of tokens staked in the vault // in the same currency as tokenPrice for an accurate APY calculation - const apy = (annualRewardValue / vaultTokenStaked) * 100; + const apy = vaultTokenStaked > 0 ? (annualRewardValue / vaultTokenStaked) * 100 : 0; return apy > 100 ? +apy.toFixed(0) : +apy.toFixed(2); } diff --git a/packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultDepositsSection/VaultAssetsSection/components/VaultAsset.tsx b/packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultDepositsSection/VaultAssetsSection/components/VaultAsset.tsx index b6f8e339b..01411d7a6 100644 --- a/packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultDepositsSection/VaultAssetsSection/components/VaultAsset.tsx +++ b/packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultDepositsSection/VaultAssetsSection/components/VaultAsset.tsx @@ -17,6 +17,7 @@ export const VaultAsset = ({ vault }: VaultAssetProps) => { const { isShowing: isShowingDepositModal, show: showDepositModal, hide: hideDepositModal } = useModal(); const vaultApy = useVaultApy(vault); + console.log(vaultApy); const isAudit = vault.description && vault.description["project-metadata"].type === "audit"; const depositsDisabled = !vault.committeeCheckedIn || vault.depositPause;