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

fetchNewRewards

Reads the sBTC, in sats, that pox-5 has received as rewards since the last calculate-rewards. Wraps the pox-5 read-only get-new-rewards.


Usage

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

const [rewards, lastAccounted, newRewards] = await Promise.all([
  fetchRewards({ network: 'mainnet' }),
  fetchLastAccountedRewards({ network: 'mainnet' }),
  fetchNewRewards({ network: 'mainnet' }),
]);
// At the same chain tip: newRewards === rewards - lastAccounted

Notes

  • get-new-rewards returns get-rewards minus the last-accounted-rewards-only data-var (get-new-rewards).

  • The next calculate-rewards distributes this amount (calculate-rewards). The protocol bond tranche is paid first, each bond up to its target yield (calculate-bond-rewards). The reserve fund tranche takes 15% of the remainder (RESERVE_RATIO, 1,500 basis points), and the STX-only staking tranche gets the rest. When no STX is staked in the cycle, the STX-only staking tranche's part also goes to the reserve fund tranche (calculate-rewards).

  • 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.


Signature


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?