Skip to content

Instantly share code, notes, and snippets.

@vetri02
Created July 28, 2020 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vetri02/4dbc91f97fc03d9cce9feed8f5d52a64 to your computer and use it in GitHub Desktop.
Save vetri02/4dbc91f97fc03d9cce9feed8f5d52a64 to your computer and use it in GitHub Desktop.
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