bondPeriodToRewardCycle
Returns the first reward cycle of a bond. Pure computation that mirrors the pox-5 read-only bond-period-to-reward-cycle.
Usage
import { bondPeriodToRewardCycle, fetchPoxInfo } from '@stacks/bitcoin-staking';
const poxInfo = await fetchPoxInfo({ network: 'mainnet' });
const firstCycle = bondPeriodToRewardCycle({ bondIndex: 3, poxInfo });
// firstPox5RewardCycle(poxInfo) + 3 * 2Notes
Computes
firstPox5RewardCycle(poxInfo) + bondIndex * 2. Bond periods start every 2 reward cycles (BOND_GAP_CYCLES), and each bond runs for 12 (BOND_LENGTH_CYCLES).Throws an
Errorwhose message starts withpox-5 not activated yetifpoxInfo.contractVersionshas no pox-5 entry. See firstPox5RewardCycle.
Signature
function bondPeriodToRewardCycle(opts: { bondIndex: number; poxInfo: PoxInfo }): number;Returns
number
The bond's first reward cycle.
Parameters
opts.bondIndex (required)
Type:
number
The bond index. Bond 0 starts in the first pox-5 reward cycle.
opts.poxInfo (required)
Type:
PoxInfo
A PoxInfo, usually from fetchPoxInfo.
Was this helpful?