Skip to content

Commit

Permalink
feat: take finishedAt into consideration
Browse files Browse the repository at this point in the history
  • Loading branch information
w84april committed Oct 23, 2024
1 parent a3be1d3 commit 93cff89
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion apps/vaults-v3/components/details/VaultActionsTabsWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export function VaultActionsTabsWrapper({currentVault}: {currentVault: TYDaemonV
}
]
});

const hasLiveRewards = decodeAsBigInt(result[1]) > Math.floor(Date.now() / 1000);
const hasLiveRewardsFromYDaemon = (currentVault.staking.rewards || []).some(e => !e.isFinished);
set_unstakedBalance(toNormalizedBN(decodeAsBigInt(result[0]), currentVault.decimals));
Expand Down Expand Up @@ -360,6 +361,15 @@ export function VaultActionsTabsWrapper({currentVault}: {currentVault: TYDaemonV
}
}, [currentVault?.migration?.available, currentVault?.info?.isRetired, actionParams.isReady, hasStakingRewards]);

useEffect(() => {
const finishedAt = 1729022801; // temporary value
if (!hasStakingRewardsLive && Math.floor(Date.now() / 1000) - finishedAt > 60 * 60 * 24 * 7) {
set_isAutoStakingEnabled(false);
return;
}
set_isAutoStakingEnabled(true);
}, [hasStakingRewardsLive, set_isAutoStakingEnabled]);

const isSonneRetiredVault =
toAddress(currentVault.address) === toAddress(`0x5b977577eb8a480f63e11fc615d6753adb8652ae`) ||
toAddress(currentVault.address) === toAddress(`0xad17a225074191d5c8a37b50fda1ae278a2ee6a2`) ||
Expand Down Expand Up @@ -515,7 +525,7 @@ export function VaultActionsTabsWrapper({currentVault}: {currentVault: TYDaemonV
<p className={'hidden text-base md:inline'}>&nbsp;</p>
<div>
<VaultDetailsQuickActionsButtons currentVault={currentVault} />
{hasStakingRewards && (
{!hasStakingRewardsLive && (
<div className={'mt-1 flex justify-between'}>
<button
className={'font-number text-xxs text-neutral-900/50'}
Expand Down

0 comments on commit 93cff89

Please sign in to comment.