config#GLIDE_BONUS_PERIOD TypeScript Examples
The following examples show how to use
config#GLIDE_BONUS_PERIOD.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: calculations.ts From glide-frontend with GNU General Public License v3.0 | 6 votes |
getGlidesPerYear = (currentBlock: BigNumber) => {
// Reward sum
let rewardSum = new BigNumber(0)
let totalBlocks = BLOCKS_PER_YEAR
if (currentBlock.lt(GLIDE_START_BLOCK)) {
totalBlocks = totalBlocks.minus(GLIDE_START_BLOCK.minus(currentBlock))
}
let iterationBlocks = GLIDE_START_BLOCK.plus(1)
const currentPhase = phase(currentBlock)
// Calculate reward sum
while (totalBlocks.gt(0)) {
let nextBlockBorder
const iterationPhase = phase(iterationBlocks)
if (iterationPhase === 1) {
nextBlockBorder = GLIDE_BONUS_PERIOD
} else {
nextBlockBorder = GLIDE_REDUCTION_PERIOD
}
// If loop is same or after current block phase
if (currentPhase > 0 && iterationPhase >= currentPhase) {
let blocksForReward
if (iterationPhase === currentPhase) {
blocksForReward = iterationBlocks.minus(currentBlock)
} else if (iterationPhase > currentPhase) {
blocksForReward = nextBlockBorder
}
// Calculate rewards for current loop phase
blocksForReward = totalBlocks.minus(blocksForReward).gt(0) ? blocksForReward : totalBlocks
// Calculate reward sum before and for current loop phase
rewardSum = rewardSum.plus(rewardPerPhase(iterationPhase).multipliedBy(new BigNumber(blocksForReward)))
totalBlocks = totalBlocks.minus(blocksForReward)
}
iterationBlocks = iterationBlocks.plus(nextBlockBorder)
}
return rewardSum
}