{
  "version": 3,
  "sources": ["../src/pox5/constants.ts", "../src/pox5/activation.ts", "../src/pox5/errors.ts", "../src/pox5/abi.ts", "../src/pox5/actions.ts", "../src/pox5/cycles.ts", "../src/pox5/eligibility.ts", "../src/pox5/script.ts", "../src/pox5/grants.ts", "../src/pox5/lockProof.ts", "../src/pox5/reclaim.ts", "../src/pox5/extension.ts", "../src/pox5/signerCalldata.ts"],
  "sourcesContent": [
    "/**\n * PoX-5 (SIP-045 Bitcoin Staking) constants, pinned against the final\n * contract shipped in stacks-core 4.0.1 (`stackslib/.../boot/pox-5.clar`);\n * `scripts/ci/check-pox5-pin.ts` holds the pinned tag + content hash.\n */\n\nimport { EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET } from \"../epochs.ts\";\n\n/** Boot contract name; deployer is the chain's boot address. */\nexport const POX5_CONTRACT_NAME = \"pox-5\";\n\n/** Fully-qualified mainnet contract id (boot address + `pox-5`). */\nexport const POX5_CONTRACT_ID_MAINNET: string = `SP000000000000000000002Q6VF78.${POX5_CONTRACT_NAME}`;\n\n/**\n * All print-event topic strings emitted by `pox-5.clar`. Unlike pox-2/3/4,\n * pox-5 has NO node-synthesized events — every event is a real `(print ...)`\n * with these `topic` values and the remaining tuple fields flattened at the\n * top level via `merge` (not nested under a `data` key).\n *\n * `add-to-allowlist` and `bond-distribution` are emitted per-item inside\n * folds (`setup-bond` / `calculate-rewards`), so one transaction can carry\n * many prints.\n */\nexport const POX5_EVENT_TOPICS = [\n\t\"set-bond-admin\",\n\t\"set-pause-admin\",\n\t\"pause-rewards\",\n\t\"setup-bond\",\n\t\"add-to-allowlist\",\n\t\"register-for-bond\",\n\t\"update-bond-registration\",\n\t\"register-signer\",\n\t\"stake\",\n\t\"stake-update\",\n\t\"announce-l1-early-exit\",\n\t\"unstake-sbtc\",\n\t\"unstake\",\n\t\"calculate-rewards\",\n\t\"bond-distribution\",\n\t\"claim-rewards\",\n\t\"claim-staker-rewards-for-signer\",\n\t\"grant-signer-key\",\n\t\"revoke-signer-grant\",\n] as const;\n\nexport type Pox5EventTopic = (typeof POX5_EVENT_TOPICS)[number];\n\n/**\n * Epoch 4.0 hard-fork activation height on mainnet — see\n * {@link EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET}. Prefer the runtime gate in\n * `activation.ts` (`getPox5Activation`), which reads the node's `/v2/pox` and\n * works on every network.\n */\nexport const POX5_ACTIVATION_BURN_HEIGHT_MAINNET: typeof EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET =\n\tEPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET;\n\n/** Length of a paired-BTC bond, in reward cycles (`BOND_LENGTH_CYCLES`). */\nexport const BOND_LENGTH_CYCLES = 12;\n\n/** Gap between consecutive bond starts, in reward cycles (`BOND_GAP_CYCLES`). */\nexport const BOND_GAP_CYCLES = 2;\n\n/** Hard cap for STX-only stake duration, in cycles (`MAX_NUM_CYCLES`). */\nexport const MAX_NUM_CYCLES = 96;\n\n/** SIP-018 domain for signer-key grants (`POX_5_SIGNER_DOMAIN`). */\nexport const POX5_SIGNER_DOMAIN = {\n\tname: \"pox-5-signer\",\n\tversion: \"1.0.0\",\n} as const;\n\n/**\n * `serialize-c-script-num` rejects values at or above 2^39 — the ceiling of a\n * 5-byte minimally-encoded ScriptNum (`ERR_INVALID_UNLOCK_HEIGHT`).\n */\nexport const C_SCRIPT_NUM_MAX = 549_755_813_888n; // 2^39\n\n/**\n * Bitcoin treats CLTV values >= 500,000,000 as Unix timestamps (BIP-65); the\n * contract rejects unlock heights at or above this so a lockup can never\n * commit a height Bitcoin would reinterpret.\n */\nexport const BITCOIN_LOCKTIME_THRESHOLD = 500_000_000n;\n",
    "import type { Client } from \"../clients/types.ts\";\nimport { POX5_CONTRACT_NAME } from \"./constants.ts\";\n\n/**\n * Chain-reported PoX-5 activation facts, read from the node's `/v2/pox`\n * `contract_versions[]`. Present the moment nodes run stacks-core >= 4.0.0 —\n * no hardcoded heights, works on any network.\n */\nexport type Pox5Activation = {\n\t/** Fully-qualified `pox-5` contract id (boot address differs per network). */\n\tcontractId: string;\n\t/** Bitcoin block height at which Epoch 4.0 (and pox-5) activates. */\n\tactivationBurnchainBlockHeight: number;\n\t/** First reward cycle in which pox-5 governs PoX. */\n\tfirstRewardCycleId: number;\n};\n\ntype PoxInfoResponse = {\n\tcontract_id?: string;\n\tcurrent_burnchain_block_height?: number;\n\tfirst_burnchain_block_height?: number;\n\tpox_5_sbtc_contract?: string;\n\tpox_5_sbtc_registry_contract?: string;\n\tcontract_versions?: Array<{\n\t\tcontract_id: string;\n\t\tactivation_burnchain_block_height: number;\n\t\tfirst_reward_cycle_id: number;\n\t}>;\n};\n\n/**\n * `/v2/pox` fields a pox-5 integration actually needs. `sbtcContract` is\n * compiled into the boot contract per network — never hardcode it.\n */\nexport type Pox5Info = {\n\tcontractId?: string;\n\tcurrentBurnchainBlockHeight?: number;\n\tfirstBurnchainBlockHeight?: number;\n\t/** Token principal pox-5 custodies. Read this for sBTC post-conditions. */\n\tsbtcContract?: string;\n\tsbtcRegistryContract?: string;\n\tcontractVersions: Array<{\n\t\tcontractId: string;\n\t\tactivationBurnchainBlockHeight: number;\n\t\tfirstRewardCycleId: number;\n\t}>;\n};\n\nexport async function getPoxInfo(client: Client): Promise<Pox5Info> {\n\tconst info = (await client.request(\"/v2/pox\", {\n\t\tmethod: \"GET\",\n\t})) as PoxInfoResponse;\n\treturn {\n\t\tcontractId: info.contract_id,\n\t\tcurrentBurnchainBlockHeight: info.current_burnchain_block_height,\n\t\tfirstBurnchainBlockHeight: info.first_burnchain_block_height,\n\t\tsbtcContract: info.pox_5_sbtc_contract,\n\t\tsbtcRegistryContract: info.pox_5_sbtc_registry_contract,\n\t\tcontractVersions: (info.contract_versions ?? []).map((v) => ({\n\t\t\tcontractId: v.contract_id,\n\t\t\tactivationBurnchainBlockHeight: v.activation_burnchain_block_height,\n\t\t\tfirstRewardCycleId: v.first_reward_cycle_id,\n\t\t})),\n\t};\n}\n\n/**\n * Read pox-5's activation entry from the node. Returns `undefined` when the\n * node doesn't know about pox-5 yet (pre-4.0.0 node software).\n */\nexport async function getPox5Activation(\n\tclient: Client,\n): Promise<Pox5Activation | undefined> {\n\tconst info = (await client.request(\"/v2/pox\", {\n\t\tmethod: \"GET\",\n\t})) as PoxInfoResponse;\n\tconst entry = info.contract_versions?.find((v) =>\n\t\tv.contract_id.endsWith(`.${POX5_CONTRACT_NAME}`),\n\t);\n\tif (!entry) return undefined;\n\treturn {\n\t\tcontractId: entry.contract_id,\n\t\tactivationBurnchainBlockHeight: entry.activation_burnchain_block_height,\n\t\tfirstRewardCycleId: entry.first_reward_cycle_id,\n\t};\n}\n\n/**\n * Whether pox-5 is live on the node's chain: the node software knows the\n * contract AND the burnchain has reached its activation height. One request.\n */\nexport async function isPox5Active(client: Client): Promise<boolean> {\n\tconst info = (await client.request(\"/v2/pox\", {\n\t\tmethod: \"GET\",\n\t})) as PoxInfoResponse;\n\tconst entry = info.contract_versions?.find((v) =>\n\t\tv.contract_id.endsWith(`.${POX5_CONTRACT_NAME}`),\n\t);\n\tif (!entry || typeof info.current_burnchain_block_height !== \"number\")\n\t\treturn false;\n\treturn (\n\t\tinfo.current_burnchain_block_height >=\n\t\tentry.activation_burnchain_block_height\n\t);\n}\n\n/** Throw a descriptive error unless pox-5 is active on the client's chain. */\nexport async function assertPox5Active(client: Client): Promise<void> {\n\tif (!(await isPox5Active(client))) {\n\t\tthrow new Error(\n\t\t\t\"pox-5 is not active on this chain yet (Epoch 4.0 activates at Bitcoin block 960,230 on mainnet, ~2026-07-29). \" +\n\t\t\t\t\"Check getPox5Activation(client) for this network's activation height.\",\n\t\t);\n\t}\n}\n",
    "import type { ClarityValue } from \"../clarity/types.ts\";\n\n/**\n * Numeric `(err uN)` codes from pox-5. Missing numbers were never assigned\n * on-chain. Pair with {@link parsePox5Error} / {@link describePox5Error}.\n */\nexport const Pox5ErrorCode = {\n\tUnauthorized: 1,\n\tCannotSetupBondTooSoon: 2,\n\tCannotSetupBondTooLate: 3,\n\tBondAlreadySetup: 4,\n\tStakerAlreadyAdded: 5,\n\tBondNotFound: 7,\n\tInsufficientStx: 8,\n\tAlreadyRegistered: 9,\n\tTooMuchSats: 10,\n\tNotAllowlisted: 11,\n\tSignerKeyGrantUsed: 12,\n\tInvalidSignatureRecover: 13,\n\tInvalidSignaturePubkey: 14,\n\tSignerKeyGrantNotFound: 17,\n\tAlreadyStaked: 19,\n\tInvalidNumCycles: 20,\n\tSignerNotFound: 23,\n\tInvalidStartBurnHeight: 24,\n\tUnauthorizedSignerRegistration: 26,\n\tNotStaking: 27,\n\tUnstakeInPreparePhase: 28,\n\tInvalidBondPeriodOrdering: 29,\n\tDistributionAlreadyComputed: 30,\n\tBondNotActive: 31,\n\tNoClaimableRewards: 32,\n\tActiveBondNotIncluded: 33,\n\tNotBondParticipant: 34,\n\tCannotAnnounceL1EarlyUnlock: 35,\n\tInvalidOldSignerManager: 36,\n\tInvalidUnstakeSbtcAmount: 37,\n\tCannotUnstakeSbtc: 38,\n\tReadTxOutOfBounds: 39,\n\tInvalidBtcHeader: 40,\n\tInvalidMerkleProof: 41,\n\tInvalidLockupScript: 42,\n\tBondAlreadyStarted: 43,\n\tUpdateBondSameSigner: 44,\n\tInvalidLockupAmount: 45,\n\tDuplicateLockupOutpoint: 46,\n\tStakeInPreparePhase: 47,\n\tRolloverTooEarly: 48,\n\tReentrantCall: 49,\n\tL1EarlyExitAlreadyAnnounced: 50,\n\tInsufficientReserveBalance: 51,\n\tInvalidUnlockHeight: 52,\n\tRewardsPaused: 53,\n} as const;\n\nexport type Pox5ErrorCode = (typeof Pox5ErrorCode)[keyof typeof Pox5ErrorCode];\n\nexport const POX5_ERROR_NAMES: Record<Pox5ErrorCode, string> = {\n\t[Pox5ErrorCode.Unauthorized]: \"ERR_UNAUTHORIZED\",\n\t[Pox5ErrorCode.CannotSetupBondTooSoon]: \"ERR_CANNOT_SETUP_BOND_TOO_SOON\",\n\t[Pox5ErrorCode.CannotSetupBondTooLate]: \"ERR_CANNOT_SETUP_BOND_TOO_LATE\",\n\t[Pox5ErrorCode.BondAlreadySetup]: \"ERR_BOND_ALREADY_SETUP\",\n\t[Pox5ErrorCode.StakerAlreadyAdded]: \"ERR_STAKER_ALREADY_ADDED\",\n\t[Pox5ErrorCode.BondNotFound]: \"ERR_BOND_NOT_FOUND\",\n\t[Pox5ErrorCode.InsufficientStx]: \"ERR_INSUFFICIENT_STX\",\n\t[Pox5ErrorCode.AlreadyRegistered]: \"ERR_ALREADY_REGISTERED\",\n\t[Pox5ErrorCode.TooMuchSats]: \"ERR_TOO_MUCH_SATS\",\n\t[Pox5ErrorCode.NotAllowlisted]: \"ERR_NOT_ALLOWLISTED\",\n\t[Pox5ErrorCode.SignerKeyGrantUsed]: \"ERR_SIGNER_KEY_GRANT_USED\",\n\t[Pox5ErrorCode.InvalidSignatureRecover]: \"ERR_INVALID_SIGNATURE_RECOVER\",\n\t[Pox5ErrorCode.InvalidSignaturePubkey]: \"ERR_INVALID_SIGNATURE_PUBKEY\",\n\t[Pox5ErrorCode.SignerKeyGrantNotFound]: \"ERR_SIGNER_KEY_GRANT_NOT_FOUND\",\n\t[Pox5ErrorCode.AlreadyStaked]: \"ERR_ALREADY_STAKED\",\n\t[Pox5ErrorCode.InvalidNumCycles]: \"ERR_INVALID_NUM_CYCLES\",\n\t[Pox5ErrorCode.SignerNotFound]: \"ERR_SIGNER_NOT_FOUND\",\n\t[Pox5ErrorCode.InvalidStartBurnHeight]: \"ERR_INVALID_START_BURN_HEIGHT\",\n\t[Pox5ErrorCode.UnauthorizedSignerRegistration]:\n\t\t\"ERR_UNAUTHORIZED_SIGNER_REGISTRATION\",\n\t[Pox5ErrorCode.NotStaking]: \"ERR_NOT_STAKING\",\n\t[Pox5ErrorCode.UnstakeInPreparePhase]: \"ERR_UNSTAKE_IN_PREPARE_PHASE\",\n\t[Pox5ErrorCode.InvalidBondPeriodOrdering]: \"ERR_INVALID_BOND_PERIOD_ORDERING\",\n\t[Pox5ErrorCode.DistributionAlreadyComputed]:\n\t\t\"ERR_DISTRIBUTION_ALREADY_COMPUTED\",\n\t[Pox5ErrorCode.BondNotActive]: \"ERR_BOND_NOT_ACTIVE\",\n\t[Pox5ErrorCode.NoClaimableRewards]: \"ERR_NO_CLAIMABLE_REWARDS\",\n\t[Pox5ErrorCode.ActiveBondNotIncluded]: \"ERR_ACTIVE_BOND_NOT_INCLUDED\",\n\t[Pox5ErrorCode.NotBondParticipant]: \"ERR_NOT_BOND_PARTICIPANT\",\n\t[Pox5ErrorCode.CannotAnnounceL1EarlyUnlock]:\n\t\t\"ERR_CANNOT_ANNOUNCE_L1_EARLY_UNLOCK\",\n\t[Pox5ErrorCode.InvalidOldSignerManager]: \"ERR_INVALID_OLD_SIGNER_MANAGER\",\n\t[Pox5ErrorCode.InvalidUnstakeSbtcAmount]: \"ERR_INVALID_UNSTAKE_SBTC_AMOUNT\",\n\t[Pox5ErrorCode.CannotUnstakeSbtc]: \"ERR_CANNOT_UNSTAKE_SBTC\",\n\t[Pox5ErrorCode.ReadTxOutOfBounds]: \"ERR_READ_TX_OUT_OF_BOUNDS\",\n\t[Pox5ErrorCode.InvalidBtcHeader]: \"ERR_INVALID_BTC_HEADER\",\n\t[Pox5ErrorCode.InvalidMerkleProof]: \"ERR_INVALID_MERKLE_PROOF\",\n\t[Pox5ErrorCode.InvalidLockupScript]: \"ERR_INVALID_LOCKUP_SCRIPT\",\n\t[Pox5ErrorCode.BondAlreadyStarted]: \"ERR_BOND_ALREADY_STARTED\",\n\t[Pox5ErrorCode.UpdateBondSameSigner]: \"ERR_UPDATE_BOND_SAME_SIGNER\",\n\t[Pox5ErrorCode.InvalidLockupAmount]: \"ERR_INVALID_LOCKUP_AMOUNT\",\n\t[Pox5ErrorCode.DuplicateLockupOutpoint]: \"ERR_DUPLICATE_LOCKUP_OUTPOINT\",\n\t[Pox5ErrorCode.StakeInPreparePhase]: \"ERR_STAKE_IN_PREPARE_PHASE\",\n\t[Pox5ErrorCode.RolloverTooEarly]: \"ERR_ROLLOVER_TOO_EARLY\",\n\t[Pox5ErrorCode.ReentrantCall]: \"ERR_REENTRANT_CALL\",\n\t[Pox5ErrorCode.L1EarlyExitAlreadyAnnounced]:\n\t\t\"ERR_L1_EARLY_EXIT_ALREADY_ANNOUNCED\",\n\t[Pox5ErrorCode.InsufficientReserveBalance]:\n\t\t\"ERR_INSUFFICIENT_RESERVE_BALANCE\",\n\t[Pox5ErrorCode.InvalidUnlockHeight]: \"ERR_INVALID_UNLOCK_HEIGHT\",\n\t[Pox5ErrorCode.RewardsPaused]: \"ERR_REWARDS_PAUSED\",\n};\n\nconst POX5_ERROR_DESCRIPTIONS: Record<Pox5ErrorCode, string> = {\n\t[Pox5ErrorCode.Unauthorized]: \"Caller is not authorized.\",\n\t[Pox5ErrorCode.CannotSetupBondTooSoon]: \"Bond setup window has not opened.\",\n\t[Pox5ErrorCode.CannotSetupBondTooLate]: \"Bond setup window has closed.\",\n\t[Pox5ErrorCode.BondAlreadySetup]: \"This bond period is already set up.\",\n\t[Pox5ErrorCode.StakerAlreadyAdded]: \"Staker is already on this bond.\",\n\t[Pox5ErrorCode.BondNotFound]: \"No bond at this index.\",\n\t[Pox5ErrorCode.InsufficientStx]: \"Not enough STX for this operation.\",\n\t[Pox5ErrorCode.AlreadyRegistered]:\n\t\t\"Staker already has an overlapping position.\",\n\t[Pox5ErrorCode.TooMuchSats]: \"Sats amount exceeds the allowlist maximum.\",\n\t[Pox5ErrorCode.NotAllowlisted]: \"Principal is not on the bond allowlist.\",\n\t[Pox5ErrorCode.SignerKeyGrantUsed]:\n\t\t\"This signer-key grant was already consumed.\",\n\t[Pox5ErrorCode.InvalidSignatureRecover]:\n\t\t\"Could not recover a public key from the signature.\",\n\t[Pox5ErrorCode.InvalidSignaturePubkey]:\n\t\t\"Recovered public key does not match the signer key.\",\n\t[Pox5ErrorCode.SignerKeyGrantNotFound]: \"No grant found for this signer key.\",\n\t[Pox5ErrorCode.AlreadyStaked]: \"Principal already has an overlapping stake.\",\n\t[Pox5ErrorCode.InvalidNumCycles]: \"Cycle count is outside the allowed range.\",\n\t[Pox5ErrorCode.SignerNotFound]: \"No signer found for this principal.\",\n\t[Pox5ErrorCode.InvalidStartBurnHeight]:\n\t\t\"Start burn height must fall in the current reward cycle.\",\n\t[Pox5ErrorCode.UnauthorizedSignerRegistration]:\n\t\t\"Caller is not authorized to register this signer.\",\n\t[Pox5ErrorCode.NotStaking]: \"Principal is not currently staking.\",\n\t[Pox5ErrorCode.UnstakeInPreparePhase]:\n\t\t\"Unstaking is not allowed in the prepare phase.\",\n\t[Pox5ErrorCode.InvalidBondPeriodOrdering]:\n\t\t\"Bond periods were supplied out of order.\",\n\t[Pox5ErrorCode.DistributionAlreadyComputed]:\n\t\t\"Reward distribution already computed for this period.\",\n\t[Pox5ErrorCode.BondNotActive]: \"Bond is not currently active.\",\n\t[Pox5ErrorCode.NoClaimableRewards]: \"No claimable rewards for this caller.\",\n\t[Pox5ErrorCode.ActiveBondNotIncluded]:\n\t\t\"The currently active bond was not included in the list.\",\n\t[Pox5ErrorCode.NotBondParticipant]: \"Caller is not in a bond.\",\n\t[Pox5ErrorCode.CannotAnnounceL1EarlyUnlock]:\n\t\t\"Early-exit announce is not valid for this membership.\",\n\t[Pox5ErrorCode.InvalidOldSignerManager]:\n\t\t\"old-signer-manager does not match the staker's current signer.\",\n\t[Pox5ErrorCode.InvalidUnstakeSbtcAmount]: \"sBTC unstake amount is invalid.\",\n\t[Pox5ErrorCode.CannotUnstakeSbtc]: \"Bond participant did not stake sBTC.\",\n\t[Pox5ErrorCode.ReadTxOutOfBounds]: \"Lockup proof buffer was truncated.\",\n\t[Pox5ErrorCode.InvalidBtcHeader]:\n\t\t\"Bitcoin header in the lockup proof is invalid.\",\n\t[Pox5ErrorCode.InvalidMerkleProof]:\n\t\t\"Merkle proof in the lockup proof is invalid.\",\n\t[Pox5ErrorCode.InvalidLockupScript]: \"Lockup output script does not match.\",\n\t[Pox5ErrorCode.BondAlreadyStarted]:\n\t\t\"Cannot register after the bond has started.\",\n\t[Pox5ErrorCode.UpdateBondSameSigner]:\n\t\t\"update-bond-registration cannot keep the same signer.\",\n\t[Pox5ErrorCode.InvalidLockupAmount]:\n\t\t\"Lockup output amount does not match sats.\",\n\t[Pox5ErrorCode.DuplicateLockupOutpoint]:\n\t\t\"The same Bitcoin outpoint appeared twice in the lockup list.\",\n\t[Pox5ErrorCode.StakeInPreparePhase]:\n\t\t\"Cannot modify next-cycle stake during the prepare phase.\",\n\t[Pox5ErrorCode.RolloverTooEarly]: \"Bond rollover is too early.\",\n\t[Pox5ErrorCode.ReentrantCall]:\n\t\t\"Reentrant call into pox-5 while a trait call is in flight.\",\n\t[Pox5ErrorCode.L1EarlyExitAlreadyAnnounced]:\n\t\t\"L1 early exit already announced for this bond period.\",\n\t[Pox5ErrorCode.InsufficientReserveBalance]:\n\t\t\"Reserve withdrawal exceeds the balance.\",\n\t[Pox5ErrorCode.InvalidUnlockHeight]:\n\t\t\"Unlock height is below the bond minimum or at/above 500,000,000.\",\n\t[Pox5ErrorCode.RewardsPaused]: \"Signer reward claims are paused.\",\n};\n\n/** Extract `(err uN)` from a Clarity value or Hiro `repr` string. */\nexport function parsePox5Error(\n\tresult: ClarityValue | string | undefined,\n): number | undefined {\n\tif (result == null) return undefined;\n\tif (typeof result === \"string\") {\n\t\tconst match = result.trim().match(/^\\(err u(\\d+)\\)$/);\n\t\treturn match ? Number(match[1]) : undefined;\n\t}\n\tif (result.type !== \"err\") return undefined;\n\treturn result.value.type === \"uint\" ? Number(result.value.value) : undefined;\n}\n\nexport function describePox5Error(\n\tcode: number | bigint,\n): { code: number; name: string; description: string } | undefined {\n\tconst n = Number(code) as Pox5ErrorCode;\n\tconst name = POX5_ERROR_NAMES[n];\n\tif (!name) return undefined;\n\treturn { code: n, name, description: POX5_ERROR_DESCRIPTIONS[n] };\n}\n",
    "/**\n * Curated pox-5 ABI — the 32 functions this module calls, subset of the full\n * boot-contract interface (88 functions). Regenerate when stacks-core bumps\n * pox-5: `bun spike/pox5-getContract/extract-abi.ts`, then re-curate.\n * Drift-guarded by __tests__/actions.simnet.test.ts.\n */\nimport type { AbiContract } from \"../clarity/abi/contract.ts\";\n\n// NOTE: ABI fragments are written out at each use site rather than shared via a\n// module-local const. bunup's dts emitter cannot express a reference to a\n// non-exported const — it drops the `type` property entirely (and collapses it\n// to `{}` if the const is exported), so the SHIPPED types were malformed while\n// the source type-checked clean. Verbose here beats broken for consumers.\n\nexport const POX5_ABI = {\n\tfunctions: [\n\t\t// Read-only\n\t\t{\n\t\t\tname: \"current-pox-reward-cycle\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-bond-allowance\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t],\n\t\t\toutputs: { optional: \"uint128\" },\n\t\t},\n\t\t{\n\t\t\tname: \"get-bond-l1-unlock-height\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"bond-index\", type: \"uint128\" }],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-bond-membership\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"staker\", type: \"principal\" }],\n\t\t\toutputs: {\n\t\t\t\toptional: {\n\t\t\t\t\ttuple: [\n\t\t\t\t\t\t{ name: \"amount-sats\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"is-l1-lock\", type: \"bool\" },\n\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"get-first-pox-5-reward-cycle\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-protocol-bond\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"bond-index\", type: \"uint128\" }],\n\t\t\toutputs: {\n\t\t\t\toptional: {\n\t\t\t\t\ttuple: [\n\t\t\t\t\t\t{ name: \"early-unlock-bytes\", type: { buff: { length: 683 } } },\n\t\t\t\t\t\t{ name: \"min-ustx-ratio\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"stx-value-ratio\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"target-rate\", type: \"uint128\" },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"get-signer-info\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"signer\", type: \"principal\" }],\n\t\t\toutputs: { optional: { buff: { length: 33 } } },\n\t\t},\n\t\t{\n\t\t\tname: \"get-staker-custodied-sbtc\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"staker\", type: \"principal\" }],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-staker-info\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"staker\", type: \"principal\" }],\n\t\t\toutputs: {\n\t\t\t\toptional: {\n\t\t\t\t\ttuple: [\n\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"get-total-sbtc-staked-for-bond\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"bond-index\", type: \"uint128\" }],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"has-announced-l1-early-exit\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t],\n\t\t\toutputs: \"bool\",\n\t\t},\n\t\t{\n\t\t\tname: \"verify-signer-key-grant\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t],\n\t\t\toutputs: { response: { ok: \"bool\", error: \"uint128\" } },\n\t\t},\n\t\t{\n\t\t\tname: \"get-earned\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t\t{ name: \"bond-index\", type: { optional: \"uint128\" } },\n\t\t\t],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-earned-staker-rewards\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t\t{ name: \"bond-index\", type: { optional: \"uint128\" } },\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-last-reward-compute-height\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-total-shares-staked-for-cycle\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t\t{ name: \"bond-index\", type: { optional: \"uint128\" } },\n\t\t\t],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\n\t\t// Public\n\t\t{\n\t\t\tname: \"announce-l1-early-exit\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t{ name: \"old-signer-manager\", type: \"trait_reference\" },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-sats-released\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"calculate-rewards\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{\n\t\t\t\t\tname: \"bond-periods\",\n\t\t\t\t\ttype: { list: { type: \"uint128\", length: 6 } },\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"accrued-rewards-per-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"bond-periods\",\n\t\t\t\t\t\t\t\ttype: { list: { type: \"uint128\", length: 6 } },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"calculation-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"cumulative-rewards-per-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"cycle-staked-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"gross-accrued-rewards\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"reserve-balance\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"reserve-deposit\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"stx-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"total-bond-rewards\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"total-stx-staker-rewards\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"claim-rewards\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{\n\t\t\t\t\tname: \"bond-periods\",\n\t\t\t\t\ttype: { list: { type: \"uint128\", length: 6 } },\n\t\t\t\t},\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"bond-rewards\",\n\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"earned\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"rewards-per-token\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tlength: 6,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"bond-totals\", type: \"uint128\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"stx-rewards\",\n\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t{ name: \"earned\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t{ name: \"rewards-per-token\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"total-rewards\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"claim-staker-rewards-for-signer\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t\t{ name: \"bond-index\", type: { optional: \"uint128\" } },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"earned\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"rewards-per-token\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"grant-signer-key\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t{ name: \"auth-id\", type: \"uint128\" },\n\t\t\t\t{ name: \"signer-sig\", type: { buff: { length: 65 } } },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"auth-id\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"register-for-bond\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"btc-lockup\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tok: {\n\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: \"outputs\",\n\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"amount\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"header\", type: { buff: { length: 80 } } },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"height\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tname: \"leaf-hashes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: { buff: { length: 32 } },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlength: 14,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"output-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"tx\", type: { buff: { length: 100000 } } },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"tx-count\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"tx-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\tlength: 10,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: \"staker-unlock-bytes\",\n\t\t\t\t\t\t\t\t\t\ttype: { buff: { length: 683 } },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\terror: \"uint128\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"signer-calldata\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\toptional: { buff: { length: 500 } },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"btc-lockup\",\n\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tname: \"txs\",\n\t\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\t\toptional: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"output-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tname: \"txid\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: { buff: { length: 32 } },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlength: 10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tname: \"type\",\n\t\t\t\t\t\t\t\t\t\t\ttype: { \"string-ascii\": { length: 2 } },\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"is-l1-lock\", type: \"bool\" },\n\t\t\t\t\t\t\t{ name: \"sats-total\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"unlock-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"revoke-signer-grant\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"existed\", type: \"bool\" },\n\t\t\t\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"setup-bond\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"target-rate\", type: \"uint128\" },\n\t\t\t\t{ name: \"stx-value-ratio\", type: \"uint128\" },\n\t\t\t\t{ name: \"min-ustx-ratio\", type: \"uint128\" },\n\t\t\t\t{ name: \"early-unlock-bytes\", type: { buff: { length: 683 } } },\n\t\t\t\t{\n\t\t\t\t\tname: \"allowlist\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t{ name: \"max-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlength: 1000,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"early-unlock-bytes\",\n\t\t\t\t\t\t\t\ttype: { buff: { length: 683 } },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"max-allocation-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"min-ustx-ratio\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"stx-value-ratio\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"target-rate\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"stake\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t{ name: \"start-burn-ht\", type: \"uint128\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"signer-calldata\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\toptional: { buff: { length: 500 } },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"unlock-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"stake-update\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"old-signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"cycles-to-extend\", type: \"uint128\" },\n\t\t\t\t{ name: \"amount-increase\", type: \"uint128\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"signer-calldata\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\toptional: { buff: { length: 500 } },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-increase\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"cycles-to-extend\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"old-signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"prev-unlock-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"unlock-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"unstake\",\n\t\t\taccess: \"public\",\n\t\t\targs: [{ name: \"old-signer-manager\", type: \"trait_reference\" }],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"unlock-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"unstake-sbtc\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"amount-to-withdrawal-sats\", type: \"uint128\" },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-withdrawn-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"new-amount-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"update-bond-registration\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"old-signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"signer-calldata\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\toptional: { buff: { length: 500 } },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"is-l1-lock\", type: \"bool\" },\n\t\t\t\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"old-signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"set-bond-admin\",\n\t\t\taccess: \"public\",\n\t\t\targs: [{ name: \"new-admin\", type: \"principal\" }],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"new-admin\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"old-admin\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"set-pause-admin\",\n\t\t\taccess: \"public\",\n\t\t\targs: [{ name: \"new-admin\", type: \"principal\" }],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"new-admin\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"old-admin\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"pause-rewards\",\n\t\t\taccess: \"public\",\n\t\t\targs: [],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: \"bool\",\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n} as const satisfies AbiContract;\n",
    "import { getContract } from \"../actions/getContract.ts\";\nimport type { FeeParam } from \"../actions/wallet/utils.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../postconditions/types.ts\";\nimport {\n\ttype IntegerType,\n\thexToBytes,\n\tintToBigInt,\n} from \"../utils/encoding.ts\";\nimport { POX5_ABI } from \"./abi.ts\";\nimport { POX5_CONTRACT_NAME } from \"./constants.ts\";\nimport type {\n\tBondAllowance,\n\tBondMembership,\n\tProtocolBond,\n\tSignerInfo,\n\tStakerInfo,\n} from \"./types.ts\";\n\n/**\n * PoX-5 contract calls and reads, pinned against the final contract in\n * stacks-core 4.0.0. Wallet actions route through `callContract`, so they\n * inherit fee tiers, nonce management, and typed broadcast errors; pair the\n * returned txid with `waitForTransactionReceipt` to await inclusion.\n *\n * Note: pox-5 uses `contract-caller`/`tx-sender` directly (there is no\n * `allow-contract-caller` indirection like pox-4). Amount/lock safety is\n * expressed with the new Epoch 4.0 `Staking`/`Pox` post-conditions — pass\n * them via `postConditions` on any of these actions.\n */\n\n/** Resolve the boot `pox-5` contract id for the client's chain. */\nexport function pox5ContractId(client: Client): string {\n\tconst boot = client.chain?.bootAddress;\n\tif (!boot) throw new Error(\"Client must have a chain with a bootAddress\");\n\treturn `${boot}.${POX5_CONTRACT_NAME}`;\n}\n\ntype TxOptions = {\n\tfee?: FeeParam;\n\tnonce?: IntegerType;\n\tpostConditions?: PostConditionInput[];\n\tpostConditionMode?: PostConditionMode;\n};\n\nfunction getPox5Contract(client: Client) {\n\tconst [address, name] = pox5ContractId(client).split(\".\") as [string, string];\n\treturn getContract({ client, address, name, abi: POX5_ABI });\n}\n\n// ---------------------------------------------------------------------------\n// L1 BTC lockup proof shape (register-for-bond's ok-branch outputs)\n// ---------------------------------------------------------------------------\n\n/**\n * One proven L1 timelock output — a Bitcoin SPV inclusion proof of the lockup\n * tx plus which output is the lockup. `@secondlayer/stacks/bitcoin`'s\n * `buildTxProof` produces the proof fields.\n */\nexport type L1LockupOutput = {\n\t/** Burn height of the Bitcoin block containing the lockup tx. */\n\theight: IntegerType;\n\t/** Raw Bitcoin tx (witness-stripped), hex or bytes. */\n\ttx: Uint8Array | string;\n\toutputIndex: IntegerType;\n\t/** 80-byte Bitcoin block header. */\n\theader: Uint8Array | string;\n\t/** Merkle siblings, leaf→root (max 14). */\n\tleafHashes: Array<Uint8Array | string>;\n\ttxCount: IntegerType;\n\ttxIndex: IntegerType;\n\t/** Output value in sats. */\n\tamount: IntegerType;\n\tunlockBurnHeight: IntegerType;\n};\n\n/** BTC side of a bond registration: proven L1 lockups, or an sBTC amount. */\nexport type BtcLockup =\n\t| { l1Outputs: L1LockupOutput[]; stakerUnlockBytes: Uint8Array | string }\n\t| { sbtcSats: IntegerType };\n\n/** ABI buff args take `Uint8Array`; hex strings decode exactly like `Cl.bufferFromHex`. */\nfunction toBytes(input: Uint8Array | string): Uint8Array {\n\treturn typeof input === \"string\" ? hexToBytes(input) : input;\n}\n\n/** ABI `(optional (buff …))` args are required-with-null. */\nfunction optionalBytes(input?: Uint8Array | string): Uint8Array | null {\n\treturn input === undefined ? null : toBytes(input);\n}\n\nconst MAX_LOCKUP_OUTPUTS = 10;\nconst MAX_LEAF_HASHES = 14;\n\n/** Map `BtcLockup` to the ABI's `(response (tuple …) uint)` arg shape. */\nfunction btcLockupArg(lockup: BtcLockup) {\n\tif (\"sbtcSats\" in lockup) return { err: intToBigInt(lockup.sbtcSats) };\n\tif (lockup.l1Outputs.length === 0) {\n\t\tthrow new Error(\n\t\t\t\"registerForBond: l1Outputs is empty — nothing would be locked\",\n\t\t);\n\t}\n\tif (lockup.l1Outputs.length > MAX_LOCKUP_OUTPUTS) {\n\t\tthrow new Error(\n\t\t\t`registerForBond: ${lockup.l1Outputs.length} lockup outputs; pox-5 accepts at most ${MAX_LOCKUP_OUTPUTS}`,\n\t\t);\n\t}\n\tfor (let i = 0; i < lockup.l1Outputs.length; i++) {\n\t\tconst n = lockup.l1Outputs[i]?.leafHashes.length ?? 0;\n\t\tif (n > MAX_LEAF_HASHES) {\n\t\t\tthrow new Error(\n\t\t\t\t`registerForBond: output ${i} has ${n} merkle siblings; pox-5 accepts at most ${MAX_LEAF_HASHES}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\tok: {\n\t\t\toutputs: lockup.l1Outputs.map((o) => ({\n\t\t\t\theight: intToBigInt(o.height),\n\t\t\t\ttx: toBytes(o.tx),\n\t\t\t\toutputIndex: intToBigInt(o.outputIndex),\n\t\t\t\theader: toBytes(o.header),\n\t\t\t\tleafHashes: o.leafHashes.map(toBytes),\n\t\t\t\ttxCount: intToBigInt(o.txCount),\n\t\t\t\ttxIndex: intToBigInt(o.txIndex),\n\t\t\t\tamount: intToBigInt(o.amount),\n\t\t\t\tunlockBurnHeight: intToBigInt(o.unlockBurnHeight),\n\t\t\t})),\n\t\t\tstakerUnlockBytes: toBytes(lockup.stakerUnlockBytes),\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Wallet actions (broadcast a pox-5 contract call, return the txid)\n// ---------------------------------------------------------------------------\n\nexport type SetupBondParams = TxOptions & {\n\tbondIndex: IntegerType;\n\t/** Target yield rate, basis points. */\n\ttargetRate: IntegerType;\n\t/** µSTX per 100 sats (BTCUSD / STXUSD representation). */\n\tstxValueRatio: IntegerType;\n\t/** Minimum locked STX relative to BTC, basis points. */\n\tminUstxRatio: IntegerType;\n\t/** Early-unlock subscript for this bond's L1 lockup scripts (max 683B). */\n\tearlyUnlockBytes: Uint8Array | string;\n\tallowlist: Array<{ staker: string; maxSats: IntegerType }>;\n};\n\n/** `setup-bond` — bond-admin only. */\nexport function setupBond(\n\tclient: Client,\n\tparams: SetupBondParams,\n): Promise<string> {\n\tconst {\n\t\tbondIndex,\n\t\ttargetRate,\n\t\tstxValueRatio,\n\t\tminUstxRatio,\n\t\tearlyUnlockBytes,\n\t\tallowlist,\n\t\t...tx\n\t} = params;\n\treturn getPox5Contract(client).call.setupBond(\n\t\t{\n\t\t\tbondIndex: intToBigInt(bondIndex),\n\t\t\ttargetRate: intToBigInt(targetRate),\n\t\t\tstxValueRatio: intToBigInt(stxValueRatio),\n\t\t\tminUstxRatio: intToBigInt(minUstxRatio),\n\t\t\tearlyUnlockBytes: toBytes(earlyUnlockBytes),\n\t\t\tallowlist: allowlist.map((a) => ({\n\t\t\t\tstaker: a.staker,\n\t\t\t\tmaxSats: intToBigInt(a.maxSats),\n\t\t\t})),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type RegisterForBondParams = TxOptions & {\n\tbondIndex: IntegerType;\n\t/** Signer-manager contract principal. */\n\tsignerManager: string;\n\tamountUstx: IntegerType;\n\tbtcLockup: BtcLockup;\n\tsignerCalldata?: Uint8Array | string;\n};\n\n/** `register-for-bond` — join a bond with proven L1 lockups or sBTC. */\nexport function registerForBond(\n\tclient: Client,\n\tparams: RegisterForBondParams,\n): Promise<string> {\n\tconst {\n\t\tbondIndex,\n\t\tsignerManager,\n\t\tamountUstx,\n\t\tbtcLockup,\n\t\tsignerCalldata,\n\t\t...tx\n\t} = params;\n\treturn getPox5Contract(client).call.registerForBond(\n\t\t{\n\t\t\tbondIndex: intToBigInt(bondIndex),\n\t\t\tsignerManager,\n\t\t\tamountUstx: intToBigInt(amountUstx),\n\t\t\tbtcLockup: btcLockupArg(btcLockup),\n\t\t\tsignerCalldata: optionalBytes(signerCalldata),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type UpdateBondRegistrationParams = TxOptions & {\n\tsignerManager: string;\n\toldSignerManager: string;\n\tsignerCalldata?: Uint8Array | string;\n};\n\n/** `update-bond-registration` — switch signer-managers mid-bond. */\nexport function updateBondRegistration(\n\tclient: Client,\n\tparams: UpdateBondRegistrationParams,\n): Promise<string> {\n\tconst { signerManager, oldSignerManager, signerCalldata, ...tx } = params;\n\treturn getPox5Contract(client).call.updateBondRegistration(\n\t\t{\n\t\t\tsignerManager,\n\t\t\toldSignerManager,\n\t\t\tsignerCalldata: optionalBytes(signerCalldata),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type StakeParams = TxOptions & {\n\tsignerManager: string;\n\tamountUstx: IntegerType;\n\tnumCycles: IntegerType;\n\tstartBurnHeight: IntegerType;\n\tsignerCalldata?: Uint8Array | string;\n};\n\n/** `stake` — STX-only staking. */\nexport function stake(client: Client, params: StakeParams): Promise<string> {\n\tconst {\n\t\tsignerManager,\n\t\tamountUstx,\n\t\tnumCycles,\n\t\tstartBurnHeight,\n\t\tsignerCalldata,\n\t\t...tx\n\t} = params;\n\treturn getPox5Contract(client).call.stake(\n\t\t{\n\t\t\tsignerManager,\n\t\t\tamountUstx: intToBigInt(amountUstx),\n\t\t\tnumCycles: intToBigInt(numCycles),\n\t\t\tstartBurnHt: intToBigInt(startBurnHeight),\n\t\t\tsignerCalldata: optionalBytes(signerCalldata),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type StakeUpdateParams = TxOptions & {\n\tsignerManager: string;\n\toldSignerManager: string;\n\tcyclesToExtend: IntegerType;\n\tamountIncrease: IntegerType;\n\tsignerCalldata?: Uint8Array | string;\n};\n\n/** `stake-update` — extend and/or increase an STX-only position. */\nexport function stakeUpdate(\n\tclient: Client,\n\tparams: StakeUpdateParams,\n): Promise<string> {\n\tconst {\n\t\tsignerManager,\n\t\toldSignerManager,\n\t\tcyclesToExtend,\n\t\tamountIncrease,\n\t\tsignerCalldata,\n\t\t...tx\n\t} = params;\n\treturn getPox5Contract(client).call.stakeUpdate(\n\t\t{\n\t\t\tsignerManager,\n\t\t\toldSignerManager,\n\t\t\tcyclesToExtend: intToBigInt(cyclesToExtend),\n\t\t\tamountIncrease: intToBigInt(amountIncrease),\n\t\t\tsignerCalldata: optionalBytes(signerCalldata),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type UnstakeParams = TxOptions & { oldSignerManager: string };\n\n/** `unstake` — wind down an STX-only position at the next cycle. */\nexport function unstake(\n\tclient: Client,\n\tparams: UnstakeParams,\n): Promise<string> {\n\tconst { oldSignerManager, ...tx } = params;\n\treturn getPox5Contract(client).call.unstake({ oldSignerManager }, tx);\n}\n\nexport type UnstakeSbtcParams = TxOptions & {\n\tsignerManager: string;\n\tamountSats: IntegerType;\n};\n\n/** `unstake-sbtc` — withdraw custodied sBTC from a bond (rejected in prepare phase). */\nexport function unstakeSbtc(\n\tclient: Client,\n\tparams: UnstakeSbtcParams,\n): Promise<string> {\n\tconst { signerManager, amountSats, ...tx } = params;\n\treturn getPox5Contract(client).call.unstakeSbtc(\n\t\t{ signerManager, amountToWithdrawalSats: intToBigInt(amountSats) },\n\t\ttx,\n\t);\n}\n\nexport type AnnounceL1EarlyExitParams = TxOptions & {\n\tstaker: string;\n\toldSignerManager: string;\n};\n\n/** `announce-l1-early-exit` — staker-callable since 4.0.0 (rejected in prepare phase). */\nexport function announceL1EarlyExit(\n\tclient: Client,\n\tparams: AnnounceL1EarlyExitParams,\n): Promise<string> {\n\tconst { staker, oldSignerManager, ...tx } = params;\n\treturn getPox5Contract(client).call.announceL1EarlyExit(\n\t\t{ staker, oldSignerManager },\n\t\ttx,\n\t);\n}\n\nexport type CalculateRewardsParams = TxOptions & {\n\tbondPeriods: IntegerType[];\n};\n\n/** `calculate-rewards` — settle the reward accounting for up to 6 bond periods. */\nexport function calculateRewards(\n\tclient: Client,\n\tparams: CalculateRewardsParams,\n): Promise<string> {\n\tconst { bondPeriods, ...tx } = params;\n\treturn getPox5Contract(client).call.calculateRewards(\n\t\t{ bondPeriods: bondPeriods.map(intToBigInt) },\n\t\ttx,\n\t);\n}\n\nexport type ClaimRewardsParams = TxOptions & {\n\tbondPeriods: IntegerType[];\n\trewardCycle: IntegerType;\n};\n\n/** `claim-rewards` — signer-manager claims accrued rewards for a cycle. */\nexport function claimRewards(\n\tclient: Client,\n\tparams: ClaimRewardsParams,\n): Promise<string> {\n\tconst { bondPeriods, rewardCycle, ...tx } = params;\n\treturn getPox5Contract(client).call.claimRewards(\n\t\t{\n\t\t\tbondPeriods: bondPeriods.map(intToBigInt),\n\t\t\trewardCycle: intToBigInt(rewardCycle),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type ClaimStakerRewardsForSignerParams = TxOptions & {\n\tstaker: string;\n\trewardCycle: IntegerType;\n\tbondIndex?: IntegerType;\n};\n\n/** `claim-staker-rewards-for-signer`. */\nexport function claimStakerRewardsForSigner(\n\tclient: Client,\n\tparams: ClaimStakerRewardsForSignerParams,\n): Promise<string> {\n\tconst { staker, rewardCycle, bondIndex, ...tx } = params;\n\treturn getPox5Contract(client).call.claimStakerRewardsForSigner(\n\t\t{\n\t\t\tstaker,\n\t\t\trewardCycle: intToBigInt(rewardCycle),\n\t\t\tbondIndex: bondIndex === undefined ? null : intToBigInt(bondIndex),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type GrantSignerKeyParams = TxOptions & {\n\t/** 33-byte compressed signer key. */\n\tsignerKey: Uint8Array | string;\n\tsignerManager: string;\n\tauthId: IntegerType;\n\t/** 65-byte RSV signature from `signSignerGrant`. */\n\tsignerSig: Uint8Array | string;\n};\n\n/** `grant-signer-key` — callable by the signer-manager contract itself. */\nexport function grantSignerKey(\n\tclient: Client,\n\tparams: GrantSignerKeyParams,\n): Promise<string> {\n\tconst { signerKey, signerManager, authId, signerSig, ...tx } = params;\n\treturn getPox5Contract(client).call.grantSignerKey(\n\t\t{\n\t\t\tsignerKey: toBytes(signerKey),\n\t\t\tsignerManager,\n\t\t\tauthId: intToBigInt(authId),\n\t\t\tsignerSig: toBytes(signerSig),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type RevokeSignerGrantParams = TxOptions & {\n\tsignerManager: string;\n\tsignerKey: Uint8Array | string;\n};\n\n/** `revoke-signer-grant`. */\nexport function revokeSignerGrant(\n\tclient: Client,\n\tparams: RevokeSignerGrantParams,\n): Promise<string> {\n\tconst { signerManager, signerKey, ...tx } = params;\n\treturn getPox5Contract(client).call.revokeSignerGrant(\n\t\t{ signerManager, signerKey: toBytes(signerKey) },\n\t\ttx,\n\t);\n}\n\nexport type SetBondAdminParams = TxOptions & { newAdmin: string };\n\n/** `set-bond-admin` — current bond-admin only. */\nexport function setBondAdmin(\n\tclient: Client,\n\tparams: SetBondAdminParams,\n): Promise<string> {\n\tconst { newAdmin, ...tx } = params;\n\treturn getPox5Contract(client).call.setBondAdmin({ newAdmin }, tx);\n}\n\nexport type SetPauseAdminParams = TxOptions & { newAdmin: string };\n\n/** `set-pause-admin` — current pause-admin only. */\nexport function setPauseAdmin(\n\tclient: Client,\n\tparams: SetPauseAdminParams,\n): Promise<string> {\n\tconst { newAdmin, ...tx } = params;\n\treturn getPox5Contract(client).call.setPauseAdmin({ newAdmin }, tx);\n}\n\nexport type PauseRewardsParams = TxOptions;\n\n/**\n * `pause-rewards` — one-way. After this call succeeds, rewards stay paused\n * (`ERR_REWARDS_PAUSED`); there is no unpause.\n */\nexport function pauseRewards(\n\tclient: Client,\n\tparams?: PauseRewardsParams,\n): Promise<string> {\n\treturn getPox5Contract(client).call.pauseRewards({}, params ?? {});\n}\n\n// ---------------------------------------------------------------------------\n// Reads (JS-mapped return types — see types.ts)\n// ---------------------------------------------------------------------------\n\n/** `get-staker-info` — lock dimensions + signer, `none` when expired/absent. */\nexport async function getStakerInfo(\n\tclient: Client,\n\tstaker: string,\n): Promise<StakerInfo> {\n\treturn (await getPox5Contract(client).read.getStakerInfo({\n\t\tstaker,\n\t})) as StakerInfo;\n}\n\n/** `get-bond-membership` — the staker's active bond membership, if any. */\nexport async function getBondMembership(\n\tclient: Client,\n\tstaker: string,\n): Promise<BondMembership> {\n\treturn (await getPox5Contract(client).read.getBondMembership({\n\t\tstaker,\n\t})) as BondMembership;\n}\n\n/** `get-protocol-bond` — a bond's core parameters. */\nexport async function getProtocolBond(\n\tclient: Client,\n\tbondIndex: IntegerType,\n): Promise<ProtocolBond> {\n\treturn (await getPox5Contract(client).read.getProtocolBond({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t})) as ProtocolBond;\n}\n\n/** `get-bond-allowance` — a staker's allowlisted max sats for a bond. */\nexport async function getBondAllowance(\n\tclient: Client,\n\tbondIndex: IntegerType,\n\tstaker: string,\n): Promise<BondAllowance> {\n\treturn (await getPox5Contract(client).read.getBondAllowance({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t\tstaker,\n\t})) as BondAllowance;\n}\n\n/** `get-total-sbtc-staked-for-bond`. */\nexport function getTotalSbtcStakedForBond(\n\tclient: Client,\n\tbondIndex: IntegerType,\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getTotalSbtcStakedForBond({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t});\n}\n\n/** `get-staker-custodied-sbtc`. */\nexport function getStakerCustodiedSbtc(\n\tclient: Client,\n\tstaker: string,\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getStakerCustodiedSbtc({ staker });\n}\n\n/** `has-announced-l1-early-exit`. */\nexport function hasAnnouncedL1EarlyExit(\n\tclient: Client,\n\tbondIndex: IntegerType,\n\tstaker: string,\n): Promise<boolean> {\n\treturn getPox5Contract(client).read.hasAnnouncedL1EarlyExit({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t\tstaker,\n\t});\n}\n\n/** `get-bond-l1-unlock-height` — half a cycle before the bond period ends. */\nexport function getBondL1UnlockHeight(\n\tclient: Client,\n\tbondIndex: IntegerType,\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getBondL1UnlockHeight({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t});\n}\n\n/** `get-signer-info`. */\nexport async function getSignerInfo(\n\tclient: Client,\n\tsigner: string,\n): Promise<SignerInfo> {\n\treturn (await getPox5Contract(client).read.getSignerInfo({\n\t\tsigner,\n\t})) as SignerInfo;\n}\n\n/** `verify-signer-key-grant` — whether a grant exists on-chain. */\nexport function verifySignerKeyGrantOnChain(\n\tclient: Client,\n\tsignerManager: string,\n\tsignerKey: Uint8Array | string,\n): Promise<boolean> {\n\treturn getPox5Contract(client).read.verifySignerKeyGrant({\n\t\tsignerManager,\n\t\tsignerKey: toBytes(signerKey),\n\t});\n}\n\n/** `current-pox-reward-cycle`. */\nexport function getCurrentRewardCycle(client: Client): Promise<bigint> {\n\treturn getPox5Contract(client).read.currentPoxRewardCycle({});\n}\n\n/** `get-first-pox-5-reward-cycle`. */\nexport function getFirstPox5RewardCycle(client: Client): Promise<bigint> {\n\treturn getPox5Contract(client).read.getFirstPox5RewardCycle({});\n}\n\n/** `get-earned` — claimable rewards for a signer in a cycle (optional bond). */\nexport function getEarned(\n\tclient: Client,\n\tparams: {\n\t\tsigner: string;\n\t\trewardCycle: IntegerType;\n\t\tbondIndex?: IntegerType;\n\t},\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getEarned({\n\t\tsigner: params.signer,\n\t\trewardCycle: intToBigInt(params.rewardCycle),\n\t\tbondIndex:\n\t\t\tparams.bondIndex === undefined ? null : intToBigInt(params.bondIndex),\n\t});\n}\n\n/** `get-earned-staker-rewards` — a staker's share of a signer's cycle rewards. */\nexport function getEarnedStakerRewards(\n\tclient: Client,\n\tparams: {\n\t\tsigner: string;\n\t\trewardCycle: IntegerType;\n\t\tbondIndex?: IntegerType;\n\t\tstaker: string;\n\t},\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getEarnedStakerRewards({\n\t\tsigner: params.signer,\n\t\trewardCycle: intToBigInt(params.rewardCycle),\n\t\tbondIndex:\n\t\t\tparams.bondIndex === undefined ? null : intToBigInt(params.bondIndex),\n\t\tstaker: params.staker,\n\t});\n}\n\n/** `get-last-reward-compute-height`. */\nexport function getLastRewardComputeHeight(client: Client): Promise<bigint> {\n\treturn getPox5Contract(client).read.getLastRewardComputeHeight({});\n}\n\n/** `get-total-shares-staked-for-cycle`. */\nexport function getTotalSharesStakedForCycle(\n\tclient: Client,\n\trewardCycle: IntegerType,\n\tbondIndex?: IntegerType,\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getTotalSharesStakedForCycle({\n\t\trewardCycle: intToBigInt(rewardCycle),\n\t\tbondIndex: bondIndex === undefined ? null : intToBigInt(bondIndex),\n\t});\n}\n",
    "import { BOND_GAP_CYCLES, BOND_LENGTH_CYCLES } from \"./constants.ts\";\n\n/**\n * Pure cycle/height math, mirroring the pox-5 helper read-onlys byte-for-byte\n * (`burn-height-to-reward-cycle`, `reward-cycle-to-burn-height`,\n * `bond-period-to-reward-cycle`, `burn-height-to-distribution-index`).\n *\n * All functions anchor on chain-reported parameters — pass values from\n * `/v2/pox` (`first_burnchain_block_height`, `reward_cycle_length`,\n * `prepare_cycle_length`) and `getPox5Activation` (`firstRewardCycleId` =\n * the contract's `first-bond-period-cycle`). Nothing is hardcoded, so the\n * math is correct on mainnet, testnet, and devnet alike.\n */\nexport type PoxCycleParams = {\n\t/** `/v2/pox` `first_burnchain_block_height`. */\n\tfirstBurnchainBlockHeight: number;\n\t/** `/v2/pox` `reward_cycle_length` (mainnet 2100). */\n\trewardCycleLength: number;\n};\n\nexport type BondCycleParams = PoxCycleParams & {\n\t/** pox-5's first bond-period cycle (`getPox5Activation().firstRewardCycleId`). */\n\tfirstBondPeriodCycle: number;\n};\n\n/** Reward cycle containing `burnHeight`. Mirrors `burn-height-to-reward-cycle`. */\nexport function burnHeightToRewardCycle(\n\tburnHeight: number,\n\tparams: PoxCycleParams,\n): number {\n\tif (burnHeight < params.firstBurnchainBlockHeight) {\n\t\tthrow new Error(\n\t\t\t`burnHeight ${burnHeight} precedes first burnchain block ${params.firstBurnchainBlockHeight}`,\n\t\t);\n\t}\n\treturn Math.floor(\n\t\t(burnHeight - params.firstBurnchainBlockHeight) / params.rewardCycleLength,\n\t);\n}\n\n/** Burn height at the start of `cycle`. Mirrors `reward-cycle-to-burn-height`. */\nexport function rewardCycleToBurnHeight(\n\tcycle: number,\n\tparams: PoxCycleParams,\n): number {\n\treturn params.firstBurnchainBlockHeight + cycle * params.rewardCycleLength;\n}\n\n/** Reward cycle at which bond period `bondIndex` starts. Mirrors `bond-period-to-reward-cycle`. */\nexport function bondPeriodToRewardCycle(\n\tbondIndex: number,\n\tparams: BondCycleParams,\n): number {\n\treturn params.firstBondPeriodCycle + bondIndex * BOND_GAP_CYCLES;\n}\n\n/** Burn height at which bond period `bondIndex` starts. Mirrors `bond-period-to-burn-height`. */\nexport function bondPeriodToBurnHeight(\n\tbondIndex: number,\n\tparams: BondCycleParams,\n): number {\n\treturn rewardCycleToBurnHeight(\n\t\tbondPeriodToRewardCycle(bondIndex, params),\n\t\tparams,\n\t);\n}\n\n/** First reward cycle in which bond `bondIndex`'s STX unlock (start + 12 cycles). */\nexport function bondUnlockCycle(\n\tbondIndex: number,\n\tparams: BondCycleParams,\n): number {\n\treturn bondPeriodToRewardCycle(bondIndex, params) + BOND_LENGTH_CYCLES;\n}\n\n/**\n * Minimum L1 CLTV height for bond `bondIndex` — half a cycle before the\n * bond period ends. Mirrors `get-bond-l1-unlock-height`. Distinct from\n * {@link bondUnlockCycle} (the STX unlock cycle).\n */\nexport function computeBondUnlockHeight(\n\tbondIndex: number,\n\tparams: BondCycleParams,\n): number {\n\tconst endCycle = bondPeriodToRewardCycle(\n\t\tbondIndex + BOND_LENGTH_CYCLES / BOND_GAP_CYCLES,\n\t\tparams,\n\t);\n\treturn (\n\t\trewardCycleToBurnHeight(endCycle, params) -\n\t\tMath.floor(params.rewardCycleLength / 2)\n\t);\n}\n\n/**\n * Distribution-cycle index at `burnHeight` — distribution cycles are half a\n * reward cycle long. Mirrors `burn-height-to-distribution-index`.\n */\nexport function burnHeightToDistributionIndex(\n\tburnHeight: number,\n\tparams: PoxCycleParams,\n): number {\n\treturn Math.floor(\n\t\t(burnHeight - params.firstBurnchainBlockHeight) /\n\t\t\tMath.floor(params.rewardCycleLength / 2),\n\t);\n}\n\n/** Burn height at the start of `distIndex`. Mirrors `distribution-cycle-to-burn-height`. */\nexport function distributionCycleToBurnHeight(\n\tdistIndex: number,\n\tparams: PoxCycleParams,\n): number {\n\treturn (\n\t\tparams.firstBurnchainBlockHeight +\n\t\tdistIndex * Math.floor(params.rewardCycleLength / 2)\n\t);\n}\n\n/**\n * Distribution cycle containing `burnHeight`. Named after the contract's\n * `current-distribution-cycle` but takes height as an argument — no clock.\n */\nexport function currentDistributionCycle(\n\tburnHeight: number,\n\tparams: PoxCycleParams,\n): number {\n\treturn burnHeightToDistributionIndex(burnHeight, params);\n}\n\n/**\n * Whether `burnHeight` falls in a cycle's prepare phase (the final\n * `prepareCycleLength` blocks). pox-5 rejects `unstake-sbtc` and\n * `announce-l1-early-exit` during a prepare phase.\n */\nexport function isInPreparePhase(\n\tburnHeight: number,\n\tparams: PoxCycleParams & { prepareCycleLength: number },\n): boolean {\n\tconst offset =\n\t\t(burnHeight - params.firstBurnchainBlockHeight) % params.rewardCycleLength;\n\treturn offset >= params.rewardCycleLength - params.prepareCycleLength;\n}\n\nexport type BondPhase = \"too-early\" | \"open\" | \"locked\" | \"unlocked\";\n\n/**\n * Coarse lifecycle phase of bond `bondIndex` at `burnHeight`: `too-early`\n * (before the bond's start is registerable), `open`/`locked` while active,\n * `unlocked` after 12 cycles.\n */\nexport function bondPhaseAtHeight(\n\tbondIndex: number,\n\tburnHeight: number,\n\tparams: BondCycleParams,\n): BondPhase {\n\tconst cycle = burnHeightToRewardCycle(burnHeight, params);\n\tconst start = bondPeriodToRewardCycle(bondIndex, params);\n\tconst unlock = bondUnlockCycle(bondIndex, params);\n\tif (cycle < start - BOND_GAP_CYCLES) return \"too-early\";\n\tif (cycle < start) return \"open\";\n\tif (cycle < unlock) return \"locked\";\n\treturn \"unlocked\";\n}\n\n/**\n * Prepare-aware bond lifecycle. `open` is the registerable window — it\n * ends when the start cycle's prepare phase begins (`register-for-bond`\n * then fails with `ERR_STAKE_IN_PREPARE_PHASE`). Coarse cycle buckets\n * (whole pre-start cycle as `open`) stay on {@link BondPhase}.\n *\n * `eligible`/`missed`/`finished` are omitted: they are not contract\n * states (registration is height-gated, not a per-staker enum).\n */\nexport type BondStatusName = \"too-early\" | \"open\" | \"locked\" | \"unlocked\";\n\nexport function bondStatusAtHeight(\n\tbondIndex: number,\n\tburnHeight: number,\n\tparams: BondCycleParams & { prepareCycleLength: number },\n): BondStatusName {\n\tconst cycle = burnHeightToRewardCycle(burnHeight, params);\n\tconst start = bondPeriodToRewardCycle(bondIndex, params);\n\tconst unlock = bondUnlockCycle(bondIndex, params);\n\tif (cycle < start - BOND_GAP_CYCLES) return \"too-early\";\n\tif (cycle < start) {\n\t\t// Prepare of the start cycle (last prepareCycleLength blocks of\n\t\t// cycle start-1) permanently closes registration. Other prepares\n\t\t// in the window still report `open`; st-022 layers isInPreparePhase.\n\t\tif (cycle === start - 1 && isInPreparePhase(burnHeight, params)) {\n\t\t\treturn \"locked\";\n\t\t}\n\t\treturn \"open\";\n\t}\n\tif (cycle < unlock) return \"locked\";\n\treturn \"unlocked\";\n}\n",
    "/**\n * Client-side pox-5 eligibility preflights. Rebuilds the contract's assert\n * chains from existing reads so callers can avoid burning fees on a known\n * abort.\n *\n * `reasons` is a **set**, not the on-chain abort order.\n *\n * Uncovered gates (Hiro skips these too — a preflight `{ ok: true }` is not\n * a guarantee the tx will land):\n * - `signer-manager-validate-stake!` (trait callback)\n * - L1 merkle proof (`ERR_INVALID_MERKLE_PROOF` u41)\n * - L1 lockup script match (`ERR_INVALID_LOCKUP_SCRIPT` u42)\n * - L1 lockup amount vs parsed tx (`ERR_INVALID_LOCKUP_AMOUNT` u45, except\n *   the empty-outputs case which we do flag)\n * - Bitcoin header / tx parse (`ERR_INVALID_BTC_HEADER` u40,\n *   `ERR_READ_TX_OUT_OF_BOUNDS` u39)\n *\n * These functions are never attached to wallet actions — call them\n * explicitly. Do not infer coverage of a gate from a missing reason.\n */\n\nimport { getBalance } from \"../actions/public/getBalance.ts\";\nimport { getDataVar } from \"../actions/public/getDataVar.ts\";\nimport { getMapEntry } from \"../actions/public/getMapEntry.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport {\n\ttype IntegerType,\n\tbytesToHex,\n\thexToBytes,\n\tintToBigInt,\n} from \"../utils/encoding.ts\";\nimport {\n\ttype BtcLockup,\n\tgetBondAllowance,\n\tgetBondL1UnlockHeight,\n\tgetBondMembership,\n\tgetEarned,\n\tgetProtocolBond,\n\tgetSignerInfo,\n\tgetStakerInfo,\n\tpox5ContractId,\n\tverifySignerKeyGrantOnChain,\n} from \"./actions.ts\";\nimport { getPoxInfo } from \"./activation.ts\";\nimport {\n\tBITCOIN_LOCKTIME_THRESHOLD,\n\tBOND_LENGTH_CYCLES,\n\tMAX_NUM_CYCLES,\n\tPOX5_CONTRACT_NAME,\n} from \"./constants.ts\";\nimport {\n\ttype PoxCycleParams,\n\tbondPeriodToBurnHeight,\n\tbondPeriodToRewardCycle,\n\tburnHeightToRewardCycle,\n\tisInPreparePhase,\n} from \"./cycles.ts\";\nimport { Pox5ErrorCode } from \"./errors.ts\";\nimport type { BondMembership, SignerInfo } from \"./types.ts\";\n\nexport type EligibilityResult =\n\t| { ok: true }\n\t| { ok: false; reasons: [Pox5ErrorCode, ...Pox5ErrorCode[]] };\n\nexport type EligibleStakeParams = {\n\tstaker: string;\n\tsignerManager: string;\n\tamountUstx: IntegerType;\n\tnumCycles: IntegerType;\n\tstartBurnHeight: IntegerType;\n};\n\nexport type EligibleRegisterForBondParams = {\n\tstaker: string;\n\tbondIndex: IntegerType;\n\tsignerManager: string;\n\tamountUstx: IntegerType;\n\tbtcLockup: BtcLockup;\n};\n\nexport type EligibleUnstakeParams = {\n\tstaker: string;\n\toldSignerManager: string;\n};\n\nexport type EligibleUnstakeSbtcParams = {\n\tstaker: string;\n\tsignerManager: string;\n\tamountSats: IntegerType;\n};\n\nexport type EligibleClaimRewardsParams = {\n\tsigner: string;\n\trewardCycle: IntegerType;\n\tbondIndex?: IntegerType;\n\tbondPeriods?: IntegerType[];\n};\n\nexport type EligibleGrantSignerKeyParams = {\n\tsignerKey: Uint8Array | string;\n\tsignerManager: string;\n\tauthId: IntegerType;\n};\n\nexport type EligibleAdminParams = {\n\tcaller: string;\n};\n\ntype CycleClock = {\n\tburnHeight: number;\n\tparams: PoxCycleParams & { prepareCycleLength: number };\n\tfirstBondPeriodCycle: number;\n};\n\nfunction finish(reasons: Pox5ErrorCode[]): EligibilityResult {\n\tconst unique: Pox5ErrorCode[] = [];\n\tconst seen = new Set<Pox5ErrorCode>();\n\tfor (const code of reasons) {\n\t\tif (!seen.has(code)) {\n\t\t\tseen.add(code);\n\t\t\tunique.push(code);\n\t\t}\n\t}\n\tif (unique.length === 0) return { ok: true };\n\treturn { ok: false, reasons: unique as [Pox5ErrorCode, ...Pox5ErrorCode[]] };\n}\n\nfunction toBytes(input: Uint8Array | string): Uint8Array {\n\treturn typeof input === \"string\" ? hexToBytes(input) : input;\n}\n\nfunction outpointKey(\n\ttx: Uint8Array | string,\n\toutputIndex: IntegerType,\n): string {\n\tconst hex = typeof tx === \"string\" ? tx.toLowerCase() : bytesToHex(tx);\n\treturn `${hex}:${intToBigInt(outputIndex)}`;\n}\n\n/**\n * Burn height from `getPoxInfo` (pox5/activation.ts, not frozen pox-4).\n * Cycle lengths are on `/v2/pox` but not mapped through `Pox5Info` — read\n * the same endpoint rather than guessing mainnet constants. Missing height\n * or lengths → `undefined` so callers fail closed instead of guessing.\n */\nasync function readCycleClock(client: Client): Promise<CycleClock | undefined> {\n\tconst info = await getPoxInfo(client);\n\tconst burnHeight = info.currentBurnchainBlockHeight;\n\tconst first = info.firstBurnchainBlockHeight;\n\tconst raw = (await client.request(\"/v2/pox\", { method: \"GET\" })) as {\n\t\treward_cycle_length?: number;\n\t\tprepare_cycle_length?: number;\n\t};\n\tconst pox5 = info.contractVersions.find((v) =>\n\t\tv.contractId.endsWith(`.${POX5_CONTRACT_NAME}`),\n\t);\n\tif (\n\t\ttypeof burnHeight !== \"number\" ||\n\t\ttypeof first !== \"number\" ||\n\t\ttypeof raw.reward_cycle_length !== \"number\" ||\n\t\ttypeof raw.prepare_cycle_length !== \"number\" ||\n\t\tpox5 == null\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tburnHeight,\n\t\tparams: {\n\t\t\tfirstBurnchainBlockHeight: first,\n\t\t\trewardCycleLength: raw.reward_cycle_length,\n\t\t\tprepareCycleLength: raw.prepare_cycle_length,\n\t\t},\n\t\tfirstBondPeriodCycle: pox5.firstRewardCycleId,\n\t};\n}\n\nfunction inPrepare(clock: CycleClock | undefined): boolean {\n\tif (!clock) return true;\n\treturn isInPreparePhase(clock.burnHeight, clock.params);\n}\n\nasync function signerReasons(\n\tclient: Client,\n\tsignerManager: string,\n): Promise<Pox5ErrorCode[]> {\n\tconst info: SignerInfo = await getSignerInfo(client, signerManager);\n\tif (info == null) return [Pox5ErrorCode.SignerNotFound];\n\ttry {\n\t\tconst granted = await verifySignerKeyGrantOnChain(\n\t\t\tclient,\n\t\t\tsignerManager,\n\t\t\tinfo,\n\t\t);\n\t\tif (!granted) return [Pox5ErrorCode.SignerKeyGrantNotFound];\n\t} catch {\n\t\treturn [Pox5ErrorCode.SignerKeyGrantNotFound];\n\t}\n\treturn [];\n}\n\nfunction bondOverlaps(\n\tmembership: BondMembership,\n\tnewFirstCycle: number,\n\tclock: CycleClock,\n): boolean {\n\tif (!membership) return false;\n\tconst start = bondPeriodToRewardCycle(Number(membership.bondIndex), {\n\t\t...clock.params,\n\t\tfirstBondPeriodCycle: clock.firstBondPeriodCycle,\n\t});\n\treturn start + BOND_LENGTH_CYCLES > newFirstCycle;\n}\n\nasync function stxFloor(\n\tclient: Client,\n\tstaker: string,\n\tamountUstx: bigint,\n): Promise<Pox5ErrorCode | undefined> {\n\tconst balance = await getBalance(client, { address: staker });\n\t// `/v2/accounts` `balance` is unlocked STX. Rollover (locked+unlocked)\n\t// can still succeed on-chain when this flags InsufficientStx.\n\tif (balance < amountUstx) return Pox5ErrorCode.InsufficientStx;\n\treturn undefined;\n}\n\nfunction principalValue(cv: ClarityValue): string | undefined {\n\tif (cv.type === \"address\" || cv.type === \"contract\") return cv.value;\n\treturn undefined;\n}\n\nfunction minUstxForSats(\n\tsats: bigint,\n\tstxValueRatio: bigint,\n\tminUstxRatio: bigint,\n): bigint {\n\treturn (((stxValueRatio * sats) / 100n) * minUstxRatio) / 10_000n;\n}\n\nexport async function eligibleStake(\n\tclient: Client,\n\tparams: EligibleStakeParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst amountUstx = intToBigInt(params.amountUstx);\n\tconst numCycles = intToBigInt(params.numCycles);\n\tconst startBurnHeight = intToBigInt(params.startBurnHeight);\n\n\tconst [clock, stakerInfo, membership, signerErrs, floor] = await Promise.all([\n\t\treadCycleClock(client),\n\t\tgetStakerInfo(client, params.staker),\n\t\tgetBondMembership(client, params.staker),\n\t\tsignerReasons(client, params.signerManager),\n\t\tstxFloor(client, params.staker, amountUstx),\n\t]);\n\n\tif (inPrepare(clock)) reasons.push(Pox5ErrorCode.StakeInPreparePhase);\n\treasons.push(...signerErrs);\n\tif (floor !== undefined) reasons.push(floor);\n\n\tif (numCycles < 1n || numCycles > BigInt(MAX_NUM_CYCLES)) {\n\t\treasons.push(Pox5ErrorCode.InvalidNumCycles);\n\t}\n\n\tif (clock) {\n\t\tconst currentCycle = burnHeightToRewardCycle(\n\t\t\tclock.burnHeight,\n\t\t\tclock.params,\n\t\t);\n\t\tconst firstRewardCycle = currentCycle + 1;\n\t\tconst specified =\n\t\t\tburnHeightToRewardCycle(Number(startBurnHeight), clock.params) + 1;\n\t\tif (firstRewardCycle !== specified) {\n\t\t\treasons.push(Pox5ErrorCode.InvalidStartBurnHeight);\n\t\t}\n\t\tif (stakerInfo) reasons.push(Pox5ErrorCode.AlreadyStaked);\n\t\tif (bondOverlaps(membership, firstRewardCycle, clock)) {\n\t\t\treasons.push(Pox5ErrorCode.AlreadyStaked);\n\t\t}\n\t\tif (membership) {\n\t\t\tconst unlock = await getBondL1UnlockHeight(client, membership.bondIndex);\n\t\t\tif (BigInt(clock.burnHeight) < unlock) {\n\t\t\t\treasons.push(Pox5ErrorCode.RolloverTooEarly);\n\t\t\t}\n\t\t}\n\t} else if (stakerInfo) {\n\t\treasons.push(Pox5ErrorCode.AlreadyStaked);\n\t}\n\n\treturn finish(reasons);\n}\n\nexport async function eligibleRegisterForBond(\n\tclient: Client,\n\tparams: EligibleRegisterForBondParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst amountUstx = intToBigInt(params.amountUstx);\n\tconst lockup = params.btcLockup;\n\n\tlet sats = 0n;\n\tif (\"sbtcSats\" in lockup) {\n\t\tsats = intToBigInt(lockup.sbtcSats);\n\t} else {\n\t\tif (lockup.l1Outputs.length === 0) {\n\t\t\treasons.push(Pox5ErrorCode.InvalidLockupAmount);\n\t\t}\n\t\tconst seen = new Set<string>();\n\t\tfor (const output of lockup.l1Outputs) {\n\t\t\tsats += intToBigInt(output.amount);\n\t\t\tconst key = outpointKey(output.tx, output.outputIndex);\n\t\t\tif (seen.has(key)) reasons.push(Pox5ErrorCode.DuplicateLockupOutpoint);\n\t\t\tseen.add(key);\n\t\t}\n\t}\n\n\tconst [clock, stakerInfo, membership, bond, allowance, signerErrs, floor] =\n\t\tawait Promise.all([\n\t\t\treadCycleClock(client),\n\t\t\tgetStakerInfo(client, params.staker),\n\t\t\tgetBondMembership(client, params.staker),\n\t\t\tgetProtocolBond(client, params.bondIndex),\n\t\t\tgetBondAllowance(client, params.bondIndex, params.staker),\n\t\t\tsignerReasons(client, params.signerManager),\n\t\t\tstxFloor(client, params.staker, amountUstx),\n\t\t]);\n\n\tif (inPrepare(clock)) reasons.push(Pox5ErrorCode.StakeInPreparePhase);\n\treasons.push(...signerErrs);\n\tif (floor !== undefined) reasons.push(floor);\n\n\tif (!bond) reasons.push(Pox5ErrorCode.BondNotFound);\n\tif (allowance == null) reasons.push(Pox5ErrorCode.NotAllowlisted);\n\telse if (sats > allowance) reasons.push(Pox5ErrorCode.TooMuchSats);\n\n\tif (bond) {\n\t\tconst min = minUstxForSats(sats, bond.stxValueRatio, bond.minUstxRatio);\n\t\tif (amountUstx < min) reasons.push(Pox5ErrorCode.InsufficientStx);\n\t}\n\n\tif (clock) {\n\t\tconst bondStart = bondPeriodToBurnHeight(\n\t\t\tNumber(intToBigInt(params.bondIndex)),\n\t\t\t{\n\t\t\t\t...clock.params,\n\t\t\t\tfirstBondPeriodCycle: clock.firstBondPeriodCycle,\n\t\t\t},\n\t\t);\n\t\tif (clock.burnHeight >= bondStart) {\n\t\t\treasons.push(Pox5ErrorCode.BondAlreadyStarted);\n\t\t}\n\t\tconst firstRewardCycle = bondPeriodToRewardCycle(\n\t\t\tNumber(intToBigInt(params.bondIndex)),\n\t\t\t{ ...clock.params, firstBondPeriodCycle: clock.firstBondPeriodCycle },\n\t\t);\n\t\tif (stakerInfo) {\n\t\t\tconst unlockCycle =\n\t\t\t\tNumber(stakerInfo.firstRewardCycle) + Number(stakerInfo.numCycles);\n\t\t\tif (unlockCycle > firstRewardCycle) {\n\t\t\t\treasons.push(Pox5ErrorCode.AlreadyStaked);\n\t\t\t}\n\t\t}\n\t\tif (bondOverlaps(membership, firstRewardCycle, clock)) {\n\t\t\treasons.push(Pox5ErrorCode.AlreadyRegistered);\n\t\t}\n\t\tif (membership) {\n\t\t\tconst unlock = await getBondL1UnlockHeight(client, membership.bondIndex);\n\t\t\tif (BigInt(clock.burnHeight) < unlock) {\n\t\t\t\treasons.push(Pox5ErrorCode.RolloverTooEarly);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (\"l1Outputs\" in lockup && lockup.l1Outputs.length > 0) {\n\t\tconst minUnlock = await getBondL1UnlockHeight(client, params.bondIndex);\n\t\tfor (const output of lockup.l1Outputs) {\n\t\t\tconst height = intToBigInt(output.unlockBurnHeight);\n\t\t\tif (height < minUnlock || height >= BITCOIN_LOCKTIME_THRESHOLD) {\n\t\t\t\treasons.push(Pox5ErrorCode.InvalidUnlockHeight);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn finish(reasons);\n}\n\nexport async function eligibleUnstake(\n\tclient: Client,\n\tparams: EligibleUnstakeParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst [clock, stakerInfo] = await Promise.all([\n\t\treadCycleClock(client),\n\t\tgetStakerInfo(client, params.staker),\n\t]);\n\tif (inPrepare(clock)) reasons.push(Pox5ErrorCode.UnstakeInPreparePhase);\n\tif (!stakerInfo) reasons.push(Pox5ErrorCode.NotStaking);\n\telse if (stakerInfo.signer !== params.oldSignerManager) {\n\t\treasons.push(Pox5ErrorCode.InvalidOldSignerManager);\n\t}\n\treturn finish(reasons);\n}\n\nexport async function eligibleUnstakeSbtc(\n\tclient: Client,\n\tparams: EligibleUnstakeSbtcParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst amount = intToBigInt(params.amountSats);\n\tconst [clock, membership] = await Promise.all([\n\t\treadCycleClock(client),\n\t\tgetBondMembership(client, params.staker),\n\t]);\n\t// unstake-sbtc uses verify-not-prepare-phase → ERR_STAKE_IN_PREPARE_PHASE\n\tif (inPrepare(clock)) reasons.push(Pox5ErrorCode.StakeInPreparePhase);\n\tif (!membership) reasons.push(Pox5ErrorCode.NotBondParticipant);\n\telse {\n\t\tif (membership.signer !== params.signerManager) {\n\t\t\treasons.push(Pox5ErrorCode.InvalidOldSignerManager);\n\t\t}\n\t\tif (membership.isL1Lock) reasons.push(Pox5ErrorCode.CannotUnstakeSbtc);\n\t\tif (amount > membership.amountSats) {\n\t\t\treasons.push(Pox5ErrorCode.InvalidUnstakeSbtcAmount);\n\t\t}\n\t}\n\treturn finish(reasons);\n}\n\nexport async function eligibleClaimRewards(\n\tclient: Client,\n\tparams: EligibleClaimRewardsParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst contract = pox5ContractId(client);\n\tconst paused = await getDataVar(client, {\n\t\tcontract,\n\t\tvarName: \"rewards-paused\",\n\t});\n\tif (paused.type === \"true\") reasons.push(Pox5ErrorCode.RewardsPaused);\n\n\tconst periods = params.bondPeriods ?? [];\n\tconst earnedParts = await Promise.all([\n\t\tgetEarned(client, {\n\t\t\tsigner: params.signer,\n\t\t\trewardCycle: params.rewardCycle,\n\t\t\tbondIndex: params.bondIndex,\n\t\t}),\n\t\t...periods.map((bondIndex) =>\n\t\t\tgetEarned(client, {\n\t\t\t\tsigner: params.signer,\n\t\t\t\trewardCycle: params.rewardCycle,\n\t\t\t\tbondIndex,\n\t\t\t}),\n\t\t),\n\t]);\n\tlet total = 0n;\n\tfor (const part of earnedParts) total += part;\n\tif (total === 0n) reasons.push(Pox5ErrorCode.NoClaimableRewards);\n\n\treturn finish(reasons);\n}\n\nexport async function eligibleGrantSignerKey(\n\tclient: Client,\n\tparams: EligibleGrantSignerKeyParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst used = await getMapEntry(client, {\n\t\tcontract: pox5ContractId(client),\n\t\tmapName: \"used-signer-key-grants\",\n\t\tkey: Cl.tuple({\n\t\t\t\"signer-key\": Cl.buffer(toBytes(params.signerKey)),\n\t\t\t\"signer-manager\": Cl.principal(params.signerManager),\n\t\t\t\"auth-id\": Cl.uint(intToBigInt(params.authId)),\n\t\t}),\n\t});\n\tif (used.type === \"some\") reasons.push(Pox5ErrorCode.SignerKeyGrantUsed);\n\treturn finish(reasons);\n}\n\nexport async function eligibleSetBondAdmin(\n\tclient: Client,\n\tparams: EligibleAdminParams,\n): Promise<EligibilityResult> {\n\tconst admin = await getDataVar(client, {\n\t\tcontract: pox5ContractId(client),\n\t\tvarName: \"bond-admin\",\n\t});\n\tif (principalValue(admin) !== params.caller) {\n\t\treturn finish([Pox5ErrorCode.Unauthorized]);\n\t}\n\treturn { ok: true };\n}\n\nexport async function eligiblePauseRewards(\n\tclient: Client,\n\tparams: EligibleAdminParams,\n): Promise<EligibilityResult> {\n\tconst admin = await getDataVar(client, {\n\t\tcontract: pox5ContractId(client),\n\t\tvarName: \"pause-admin\",\n\t});\n\tif (principalValue(admin) !== params.caller) {\n\t\treturn finish([Pox5ErrorCode.Unauthorized]);\n\t}\n\treturn { ok: true };\n}\n",
    "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bech32 } from \"@scure/base\";\nimport { BITCOIN_NETWORK_PARAMS } from \"../bitcoin/address.ts\";\nimport type { BitcoinNetwork } from \"../bitcoin/constants.ts\";\nimport { serializeCVBytes } from \"../clarity/serialize.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { concatBytes, hexToBytes } from \"../utils/encoding.ts\";\nimport { BITCOIN_LOCKTIME_THRESHOLD, C_SCRIPT_NUM_MAX } from \"./constants.ts\";\nimport { type BondCycleParams, computeBondUnlockHeight } from \"./cycles.ts\";\n\n/**\n * Byte-for-byte TypeScript mirrors of pox-5's Bitcoin-script helpers\n * (`serialize-c-script-num`, `push-c-script-num`, `push-script-bytes`,\n * `construct-lockup-script`, `construct-lockup-output-script`), pinned\n * against the final contract in stacks-core 4.0.1. The contract validates a\n * staker's L1 lockup output against exactly these bytes, so any divergence\n * means a rejected registration — the read-onlys on-chain double as a\n * cross-check oracle for these functions.\n */\n\n/**\n * Minimal little-endian ScriptNum encoding of a non-negative integer\n * (`0` → empty; a `0x00` sign byte is appended when the top byte's high bit\n * is set). Mirrors `serialize-c-script-num`, including its 2^39 ceiling.\n */\nexport function serializeCScriptNum(n: number | bigint): Uint8Array {\n\tconst big = typeof n === \"bigint\" ? n : BigInt(n);\n\tif (big < 0n) throw new Error(\"serializeCScriptNum: negative value\");\n\tif (big >= C_SCRIPT_NUM_MAX) {\n\t\tthrow new Error(\n\t\t\t\"serializeCScriptNum: n >= 2^39 (contract rejects with ERR_INVALID_UNLOCK_HEIGHT)\",\n\t\t);\n\t}\n\tif (big === 0n) return new Uint8Array(0);\n\tconst out: number[] = [];\n\tlet v = big;\n\twhile (v > 0n) {\n\t\tout.push(Number(v & 0xffn));\n\t\tv >>= 8n;\n\t}\n\tif ((out[out.length - 1] as number) & 0x80) out.push(0x00);\n\treturn Uint8Array.from(out);\n}\n\n/**\n * Push arbitrary bytes onto a Bitcoin script: direct length byte under 76,\n * `OP_PUSHDATA1` under 256, `OP_PUSHDATA2` otherwise. Mirrors\n * `push-script-bytes`.\n */\nexport function pushScriptBytes(bytes: Uint8Array): Uint8Array {\n\tconst len = bytes.length;\n\tif (len > 0xffff)\n\t\tthrow new Error(`pushScriptBytes: payload too large (${len} > 65535)`);\n\tlet prefix: Uint8Array;\n\tif (len < 76) prefix = Uint8Array.of(len);\n\telse if (len < 256) prefix = Uint8Array.of(0x4c, len);\n\telse prefix = Uint8Array.of(0x4d, len & 0xff, len >> 8);\n\treturn concatBytes(prefix, bytes);\n}\n\n/**\n * Push a numeric script value: `OP_0` for zero, the single-byte ops\n * `OP_1`..`OP_16` for 1–16, else a minimal ScriptNum push. Mirrors\n * `push-c-script-num`.\n */\nexport function pushCScriptNum(n: number | bigint): Uint8Array {\n\tconst big = typeof n === \"bigint\" ? n : BigInt(n);\n\tif (big === 0n) return Uint8Array.of(0x00);\n\tif (big >= 1n && big <= 16n) return Uint8Array.of(0x50 + Number(big));\n\treturn pushScriptBytes(serializeCScriptNum(big));\n}\n\n/** `to-consensus-buff?` of a principal — the staker identity the script commits to. */\nexport function stakerConsensusBuff(stxAddress: string): Uint8Array {\n\treturn serializeCVBytes(Cl.principal(stxAddress));\n}\n\n/**\n * The 32-byte witness item the early-exit branch must reveal:\n * `sha256(to-consensus-buff? staker)`. The script stores `sha256` of THIS,\n * so revealing it proves which staker the exit is for.\n */\nexport function stakerPreimage(stxAddress: string): Uint8Array {\n\treturn sha256(stakerConsensusBuff(stxAddress));\n}\n\nexport type BuildLockupScriptOptions = {\n\t/** Staker principal (standard or contract address). */\n\tstxAddress: string;\n\t/** Burn height at which the CLTV branch becomes spendable. */\n\tunlockBurnHeight: number | bigint;\n\t/** Staker-signature subscript, run last in BOTH branches. */\n\tstakerUnlockBytes: Uint8Array | string;\n\t/** Per-bond early-unlock subscript (from `protocol-bonds.early-unlock-bytes`). */\n\tearlyUnlockBytes: Uint8Array | string;\n};\n\nfunction toBytes(input: Uint8Array | string): Uint8Array {\n\treturn typeof input === \"string\" ? hexToBytes(input) : input;\n}\n\n/**\n * The L1 lockup witness script. Mirrors `construct-lockup-script`:\n *\n * ```\n * OP_IF\n *   <unlockBurnHeight> OP_CHECKLOCKTIMEVERIFY\n * OP_ELSE\n *   OP_SIZE <32> OP_EQUALVERIFY OP_SHA256\n *   <sha256(sha256(consensus-buff(staker)))> OP_EQUALVERIFY\n *   <earlyUnlockBytes>\n * OP_ENDIF\n * OP_VERIFY\n * <stakerUnlockBytes>\n * ```\n */\nexport function buildLockupScript(opts: BuildLockupScriptOptions): Uint8Array {\n\tconst height = BigInt(opts.unlockBurnHeight);\n\tif (height <= 0n) {\n\t\tthrow new Error(\n\t\t\t\"unlockBurnHeight must be > 0 (contract rejects with ERR_INVALID_UNLOCK_HEIGHT)\",\n\t\t);\n\t}\n\tif (height >= BITCOIN_LOCKTIME_THRESHOLD) {\n\t\tthrow new Error(\n\t\t\t\"unlockBurnHeight >= 500,000,000 would be read by Bitcoin as a timestamp (contract rejects it)\",\n\t\t);\n\t}\n\tconst stakerHash = sha256(stakerPreimage(opts.stxAddress));\n\treturn concatBytes(\n\t\tUint8Array.of(0x63), // OP_IF\n\t\tpushCScriptNum(height),\n\t\tUint8Array.of(0xb1, 0x67), // OP_CHECKLOCKTIMEVERIFY, OP_ELSE\n\t\t// OP_SIZE, <0x20>, OP_EQUALVERIFY, OP_SHA256, OP_PUSHBYTES_32\n\t\thexToBytes(\"82012088a820\"),\n\t\tstakerHash,\n\t\tUint8Array.of(0x88), // OP_EQUALVERIFY\n\t\ttoBytes(opts.earlyUnlockBytes),\n\t\tUint8Array.of(0x68, 0x69), // OP_ENDIF, OP_VERIFY\n\t\ttoBytes(opts.stakerUnlockBytes),\n\t);\n}\n\n/**\n * P2WSH `scriptPubKey` for a lockup script: `0x0020 || sha256(script)`.\n * Mirrors `construct-lockup-output-script`.\n */\nexport function buildLockupOutputScript(\n\topts: BuildLockupScriptOptions,\n): Uint8Array {\n\treturn concatBytes(\n\t\tUint8Array.of(0x00, 0x20),\n\t\tsha256(buildLockupScript(opts)),\n\t);\n}\n\n/** The bech32 P2WSH address a staker sends their L1 BTC lockup to. */\nexport function buildLockupAddress(\n\topts: BuildLockupScriptOptions,\n\tnetwork: BitcoinNetwork = \"mainnet\",\n): string {\n\tconst hash = sha256(buildLockupScript(opts));\n\treturn bech32.encode(BITCOIN_NETWORK_PARAMS[network].hrp, [\n\t\t0,\n\t\t...bech32.toWords(hash),\n\t]);\n}\n\n/**\n * The default staker subscript: `<pubkey> OP_CHECKSIG` — spendable by one\n * key. Any script tail is valid as far as the contract is concerned; this is\n * the common case.\n */\nexport function buildDefaultStakerUnlockBytes(\n\tpublicKey: Uint8Array | string,\n): Uint8Array {\n\tconst pubkey = toBytes(publicKey);\n\tif (pubkey.length !== 33)\n\t\tthrow new Error(`Expected 33-byte compressed pubkey, got ${pubkey.length}`);\n\tconst prefix = pubkey[0];\n\tif (prefix !== 0x02 && prefix !== 0x03) {\n\t\tthrow new Error(\n\t\t\t`Expected compressed pubkey prefix 0x02 or 0x03, got ${prefix}`,\n\t\t);\n\t}\n\treturn concatBytes(pushScriptBytes(pubkey), Uint8Array.of(0xac)); // OP_CHECKSIG\n}\n\nexport type RegisterMetadata = {\n\tlockAddress: string;\n\tlockScript: Uint8Array;\n\toutputScript: Uint8Array;\n\tunlockBytes: Uint8Array;\n\tunlockHeight: number;\n};\n\n/**\n * One-call L1 register metadata: unlock height, staker subscript, lock\n * script, P2WSH output, and address. Staker funds `lockAddress` then\n * passes `lockScript` into the proof mapper.\n */\nexport function buildRegisterMetadata(opts: {\n\tbondIndex: number;\n\tstxAddress: string;\n\tbitcoinPublicKey: Uint8Array | string;\n\tearlyUnlockBytes: Uint8Array | string;\n\tnetwork?: BitcoinNetwork;\n\tcycle: BondCycleParams;\n}): RegisterMetadata {\n\tconst unlockHeight = computeBondUnlockHeight(opts.bondIndex, opts.cycle);\n\tconst unlockBytes = buildDefaultStakerUnlockBytes(opts.bitcoinPublicKey);\n\tconst lockOpts: BuildLockupScriptOptions = {\n\t\tstxAddress: opts.stxAddress,\n\t\tunlockBurnHeight: unlockHeight,\n\t\tstakerUnlockBytes: unlockBytes,\n\t\tearlyUnlockBytes: opts.earlyUnlockBytes,\n\t};\n\treturn {\n\t\tlockAddress: buildLockupAddress(lockOpts, opts.network ?? \"mainnet\"),\n\t\tlockScript: buildLockupScript(lockOpts),\n\t\toutputScript: buildLockupOutputScript(lockOpts),\n\t\tunlockBytes,\n\t\tunlockHeight,\n\t};\n}\n",
    "import { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport type { LocalAccount } from \"../accounts/types.ts\";\nimport { structuredDataHash } from \"../clarity/structuredData.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { bytesToHex, concatBytes, hexToBytes } from \"../utils/encoding.ts\";\nimport { POX5_SIGNER_DOMAIN } from \"./constants.ts\";\n\n/**\n * PoX-5 signer-key grants: SIP-018 structured-data signatures authorizing a\n * signer-manager contract to use a signer key. Mirrors\n * `pox-5.get-signer-grant-message-hash` — domain `pox-5-signer/1.0.0`,\n * message `{ topic: \"grant-authorization\", signer-manager, auth-id }`.\n */\nexport type SignerGrantOptions = {\n\t/** The signer-manager contract principal being authorized. */\n\tsignerManager: string;\n\t/** Replay-protection id, chosen by the signer. */\n\tauthId: bigint | number;\n\t/** Stacks chain id (`mainnet.id` / `testnet.id`). */\n\tchainId: number;\n};\n\n/**\n * The 32-byte hash a signer signs to grant their key — byte-identical to the\n * contract's `get-signer-grant-message-hash` read-only (which doubles as an\n * on-chain cross-check).\n */\nexport function computeSignerGrantHash(opts: SignerGrantOptions): Uint8Array {\n\treturn structuredDataHash({\n\t\tdomain: Cl.tuple({\n\t\t\tname: Cl.stringAscii(POX5_SIGNER_DOMAIN.name),\n\t\t\tversion: Cl.stringAscii(POX5_SIGNER_DOMAIN.version),\n\t\t\t\"chain-id\": Cl.uint(opts.chainId),\n\t\t}),\n\t\tmessage: Cl.tuple({\n\t\t\ttopic: Cl.stringAscii(\"grant-authorization\"),\n\t\t\t\"signer-manager\": Cl.principal(opts.signerManager),\n\t\t\t\"auth-id\": Cl.uint(opts.authId),\n\t\t}),\n\t});\n}\n\n/**\n * Sign a signer-key grant. Returns the 65-byte recoverable signature in RSV\n * order (recovery byte last), hex — the layout `grant-signer-key`'s\n * `signer-sig (buff 65)` expects.\n */\nexport async function signSignerGrant(\n\taccount: LocalAccount,\n\topts: SignerGrantOptions,\n): Promise<string> {\n\tconst vrs = await account.sign(computeSignerGrantHash(opts));\n\tif (vrs.length !== 65)\n\t\tthrow new Error(\n\t\t\t`Expected 65-byte recoverable signature, got ${vrs.length}`,\n\t\t);\n\t// account.sign returns VRS; the contract wants RSV.\n\treturn bytesToHex(concatBytes(vrs.slice(1), vrs.slice(0, 1)));\n}\n\n/**\n * Verify a signer-key grant signature locally: recover the pubkey from the\n * RSV signature over the grant hash and compare. Returns `false` for\n * malformed input rather than throwing.\n */\nexport function verifySignerGrant(\n\topts: SignerGrantOptions & {\n\t\tpublicKey: Uint8Array | string;\n\t\tsignature: Uint8Array | string;\n\t},\n): boolean {\n\ttry {\n\t\tconst sig =\n\t\t\ttypeof opts.signature === \"string\"\n\t\t\t\t? hexToBytes(opts.signature)\n\t\t\t\t: opts.signature;\n\t\tif (sig.length !== 65) return false;\n\t\tconst pubkey =\n\t\t\ttypeof opts.publicKey === \"string\"\n\t\t\t\t? hexToBytes(opts.publicKey)\n\t\t\t\t: opts.publicKey;\n\t\tconst hash = computeSignerGrantHash(opts);\n\t\tconst recovered = secp256k1.Signature.fromBytes(sig.slice(0, 64))\n\t\t\t.addRecoveryBit(sig[64] as number)\n\t\t\t.recoverPublicKey(hash)\n\t\t\t.toBytes(true);\n\t\treturn bytesToHex(recovered) === bytesToHex(pubkey);\n\t} catch {\n\t\treturn false;\n\t}\n}\n",
    "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n\ttype ProofSource,\n\ttype SpvProof,\n\tbuildTxProof,\n} from \"../bitcoin/proof.ts\";\nimport { parseBitcoinTx, stripWitness } from \"../bitcoin/serialize.ts\";\nimport {\n\ttype IntegerType,\n\tbytesToHex,\n\tconcatBytes,\n} from \"../utils/encoding.ts\";\nimport type { L1LockupOutput } from \"./actions.ts\";\n\n/** pox-5 ABI: `(list 14 (buff 32))`. SIP-044 allows 24; we throw rather than truncate. */\nconst MAX_LEAF_HASHES = 14;\n\n/** P2WSH scriptPubKey: `0x0020 || sha256(witness script)`. */\nfunction lockupScriptPubKey(lockScript: Uint8Array): Uint8Array {\n\treturn concatBytes(Uint8Array.of(0x00, 0x20), sha256(lockScript));\n}\n\nfunction scriptsEqual(a: Uint8Array, b: Uint8Array): boolean {\n\treturn bytesToHex(a) === bytesToHex(b);\n}\n\n/**\n * Map a generic SIP-044 `SpvProof` onto pox-5's `L1LockupOutput`.\n * Witness is stripped, the lockup vout is resolved against the P2WSH\n * of `lockScript`, and more than {@link MAX_LEAF_HASHES} siblings throws.\n */\nexport function spvProofToL1LockupOutput(opts: {\n\tproof: SpvProof;\n\t/** Witness script; hashed to match the P2WSH lockup output. */\n\tlockScript: Uint8Array;\n\tunlockBurnHeight: IntegerType;\n\t/** Default: `proof.vout`, else the unique matching output. */\n\tvout?: number;\n}): L1LockupOutput {\n\tconst { proof, lockScript, unlockBurnHeight } = opts;\n\tconst tx = stripWitness(proof.rawTx);\n\tconst parsed = parseBitcoinTx(proof.rawTx);\n\tconst expected = lockupScriptPubKey(lockScript);\n\n\tlet outputIndex = opts.vout ?? proof.vout;\n\tif (outputIndex === undefined) {\n\t\tconst matches: number[] = [];\n\t\tfor (let i = 0; i < parsed.outputs.length; i++) {\n\t\t\tconst spk = parsed.outputs[i]?.scriptPubKey;\n\t\t\tif (spk && scriptsEqual(spk, expected)) matches.push(i);\n\t\t}\n\t\tif (matches.length !== 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`spvProofToL1LockupOutput: expected exactly one matching lockup output, found ${matches.length}`,\n\t\t\t);\n\t\t}\n\t\toutputIndex = matches[0] as number;\n\t}\n\n\tconst output = parsed.outputs[outputIndex];\n\tif (!output) {\n\t\tthrow new Error(\n\t\t\t`spvProofToL1LockupOutput: output ${outputIndex} is out of range (${parsed.outputs.length} outputs)`,\n\t\t);\n\t}\n\tif (!scriptsEqual(output.scriptPubKey, expected)) {\n\t\tthrow new Error(\"lockup output script does not match\");\n\t}\n\n\tconst leafHashes = proof.merkle.siblings;\n\tif (leafHashes.length > MAX_LEAF_HASHES) {\n\t\tthrow new Error(\n\t\t\t`spvProofToL1LockupOutput: ${leafHashes.length} merkle siblings; pox-5 accepts at most ${MAX_LEAF_HASHES}`,\n\t\t);\n\t}\n\n\treturn {\n\t\theight: proof.height,\n\t\ttx,\n\t\toutputIndex,\n\t\theader: proof.header,\n\t\tleafHashes,\n\t\ttxCount: proof.merkle.txCount,\n\t\ttxIndex: proof.merkle.txIndex,\n\t\tamount: output.value,\n\t\tunlockBurnHeight,\n\t};\n}\n\n/**\n * Fetch a SIP-044 proof from `source` and map it onto pox-5's lockup shape.\n * `source` is required — no hosted Esplora default.\n */\nexport async function buildPox5LockProof(opts: {\n\tsource: ProofSource;\n\ttxid: string;\n\tlockScript: Uint8Array;\n\tunlockBurnHeight: IntegerType;\n\tvout?: number;\n}): Promise<L1LockupOutput> {\n\tconst proof = await buildTxProof(opts.source, {\n\t\ttxid: opts.txid,\n\t\tvout: opts.vout,\n\t});\n\treturn spvProofToL1LockupOutput({\n\t\tproof,\n\t\tlockScript: opts.lockScript,\n\t\tunlockBurnHeight: opts.unlockBurnHeight,\n\t\tvout: opts.vout,\n\t});\n}\n",
    "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport * as btc from \"@scure/btc-signer\";\nimport { signECDSA } from \"@scure/btc-signer/utils.js\";\nimport type { BitcoinNetwork } from \"../bitcoin/constants.ts\";\nimport {\n\ttype IntegerType,\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToBigInt,\n} from \"../utils/encoding.ts\";\nimport { stakerPreimage } from \"./script.ts\";\n\n/**\n * Spend a pox-5 P2WSH lockup back out.\n *\n * Two paths through the lockup script (mirror of `construct-lockup-script`):\n * - `'locktime'` — CLTV exit (`OP_IF`), single-sig, spendable once the burn\n *   height is past the lock's unlock height.\n * - `'early-exit'` — cosigned exit (`OP_ELSE`), 2-of-2 staker + bond cosigner.\n *   Valid only after `announce-l1-early-exit` on Stacks; this helper spends the\n *   UTXO and does not announce.\n */\nexport type ReclaimPath = \"locktime\" | \"early-exit\";\n\nconst SIGHASH_ALL = 1;\n/** Conservative dust limit (the 546-sat P2PKH bound covers all output types). */\nconst DUST_LIMIT_SATS = 546n;\n/** Empty witness item — selects the `OP_ELSE` (early-exit) branch. */\nconst ELSE_SELECTOR = new Uint8Array(0);\n/** Truthy witness item — selects the `OP_IF` (CLTV) branch. */\nconst IF_SELECTOR = new Uint8Array([0x01]);\n/** Custom-script spend; let btc-signer carry it unvalidated. */\nconst TX_OPTS = {\n\tallowUnknownOutputs: true,\n\tdisableScriptCheck: true,\n\tallowUnknownInputs: true,\n} as const;\n\nconst REGTEST_NETWORK = { ...btc.TEST_NETWORK, bech32: \"bcrt\" };\n\nfunction btcNetworkFrom(network: BitcoinNetwork): typeof btc.NETWORK {\n\tif (network === \"mainnet\") return btc.NETWORK;\n\tif (network === \"testnet\") return btc.TEST_NETWORK;\n\treturn REGTEST_NETWORK;\n}\n\nfunction toBytes(value: Uint8Array | string): Uint8Array {\n\treturn typeof value === \"string\" ? hexToBytes(value) : value;\n}\n\nfunction toPrivBytes(value: Uint8Array | string): Uint8Array {\n\treturn toBytes(value).slice(0, 32);\n}\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n\treturn bytesToHex(a) === bytesToHex(b);\n}\n\n/** P2WSH `scriptPubKey`: `0x0020 || sha256(lockScript)`. */\nfunction scriptToWshOutput(lockScript: Uint8Array): Uint8Array {\n\treturn concatBytes(Uint8Array.of(0x00, 0x20), sha256(lockScript));\n}\n\n/** Ops in the fixed lockup scaffold before the early-unlock subscript. */\nconst SCAFFOLD_PREFIX_LEN = 10;\n\n/**\n * Split a lockup witness script on the `construct-lockup-script` scaffold so\n * each subscript's keys stay attributed to the right party. Locate\n * `OP_ENDIF OP_VERIFY` from the end — a subscript may contain conditionals of\n * its own.\n *\n * @throws if the script is not a pox-5 lockup script.\n */\nfunction decodeLockScript(script: Uint8Array): {\n\tstakerPubs: Uint8Array[];\n\tcosignerPubs: Uint8Array[];\n\tunlockHeight?: number;\n} {\n\tconst ops = btc.Script.decode(script);\n\n\tconst endifIdx = ops.reduce<number>(\n\t\t(found, op, i) => (op === \"ENDIF\" && ops[i + 1] === \"VERIFY\" ? i : found),\n\t\t-1,\n\t);\n\n\tconst hashOp = ops[8];\n\tconst shapeOk =\n\t\tendifIdx >= SCAFFOLD_PREFIX_LEN &&\n\t\tops[0] === \"IF\" &&\n\t\tops[2] === \"CHECKLOCKTIMEVERIFY\" &&\n\t\tops[3] === \"ELSE\" &&\n\t\tops[4] === \"SIZE\" &&\n\t\tops[6] === \"EQUALVERIFY\" &&\n\t\tops[7] === \"SHA256\" &&\n\t\thashOp instanceof Uint8Array &&\n\t\thashOp.length === 32 &&\n\t\tops[9] === \"EQUALVERIFY\";\n\tif (!shapeOk) {\n\t\tthrow new Error(\n\t\t\t\"reclaim: lockScript is not a pox-5 lockup script (expected the OP_IF/OP_ELSE … OP_ENDIF OP_VERIFY scaffold)\",\n\t\t);\n\t}\n\n\tconst keysIn = (slice: btc.ScriptType) =>\n\t\tslice.filter(\n\t\t\t(op): op is Uint8Array => op instanceof Uint8Array && op.length === 33,\n\t\t);\n\n\tconst heightOp = ops[1];\n\tconst unlockHeight =\n\t\ttypeof heightOp === \"number\"\n\t\t\t? heightOp\n\t\t\t: heightOp instanceof Uint8Array\n\t\t\t\t? Number(btc.ScriptNum().decode(heightOp))\n\t\t\t\t: undefined;\n\n\treturn {\n\t\tcosignerPubs: keysIn(ops.slice(SCAFFOLD_PREFIX_LEN, endifIdx)),\n\t\tstakerPubs: keysIn(ops.slice(endifIdx + 2)),\n\t\tunlockHeight,\n\t};\n}\n\n/** Confirmed lockup UTXO (esplora / mempool.space shape). */\nexport type ReclaimUtxo = {\n\ttxid: string;\n\tvout: number;\n\tvalue: IntegerType;\n\t/** Cross-check only; re-derived from `lockScript` when omitted. */\n\tscriptPubKey?: Uint8Array;\n};\n\n/** Inputs to {@link buildReclaim}. */\nexport type BuildReclaimOpts = {\n\tpath: ReclaimPath;\n\tutxo: ReclaimUtxo;\n\tnetwork: BitcoinNetwork;\n\t/**\n\t * Sweep output: `value - feeSats` pays `address`. Mutate the returned tx's\n\t * outputs before signing if needed (`SIGHASH_ALL` commits to them).\n\t */\n\toutput: { address: string; feeSats: IntegerType };\n\t/**\n\t * The lockup `witnessScript` — pass the bytes you funded (typically\n\t * `buildLockupScript(...)` / `RegisterMetadata.lockScript`). The CLTV\n\t * unlock height is decoded from it.\n\t */\n\tlockScript: Uint8Array | string;\n};\n\n/**\n * Build the unsigned reclaim transaction (a `@scure/btc-signer` `Transaction`).\n *\n * One P2WSH input with `witnessUtxo` + `witnessScript` so the tx is a complete\n * PSBT (`toPSBT` / `fromPSBT` round-trip). HSM path: `buildReclaim` →\n * `tx.signIdx` or {@link computeReclaimSighash} + detached `partialSig` →\n * {@link finalizeReclaim}.\n *\n * - `path: \"early-exit\"` → `sequence = 0xffffffff`, `lockTime = 0`\n * - `path: \"locktime\"` → `sequence = 0xfffffffe`, `lockTime = unlockHeight`\n */\nexport function buildReclaim(opts: BuildReclaimOpts): btc.Transaction {\n\tconst network = btcNetworkFrom(opts.network);\n\tconst lockScript = toBytes(opts.lockScript);\n\tconst { unlockHeight: scriptHeight } = decodeLockScript(lockScript);\n\n\tconst amount = intToBigInt(opts.utxo.value);\n\tconst { address } = opts.output;\n\tconst feeSats = intToBigInt(opts.output.feeSats);\n\n\tif (feeSats < 0n) {\n\t\tthrow new Error(`buildReclaim: feeSats (${feeSats}) must be non-negative`);\n\t}\n\n\tconst outputScript = scriptToWshOutput(lockScript);\n\tif (\n\t\topts.utxo.scriptPubKey &&\n\t\t!bytesEqual(opts.utxo.scriptPubKey, outputScript)\n\t) {\n\t\tthrow new Error(\n\t\t\t\"buildReclaim: utxo.scriptPubKey does not match the lockScript — the signature would commit to the wrong output and every reclaim attempt would fail at relay\",\n\t\t);\n\t}\n\n\tconst sweepSats = amount - feeSats;\n\tif (sweepSats <= 0n) {\n\t\tthrow new Error(`buildReclaim: fee (${feeSats}) >= utxo value (${amount})`);\n\t}\n\tif (sweepSats < DUST_LIMIT_SATS) {\n\t\tthrow new Error(\n\t\t\t`buildReclaim: sweep of ${sweepSats} sats is below the ${DUST_LIMIT_SATS}-sat dust limit — nodes would not relay the tx`,\n\t\t);\n\t}\n\n\tconst earlyExit = opts.path === \"early-exit\";\n\tif (!earlyExit && scriptHeight == null) {\n\t\tthrow new Error(\n\t\t\t\"buildReclaim: the locktime path needs a lockScript that encodes a CLTV unlock height\",\n\t\t);\n\t}\n\tconst lockTime = earlyExit ? 0 : scriptHeight;\n\n\tconst tx = new btc.Transaction({ ...TX_OPTS, lockTime });\n\ttx.addInput({\n\t\ttxid: opts.utxo.txid,\n\t\tindex: opts.utxo.vout,\n\t\tsequence: earlyExit ? 0xffffffff : 0xfffffffe,\n\t\twitnessUtxo: { script: outputScript, amount },\n\t\twitnessScript: lockScript,\n\t});\n\ttx.addOutputAddress(address, sweepSats, network);\n\treturn tx;\n}\n\n/**\n * Input-0 BIP-143 sighash for a reclaim tx.\n *\n * In-process keys should prefer `tx.signIdx(privateKey, 0)`. This helper is\n * for HSMs / MPC that sign a bare digest, and for passing the early-exit\n * sighash between parties. Recompute after any output/fee change.\n *\n * Reads `witnessScript` + amount off the tx (set by {@link buildReclaim});\n * pass `opts` to re-supply them for a tx parsed from raw hex.\n */\nexport function computeReclaimSighash(\n\ttx: btc.Transaction,\n\topts?: { witnessScript?: Uint8Array | string; amountSats?: IntegerType },\n): Uint8Array {\n\tconst input = tx.getInput(0);\n\tconst witnessScript =\n\t\topts?.witnessScript != null\n\t\t\t? toBytes(opts.witnessScript)\n\t\t\t: input.witnessScript;\n\tconst amount =\n\t\topts?.amountSats != null\n\t\t\t? intToBigInt(opts.amountSats)\n\t\t\t: input.witnessUtxo?.amount;\n\tif (!witnessScript || amount == null) {\n\t\tthrow new Error(\n\t\t\t\"computeReclaimSighash: need witnessScript + amount (pass `opts` for a raw-hex tx)\",\n\t\t);\n\t}\n\treturn tx.preimageWitnessV0(0, witnessScript, SIGHASH_ALL, amount);\n}\n\n/**\n * Sign a reclaim sighash with a software key: DER + trailing `SIGHASH_ALL`.\n * `lowR` defaults to `false` to match btc-signer's `signIdx`. Kept as the\n * software stand-in for a detached signer (HSM tests).\n */\nexport function signReclaim(\n\tsighash: Uint8Array,\n\tprivateKey: Uint8Array | string,\n\topts?: { lowR?: boolean },\n): Uint8Array {\n\tconst priv = toPrivBytes(privateKey);\n\treturn concatBytes(\n\t\tsignECDSA(sighash, priv, opts?.lowR ?? false),\n\t\tUint8Array.of(SIGHASH_ALL),\n\t);\n}\n\n/** Arguments to {@link finalizeReclaim}, discriminated on the spend path. */\nexport type FinalizeReclaimOpts =\n\t| {\n\t\t\tpath: \"early-exit\";\n\t\t\ttx: btc.Transaction;\n\t\t\t/** Staker principal — rebuilds the 32-byte preimage the `OP_ELSE` branch reveals. */\n\t\t\tstxAddress: string;\n\t  }\n\t| { path: \"locktime\"; tx: btc.Transaction };\n\n/**\n * Assemble the custom IF/ELSE witness from signatures already on the tx.\n *\n * btc-signer's own finalizer cannot build this script, so we splice\n * `finalScriptWitness` directly. Does not broadcast.\n *\n * - locktime: `[stakerSig, 0x01, witnessScript]`\n * - early-exit: `[stakerSig, cosignerSig, preimage, <empty>, witnessScript]`\n */\nexport function finalizeReclaim(opts: FinalizeReclaimOpts): {\n\ttxHex: string;\n\ttxid: string;\n} {\n\tconst { tx } = opts;\n\tconst witnessScript = tx.getInput(0).witnessScript;\n\tif (!witnessScript)\n\t\tthrow new Error(\"finalizeReclaim: input 0 has no witnessScript\");\n\n\ttx.updateInput(\n\t\t0,\n\t\t{ finalScriptWitness: reclaimWitness(opts, witnessScript) },\n\t\ttrue,\n\t);\n\tif (!tx.isFinal)\n\t\tthrow new Error(\"finalizeReclaim: witness injection failed (tx not final)\");\n\treturn { txHex: tx.hex, txid: tx.id };\n}\n\nfunction reclaimWitness(\n\topts: FinalizeReclaimOpts,\n\twitnessScript: Uint8Array,\n): Uint8Array[] {\n\tconst sigs = opts.tx.getInput(0).partialSig ?? [];\n\tconst { stakerPubs, cosignerPubs } = decodeLockScript(witnessScript);\n\n\tif (stakerPubs.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`finalizeReclaim: expected exactly one staker public key in the lockup script, found ${stakerPubs.length} — multi-key subscripts are not supported`,\n\t\t);\n\t}\n\tconst stakerPub = stakerPubs[0];\n\tif (!stakerPub) {\n\t\tthrow new Error(\n\t\t\t\"finalizeReclaim: expected exactly one staker public key in the lockup script, found 0 — multi-key subscripts are not supported\",\n\t\t);\n\t}\n\n\tconst sigFor = (pub: Uint8Array) =>\n\t\tsigs.find(([p]) => p !== undefined && bytesEqual(p, pub))?.[1];\n\n\tconst stakerSig = sigFor(stakerPub);\n\tif (!stakerSig)\n\t\tthrow new Error(\"finalizeReclaim: missing staker signature (partialSig)\");\n\n\tif (opts.path === \"locktime\") return [stakerSig, IF_SELECTOR, witnessScript];\n\n\tif (cosignerPubs.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`finalizeReclaim: expected exactly one cosigner public key in the lockup script, found ${cosignerPubs.length} — multi-key subscripts are not supported`,\n\t\t);\n\t}\n\tconst cosignerPub = cosignerPubs[0];\n\tif (!cosignerPub) {\n\t\tthrow new Error(\n\t\t\t\"finalizeReclaim: expected exactly one cosigner public key in the lockup script, found 0 — multi-key subscripts are not supported\",\n\t\t);\n\t}\n\tconst cosignerSig = sigFor(cosignerPub);\n\tif (!cosignerSig)\n\t\tthrow new Error(\"finalizeReclaim: missing cosigner signature (partialSig)\");\n\treturn [\n\t\tstakerSig,\n\t\tcosignerSig,\n\t\tstakerPreimage(opts.stxAddress),\n\t\tELSE_SELECTOR,\n\t\twitnessScript,\n\t];\n}\n\nexport type ReclaimOpts = BuildReclaimOpts & {\n\t/** 32-byte BTC private key (raw bytes or hex). Not a Stacks account key. */\n\tstakerPrivateKey: Uint8Array | string;\n\t/** Required for `path: \"early-exit\"`. */\n\tcosignerPrivateKey?: Uint8Array | string;\n\t/** Required for `path: \"early-exit\"` — feeds {@link stakerPreimage}. */\n\tstxAddress?: string;\n};\n\n/**\n * One-shot reclaim for in-process BTC keys: build + signIdx + finalize.\n * Does not broadcast; the caller relays `txHex`.\n */\nexport function reclaim(opts: ReclaimOpts): { txHex: string; txid: string } {\n\tconst tx = buildReclaim(opts);\n\ttx.signIdx(toPrivBytes(opts.stakerPrivateKey), 0);\n\tif (opts.path === \"early-exit\") {\n\t\tif (opts.cosignerPrivateKey == null) {\n\t\t\tthrow new Error(\n\t\t\t\t'reclaim: cosignerPrivateKey is required for path \"early-exit\"',\n\t\t\t);\n\t\t}\n\t\tif (opts.stxAddress == null) {\n\t\t\tthrow new Error(\n\t\t\t\t'reclaim: stxAddress is required for path \"early-exit\" (preimage)',\n\t\t\t);\n\t\t}\n\t\ttx.signIdx(toPrivBytes(opts.cosignerPrivateKey), 0);\n\t\treturn finalizeReclaim({\n\t\t\tpath: \"early-exit\",\n\t\t\ttx,\n\t\t\tstxAddress: opts.stxAddress,\n\t\t});\n\t}\n\treturn finalizeReclaim({ path: \"locktime\", tx });\n}\n",
    "import { multicall } from \"../actions/public/multicall.ts\";\nimport type { ProofSource } from \"../bitcoin/proof.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\nimport {\n\ttype AnnounceL1EarlyExitParams,\n\ttype CalculateRewardsParams,\n\ttype ClaimRewardsParams,\n\ttype ClaimStakerRewardsForSignerParams,\n\ttype GrantSignerKeyParams,\n\ttype L1LockupOutput,\n\ttype PauseRewardsParams,\n\ttype RegisterForBondParams,\n\ttype RevokeSignerGrantParams,\n\ttype SetBondAdminParams,\n\ttype SetPauseAdminParams,\n\ttype SetupBondParams,\n\ttype StakeParams,\n\ttype StakeUpdateParams,\n\ttype UnstakeParams,\n\ttype UnstakeSbtcParams,\n\ttype UpdateBondRegistrationParams,\n\tannounceL1EarlyExit,\n\tcalculateRewards,\n\tclaimRewards,\n\tclaimStakerRewardsForSigner,\n\tgetBondAllowance,\n\tgetBondL1UnlockHeight,\n\tgetBondMembership,\n\tgetCurrentRewardCycle,\n\tgetEarned,\n\tgetEarnedStakerRewards,\n\tgetFirstPox5RewardCycle,\n\tgetLastRewardComputeHeight,\n\tgetProtocolBond,\n\tgetSignerInfo,\n\tgetStakerCustodiedSbtc,\n\tgetStakerInfo,\n\tgetTotalSbtcStakedForBond,\n\tgetTotalSharesStakedForCycle,\n\tgrantSignerKey,\n\thasAnnouncedL1EarlyExit,\n\tpauseRewards,\n\tpox5ContractId,\n\tregisterForBond,\n\trevokeSignerGrant,\n\tsetBondAdmin,\n\tsetPauseAdmin,\n\tsetupBond,\n\tstake,\n\tstakeUpdate,\n\tunstake,\n\tunstakeSbtc,\n\tupdateBondRegistration,\n\tverifySignerKeyGrantOnChain,\n} from \"./actions.ts\";\nimport {\n\ttype Pox5Activation,\n\ttype Pox5Info,\n\tgetPox5Activation,\n\tgetPoxInfo,\n\tisPox5Active,\n} from \"./activation.ts\";\nimport {\n\ttype EligibilityResult,\n\ttype EligibleAdminParams,\n\ttype EligibleClaimRewardsParams,\n\ttype EligibleGrantSignerKeyParams,\n\ttype EligibleRegisterForBondParams,\n\ttype EligibleStakeParams,\n\ttype EligibleUnstakeParams,\n\ttype EligibleUnstakeSbtcParams,\n\teligibleClaimRewards,\n\teligibleGrantSignerKey,\n\teligiblePauseRewards,\n\teligibleRegisterForBond,\n\teligibleSetBondAdmin,\n\teligibleStake,\n\teligibleUnstake,\n\teligibleUnstakeSbtc,\n} from \"./eligibility.ts\";\nimport { buildPox5LockProof } from \"./lockProof.ts\";\nimport type {\n\tBondAllowance,\n\tBondMembership,\n\tProtocolBond,\n\tSignerInfo,\n\tStakerInfo,\n} from \"./types.ts\";\n\n/**\n * A staker's whole PoX-5 position in ONE batched request: staker info, bond\n * membership, custodied sBTC, and the current cycle — the state a dashboard\n * or agent polls, without four round-trips.\n */\nexport type StakerState = {\n\tstakerInfo: ClarityValue;\n\tbondMembership: ClarityValue;\n\tcustodiedSbtc: ClarityValue;\n\tcurrentCycle: ClarityValue;\n};\n\nasync function getStakerState(\n\tclient: Client,\n\tstaker: string,\n): Promise<StakerState> {\n\tconst contract = pox5ContractId(client);\n\tconst results = await multicall(client, {\n\t\tallowFailure: false,\n\t\tcalls: [\n\t\t\t{\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: \"get-staker-info\",\n\t\t\t\targs: [Cl.principal(staker)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: \"get-bond-membership\",\n\t\t\t\targs: [Cl.principal(staker)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: \"get-staker-custodied-sbtc\",\n\t\t\t\targs: [Cl.principal(staker)],\n\t\t\t},\n\t\t\t{ contract, functionName: \"current-pox-reward-cycle\", args: [] },\n\t\t],\n\t});\n\tconst [stakerInfo, bondMembership, custodiedSbtc, currentCycle] =\n\t\tresults as ClarityValue[];\n\treturn {\n\t\tstakerInfo: stakerInfo as ClarityValue,\n\t\tbondMembership: bondMembership as ClarityValue,\n\t\tcustodiedSbtc: custodiedSbtc as ClarityValue,\n\t\tcurrentCycle: currentCycle as ClarityValue,\n\t};\n}\n\n/** Actions provided by the pox5 extension. */\nexport type Pox5Actions = {\n\tpox5: {\n\t\t// activation\n\t\tisActive: () => Promise<boolean>;\n\t\tgetActivation: () => Promise<Pox5Activation | undefined>;\n\t\tgetPoxInfo: () => Promise<Pox5Info>;\n\t\tcontractId: () => string;\n\t\t// batched state\n\t\tgetStakerState: (staker: string) => Promise<StakerState>;\n\t\t// reads\n\t\tgetStakerInfo: (staker: string) => Promise<StakerInfo>;\n\t\tgetBondMembership: (staker: string) => Promise<BondMembership>;\n\t\tgetProtocolBond: (bondIndex: IntegerType) => Promise<ProtocolBond>;\n\t\tgetBondAllowance: (\n\t\t\tbondIndex: IntegerType,\n\t\t\tstaker: string,\n\t\t) => Promise<BondAllowance>;\n\t\tgetTotalSbtcStakedForBond: (bondIndex: IntegerType) => Promise<bigint>;\n\t\tgetStakerCustodiedSbtc: (staker: string) => Promise<bigint>;\n\t\thasAnnouncedL1EarlyExit: (\n\t\t\tbondIndex: IntegerType,\n\t\t\tstaker: string,\n\t\t) => Promise<boolean>;\n\t\tgetBondL1UnlockHeight: (bondIndex: IntegerType) => Promise<bigint>;\n\t\tgetSignerInfo: (signer: string) => Promise<SignerInfo>;\n\t\tverifySignerKeyGrant: (\n\t\t\tsignerManager: string,\n\t\t\tsignerKey: Uint8Array | string,\n\t\t) => Promise<boolean>;\n\t\tgetCurrentRewardCycle: () => Promise<bigint>;\n\t\tgetFirstRewardCycle: () => Promise<bigint>;\n\t\tgetEarned: (params: {\n\t\t\tsigner: string;\n\t\t\trewardCycle: IntegerType;\n\t\t\tbondIndex?: IntegerType;\n\t\t}) => Promise<bigint>;\n\t\tgetEarnedStakerRewards: (params: {\n\t\t\tsigner: string;\n\t\t\trewardCycle: IntegerType;\n\t\t\tbondIndex?: IntegerType;\n\t\t\tstaker: string;\n\t\t}) => Promise<bigint>;\n\t\tgetLastRewardComputeHeight: () => Promise<bigint>;\n\t\tgetTotalSharesStakedForCycle: (\n\t\t\trewardCycle: IntegerType,\n\t\t\tbondIndex?: IntegerType,\n\t\t) => Promise<bigint>;\n\t\t// eligibility preflights (never auto-called from wallet actions)\n\t\teligibleStake: (params: EligibleStakeParams) => Promise<EligibilityResult>;\n\t\teligibleRegisterForBond: (\n\t\t\tparams: EligibleRegisterForBondParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleUnstake: (\n\t\t\tparams: EligibleUnstakeParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleUnstakeSbtc: (\n\t\t\tparams: EligibleUnstakeSbtcParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleClaimRewards: (\n\t\t\tparams: EligibleClaimRewardsParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleGrantSignerKey: (\n\t\t\tparams: EligibleGrantSignerKeyParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleSetBondAdmin: (\n\t\t\tparams: EligibleAdminParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligiblePauseRewards: (\n\t\t\tparams: EligibleAdminParams,\n\t\t) => Promise<EligibilityResult>;\n\t\t// wallet actions (txids; pair with waitForTransactionReceipt)\n\t\tsetupBond: (params: SetupBondParams) => Promise<string>;\n\t\tregisterForBond: (params: RegisterForBondParams) => Promise<string>;\n\t\tupdateBondRegistration: (\n\t\t\tparams: UpdateBondRegistrationParams,\n\t\t) => Promise<string>;\n\t\tstake: (params: StakeParams) => Promise<string>;\n\t\tstakeUpdate: (params: StakeUpdateParams) => Promise<string>;\n\t\tunstake: (params: UnstakeParams) => Promise<string>;\n\t\tunstakeSbtc: (params: UnstakeSbtcParams) => Promise<string>;\n\t\tannounceL1EarlyExit: (params: AnnounceL1EarlyExitParams) => Promise<string>;\n\t\tcalculateRewards: (params: CalculateRewardsParams) => Promise<string>;\n\t\tclaimRewards: (params: ClaimRewardsParams) => Promise<string>;\n\t\tclaimStakerRewardsForSigner: (\n\t\t\tparams: ClaimStakerRewardsForSignerParams,\n\t\t) => Promise<string>;\n\t\tgrantSignerKey: (params: GrantSignerKeyParams) => Promise<string>;\n\t\trevokeSignerGrant: (params: RevokeSignerGrantParams) => Promise<string>;\n\t\tsetBondAdmin: (params: SetBondAdminParams) => Promise<string>;\n\t\tsetPauseAdmin: (params: SetPauseAdminParams) => Promise<string>;\n\t\tpauseRewards: (params?: PauseRewardsParams) => Promise<string>;\n\t\tbuildLockProof: (opts: {\n\t\t\tsource: ProofSource;\n\t\t\ttxid: string;\n\t\t\tlockScript: Uint8Array;\n\t\t\tunlockBurnHeight: IntegerType;\n\t\t\tvout?: number;\n\t\t}) => Promise<L1LockupOutput>;\n\t};\n};\n\n/**\n * PoX-5 extension for the Stacks client.\n *\n * @example\n * const client = createWalletClient({ chain: mainnet, transport: http(), account })\n *   .extend(pox5());\n *\n * if (await client.pox5.isActive()) {\n *   const txid = await client.pox5.stake({\n *     signerManager: \"SP…​.signer-mgr\",\n *     amountUstx: 100_000_000_000n,\n *     numCycles: 12,\n *     startBurnHeight: 960_231,\n *     fee: \"low\",\n *   });\n *   await client.waitForTransactionReceipt({ txid });\n * }\n */\nexport function pox5(): (client: Client) => Pox5Actions {\n\treturn (client: Client) => ({\n\t\tpox5: {\n\t\t\tisActive: () => isPox5Active(client),\n\t\t\tgetActivation: () => getPox5Activation(client),\n\t\t\tgetPoxInfo: () => getPoxInfo(client),\n\t\t\tcontractId: () => pox5ContractId(client),\n\t\t\tgetStakerState: (staker) => getStakerState(client, staker),\n\t\t\tgetStakerInfo: (staker) => getStakerInfo(client, staker),\n\t\t\tgetBondMembership: (staker) => getBondMembership(client, staker),\n\t\t\tgetProtocolBond: (bondIndex) => getProtocolBond(client, bondIndex),\n\t\t\tgetBondAllowance: (bondIndex, staker) =>\n\t\t\t\tgetBondAllowance(client, bondIndex, staker),\n\t\t\tgetTotalSbtcStakedForBond: (bondIndex) =>\n\t\t\t\tgetTotalSbtcStakedForBond(client, bondIndex),\n\t\t\tgetStakerCustodiedSbtc: (staker) =>\n\t\t\t\tgetStakerCustodiedSbtc(client, staker),\n\t\t\thasAnnouncedL1EarlyExit: (bondIndex, staker) =>\n\t\t\t\thasAnnouncedL1EarlyExit(client, bondIndex, staker),\n\t\t\tgetBondL1UnlockHeight: (bondIndex) =>\n\t\t\t\tgetBondL1UnlockHeight(client, bondIndex),\n\t\t\tgetSignerInfo: (signer) => getSignerInfo(client, signer),\n\t\t\tverifySignerKeyGrant: (signerManager, signerKey) =>\n\t\t\t\tverifySignerKeyGrantOnChain(client, signerManager, signerKey),\n\t\t\tgetCurrentRewardCycle: () => getCurrentRewardCycle(client),\n\t\t\tgetFirstRewardCycle: () => getFirstPox5RewardCycle(client),\n\t\t\tgetEarned: (params) => getEarned(client, params),\n\t\t\tgetEarnedStakerRewards: (params) =>\n\t\t\t\tgetEarnedStakerRewards(client, params),\n\t\t\tgetLastRewardComputeHeight: () => getLastRewardComputeHeight(client),\n\t\t\tgetTotalSharesStakedForCycle: (rewardCycle, bondIndex) =>\n\t\t\t\tgetTotalSharesStakedForCycle(client, rewardCycle, bondIndex),\n\t\t\teligibleStake: (params) => eligibleStake(client, params),\n\t\t\teligibleRegisterForBond: (params) =>\n\t\t\t\teligibleRegisterForBond(client, params),\n\t\t\teligibleUnstake: (params) => eligibleUnstake(client, params),\n\t\t\teligibleUnstakeSbtc: (params) => eligibleUnstakeSbtc(client, params),\n\t\t\teligibleClaimRewards: (params) => eligibleClaimRewards(client, params),\n\t\t\teligibleGrantSignerKey: (params) =>\n\t\t\t\teligibleGrantSignerKey(client, params),\n\t\t\teligibleSetBondAdmin: (params) => eligibleSetBondAdmin(client, params),\n\t\t\teligiblePauseRewards: (params) => eligiblePauseRewards(client, params),\n\t\t\tsetupBond: (params) => setupBond(client, params),\n\t\t\tregisterForBond: (params) => registerForBond(client, params),\n\t\t\tupdateBondRegistration: (params) =>\n\t\t\t\tupdateBondRegistration(client, params),\n\t\t\tstake: (params) => stake(client, params),\n\t\t\tstakeUpdate: (params) => stakeUpdate(client, params),\n\t\t\tunstake: (params) => unstake(client, params),\n\t\t\tunstakeSbtc: (params) => unstakeSbtc(client, params),\n\t\t\tannounceL1EarlyExit: (params) => announceL1EarlyExit(client, params),\n\t\t\tcalculateRewards: (params) => calculateRewards(client, params),\n\t\t\tclaimRewards: (params) => claimRewards(client, params),\n\t\t\tclaimStakerRewardsForSigner: (params) =>\n\t\t\t\tclaimStakerRewardsForSigner(client, params),\n\t\t\tgrantSignerKey: (params) => grantSignerKey(client, params),\n\t\t\trevokeSignerGrant: (params) => revokeSignerGrant(client, params),\n\t\t\tsetBondAdmin: (params) => setBondAdmin(client, params),\n\t\t\tsetPauseAdmin: (params) => setPauseAdmin(client, params),\n\t\t\tpauseRewards: (params) => pauseRewards(client, params),\n\t\t\tbuildLockProof: (opts) => buildPox5LockProof(opts),\n\t\t},\n\t});\n}\n",
    "import { deserializeCVBytes } from \"../clarity/deserialize.ts\";\nimport { serializeCVBytes } from \"../clarity/serialize.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { type IntegerType, hexToBytes } from \"../utils/encoding.ts\";\nimport {\n\ttype BtcAddressRepr,\n\tcanonicalizeBtcAddress,\n\tparseBtcAddress,\n} from \"./btcAddress.ts\";\n\nexport function buildSignerCalldata(opts: {\n\tpoxAddress: string | BtcAddressRepr;\n\tmaxFeeSats: IntegerType;\n}): Uint8Array {\n\tconst repr = canonicalizeBtcAddress(\n\t\ttypeof opts.poxAddress === \"string\"\n\t\t\t? parseBtcAddress(opts.poxAddress)\n\t\t\t: opts.poxAddress,\n\t);\n\treturn serializeCVBytes(\n\t\tCl.tuple({\n\t\t\t\"pox-addr\": Cl.tuple({\n\t\t\t\tversion: Cl.buffer(Uint8Array.of(repr.version)),\n\t\t\t\thashbytes: Cl.buffer(repr.hashbytes),\n\t\t\t}),\n\t\t\t\"max-fee\": Cl.uint(opts.maxFeeSats),\n\t\t}),\n\t);\n}\n\nexport function parseSignerCalldata(calldata: Uint8Array | string): {\n\tpoxAddress: BtcAddressRepr;\n\tmaxFeeSats: bigint;\n} {\n\tconst cv = deserializeCVBytes(calldata);\n\tif (cv.type !== \"tuple\") {\n\t\tthrow new Error(\"signer calldata is not a Clarity tuple\");\n\t}\n\tconst poxAddr = cv.value[\"pox-addr\"];\n\tconst maxFee = cv.value[\"max-fee\"];\n\tif (!poxAddr || poxAddr.type !== \"tuple\") {\n\t\tthrow new Error(\"signer calldata missing pox-addr tuple\");\n\t}\n\tif (!maxFee || maxFee.type !== \"uint\") {\n\t\tthrow new Error(\"signer calldata missing max-fee uint\");\n\t}\n\tconst versionCv = poxAddr.value.version;\n\tconst hashCv = poxAddr.value.hashbytes;\n\tif (!versionCv || versionCv.type !== \"buffer\") {\n\t\tthrow new Error(\"signer calldata pox-addr missing version buffer\");\n\t}\n\tif (!hashCv || hashCv.type !== \"buffer\") {\n\t\tthrow new Error(\"signer calldata pox-addr missing hashbytes buffer\");\n\t}\n\tconst versionBytes = hexToBytes(versionCv.value);\n\tif (versionBytes.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`signer calldata version must be buff 1, got ${versionBytes.length}`,\n\t\t);\n\t}\n\tconst version = versionBytes[0];\n\tif (version === undefined) {\n\t\tthrow new Error(\"signer calldata version buffer is empty\");\n\t}\n\treturn {\n\t\tpoxAddress: canonicalizeBtcAddress({\n\t\t\tversion,\n\t\t\thashbytes: hexToBytes(hashCv.value),\n\t\t}),\n\t\tmaxFeeSats: maxFee.value,\n\t};\n}\n"
  ],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,IAAM,qBAAqB;AAG3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