/** Account derived from a local private key (mnemonic or raw key). */ type LocalAccount = { type: "local" address: string /** Compressed public key (hex) */ publicKey: string /** Raw ECDSA sign over a hash */ sign(hash: Uint8Array): Uint8Array /** Sign a raw UTF-8 / byte message (`sha256(bytes)`). Not SIP-018. */ signMessage(message: string | Uint8Array): string }; /** Account with a user-provided signing function (sync or async). */ type CustomAccount = { type: "custom" address: string publicKey: string sign(hash: Uint8Array): Promise | Uint8Array }; /** Browser wallet provider interface (e.g. Leather, Xverse). */ type StacksProvider = { request(method: string, params?: any): Promise }; /** Account backed by a browser wallet {@link StacksProvider}. */ type ProviderAccount = { type: "provider" address: string publicKey: string provider: StacksProvider }; type IntCV = { readonly type: "int" readonly value: bigint }; type UIntCV = { readonly type: "uint" readonly value: bigint }; type BooleanCV = TrueCV | FalseCV; type TrueCV = { readonly type: "true" }; type FalseCV = { readonly type: "false" }; type BufferCV = { readonly type: "buffer" readonly value: string }; type NoneCV = { readonly type: "none" }; type SomeCV = { readonly type: "some" readonly value: ClarityValue }; type ResponseOkCV = { readonly type: "ok" readonly value: ClarityValue }; type ResponseErrorCV = { readonly type: "err" readonly value: ClarityValue }; type StandardPrincipalCV = { readonly type: "address" readonly value: string }; type ContractPrincipalCV = { readonly type: "contract" readonly value: string }; type ListCV = { type: "list" value: ClarityValue[] }; type TupleData = { [key: string]: ClarityValue }; type TupleCV = { type: "tuple" value: TupleData }; type StringAsciiCV = { readonly type: "ascii" readonly value: string }; type StringUtf8CV = { readonly type: "utf8" readonly value: string }; type ClarityValue = IntCV | UIntCV | BooleanCV | BufferCV | NoneCV | SomeCV | ResponseOkCV | ResponseErrorCV | StandardPrincipalCV | ContractPrincipalCV | ListCV | TupleCV | StringAsciiCV | StringUtf8CV; /** Allocates mempool-safe sequential nonces across rapid broadcasts from one account. */ type NonceManager = { consume(params: { client: Client address: string }): Promise reset(params: { client: Client address: string }): void | Promise /** * Give back a nonce from {@link NonceManager.consume} whose transaction * was never accepted by the node. No-op unless it is the latest issued. */ release(params: { client: Client address: string nonce: bigint }): void | Promise /** Next nonce that {@link NonceManager.consume} would return without consuming it, or `undefined` if untracked. */ peek(params: { client: Client address: string }): Promise }; /** Full chain descriptor used by clients and transports for network-aware operations. */ type StacksChain = { /** Chain ID (e.g. 0x00000001 for mainnet) */ id: number /** Human-readable name */ name: string /** Network type */ network: "mainnet" | "testnet" /** Transaction version byte for serialization */ transactionVersion: number /** Peer network ID for P2P broadcasting */ peerNetworkId: number /** Address version bytes */ addressVersion: { singleSig: number multiSig: number } /** Magic bytes for network identification */ magicBytes: string /** Boot address (system contracts deployer) */ bootAddress: string /** Native currency info */ nativeCurrency: { name: string symbol: string decimals: number } /** Default RPC URLs */ rpcUrls: { default: { http: string[] ws?: string[] } } /** Block explorer URLs */ blockExplorers?: { default: { name: string url: string } } }; /** Function that sends an HTTP request to a Stacks node API path. */ type RequestFn = (path: string, options?: RequestOptions) => Promise; /** Options for a transport-level HTTP request. */ type RequestOptions = { method?: "GET" | "POST" | "PUT" | "DELETE" body?: unknown headers?: Record /** * Cancel the request from the caller's side. An aborted signal rejects * with the signal's reason immediately and never retries; it is combined * with the transport's own per-attempt timeout. */ signal?: AbortSignal /** * Override the transport's retry budget for this one request. Broadcasts * pass `0`: re-sending a transaction the node may already hold trades a * transient failure for a confusing nonce conflict. */ retryCount?: number }; /** Shared configuration for all transport types. */ type TransportConfig = { url?: string /** * Per-attempt deadline in ms covering headers AND body. A stalled body * rejects with `TimeoutError` instead of hanging. Default 30_000. */ timeout?: number retryCount?: number retryDelay?: number fetchOptions?: RequestInit /** Sent as `x-api-key`. Held in the request closure and stripped from * `Transport.config` so it never prints with the client. */ apiKey?: string }; /** A resolved transport instance with a bound request function. */ type Transport = { type: string request: RequestFn config: TransportConfig destroy?: () => void }; /** Union of all supported account types (local key, custom signer, or browser provider). */ type Account = LocalAccount | CustomAccount | ProviderAccount; /** * Core client instance that holds chain context, transport, and extensible actions. * Created via {@link createClient}, {@link createPublicClient}, or {@link createWalletClient}. */ type Client = Record> = { chain?: StacksChain account?: Account transport: Transport request: RequestFn /** Optional nonce manager for mempool-safe sequential nonces across rapid broadcasts. */ nonceManager?: NonceManager extend: >(fn: (client: Client) => TNew) => Client & TNew } & TExtended; /** * Chain-reported PoX-5 activation facts, read from the node's `/v2/pox` * `contract_versions[]`. Present the moment nodes run stacks-core >= 4.0.0 — * no hardcoded heights, works on any network. */ type Pox5Activation = { /** Fully-qualified `pox-5` contract id (boot address differs per network). */ contractId: string /** Bitcoin block height at which Epoch 4.0 (and pox-5) activates. */ activationBurnchainBlockHeight: number /** First reward cycle in which pox-5 governs PoX. */ firstRewardCycleId: number }; /** * `/v2/pox` fields a pox-5 integration actually needs. `sbtcContract` is * compiled into the boot contract per network — never hardcode it. */ type Pox5Info = { contractId?: string currentBurnchainBlockHeight?: number firstBurnchainBlockHeight?: number /** Token principal pox-5 custodies. Read this for sBTC post-conditions. */ sbtcContract?: string sbtcRegistryContract?: string contractVersions: Array<{ contractId: string activationBurnchainBlockHeight: number firstRewardCycleId: number }> }; declare function getPoxInfo2(client: Client): Promise; /** * Read pox-5's activation entry from the node. Returns `undefined` when the * node doesn't know about pox-5 yet (pre-4.0.0 node software). */ declare function getPox5Activation(client: Client): Promise; /** * Whether pox-5 is live on the node's chain: the node software knows the * contract AND the burnchain has reached its activation height. One request. */ declare function isPox5Active(client: Client): Promise; /** Throw a descriptive error unless pox-5 is active on the client's chain. */ declare function assertPox5Active(client: Client): Promise; /** * Numeric `(err uN)` codes from pox-5. Missing numbers were never assigned * on-chain. Pair with {@link parsePox5Error} / {@link describePox5Error}. */ declare const Pox5ErrorCode: { readonly Unauthorized: 1 readonly CannotSetupBondTooSoon: 2 readonly CannotSetupBondTooLate: 3 readonly BondAlreadySetup: 4 readonly StakerAlreadyAdded: 5 readonly BondNotFound: 7 readonly InsufficientStx: 8 readonly AlreadyRegistered: 9 readonly TooMuchSats: 10 readonly NotAllowlisted: 11 readonly SignerKeyGrantUsed: 12 readonly InvalidSignatureRecover: 13 readonly InvalidSignaturePubkey: 14 readonly SignerKeyGrantNotFound: 17 readonly AlreadyStaked: 19 readonly InvalidNumCycles: 20 readonly SignerNotFound: 23 readonly InvalidStartBurnHeight: 24 readonly UnauthorizedSignerRegistration: 26 readonly NotStaking: 27 readonly UnstakeInPreparePhase: 28 readonly InvalidBondPeriodOrdering: 29 readonly DistributionAlreadyComputed: 30 readonly BondNotActive: 31 readonly NoClaimableRewards: 32 readonly ActiveBondNotIncluded: 33 readonly NotBondParticipant: 34 readonly CannotAnnounceL1EarlyUnlock: 35 readonly InvalidOldSignerManager: 36 readonly InvalidUnstakeSbtcAmount: 37 readonly CannotUnstakeSbtc: 38 readonly ReadTxOutOfBounds: 39 readonly InvalidBtcHeader: 40 readonly InvalidMerkleProof: 41 readonly InvalidLockupScript: 42 readonly BondAlreadyStarted: 43 readonly UpdateBondSameSigner: 44 readonly InvalidLockupAmount: 45 readonly DuplicateLockupOutpoint: 46 readonly StakeInPreparePhase: 47 readonly RolloverTooEarly: 48 readonly ReentrantCall: 49 readonly L1EarlyExitAlreadyAnnounced: 50 readonly InsufficientReserveBalance: 51 readonly InvalidUnlockHeight: 52 readonly RewardsPaused: 53 }; type Pox5ErrorCode = (typeof Pox5ErrorCode)[keyof typeof Pox5ErrorCode]; declare const POX5_ERROR_NAMES: Record; /** Extract `(err uN)` from a Clarity value or Hiro `repr` string. */ declare function parsePox5Error(result: ClarityValue | string | undefined): number | undefined; declare function describePox5Error(code: number | bigint): { code: number name: string description: string } | undefined; /** * Stacks hard-fork epoch activation heights, as Bitcoin burn block heights. * * Epoch 4.0 carries both SIP-044 (the native Bitcoin SPV built-ins / Clarity 6) * and SIP-045 (`pox-5` Bitcoin Staking) — one fork, one height. Keep it here so * the two modules can never disagree. */ /** * Epoch 4.0 activation height on mainnet — Bitcoin block 960,230 (~2026-07-30 * AM UTC, per the stacks-core 4.0.1 release notes). * * Only mainnet has a fixed height. On other networks, read it from the node * (`getPox5Activation` for pox-5) or pass it explicitly. */ declare const EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET = 960230; /** Boot contract name; deployer is the chain's boot address. */ declare const POX5_CONTRACT_NAME = "pox-5"; /** Fully-qualified mainnet contract id (boot address + `pox-5`). */ declare const POX5_CONTRACT_ID_MAINNET: string; /** * All print-event topic strings emitted by `pox-5.clar`. Unlike pox-2/3/4, * pox-5 has NO node-synthesized events — every event is a real `(print ...)` * with these `topic` values and the remaining tuple fields flattened at the * top level via `merge` (not nested under a `data` key). * * `add-to-allowlist` and `bond-distribution` are emitted per-item inside * folds (`setup-bond` / `calculate-rewards`), so one transaction can carry * many prints. */ declare const POX5_EVENT_TOPICS: readonly ["set-bond-admin", "set-pause-admin", "pause-rewards", "setup-bond", "add-to-allowlist", "register-for-bond", "update-bond-registration", "register-signer", "stake", "stake-update", "announce-l1-early-exit", "unstake-sbtc", "unstake", "calculate-rewards", "bond-distribution", "claim-rewards", "claim-staker-rewards-for-signer", "grant-signer-key", "revoke-signer-grant"]; type Pox5EventTopic = (typeof POX5_EVENT_TOPICS)[number]; /** * Epoch 4.0 hard-fork activation height on mainnet — see * {@link EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET}. Prefer the runtime gate in * `activation.ts` (`getPox5Activation`), which reads the node's `/v2/pox` and * works on every network. */ declare const POX5_ACTIVATION_BURN_HEIGHT_MAINNET: typeof EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET; /** Length of a paired-BTC bond, in reward cycles (`BOND_LENGTH_CYCLES`). */ declare const BOND_LENGTH_CYCLES = 12; /** Gap between consecutive bond starts, in reward cycles (`BOND_GAP_CYCLES`). */ declare const BOND_GAP_CYCLES = 2; /** Hard cap for STX-only stake duration, in cycles (`MAX_NUM_CYCLES`). */ declare const MAX_NUM_CYCLES = 96; /** SIP-018 domain for signer-key grants (`POX_5_SIGNER_DOMAIN`). */ declare const POX5_SIGNER_DOMAIN: { readonly name: "pox-5-signer" readonly version: "1.0.0" }; /** * `serialize-c-script-num` rejects values at or above 2^39 — the ceiling of a * 5-byte minimally-encoded ScriptNum (`ERR_INVALID_UNLOCK_HEIGHT`). */ declare const C_SCRIPT_NUM_MAX = 549755813888n; /** * Bitcoin treats CLTV values >= 500,000,000 as Unix timestamps (BIP-65); the * contract rejects unlock heights at or above this so a lockup can never * commit a height Bitcoin would reinterpret. */ declare const BITCOIN_LOCKTIME_THRESHOLD = 500000000n; type IntegerType = number | string | bigint | Uint8Array; /** * Named fee tiers. `'low' | 'mid' | 'high'` map to the node's three fee * estimations; `'min'` is the node's minimum relay fee — 1 uSTX per byte of * the serialized transaction, computable offline. */ type FeeTier = "min" | "low" | "mid" | "high"; /** Fee input accepted by wallet actions: an explicit amount or a named tier. */ type FeeParam = IntegerType | FeeTier; type FungibleComparator = "eq" | "gt" | "gte" | "lt" | "lte"; type NonFungibleComparator = "sent" | "not-sent" | "maybe-sent"; type StxPostCondition = { type: "stx-postcondition" address: string condition: FungibleComparator amount: string | bigint | number }; type FtPostCondition = { type: "ft-postcondition" address: string condition: FungibleComparator asset: string amount: string | bigint | number }; type NftPostCondition = { type: "nft-postcondition" address: string condition: NonFungibleComparator asset: string assetId: ClarityValue }; type StakingPostCondition = { type: "staking-postcondition" address: string condition: FungibleComparator amount: string | bigint | number }; type PoxComparator = "will-not-perform" | "may-perform" | "will-perform"; type PoxPostCondition = { type: "pox-postcondition" address: string condition: PoxComparator }; type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition; /** Serialized PC hex is accepted anywhere a `PostCondition` object is. */ type PostConditionInput = PostCondition | string; type PostConditionMode = "allow" | "deny" | "originator"; /** * Mapped read-return types for the pox-5 contract — the JS shapes * `getContract` produces from the ABI (camelCase keys, `uint` → `bigint`, * `buff` → `Uint8Array`, `none` → `null`, response ok auto-unwrapped). */ /** Staker info from `get-staker-info`; `null` when expired/absent. */ type StakerInfo = { amountUstx: bigint firstRewardCycle: bigint numCycles: bigint signer: string } | null; /** Bond membership from `get-bond-membership`; `null` when not in a bond. */ type BondMembership = { amountSats: bigint amountUstx: bigint bondIndex: bigint isL1Lock: boolean signer: string } | null; /** Bond parameters from `get-protocol-bond`; `null` for an unknown bond. */ type ProtocolBond = { earlyUnlockBytes: Uint8Array minUstxRatio: bigint stxValueRatio: bigint targetRate: bigint } | null; /** Allowlisted max sats from `get-bond-allowance`; `null` when not allowlisted. */ type BondAllowance = bigint | null; /** Signer key from `get-signer-info`; `null` for an unknown signer. */ type SignerInfo = Uint8Array | null; /** * PoX-5 contract calls and reads, pinned against the final contract in * stacks-core 4.0.0. Wallet actions route through `callContract`, so they * inherit fee tiers, nonce management, and typed broadcast errors; pair the * returned txid with `waitForTransactionReceipt` to await inclusion. * * Note: pox-5 uses `contract-caller`/`tx-sender` directly (there is no * `allow-contract-caller` indirection like pox-4). Amount/lock safety is * expressed with the new Epoch 4.0 `Staking`/`Pox` post-conditions — pass * them via `postConditions` on any of these actions. */ /** Resolve the boot `pox-5` contract id for the client's chain. */ declare function pox5ContractId(client: Client): string; type TxOptions = { fee?: FeeParam nonce?: IntegerType postConditions?: PostConditionInput[] postConditionMode?: PostConditionMode }; /** * One proven L1 timelock output — a Bitcoin SPV inclusion proof of the lockup * tx plus which output is the lockup. `@secondlayer/stacks/bitcoin`'s * `buildTxProof` produces the proof fields. */ type L1LockupOutput = { /** Burn height of the Bitcoin block containing the lockup tx. */ height: IntegerType /** Raw Bitcoin tx (witness-stripped), hex or bytes. */ tx: Uint8Array | string outputIndex: IntegerType /** 80-byte Bitcoin block header. */ header: Uint8Array | string /** Merkle siblings, leaf→root (max 14). */ leafHashes: Array txCount: IntegerType txIndex: IntegerType /** Output value in sats. */ amount: IntegerType unlockBurnHeight: IntegerType }; /** BTC side of a bond registration: proven L1 lockups, or an sBTC amount. */ type BtcLockup = { l1Outputs: L1LockupOutput[] stakerUnlockBytes: Uint8Array | string } | { sbtcSats: IntegerType }; type SetupBondParams = TxOptions & { bondIndex: IntegerType /** Target yield rate, basis points. */ targetRate: IntegerType /** µSTX per 100 sats (BTCUSD / STXUSD representation). */ stxValueRatio: IntegerType /** Minimum locked STX relative to BTC, basis points. */ minUstxRatio: IntegerType /** Early-unlock subscript for this bond's L1 lockup scripts (max 683B). */ earlyUnlockBytes: Uint8Array | string allowlist: Array<{ staker: string maxSats: IntegerType }> }; type RegisterForBondParams = TxOptions & { bondIndex: IntegerType /** Signer-manager contract principal. */ signerManager: string amountUstx: IntegerType btcLockup: BtcLockup signerCalldata?: Uint8Array | string }; type UpdateBondRegistrationParams = TxOptions & { signerManager: string oldSignerManager: string signerCalldata?: Uint8Array | string }; type StakeParams = TxOptions & { signerManager: string amountUstx: IntegerType numCycles: IntegerType startBurnHeight: IntegerType signerCalldata?: Uint8Array | string }; type StakeUpdateParams = TxOptions & { signerManager: string oldSignerManager: string cyclesToExtend: IntegerType amountIncrease: IntegerType signerCalldata?: Uint8Array | string }; type UnstakeParams = TxOptions & { oldSignerManager: string }; type UnstakeSbtcParams = TxOptions & { signerManager: string amountSats: IntegerType }; type AnnounceL1EarlyExitParams = TxOptions & { staker: string oldSignerManager: string }; type CalculateRewardsParams = TxOptions & { bondPeriods: IntegerType[] }; type ClaimRewardsParams = TxOptions & { bondPeriods: IntegerType[] rewardCycle: IntegerType }; type ClaimStakerRewardsForSignerParams = TxOptions & { staker: string rewardCycle: IntegerType bondIndex?: IntegerType }; type GrantSignerKeyParams = TxOptions & { /** 33-byte compressed signer key. */ signerKey: Uint8Array | string signerManager: string authId: IntegerType /** 65-byte RSV signature from `signSignerGrant`. */ signerSig: Uint8Array | string }; type RevokeSignerGrantParams = TxOptions & { signerManager: string signerKey: Uint8Array | string }; type SetBondAdminParams = TxOptions & { newAdmin: string }; type SetPauseAdminParams = TxOptions & { newAdmin: string }; type PauseRewardsParams = TxOptions; type EligibilityResult = { ok: true } | { ok: false reasons: [Pox5ErrorCode, ...Pox5ErrorCode[]] }; type EligibleStakeParams = { staker: string signerManager: string amountUstx: IntegerType numCycles: IntegerType startBurnHeight: IntegerType }; type EligibleRegisterForBondParams = { staker: string bondIndex: IntegerType signerManager: string amountUstx: IntegerType btcLockup: BtcLockup }; type EligibleUnstakeParams = { staker: string oldSignerManager: string }; type EligibleUnstakeSbtcParams = { staker: string signerManager: string amountSats: IntegerType }; type EligibleClaimRewardsParams = { signer: string rewardCycle: IntegerType bondIndex?: IntegerType bondPeriods?: IntegerType[] }; type EligibleGrantSignerKeyParams = { signerKey: Uint8Array | string signerManager: string authId: IntegerType }; type EligibleAdminParams = { caller: string }; declare function eligibleStake2(client: Client, params: EligibleStakeParams): Promise; declare function eligibleRegisterForBond2(client: Client, params: EligibleRegisterForBondParams): Promise; declare function eligibleUnstake2(client: Client, params: EligibleUnstakeParams): Promise; declare function eligibleUnstakeSbtc2(client: Client, params: EligibleUnstakeSbtcParams): Promise; declare function eligibleClaimRewards2(client: Client, params: EligibleClaimRewardsParams): Promise; declare function eligibleGrantSignerKey2(client: Client, params: EligibleGrantSignerKeyParams): Promise; declare function eligibleSetBondAdmin2(client: Client, params: EligibleAdminParams): Promise; declare function eligiblePauseRewards2(client: Client, params: EligibleAdminParams): Promise; /** * Pure cycle/height math, mirroring the pox-5 helper read-onlys byte-for-byte * (`burn-height-to-reward-cycle`, `reward-cycle-to-burn-height`, * `bond-period-to-reward-cycle`, `burn-height-to-distribution-index`). * * All functions anchor on chain-reported parameters — pass values from * `/v2/pox` (`first_burnchain_block_height`, `reward_cycle_length`, * `prepare_cycle_length`) and `getPox5Activation` (`firstRewardCycleId` = * the contract's `first-bond-period-cycle`). Nothing is hardcoded, so the * math is correct on mainnet, testnet, and devnet alike. */ type PoxCycleParams = { /** `/v2/pox` `first_burnchain_block_height`. */ firstBurnchainBlockHeight: number /** `/v2/pox` `reward_cycle_length` (mainnet 2100). */ rewardCycleLength: number }; type BondCycleParams = PoxCycleParams & { /** pox-5's first bond-period cycle (`getPox5Activation().firstRewardCycleId`). */ firstBondPeriodCycle: number }; /** Reward cycle containing `burnHeight`. Mirrors `burn-height-to-reward-cycle`. */ declare function burnHeightToRewardCycle(burnHeight: number, params: PoxCycleParams): number; /** Burn height at the start of `cycle`. Mirrors `reward-cycle-to-burn-height`. */ declare function rewardCycleToBurnHeight(cycle: number, params: PoxCycleParams): number; /** Reward cycle at which bond period `bondIndex` starts. Mirrors `bond-period-to-reward-cycle`. */ declare function bondPeriodToRewardCycle(bondIndex: number, params: BondCycleParams): number; /** Burn height at which bond period `bondIndex` starts. Mirrors `bond-period-to-burn-height`. */ declare function bondPeriodToBurnHeight(bondIndex: number, params: BondCycleParams): number; /** First reward cycle in which bond `bondIndex`'s STX unlock (start + 12 cycles). */ declare function bondUnlockCycle(bondIndex: number, params: BondCycleParams): number; /** * Minimum L1 CLTV height for bond `bondIndex` — half a cycle before the * bond period ends. Mirrors `get-bond-l1-unlock-height`. Distinct from * {@link bondUnlockCycle} (the STX unlock cycle). */ declare function computeBondUnlockHeight(bondIndex: number, params: BondCycleParams): number; /** * Distribution-cycle index at `burnHeight` — distribution cycles are half a * reward cycle long. Mirrors `burn-height-to-distribution-index`. */ declare function burnHeightToDistributionIndex(burnHeight: number, params: PoxCycleParams): number; /** Burn height at the start of `distIndex`. Mirrors `distribution-cycle-to-burn-height`. */ declare function distributionCycleToBurnHeight(distIndex: number, params: PoxCycleParams): number; /** * Distribution cycle containing `burnHeight`. Named after the contract's * `current-distribution-cycle` but takes height as an argument — no clock. */ declare function currentDistributionCycle(burnHeight: number, params: PoxCycleParams): number; /** * Whether `burnHeight` falls in a cycle's prepare phase (the final * `prepareCycleLength` blocks). pox-5 rejects `unstake-sbtc` and * `announce-l1-early-exit` during a prepare phase. */ declare function isInPreparePhase(burnHeight: number, params: PoxCycleParams & { prepareCycleLength: number }): boolean; type BondPhase = "too-early" | "open" | "locked" | "unlocked"; /** * Coarse lifecycle phase of bond `bondIndex` at `burnHeight`: `too-early` * (before the bond's start is registerable), `open`/`locked` while active, * `unlocked` after 12 cycles. */ declare function bondPhaseAtHeight(bondIndex: number, burnHeight: number, params: BondCycleParams): BondPhase; /** * Prepare-aware bond lifecycle. `open` is the registerable window — it * ends when the start cycle's prepare phase begins (`register-for-bond` * then fails with `ERR_STAKE_IN_PREPARE_PHASE`). Coarse cycle buckets * (whole pre-start cycle as `open`) stay on {@link BondPhase}. * * `eligible`/`missed`/`finished` are omitted: they are not contract * states (registration is height-gated, not a per-staker enum). */ type BondStatusName = "too-early" | "open" | "locked" | "unlocked"; declare function bondStatusAtHeight(bondIndex: number, burnHeight: number, params: BondCycleParams & { prepareCycleLength: number }): BondStatusName; type BitcoinNetwork = "mainnet" | "testnet" | "regtest"; /** * Byte-for-byte TypeScript mirrors of pox-5's Bitcoin-script helpers * (`serialize-c-script-num`, `push-c-script-num`, `push-script-bytes`, * `construct-lockup-script`, `construct-lockup-output-script`), pinned * against the final contract in stacks-core 4.0.1. The contract validates a * staker's L1 lockup output against exactly these bytes, so any divergence * means a rejected registration — the read-onlys on-chain double as a * cross-check oracle for these functions. */ /** * Minimal little-endian ScriptNum encoding of a non-negative integer * (`0` → empty; a `0x00` sign byte is appended when the top byte's high bit * is set). Mirrors `serialize-c-script-num`, including its 2^39 ceiling. */ declare function serializeCScriptNum(n: number | bigint): Uint8Array; /** * Push arbitrary bytes onto a Bitcoin script: direct length byte under 76, * `OP_PUSHDATA1` under 256, `OP_PUSHDATA2` otherwise. Mirrors * `push-script-bytes`. */ declare function pushScriptBytes(bytes: Uint8Array): Uint8Array; /** * Push a numeric script value: `OP_0` for zero, the single-byte ops * `OP_1`..`OP_16` for 1–16, else a minimal ScriptNum push. Mirrors * `push-c-script-num`. */ declare function pushCScriptNum(n: number | bigint): Uint8Array; /** `to-consensus-buff?` of a principal — the staker identity the script commits to. */ declare function stakerConsensusBuff(stxAddress: string): Uint8Array; /** * The 32-byte witness item the early-exit branch must reveal: * `sha256(to-consensus-buff? staker)`. The script stores `sha256` of THIS, * so revealing it proves which staker the exit is for. */ declare function stakerPreimage(stxAddress: string): Uint8Array; type BuildLockupScriptOptions = { /** Staker principal (standard or contract address). */ stxAddress: string /** Burn height at which the CLTV branch becomes spendable. */ unlockBurnHeight: number | bigint /** Staker-signature subscript, run last in BOTH branches. */ stakerUnlockBytes: Uint8Array | string /** Per-bond early-unlock subscript (from `protocol-bonds.early-unlock-bytes`). */ earlyUnlockBytes: Uint8Array | string }; /** * The L1 lockup witness script. Mirrors `construct-lockup-script`: * * ``` * OP_IF * OP_CHECKLOCKTIMEVERIFY * OP_ELSE * OP_SIZE <32> OP_EQUALVERIFY OP_SHA256 * OP_EQUALVERIFY * * OP_ENDIF * OP_VERIFY * * ``` */ declare function buildLockupScript(opts: BuildLockupScriptOptions): Uint8Array; /** * P2WSH `scriptPubKey` for a lockup script: `0x0020 || sha256(script)`. * Mirrors `construct-lockup-output-script`. */ declare function buildLockupOutputScript(opts: BuildLockupScriptOptions): Uint8Array; /** The bech32 P2WSH address a staker sends their L1 BTC lockup to. */ declare function buildLockupAddress(opts: BuildLockupScriptOptions, network?: BitcoinNetwork): string; /** * The default staker subscript: ` OP_CHECKSIG` — spendable by one * key. Any script tail is valid as far as the contract is concerned; this is * the common case. */ declare function buildDefaultStakerUnlockBytes(publicKey: Uint8Array | string): Uint8Array; type RegisterMetadata = { lockAddress: string lockScript: Uint8Array outputScript: Uint8Array unlockBytes: Uint8Array unlockHeight: number }; /** * One-call L1 register metadata: unlock height, staker subscript, lock * script, P2WSH output, and address. Staker funds `lockAddress` then * passes `lockScript` into the proof mapper. */ declare function buildRegisterMetadata(opts: { bondIndex: number stxAddress: string bitcoinPublicKey: Uint8Array | string earlyUnlockBytes: Uint8Array | string network?: BitcoinNetwork cycle: BondCycleParams }): RegisterMetadata; /** * PoX-5 signer-key grants: SIP-018 structured-data signatures authorizing a * signer-manager contract to use a signer key. Mirrors * `pox-5.get-signer-grant-message-hash` — domain `pox-5-signer/1.0.0`, * message `{ topic: "grant-authorization", signer-manager, auth-id }`. */ type SignerGrantOptions = { /** The signer-manager contract principal being authorized. */ signerManager: string /** Replay-protection id, chosen by the signer. */ authId: bigint | number /** Stacks chain id (`mainnet.id` / `testnet.id`). */ chainId: number }; /** * The 32-byte hash a signer signs to grant their key — byte-identical to the * contract's `get-signer-grant-message-hash` read-only (which doubles as an * on-chain cross-check). */ declare function computeSignerGrantHash(opts: SignerGrantOptions): Uint8Array; /** * Sign a signer-key grant. Returns the 65-byte recoverable signature in RSV * order (recovery byte last), hex — the layout `grant-signer-key`'s * `signer-sig (buff 65)` expects. */ declare function signSignerGrant(account: LocalAccount, opts: SignerGrantOptions): Promise; /** * Verify a signer-key grant signature locally: recover the pubkey from the * RSV signature over the grant hash and compare. Returns `false` for * malformed input rather than throwing. */ declare function verifySignerGrant(opts: SignerGrantOptions & { publicKey: Uint8Array | string signature: Uint8Array | string }): boolean; /** * A Bitcoin merkle inclusion proof, shaped for the SIP-044 `verify-merkle-proof` * built-in: `(leaf-hash, root-hash, tx-index, tx-count, sibling-hashes)`. * * - `siblings` are the sibling node hashes from the leaf up to (excluding) the * root, in *internal* byte order — never reversed. * - `txCount` (not tree-depth) pins the canonical tree shape; the built-in * rejects any proof whose length differs from `ceil(log2(tx-count))`. */ interface MerkleProof { siblings: Uint8Array[]; txIndex: number; txCount: number; } /** * A self-contained Bitcoin SPV proof: everything the SIP-044 built-ins need to * prove a tx (and one of its outputs) is committed in a confirmed block. Hashes * are internal byte order throughout. */ interface SpvProof { rawTx: Uint8Array; /** The tx's txid, internal order — the merkle leaf. */ txidInternal: Uint8Array; /** Output index of interest, if the proof targets a specific output. */ vout?: number; merkle: MerkleProof; /** The 80-byte block header that commits the tx. */ header: Uint8Array; /** Bitcoin block height. */ height: number; } /** The block context a `ProofSource` resolves for a confirmed tx. */ interface BlockForTx { /** 80-byte block header. */ header: Uint8Array; height: number; /** All of the block's txids, internal order, in block order. */ txidsInternal: Uint8Array[]; /** Index of the target tx within the block. */ txIndex: number; } /** * Where proof inputs come from. The default is the integrator's own Bitcoin node * (`bitcoinRpcSource`) — trustless; a hosted Esplora-compatible endpoint * (`esploraSource`) is the fallback. `buildTxProof` independently re-checks * whatever a source returns, so a wrong or hostile source fails loudly rather * than producing a bad proof. */ interface ProofSource { /** Raw (serialized) tx bytes for a txid (display-order hex). */ getRawTx(txid: string): Promise; /** The confirming block's header, height, and txid set for a txid. */ getBlockForTx(txid: string): Promise; } /** * Map a generic SIP-044 `SpvProof` onto pox-5's `L1LockupOutput`. * Witness is stripped, the lockup vout is resolved against the P2WSH * of `lockScript`, and more than {@link MAX_LEAF_HASHES} siblings throws. */ declare function spvProofToL1LockupOutput(opts: { proof: SpvProof /** Witness script; hashed to match the P2WSH lockup output. */ lockScript: Uint8Array unlockBurnHeight: IntegerType /** Default: `proof.vout`, else the unique matching output. */ vout?: number }): L1LockupOutput; /** * Fetch a SIP-044 proof from `source` and map it onto pox-5's lockup shape. * `source` is required — no hosted Esplora default. */ declare function buildPox5LockProof(opts: { source: ProofSource txid: string lockScript: Uint8Array unlockBurnHeight: IntegerType vout?: number }): Promise; import * as btc from "@scure/btc-signer"; /** * Spend a pox-5 P2WSH lockup back out. * * Two paths through the lockup script (mirror of `construct-lockup-script`): * - `'locktime'` — CLTV exit (`OP_IF`), single-sig, spendable once the burn * height is past the lock's unlock height. * - `'early-exit'` — cosigned exit (`OP_ELSE`), 2-of-2 staker + bond cosigner. * Valid only after `announce-l1-early-exit` on Stacks; this helper spends the * UTXO and does not announce. */ type ReclaimPath = "locktime" | "early-exit"; /** Confirmed lockup UTXO (esplora / mempool.space shape). */ type ReclaimUtxo = { txid: string vout: number value: IntegerType /** Cross-check only; re-derived from `lockScript` when omitted. */ scriptPubKey?: Uint8Array }; /** Inputs to {@link buildReclaim}. */ type BuildReclaimOpts = { path: ReclaimPath utxo: ReclaimUtxo network: BitcoinNetwork /** * Sweep output: `value - feeSats` pays `address`. Mutate the returned tx's * outputs before signing if needed (`SIGHASH_ALL` commits to them). */ output: { address: string feeSats: IntegerType } /** * The lockup `witnessScript` — pass the bytes you funded (typically * `buildLockupScript(...)` / `RegisterMetadata.lockScript`). The CLTV * unlock height is decoded from it. */ lockScript: Uint8Array | string }; /** * Build the unsigned reclaim transaction (a `@scure/btc-signer` `Transaction`). * * One P2WSH input with `witnessUtxo` + `witnessScript` so the tx is a complete * PSBT (`toPSBT` / `fromPSBT` round-trip). HSM path: `buildReclaim` → * `tx.signIdx` or {@link computeReclaimSighash} + detached `partialSig` → * {@link finalizeReclaim}. * * - `path: "early-exit"` → `sequence = 0xffffffff`, `lockTime = 0` * - `path: "locktime"` → `sequence = 0xfffffffe`, `lockTime = unlockHeight` */ declare function buildReclaim(opts: BuildReclaimOpts): btc.Transaction; /** * Input-0 BIP-143 sighash for a reclaim tx. * * In-process keys should prefer `tx.signIdx(privateKey, 0)`. This helper is * for HSMs / MPC that sign a bare digest, and for passing the early-exit * sighash between parties. Recompute after any output/fee change. * * Reads `witnessScript` + amount off the tx (set by {@link buildReclaim}); * pass `opts` to re-supply them for a tx parsed from raw hex. */ declare function computeReclaimSighash(tx: btc.Transaction, opts?: { witnessScript?: Uint8Array | string amountSats?: IntegerType }): Uint8Array; /** * Sign a reclaim sighash with a software key: DER + trailing `SIGHASH_ALL`. * `lowR` defaults to `false` to match btc-signer's `signIdx`. Kept as the * software stand-in for a detached signer (HSM tests). */ declare function signReclaim(sighash: Uint8Array, privateKey: Uint8Array | string, opts?: { lowR?: boolean }): Uint8Array; /** Arguments to {@link finalizeReclaim}, discriminated on the spend path. */ type FinalizeReclaimOpts = { path: "early-exit" tx: btc.Transaction /** Staker principal — rebuilds the 32-byte preimage the `OP_ELSE` branch reveals. */ stxAddress: string } | { path: "locktime" tx: btc.Transaction }; /** * Assemble the custom IF/ELSE witness from signatures already on the tx. * * btc-signer's own finalizer cannot build this script, so we splice * `finalScriptWitness` directly. Does not broadcast. * * - locktime: `[stakerSig, 0x01, witnessScript]` * - early-exit: `[stakerSig, cosignerSig, preimage, , witnessScript]` */ declare function finalizeReclaim(opts: FinalizeReclaimOpts): { txHex: string txid: string }; type ReclaimOpts = BuildReclaimOpts & { /** 32-byte BTC private key (raw bytes or hex). Not a Stacks account key. */ stakerPrivateKey: Uint8Array | string /** Required for `path: "early-exit"`. */ cosignerPrivateKey?: Uint8Array | string /** Required for `path: "early-exit"` — feeds {@link stakerPreimage}. */ stxAddress?: string }; /** * One-shot reclaim for in-process BTC keys: build + signIdx + finalize. * Does not broadcast; the caller relays `txHex`. */ declare function reclaim(opts: ReclaimOpts): { txHex: string txid: string }; /** * A staker's whole PoX-5 position in ONE batched request: staker info, bond * membership, custodied sBTC, and the current cycle — the state a dashboard * or agent polls, without four round-trips. */ type StakerState = { stakerInfo: ClarityValue bondMembership: ClarityValue custodiedSbtc: ClarityValue currentCycle: ClarityValue }; /** Actions provided by the pox5 extension. */ type Pox5Actions = { pox5: { isActive: () => Promise getActivation: () => Promise getPoxInfo: () => Promise contractId: () => string getStakerState: (staker: string) => Promise getStakerInfo: (staker: string) => Promise getBondMembership: (staker: string) => Promise getProtocolBond: (bondIndex: IntegerType) => Promise getBondAllowance: (bondIndex: IntegerType, staker: string) => Promise getTotalSbtcStakedForBond: (bondIndex: IntegerType) => Promise getStakerCustodiedSbtc: (staker: string) => Promise hasAnnouncedL1EarlyExit: (bondIndex: IntegerType, staker: string) => Promise getBondL1UnlockHeight: (bondIndex: IntegerType) => Promise getSignerInfo: (signer: string) => Promise verifySignerKeyGrant: (signerManager: string, signerKey: Uint8Array | string) => Promise getCurrentRewardCycle: () => Promise getFirstRewardCycle: () => Promise getEarned: (params: { signer: string rewardCycle: IntegerType bondIndex?: IntegerType }) => Promise getEarnedStakerRewards: (params: { signer: string rewardCycle: IntegerType bondIndex?: IntegerType staker: string }) => Promise getLastRewardComputeHeight: () => Promise getTotalSharesStakedForCycle: (rewardCycle: IntegerType, bondIndex?: IntegerType) => Promise eligibleStake: (params: EligibleStakeParams) => Promise eligibleRegisterForBond: (params: EligibleRegisterForBondParams) => Promise eligibleUnstake: (params: EligibleUnstakeParams) => Promise eligibleUnstakeSbtc: (params: EligibleUnstakeSbtcParams) => Promise eligibleClaimRewards: (params: EligibleClaimRewardsParams) => Promise eligibleGrantSignerKey: (params: EligibleGrantSignerKeyParams) => Promise eligibleSetBondAdmin: (params: EligibleAdminParams) => Promise eligiblePauseRewards: (params: EligibleAdminParams) => Promise setupBond: (params: SetupBondParams) => Promise registerForBond: (params: RegisterForBondParams) => Promise updateBondRegistration: (params: UpdateBondRegistrationParams) => Promise stake: (params: StakeParams) => Promise stakeUpdate: (params: StakeUpdateParams) => Promise unstake: (params: UnstakeParams) => Promise unstakeSbtc: (params: UnstakeSbtcParams) => Promise announceL1EarlyExit: (params: AnnounceL1EarlyExitParams) => Promise calculateRewards: (params: CalculateRewardsParams) => Promise claimRewards: (params: ClaimRewardsParams) => Promise claimStakerRewardsForSigner: (params: ClaimStakerRewardsForSignerParams) => Promise grantSignerKey: (params: GrantSignerKeyParams) => Promise revokeSignerGrant: (params: RevokeSignerGrantParams) => Promise setBondAdmin: (params: SetBondAdminParams) => Promise setPauseAdmin: (params: SetPauseAdminParams) => Promise pauseRewards: (params?: PauseRewardsParams) => Promise buildLockProof: (opts: { source: ProofSource txid: string lockScript: Uint8Array unlockBurnHeight: IntegerType vout?: number }) => Promise } }; /** * PoX-5 extension for the Stacks client. * * @example * const client = createWalletClient({ chain: mainnet, transport: http(), account }) * .extend(pox5()); * * if (await client.pox5.isActive()) { * const txid = await client.pox5.stake({ * signerManager: "SP…​.signer-mgr", * amountUstx: 100_000_000_000n, * numCycles: 12, * startBurnHeight: 960_231, * fee: "low", * }); * await client.waitForTransactionReceipt({ txid }); * } */ declare function pox5(): (client: Client) => Pox5Actions; /** * SIP-005 PoX `pox-addr` tuple, decoded from a Bitcoin address. `version` is * the PoX byte (`POX_ADDRESS_VERSION`), not a Bitcoin network version * (`p2sh` is 0x01 here, 0x05 on mainnet Bitcoin). `hashbytes` is the 20- or * 32-byte payload — unpadded, matching `check-pox-addr-hashbytes`. */ type BtcAddressRepr = { version: number hashbytes: Uint8Array }; /** * Parse a Bitcoin address string into a PoX address tuple. * Supports P2PKH, P2SH, P2WPKH, P2WSH, P2TR (mainnet, testnet, regtest). */ declare function parseBtcAddress(address: string): BtcAddressRepr; declare function stringifyBtcAddress(repr: BtcAddressRepr, network: BitcoinNetwork): string; declare const BtcAddress: { parse: typeof parseBtcAddress stringify: typeof stringifyBtcAddress }; declare function buildSignerCalldata(opts: { poxAddress: string | BtcAddressRepr maxFeeSats: IntegerType }): Uint8Array; declare function parseSignerCalldata(calldata: Uint8Array | string): { poxAddress: BtcAddressRepr maxFeeSats: bigint }; declare const POX5_ABI: { readonly functions: readonly [{ readonly name: "current-pox-reward-cycle" readonly access: "read-only" readonly args: readonly [] readonly outputs: "uint128" }, { readonly name: "get-bond-allowance" readonly access: "read-only" readonly args: readonly [{ readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "staker" readonly type: "principal" }] readonly outputs: { readonly optional: "uint128" } }, { readonly name: "get-bond-l1-unlock-height" readonly access: "read-only" readonly args: readonly [{ readonly name: "bond-index" readonly type: "uint128" }] readonly outputs: "uint128" }, { readonly name: "get-bond-membership" readonly access: "read-only" readonly args: readonly [{ readonly name: "staker" readonly type: "principal" }] readonly outputs: { readonly optional: { readonly tuple: readonly [{ readonly name: "amount-sats" readonly type: "uint128" }, { readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "is-l1-lock" readonly type: "bool" }, { readonly name: "signer" readonly type: "principal" }] } } }, { readonly name: "get-first-pox-5-reward-cycle" readonly access: "read-only" readonly args: readonly [] readonly outputs: "uint128" }, { readonly name: "get-protocol-bond" readonly access: "read-only" readonly args: readonly [{ readonly name: "bond-index" readonly type: "uint128" }] readonly outputs: { readonly optional: { readonly tuple: readonly [{ readonly name: "early-unlock-bytes" readonly type: { readonly buff: { readonly length: 683 } } }, { readonly name: "min-ustx-ratio" readonly type: "uint128" }, { readonly name: "stx-value-ratio" readonly type: "uint128" }, { readonly name: "target-rate" readonly type: "uint128" }] } } }, { readonly name: "get-signer-info" readonly access: "read-only" readonly args: readonly [{ readonly name: "signer" readonly type: "principal" }] readonly outputs: { readonly optional: { readonly buff: { readonly length: 33 } } } }, { readonly name: "get-staker-custodied-sbtc" readonly access: "read-only" readonly args: readonly [{ readonly name: "staker" readonly type: "principal" }] readonly outputs: "uint128" }, { readonly name: "get-staker-info" readonly access: "read-only" readonly args: readonly [{ readonly name: "staker" readonly type: "principal" }] readonly outputs: { readonly optional: { readonly tuple: readonly [{ readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "first-reward-cycle" readonly type: "uint128" }, { readonly name: "num-cycles" readonly type: "uint128" }, { readonly name: "signer" readonly type: "principal" }] } } }, { readonly name: "get-total-sbtc-staked-for-bond" readonly access: "read-only" readonly args: readonly [{ readonly name: "bond-index" readonly type: "uint128" }] readonly outputs: "uint128" }, { readonly name: "has-announced-l1-early-exit" readonly access: "read-only" readonly args: readonly [{ readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "staker" readonly type: "principal" }] readonly outputs: "bool" }, { readonly name: "verify-signer-key-grant" readonly access: "read-only" readonly args: readonly [{ readonly name: "signer-manager" readonly type: "principal" }, { readonly name: "signer-key" readonly type: { readonly buff: { readonly length: 33 } } }] readonly outputs: { readonly response: { readonly ok: "bool" readonly error: "uint128" } } }, { readonly name: "get-earned" readonly access: "read-only" readonly args: readonly [{ readonly name: "signer" readonly type: "principal" }, { readonly name: "reward-cycle" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: { readonly optional: "uint128" } }] readonly outputs: "uint128" }, { readonly name: "get-earned-staker-rewards" readonly access: "read-only" readonly args: readonly [{ readonly name: "signer" readonly type: "principal" }, { readonly name: "reward-cycle" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: { readonly optional: "uint128" } }, { readonly name: "staker" readonly type: "principal" }] readonly outputs: "uint128" }, { readonly name: "get-last-reward-compute-height" readonly access: "read-only" readonly args: readonly [] readonly outputs: "uint128" }, { readonly name: "get-total-shares-staked-for-cycle" readonly access: "read-only" readonly args: readonly [{ readonly name: "reward-cycle" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: { readonly optional: "uint128" } }] readonly outputs: "uint128" }, { readonly name: "announce-l1-early-exit" readonly access: "public" readonly args: readonly [{ readonly name: "staker" readonly type: "principal" }, { readonly name: "old-signer-manager" readonly type: "trait_reference" }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "amount-sats-released" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "signer" readonly type: "principal" }, { readonly name: "staker" readonly type: "principal" }] } readonly error: "uint128" } } }, { readonly name: "calculate-rewards" readonly access: "public" readonly args: readonly [{ readonly name: "bond-periods" readonly type: { readonly list: { readonly type: "uint128" readonly length: 6 } } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "accrued-rewards-per-ustx" readonly type: "uint128" }, { readonly name: "bond-periods" readonly type: { readonly list: { readonly type: "uint128" readonly length: 6 } } }, { readonly name: "calculation-height" readonly type: "uint128" }, { readonly name: "cumulative-rewards-per-ustx" readonly type: "uint128" }, { readonly name: "cycle-staked-ustx" readonly type: "uint128" }, { readonly name: "gross-accrued-rewards" readonly type: "uint128" }, { readonly name: "reserve-balance" readonly type: "uint128" }, { readonly name: "reserve-deposit" readonly type: "uint128" }, { readonly name: "stx-cycle" readonly type: "uint128" }, { readonly name: "total-bond-rewards" readonly type: "uint128" }, { readonly name: "total-stx-staker-rewards" readonly type: "uint128" }] } readonly error: "uint128" } } }, { readonly name: "claim-rewards" readonly access: "public" readonly args: readonly [{ readonly name: "bond-periods" readonly type: { readonly list: { readonly type: "uint128" readonly length: 6 } } }, { readonly name: "reward-cycle" readonly type: "uint128" }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "bond-rewards" readonly type: { readonly list: { readonly type: { readonly tuple: readonly [{ readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "earned" readonly type: "uint128" }, { readonly name: "rewards-per-token" readonly type: "uint128" }] } readonly length: 6 } } }, { readonly name: "bond-totals" readonly type: "uint128" }, { readonly name: "stx-rewards" readonly type: { readonly tuple: readonly [{ readonly name: "earned" readonly type: "uint128" }, { readonly name: "rewards-per-token" readonly type: "uint128" }] } }, { readonly name: "total-rewards" readonly type: "uint128" }] } readonly error: "uint128" } } }, { readonly name: "claim-staker-rewards-for-signer" readonly access: "public" readonly args: readonly [{ readonly name: "staker" readonly type: "principal" }, { readonly name: "reward-cycle" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: { readonly optional: "uint128" } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "earned" readonly type: "uint128" }, { readonly name: "rewards-per-token" readonly type: "uint128" }] } readonly error: "uint128" } } }, { readonly name: "grant-signer-key" readonly access: "public" readonly args: readonly [{ readonly name: "signer-key" readonly type: { readonly buff: { readonly length: 33 } } }, { readonly name: "signer-manager" readonly type: "principal" }, { readonly name: "auth-id" readonly type: "uint128" }, { readonly name: "signer-sig" readonly type: { readonly buff: { readonly length: 65 } } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "auth-id" readonly type: "uint128" }, { readonly name: "signer-key" readonly type: { readonly buff: { readonly length: 33 } } }, { readonly name: "signer-manager" readonly type: "principal" }] } readonly error: "uint128" } } }, { readonly name: "register-for-bond" readonly access: "public" readonly args: readonly [{ readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "signer-manager" readonly type: "trait_reference" }, { readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "btc-lockup" readonly type: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "outputs" readonly type: { readonly list: { readonly type: { readonly tuple: readonly [{ readonly name: "amount" readonly type: "uint128" }, { readonly name: "header" readonly type: { readonly buff: { readonly length: 80 } } }, { readonly name: "height" readonly type: "uint128" }, { readonly name: "leaf-hashes" readonly type: { readonly list: { readonly type: { readonly buff: { readonly length: 32 } } readonly length: 14 } } }, { readonly name: "output-index" readonly type: "uint128" }, { readonly name: "tx" readonly type: { readonly buff: { readonly length: 100000 } } }, { readonly name: "tx-count" readonly type: "uint128" }, { readonly name: "tx-index" readonly type: "uint128" }, { readonly name: "unlock-burn-height" readonly type: "uint128" }] } readonly length: 10 } } }, { readonly name: "staker-unlock-bytes" readonly type: { readonly buff: { readonly length: 683 } } }] } readonly error: "uint128" } } }, { readonly name: "signer-calldata" readonly type: { readonly optional: { readonly buff: { readonly length: 500 } } } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "btc-lockup" readonly type: { readonly tuple: readonly [{ readonly name: "txs" readonly type: { readonly optional: { readonly list: { readonly type: { readonly tuple: readonly [{ readonly name: "output-index" readonly type: "uint128" }, { readonly name: "txid" readonly type: { readonly buff: { readonly length: 32 } } }] } readonly length: 10 } } } }, { readonly name: "type" readonly type: { readonly "string-ascii": { readonly length: 2 } } }] } }, { readonly name: "first-reward-cycle" readonly type: "uint128" }, { readonly name: "is-l1-lock" readonly type: "bool" }, { readonly name: "sats-total" readonly type: "uint128" }, { readonly name: "signer" readonly type: "principal" }, { readonly name: "staker" readonly type: "principal" }, { readonly name: "unlock-burn-height" readonly type: "uint128" }, { readonly name: "unlock-cycle" readonly type: "uint128" }] } readonly error: "uint128" } } }, { readonly name: "revoke-signer-grant" readonly access: "public" readonly args: readonly [{ readonly name: "signer-manager" readonly type: "principal" }, { readonly name: "signer-key" readonly type: { readonly buff: { readonly length: 33 } } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "existed" readonly type: "bool" }, { readonly name: "signer-key" readonly type: { readonly buff: { readonly length: 33 } } }, { readonly name: "signer-manager" readonly type: "principal" }] } readonly error: "uint128" } } }, { readonly name: "setup-bond" readonly access: "public" readonly args: readonly [{ readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "target-rate" readonly type: "uint128" }, { readonly name: "stx-value-ratio" readonly type: "uint128" }, { readonly name: "min-ustx-ratio" readonly type: "uint128" }, { readonly name: "early-unlock-bytes" readonly type: { readonly buff: { readonly length: 683 } } }, { readonly name: "allowlist" readonly type: { readonly list: { readonly type: { readonly tuple: readonly [{ readonly name: "max-sats" readonly type: "uint128" }, { readonly name: "staker" readonly type: "principal" }] } readonly length: 1000 } } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "early-unlock-bytes" readonly type: { readonly buff: { readonly length: 683 } } }, { readonly name: "max-allocation-sats" readonly type: "uint128" }, { readonly name: "min-ustx-ratio" readonly type: "uint128" }, { readonly name: "stx-value-ratio" readonly type: "uint128" }, { readonly name: "target-rate" readonly type: "uint128" }] } readonly error: "uint128" } } }, { readonly name: "stake" readonly access: "public" readonly args: readonly [{ readonly name: "signer-manager" readonly type: "trait_reference" }, { readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "num-cycles" readonly type: "uint128" }, { readonly name: "start-burn-ht" readonly type: "uint128" }, { readonly name: "signer-calldata" readonly type: { readonly optional: { readonly buff: { readonly length: 500 } } } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "first-reward-cycle" readonly type: "uint128" }, { readonly name: "num-cycles" readonly type: "uint128" }, { readonly name: "signer" readonly type: "principal" }, { readonly name: "staker" readonly type: "principal" }, { readonly name: "unlock-burn-height" readonly type: "uint128" }, { readonly name: "unlock-cycle" readonly type: "uint128" }] } readonly error: "uint128" } } }, { readonly name: "stake-update" readonly access: "public" readonly args: readonly [{ readonly name: "signer-manager" readonly type: "trait_reference" }, { readonly name: "old-signer-manager" readonly type: "trait_reference" }, { readonly name: "cycles-to-extend" readonly type: "uint128" }, { readonly name: "amount-increase" readonly type: "uint128" }, { readonly name: "signer-calldata" readonly type: { readonly optional: { readonly buff: { readonly length: 500 } } } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "amount-increase" readonly type: "uint128" }, { readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "cycles-to-extend" readonly type: "uint128" }, { readonly name: "num-cycles" readonly type: "uint128" }, { readonly name: "old-signer" readonly type: "principal" }, { readonly name: "prev-unlock-height" readonly type: "uint128" }, { readonly name: "signer" readonly type: "principal" }, { readonly name: "staker" readonly type: "principal" }, { readonly name: "unlock-burn-height" readonly type: "uint128" }, { readonly name: "unlock-cycle" readonly type: "uint128" }] } readonly error: "uint128" } } }, { readonly name: "unstake" readonly access: "public" readonly args: readonly [{ readonly name: "old-signer-manager" readonly type: "trait_reference" }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "first-reward-cycle" readonly type: "uint128" }, { readonly name: "signer" readonly type: "principal" }, { readonly name: "staker" readonly type: "principal" }, { readonly name: "unlock-burn-height" readonly type: "uint128" }, { readonly name: "unlock-cycle" readonly type: "uint128" }] } readonly error: "uint128" } } }, { readonly name: "unstake-sbtc" readonly access: "public" readonly args: readonly [{ readonly name: "signer-manager" readonly type: "trait_reference" }, { readonly name: "amount-to-withdrawal-sats" readonly type: "uint128" }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "amount-withdrawn-sats" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "new-amount-sats" readonly type: "uint128" }, { readonly name: "signer" readonly type: "principal" }, { readonly name: "staker" readonly type: "principal" }] } readonly error: "uint128" } } }, { readonly name: "update-bond-registration" readonly access: "public" readonly args: readonly [{ readonly name: "signer-manager" readonly type: "trait_reference" }, { readonly name: "old-signer-manager" readonly type: "trait_reference" }, { readonly name: "signer-calldata" readonly type: { readonly optional: { readonly buff: { readonly length: 500 } } } }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "amount-sats" readonly type: "uint128" }, { readonly name: "amount-ustx" readonly type: "uint128" }, { readonly name: "bond-index" readonly type: "uint128" }, { readonly name: "first-reward-cycle" readonly type: "uint128" }, { readonly name: "is-l1-lock" readonly type: "bool" }, { readonly name: "num-cycles" readonly type: "uint128" }, { readonly name: "old-signer" readonly type: "principal" }, { readonly name: "signer" readonly type: "principal" }, { readonly name: "staker" readonly type: "principal" }] } readonly error: "uint128" } } }, { readonly name: "set-bond-admin" readonly access: "public" readonly args: readonly [{ readonly name: "new-admin" readonly type: "principal" }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "new-admin" readonly type: "principal" }, { readonly name: "old-admin" readonly type: "principal" }] } readonly error: "uint128" } } }, { readonly name: "set-pause-admin" readonly access: "public" readonly args: readonly [{ readonly name: "new-admin" readonly type: "principal" }] readonly outputs: { readonly response: { readonly ok: { readonly tuple: readonly [{ readonly name: "new-admin" readonly type: "principal" }, { readonly name: "old-admin" readonly type: "principal" }] } readonly error: "uint128" } } }, { readonly name: "pause-rewards" readonly access: "public" readonly args: readonly [] readonly outputs: { readonly response: { readonly ok: "bool" readonly error: "uint128" } } }] }; export { verifySignerGrant, stringifyBtcAddress, stakerPreimage, stakerConsensusBuff, spvProofToL1LockupOutput, signSignerGrant, signReclaim, serializeCScriptNum, rewardCycleToBurnHeight, reclaim, pushScriptBytes, pushCScriptNum, pox5ContractId, pox5, parseSignerCalldata, parsePox5Error, parseBtcAddress, isPox5Active, isInPreparePhase, getPoxInfo2 as getPoxInfo, getPox5Activation, finalizeReclaim, eligibleUnstakeSbtc2 as eligibleUnstakeSbtc, eligibleUnstake2 as eligibleUnstake, eligibleStake2 as eligibleStake, eligibleSetBondAdmin2 as eligibleSetBondAdmin, eligibleRegisterForBond2 as eligibleRegisterForBond, eligiblePauseRewards2 as eligiblePauseRewards, eligibleGrantSignerKey2 as eligibleGrantSignerKey, eligibleClaimRewards2 as eligibleClaimRewards, distributionCycleToBurnHeight, describePox5Error, currentDistributionCycle, computeSignerGrantHash, computeReclaimSighash, computeBondUnlockHeight, burnHeightToRewardCycle, burnHeightToDistributionIndex, buildSignerCalldata, buildRegisterMetadata, buildReclaim, buildPox5LockProof, buildLockupScript, buildLockupOutputScript, buildLockupAddress, buildDefaultStakerUnlockBytes, bondUnlockCycle, bondStatusAtHeight, bondPhaseAtHeight, bondPeriodToRewardCycle, bondPeriodToBurnHeight, assertPox5Active, UpdateBondRegistrationParams, UnstakeSbtcParams, UnstakeParams, StakerState, StakeUpdateParams, StakeParams, SignerGrantOptions, SetupBondParams, SetPauseAdminParams, SetBondAdminParams, RevokeSignerGrantParams, RegisterMetadata, RegisterForBondParams, ReclaimUtxo, ReclaimPath, ReclaimOpts, PoxCycleParams, Pox5Info, Pox5EventTopic, Pox5ErrorCode, Pox5Activation, Pox5Actions, PauseRewardsParams, POX5_SIGNER_DOMAIN, POX5_EVENT_TOPICS, POX5_ERROR_NAMES, POX5_CONTRACT_NAME, POX5_CONTRACT_ID_MAINNET, POX5_ACTIVATION_BURN_HEIGHT_MAINNET, POX5_ABI, MAX_NUM_CYCLES, L1LockupOutput, GrantSignerKeyParams, FinalizeReclaimOpts, EligibleUnstakeSbtcParams, EligibleUnstakeParams, EligibleStakeParams, EligibleRegisterForBondParams, EligibleGrantSignerKeyParams, EligibleClaimRewardsParams, EligibleAdminParams, EligibilityResult, ClaimStakerRewardsForSignerParams, ClaimRewardsParams, CalculateRewardsParams, C_SCRIPT_NUM_MAX, BuildReclaimOpts, BuildLockupScriptOptions, BtcLockup, BtcAddressRepr, BtcAddress, BondStatusName, BondPhase, BondCycleParams, BOND_LENGTH_CYCLES, BOND_GAP_CYCLES, BITCOIN_LOCKTIME_THRESHOLD, AnnounceL1EarlyExitParams };