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

minUstxForSatsAmount

Returns the minimum micro-STX a staker must lock alongside a sats amount in a bond. Pure computation that mirrors the pox-5 read-only min-ustx-for-sats-amount.


Usage

import { fetchProtocolBond, minUstxForSatsAmount } from '@stacks/bitcoin-staking';

minUstxForSatsAmount({ sats: 1_000_000n, stxValueRatio: 2_000n, minUstxRatioBps: 500 }); // 1000000n

const bond = await fetchProtocolBond({ bondIndex: 1, network: 'mainnet' });
if (bond) {
  const minUstx = minUstxForSatsAmount({
    sats: 10_000_000n, // 0.1 BTC in sats
    stxValueRatio: bond.stxValueRatio,
    minUstxRatioBps: bond.minUstxRatioBps,
  });
}

Notes

  • Computes ((stxValueRatio * sats) / 100) * minUstxRatioBps / 10000 in bigint, rounding down at each division as the contract does.

  • register-for-bond fails with ERR_INSUFFICIENT_STX (u8) when amount-ustx is below this value for the staked sats.

  • Both ratios are fixed per bond by setup-bond. Read them from fetchProtocolBond.


Signature


Returns

bigint

The minimum amount in micro-STX.


Parameters

opts.sats (required)

  • Type: IntegerType

The BTC or sBTC amount to stake, in sats. Accepts number, string, bigint or Uint8Array.

opts.stxValueRatio (required)

  • Type: IntegerType

The bond's stx-value-ratio: micro-STX per 100 sats.

opts.minUstxRatioBps (required)

  • Type: IntegerType

The bond's min-ustx-ratio in basis points. 500 is 5%.

Was this helpful?