From 99760e8561913afbc6eff9648aaba8095679fd7c Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:52:04 +0530 Subject: [PATCH 1/2] Fix APY calc --- client/components/vote-escrow/LockupForm.tsx | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/client/components/vote-escrow/LockupForm.tsx b/client/components/vote-escrow/LockupForm.tsx index 4ac94724..2fc9b689 100644 --- a/client/components/vote-escrow/LockupForm.tsx +++ b/client/components/vote-escrow/LockupForm.tsx @@ -145,16 +145,7 @@ const LockupForm: FunctionComponent = ({ existingLockup }) => { // as specified here: https://github.com/OriginProtocol/ousd-governance/blob/master/contracts/OgvStaking.sol#L21 const votingDecayFactor = 1.8; - // block.timestamp of when OgvStaking.sol was launched - const epoch = 1657584000; - const duration = lockupDuration * SECONDS_IN_A_MONTH; - // Since we'll be using blockTimestamp from CURRENT block, calculation will be - // a hair outdated... but it's negligible - const start = blockTimestamp > epoch ? blockTimestamp : epoch; // In prod, should always be blockTimestamp - const end = start + duration; - const dist = end - epoch; // Distance between end of staking period and the very beginning when staking was launched - const multiplier = dist / 365 / 86400; - const veOgvFromOgvLockup = lockupAmount * votingDecayFactor ** multiplier; + const veOgvFromOgvLockup = lockupAmount * votingDecayFactor ** (lockupDuration / 12); const ogvLockupRewardApy = getRewardsApy( veOgvFromOgvLockup, From 0eeca8f55638b995ab2b9b26688d38be4d266940 Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:54:52 +0530 Subject: [PATCH 2/2] Prettify --- client/components/vote-escrow/LockupForm.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/components/vote-escrow/LockupForm.tsx b/client/components/vote-escrow/LockupForm.tsx index 2fc9b689..2e0fe59d 100644 --- a/client/components/vote-escrow/LockupForm.tsx +++ b/client/components/vote-escrow/LockupForm.tsx @@ -145,7 +145,8 @@ const LockupForm: FunctionComponent = ({ existingLockup }) => { // as specified here: https://github.com/OriginProtocol/ousd-governance/blob/master/contracts/OgvStaking.sol#L21 const votingDecayFactor = 1.8; - const veOgvFromOgvLockup = lockupAmount * votingDecayFactor ** (lockupDuration / 12); + const veOgvFromOgvLockup = + lockupAmount * votingDecayFactor ** (lockupDuration / 12); const ogvLockupRewardApy = getRewardsApy( veOgvFromOgvLockup,