Created
July 28, 2020 11:21
-
-
Save vetri02/4dbc91f97fc03d9cce9feed8f5d52a64 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
validators.result.map(async item => { | |
const maticValidatorContract = new this.web3.eth.Contract( | |
maticABI, | |
item.contractAddress | |
); | |
const stakeManagerContractAddress = await maticValidatorContract.methods | |
.stakeManager() | |
.call() | |
.then(response => response); | |
const stakeManagerContract = new this.web3.eth.Contract( | |
stakeManagerABI, | |
stakeManagerContractAddress | |
); | |
const checkPointRewards = await stakeManagerContract.methods.CHECKPOINT_REWARD.call().then( | |
response => response | |
); | |
const currentValidatorSetTotalStake = await stakeManagerContract.methods.currentValidatorSetTotalStake | |
.call() | |
.then(response => response); | |
const bnCheckPointRewards = new BigNumber(checkPointRewards); | |
const bncurrentValidatorSetTotalStake = new BigNumber( | |
currentValidatorSetTotalStake | |
); | |
const yearlyCheckpointCount = new BigNumber(17520); | |
const yearlyRewardAmount = yearlyCheckpointCount.multipliedBy( | |
bnCheckPointRewards | |
); | |
const APR = yearlyRewardAmount.dividedBy( | |
bncurrentValidatorSetTotalStake | |
); | |
item.apr = APR.toNumber(); | |
return item; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment