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

PoxInfo

The PoX parameters, current and next cycle, and sBTC contracts from the node's /v2/pox endpoint, as returned by fetchPoxInfo. The cycle helpers such as bondPeriodToBurnHeight and isInPreparePhase compute from it without another network call.


Usage

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

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

const inPrepare = isInPreparePhase({ burnHeight: poxInfo.currentBurnchainBlockHeight, poxInfo });
const bondStart = bondPeriodToBurnHeight({ bondIndex: 0, poxInfo });

Notes

  • The bond helpers take the first pox-5 reward cycle from the contractVersions entry whose contractId ends in .pox-5. If there is no such entry, for example because the node omits contract_versions, they throw an Error whose message starts with pox-5 not activated yet.

Reference Link


Definition

export interface PoxInfo {
  /** Fully-qualified pox contract id. */
  contractId: string;
  /** Current burnchain block height. */
  currentBurnchainBlockHeight: number;
  /** Burnchain height at which PoX began. */
  firstBurnchainBlockHeight: number;
  /** Reward cycle currently in progress. */
  rewardCycleId: number;
  /** Reward cycle length in burnchain blocks. */
  rewardCycleLength: number;
  /** Prepare phase length in burnchain blocks. */
  prepareCycleLength: number;
  /** Reward slots per cycle. */
  rewardSlots: number;
  /** Current reward cycle summary. */
  currentCycle: CycleInfo;
  /** Next reward cycle summary. */
  nextCycle: NextCycleInfo;
  /** One entry per deployed pox contract version (pox through pox-5). */
  contractVersions: PoxContractVersion[];
  /**
   * sBTC token contract this node uses for pox-5 payments. Fixed on mainnet;
   * node-configured elsewhere, so read it rather than hardcoding it.
   */
  sbtcContract: string;
  /** sBTC registry contract the node reads the per-cycle waterfall recipient from. */
  sbtcRegistryContract: string;
}

Properties

Property

Type

From /v2/pox

Description

contractId

string

contract_id

Active PoX contract, SP000000000000000000002Q6VF78.pox-5 on mainnet

currentBurnchainBlockHeight

number

current_burnchain_block_height

Bitcoin block height the node has reached

firstBurnchainBlockHeight

number

first_burnchain_block_height

Bitcoin block height at which PoX began

rewardCycleId

number

reward_cycle_id

Reward cycle in progress

rewardCycleLength

number

reward_cycle_length

Cycle length in Bitcoin blocks, 2,100 on mainnet

prepareCycleLength

number

prepare_cycle_length

Prepare phase length in Bitcoin blocks, 100 on mainnet

rewardSlots

number

reward_slots

Reward slots per cycle

currentCycle

CycleInfo

current_cycle

Current cycle ID, micro-STX staked, and whether PoX is active

nextCycle

NextCycleInfo

next_cycle

Next cycle ID and micro-STX staked for it so far

contractVersions

PoxContractVersion[]

contract_versions

One entry per PoX contract version, pox through pox-5. Empty if the node omits the field

sbtcContract

string

pox_5_sbtc_contract

sBTC token contract pox-5 pays through

sbtcRegistryContract

string

pox_5_sbtc_registry_contract

sBTC registry the node reads the reward recipient from

Was this helpful?