Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1x 1x 1x 1x 12x 1x 4x 4x 4x 4x | import { stxToMicroStx } from '@utils/unit-convert'; import { BigNumber } from 'bignumber.js'; const BigNumberFloorRound = BigNumber.clone({ ROUNDING_MODE: BigNumber.ROUND_FLOOR }); export function calculateRewardSlots(ustxAmount: BigNumber, minRequireToStack: BigNumber) { return new BigNumberFloorRound(ustxAmount).dividedBy(minRequireToStack).integerValue(); } export function calculateStackingBuffer(ustxAmount: BigNumber, minRequireToStack: BigNumber) { const numberOfRewardSlots = calculateRewardSlots(ustxAmount, minRequireToStack); const stxBuffer = numberOfRewardSlots .multipliedBy(minRequireToStack) .minus(ustxAmount) .absoluteValue(); const stackingIncrements = stxToMicroStx(10_000); return new BigNumberFloorRound(stxBuffer) .dividedBy(stackingIncrements) .integerValue() .multipliedBy(stackingIncrements); } |