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

fetchLastAccountedRewards

Reads the sBTC, in sats, that calculate-rewards has distributed to the protocol bond and STX-only staking tranches and that signer-managers have not yet claimed. Wraps the pox-5 read-only get-last-accounted-rewards-only, which returns the last-accounted-rewards-only data-var.


Usage

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

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

Notes

  • calculate-rewards adds the amount it distributes, minus the reserve deposit (calculate-rewards). claim-rewards subtracts the amount it pays (claim-rewards).

  • fetchRewards minus this value is fetchNewRewards (get-new-rewards).

  • The data-var starts at 0 (last-accounted-rewards-only).

  • 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 fetchLastAccountedRewards(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?