For the complete documentation index, see llms.txt. This page is also available as Markdown.

currentDistributionCycle

Returns the distribution cycle at poxInfo.currentBurnchainBlockHeight. Pure computation that mirrors the pox-5 read-only current-distribution-cycle without a request.


Usage

import {
  currentDistributionCycle,
  distributionCycleToBurnHeight,
  fetchLastRewardComputeHeight,
  fetchPoxInfo,
} from '@stacks/bitcoin-staking';

const poxInfo = await fetchPoxInfo({ network: 'mainnet' });

const distributionCycle = currentDistributionCycle(poxInfo);
const calculationHeight = distributionCycleToBurnHeight({ distributionCycle, poxInfo }) - 1;

const lastComputed = await fetchLastRewardComputeHeight({ network: 'mainnet' });
const rewardsPending = calculationHeight > lastComputed;

Notes

  • Same as burnHeightToDistributionIndex with burnHeight: poxInfo.currentBurnchainBlockHeight. The result is only as current as poxInfo.

  • calculate-rewards settles at the last block of the previous distribution cycle: the current cycle's start height minus 1. It fails with ERR_DISTRIBUTION_ALREADY_COMPUTED (u30) once that height has been computed.

  • Throws an Error with the message burnHeight is before first-burnchain-block-height if the current height is below poxInfo.firstBurnchainBlockHeight.


Signature


Returns

number

The current distribution cycle index.


Parameters

poxInfo (required)

  • Type: PoxInfo

A PoxInfo, usually from fetchPoxInfo.

Was this helpful?