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 bigintNotes
calculate-rewardsadds the amount it distributes, minus the reserve deposit (calculate-rewards).claim-rewardssubtracts 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
Errorwhose message starts withError calling read-only function.and includes the status code and URL. If the node reports that the call failed, theErrormessage is the node'scause.
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?