fetchTotalSbtcStakedForBond
Calls the pox-5 get-total-sbtc-staked-for-bond read-only and returns the total sats recorded for a protocol bond.
Usage
import { fetchTotalSbtcStakedForBond } from '@stacks/bitcoin-staking';
const totalSats = await fetchTotalSbtcStakedForBond({ bondIndex: 1, network: 'mainnet' }); // sats, as a bigintNotes
Reads the
protocol-bonds-total-stakedmap throughget-total-sbtc-staked-for-bond. Returns0nwhen there is no entry.The total counts sats from Bitcoin L1 lockups and from sBTC alike:
register-for-bondadds the registration's sats whichever path the staker used (L673-L676).register-for-bondsets the value to the bond's first-cycle share total plus the new registration's sats (L704-L706, L793-L795).announce-l1-early-exit(L1238-L1240) andunstake-sbtc(L1312-L1315) subtract the sats they release.For the bond's share total in a specific reward cycle, the figure pox-5 uses when it computes rewards, call fetchTotalSharesStakedForCycle with
bondIndex.Throws an
Errorif the node returns a non-2xx status (the message starts withError calling read-only function.) or answersokay: false(the message is the node'scause).
Signature
function fetchTotalSbtcStakedForBond(
opts: { bondIndex: number } & NetworkClientParam
): Promise<bigint>;opts is a NetworkClientParam plus bondIndex.
Returns
Promise<bigint>
Total sats recorded for the bond.
Parameters
opts.bondIndex (required)
Type:
number
Index of the protocol bond.
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?