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

fetchReserveBalance

Reads the sBTC, in sats, held for the reserve fund tranche. Wraps the pox-5 read-only get-reserve-balance, which returns the reserve-balance data-var.


Usage

import { fetchReserveBalance } from '@stacks/bitcoin-staking';

const reserve = await fetchReserveBalance({ network: 'mainnet' }); // sats of sBTC, as a bigint

Notes

  • Each calculate-rewards adds 15% (RESERVE_RATIO, 1,500 basis points) of the rewards left after the protocol bond tranche. When no STX is staked in the cycle, it also adds the STX-only staking tranche's part (calculate-rewards).

  • Only transfer-from-reserve lowers it. That function is private and nothing in pox-5 calls it. Its comment says only the node can call it, as part of consensus through the SIP process (transfer-from-reserve).

  • fetchRewards excludes this amount.

  • A non-2xx response throws an Error whose message starts with Error calling read-only function. and includes the status code and URL. If the node reports that the call failed, the Error message is the node's cause.

Reference Link


Signature

function fetchReserveBalance(opts?: NetworkClientParam): Promise<bigint>;

opts is a NetworkClientParam.


Returns

Promise<bigint>

Resolves to an amount of sBTC in sats.


Parameters

opts.network (optional)

  • Type: StacksNetworkName | StacksNetwork

The network to query: a name such as 'mainnet' or 'testnet', or a StacksNetwork object. Defaults to 'mainnet'.

opts.client (optional)

  • Type: { baseUrl?: string; fetch?: FetchFn }

Overrides the API base URL or the fetch function, for example to query your own node. Fields you set replace the network's defaults.

Was this helpful?