Skip to content

Commit

Permalink
Fixed veOgv bug on dApp (#371)
Browse files Browse the repository at this point in the history
* fixed veOgv bug

* add comment for epoch and remove console log
  • Loading branch information
HrikB authored Feb 2, 2023
1 parent 3054726 commit 1474417
Show file tree
Hide file tree
Showing 6 changed files with 39,793 additions and 8,577 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ retroactive/progress.json
.env
scripts/claims.json
scripts/claims_dev.json
.vscode
12 changes: 10 additions & 2 deletions client/components/vote-escrow/LockupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,16 @@ const LockupForm: FunctionComponent<LockupFormProps> = ({ 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);
// 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 ogvLockupRewardApy = getRewardsApy(
veOgvFromOgvLockup,
Expand Down
Loading

0 comments on commit 1474417

Please sign in to comment.