From 517ec2733b60e3b48023602f4de600fc8312b199 Mon Sep 17 00:00:00 2001 From: brymut Date: Wed, 21 Aug 2024 10:26:20 +0300 Subject: [PATCH] Add gt check to totalDeposit val in liquidity Rewards APY calc --- ui/lib/liquidity-rewards.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/lib/liquidity-rewards.ts b/ui/lib/liquidity-rewards.ts index d151a093..ff1ebe5e 100644 --- a/ui/lib/liquidity-rewards.ts +++ b/ui/lib/liquidity-rewards.ts @@ -68,12 +68,14 @@ export function useLiquidityRewards({ nationPrice, poolValue, address }: any) { useEffect(() => { if (totalRewards && poolValue && totalDeposit && lpTokensSupply) { - setLiquidityRewardsAPY( - totalRewards - .mul(transformNumber(12 / months, NumberType.bignumber)) - .mul(transformNumber(nationPrice, NumberType.bignumber, 2)) - .div(poolValue.mul(totalDeposit).div(lpTokensSupply)) - ) + if (totalDeposit.gt(transformNumber(0, NumberType.bignumber))){ + setLiquidityRewardsAPY( + totalRewards + .mul(transformNumber(12 / months, NumberType.bignumber)) + .mul(transformNumber(nationPrice, NumberType.bignumber, 2)) + .div(poolValue.mul(totalDeposit).div(lpTokensSupply)) + ) + } } }, [ poolValue,