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

BondPhaseRange

One named phase of a bond's lifecycle as a range of Bitcoin block heights. bondPhaseRanges returns one per BondPhaseName, in order.


Usage

import { bondPhaseRanges, fetchPoxInfo } from '@stacks/bitcoin-staking';

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

const current = bondPhaseRanges({ bondIndex: 0, poxInfo }).find(
  range => height >= range.startBurnHeight && height < range.endBurnHeight
);
const blocksLeft = current ? current.endBurnHeight - height : undefined;

Definition

interface BondPhaseRange {
  /** Phase label. See {@link BondPhaseName}. */
  name: BondPhaseName;
  /** Inclusive start burn-block height. */
  startBurnHeight: number;
  /** Number of burn blocks the phase spans. */
  length: number;
  /**
   * Exclusive end burn-block height (`startBurnHeight + length`). The next
   * phase, if any, begins at this height.
   */
  endBurnHeight: number;
}

Properties

Property
Type
Description

name

BondPhaseName

Phase label: 'open', 'locked', 'unlocked' or 'finished'

startBurnHeight

number

First Bitcoin block height of the phase, inclusive

length

number

Number of Bitcoin blocks in the phase

endBurnHeight

number

startBurnHeight + length, exclusive. The next phase starts here

Was this helpful?