```js BLOCKS_PER_ROUND = 1800; // each round has 1800 blocks POINTS_PER_BLOCK = 20; // producing 1 block will get 20 points MIN_DELEGATION = 500; // staking 500 manta at least collatorCandidates = onChainData // parachainStaking.candidateInfo totalActiveCollators = filterInactiveCollator(collatorCandidates) annualInflation = totalSupply * 2% blocksPreviousRound = totalPoints(collator) / POINTS_PER_BLOCK collatorCommission = 10% collatorExpectedBlocksPerRound = BLOCKS_PER_ROUND / collatorCandidates.length annualRewardsPerCollator = annualInflation / totalActiveCollators adjustmentFactor = blocksPreviousRound / collatorExpectedBlocksPerRound marginalReward = annualRewardsPerCollator * MIN_DELEGATION / (collatorTotalStaked + MIN_DELEGATION) APY = (1.0 - collatorCommission) * 100 * adjustmentFactor * marginalReward / MIN_DELEGATION; ```