From 2e2ae9b1ff505a6429ee51b2bd1b5ed28bc7f90e Mon Sep 17 00:00:00 2001 From: Majorfi Date: Mon, 29 Jul 2024 17:01:11 +0200 Subject: [PATCH] feat: add a check on the isFinished --- components/v1/Vault.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/v1/Vault.tsx b/components/v1/Vault.tsx index dfa51b8..de8aba6 100644 --- a/components/v1/Vault.tsx +++ b/components/v1/Vault.tsx @@ -166,6 +166,7 @@ export function VaultV1(props: { return; } + const periodFinish = toBigInt(onChainData?.[6]?.result?.[2]); const rewardRate = toNormalizedBN(toBigInt(onChainData?.[6]?.result?.[3]), 18); const rewardDuration = toBigInt(onChainData?.[6]?.result?.[1]); const rewardsPerWeek = rewardRate.normalized * Number(rewardDuration); @@ -175,20 +176,17 @@ export function VaultV1(props: { const autoCoumpoundingVaultBalance = isZeroAddress(address) ? zeroNormalizedBN : toNormalizedBN(decodeAsBigInt(onChainData[8]), vault.decimals); - const stakingBalanceOf = isZeroAddress(address) ? zeroNormalizedBN : toNormalizedBN(decodeAsBigInt(onChainData[4]), vault.decimals); - const autoCoumpoundingVaultSupply = toNormalizedBN(decodeAsBigInt(onChainData[7]), vault.decimals); - const vaultBalanceOf = isZeroAddress(address) ? zeroNormalizedBN : toNormalizedBN(decodeAsBigInt(onChainData[1]), vault.decimals); - const rewardEarned = isZeroAddress(address) ? zeroNormalizedBN : toNormalizedBN(decodeAsBigInt(onChainData[5]), 18); + const isFinished = periodFinish < Date.now() / 1000; set_onChainVault({ totalVaultSupply: toNormalizedBN(decodeAsBigInt(onChainData[0]), vault.decimals), @@ -203,7 +201,7 @@ export function VaultV1(props: { rewardEarned, autoCoumpoundingVaultSupply, autoCoumpoundingVaultBalance, - weeklyStakingRewards: rewardsPerWeek, + weeklyStakingRewards: isFinished ? 0 : rewardsPerWeek, vaultPricePerShare, autoCompoundingVaultPricePerShare });