Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix APY calc #389

Merged
merged 2 commits into from
Jul 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions client/components/vote-escrow/LockupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,8 @@ const LockupForm: FunctionComponent<LockupFormProps> = ({ 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,
Expand Down