From 709d493064a78bf6e8b92d5b09b235afa238a631 Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Thu, 6 Jul 2023 15:12:54 +0530 Subject: [PATCH] Move constraint down (#397) --- client/components/claim/claim/ClaimOgv.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client/components/claim/claim/ClaimOgv.tsx b/client/components/claim/claim/ClaimOgv.tsx index 69c21b82..b89a4b06 100644 --- a/client/components/claim/claim/ClaimOgv.tsx +++ b/client/components/claim/claim/ClaimOgv.tsx @@ -33,19 +33,11 @@ const ClaimOgv: FunctionComponent = () => { maxLockupDurationInMonths ); const [error, setError] = useState(null); - if (!claim.loaded || !claim.optional.hasClaim) { - return <>; - } const isValidLockup = lockupDuration > 0; - const claimableOgv = claim.optional.isValid + const claimableOgv = claim?.optional?.isValid ? numeral(claim.optional.amount.div(decimal18Bn).toString()).value() : 0; - // as specified here: https://github.com/OriginProtocol/ousd-governance/blob/master/contracts/OgvStaking.sol#L21 - const votingDecayFactor = 1.8; - - const veOgvFromOgvLockup = - claimableOgv * votingDecayFactor ** (lockupDuration / 12); const { stakingAPY: ogvLockupRewardApy, loading: ogvLockupRewardLoading } = useStakingAPY(claimableOgv, lockupDuration); @@ -55,6 +47,16 @@ const ClaimOgv: FunctionComponent = () => { loading: maxOgvLockupRewardLoading, } = useStakingAPY(claimableOgv, 48); + if (!claim.loaded || !claim.optional.hasClaim) { + return <>; + } + + // as specified here: https://github.com/OriginProtocol/ousd-governance/blob/master/contracts/OgvStaking.sol#L21 + const votingDecayFactor = 1.8; + + const veOgvFromOgvLockup = + claimableOgv * votingDecayFactor ** (lockupDuration / 12); + let claimButtonText = ""; if (isValidLockup && claim.optional.state === "ready") { claimButtonText = "Claim & Stake OGV";