Skip to content

Commit

Permalink
feat: add a check on the isFinished
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Jul 29, 2024
1 parent baa9947 commit 2e2ae9b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions components/v1/Vault.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand All @@ -203,7 +201,7 @@ export function VaultV1(props: {
rewardEarned,
autoCoumpoundingVaultSupply,
autoCoumpoundingVaultBalance,
weeklyStakingRewards: rewardsPerWeek,
weeklyStakingRewards: isFinished ? 0 : rewardsPerWeek,
vaultPricePerShare,
autoCompoundingVaultPricePerShare
});
Expand Down

0 comments on commit 2e2ae9b

Please sign in to comment.