Last active
July 27, 2019 23:10
-
-
Save jafri/b3b99fad824b5e6ab221b0502776f881 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calculateVoteWeight () { | |
let decayWeeks = 13 | |
let timestamp_epoch = 946684800000 | |
let dates = (Date.now() / 1000) - (timestamp_epoch / 1000) | |
let weight = Math.floor(dates / (86400 * 7)) / decayWeeks | |
return Math.pow(2, weight) | |
} | |
async calculateVoteDecayPercentage (staked, last_vote_weight) { | |
let stake = staked / Math.pow(10, 8) | |
const lastVoteWeight = (last_vote_weight / calculateVoteWeight()) / Math.pow(10, 8) | |
return (lastVoteWeight / stake).toFixed(2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment