@secondlayer/stacks 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +4 -0
  2. package/dist/shared/stacks-1arrcd11.js +48 -0
  3. package/dist/shared/stacks-1arrcd11.js.map +10 -0
  4. package/dist/shared/stacks-9mqveyjv.cjs.map +2 -2
  5. package/dist/shared/{stacks-dr5en54r.cjs → stacks-9qcr921s.cjs} +42 -5
  6. package/dist/shared/stacks-9qcr921s.cjs.map +10 -0
  7. package/dist/shared/{stacks-thkhfwz8.js → stacks-bw8qvqd1.js} +18 -22
  8. package/dist/shared/{stacks-thkhfwz8.js.map → stacks-bw8qvqd1.js.map} +5 -5
  9. package/dist/shared/stacks-enpj9krt.cjs +38 -0
  10. package/dist/shared/stacks-enpj9krt.cjs.map +10 -0
  11. package/dist/shared/{stacks-90jcxs98.js → stacks-fb75yew8.js} +8 -6
  12. package/dist/shared/{stacks-90jcxs98.js.map → stacks-fb75yew8.js.map} +3 -3
  13. package/dist/shared/{stacks-rw2xbtdv.js → stacks-gxq2pbky.js} +2 -2
  14. package/dist/shared/{stacks-rw2xbtdv.js.map → stacks-gxq2pbky.js.map} +1 -1
  15. package/dist/shared/{stacks-jx146qf1.js → stacks-hnqt5rz4.js} +27 -377
  16. package/dist/shared/stacks-hnqt5rz4.js.map +13 -0
  17. package/dist/shared/{stacks-z3vztaz1.js → stacks-jpt52csy.js} +3 -3
  18. package/dist/shared/stacks-jpt52csy.js.map +10 -0
  19. package/dist/shared/{stacks-fse1f76h.js → stacks-rpqtgpyj.js} +42 -8
  20. package/dist/shared/stacks-rpqtgpyj.js.map +10 -0
  21. package/dist/shared/{stacks-g2qnr5qn.cjs → stacks-rryme9bv.cjs} +11 -364
  22. package/dist/shared/stacks-rryme9bv.cjs.map +13 -0
  23. package/dist/shared/{stacks-byyex2zk.cjs → stacks-ta1gar0b.cjs} +7 -2
  24. package/dist/shared/{stacks-byyex2zk.cjs.map → stacks-ta1gar0b.cjs.map} +2 -2
  25. package/dist/shared/stacks-tdsp5gsb.cjs.map +2 -2
  26. package/dist/shared/stacks-vea7nde7.cjs +731 -0
  27. package/dist/shared/stacks-vea7nde7.cjs.map +13 -0
  28. package/dist/shared/stacks-w23294am.js +760 -0
  29. package/dist/shared/stacks-w23294am.js.map +13 -0
  30. package/dist/shared/{stacks-zwgsbbb2.cjs → stacks-y4f7fm03.cjs} +7 -13
  31. package/dist/shared/{stacks-zwgsbbb2.cjs.map → stacks-y4f7fm03.cjs.map} +5 -5
  32. package/dist/src/accounts/index.d.cts +1 -1
  33. package/dist/src/accounts/index.d.ts +1 -1
  34. package/dist/src/actions/index.d.cts +15 -11
  35. package/dist/src/actions/index.d.ts +15 -11
  36. package/dist/src/actions/index.js +7 -6
  37. package/dist/src/actions/index.js.map +1 -1
  38. package/dist/src/bitcoin/index.d.cts +29 -29
  39. package/dist/src/bitcoin/index.d.ts +29 -29
  40. package/dist/src/bitcoin/index.js +3 -2
  41. package/dist/src/bitcoin/index.js.map +2 -2
  42. package/dist/src/bns/index.d.cts +1 -1
  43. package/dist/src/bns/index.d.ts +1 -1
  44. package/dist/src/bns/index.js +8 -6
  45. package/dist/src/bns/index.js.map +2 -2
  46. package/dist/src/clarity/index.d.cts +37 -1
  47. package/dist/src/clarity/index.d.ts +37 -1
  48. package/dist/src/clarity/index.js +14 -2
  49. package/dist/src/clarity/index.js.map +1 -1
  50. package/dist/src/index.cjs.map +2 -2
  51. package/dist/src/index.d.cts +18 -14
  52. package/dist/src/index.d.ts +18 -14
  53. package/dist/src/index.js +6 -5
  54. package/dist/src/index.js.map +3 -3
  55. package/dist/src/postconditions/index.d.cts +66 -3
  56. package/dist/src/postconditions/index.d.ts +66 -3
  57. package/dist/src/postconditions/index.js +13 -2
  58. package/dist/src/postconditions/index.js.map +1 -1
  59. package/dist/src/pox/index.d.cts +1 -1
  60. package/dist/src/pox/index.d.ts +1 -1
  61. package/dist/src/pox/index.js +6 -5
  62. package/dist/src/pox/index.js.map +2 -2
  63. package/dist/src/pox5/index.cjs +213 -14
  64. package/dist/src/pox5/index.cjs.map +8 -7
  65. package/dist/src/pox5/index.d.cts +88 -5
  66. package/dist/src/pox5/index.d.ts +88 -5
  67. package/dist/src/pox5/index.js +220 -17
  68. package/dist/src/pox5/index.js.map +8 -7
  69. package/dist/src/sbtc/index.d.cts +1 -1
  70. package/dist/src/sbtc/index.d.ts +1 -1
  71. package/dist/src/sbtc/index.js +5 -4
  72. package/dist/src/sbtc/index.js.map +2 -2
  73. package/dist/src/stackingdao/index.d.cts +1 -1
  74. package/dist/src/stackingdao/index.d.ts +1 -1
  75. package/dist/src/stackingdao/index.js +6 -5
  76. package/dist/src/stackingdao/index.js.map +2 -2
  77. package/dist/src/subscriptions/index.d.cts +1 -1
  78. package/dist/src/subscriptions/index.d.ts +1 -1
  79. package/dist/src/tools/index.cjs +494 -367
  80. package/dist/src/tools/index.cjs.map +11 -9
  81. package/dist/src/tools/index.d.cts +1 -1
  82. package/dist/src/tools/index.d.ts +1 -1
  83. package/dist/src/tools/index.js +494 -367
  84. package/dist/src/tools/index.js.map +11 -9
  85. package/dist/src/transactions/index.cjs +3 -1
  86. package/dist/src/transactions/index.cjs.map +1 -1
  87. package/dist/src/transactions/index.d.cts +16 -9
  88. package/dist/src/transactions/index.d.ts +16 -9
  89. package/dist/src/transactions/index.js +31 -27
  90. package/dist/src/transactions/index.js.map +1 -1
  91. package/package.json +2 -2
  92. package/dist/shared/stacks-dr5en54r.cjs.map +0 -10
  93. package/dist/shared/stacks-fse1f76h.js.map +0 -10
  94. package/dist/shared/stacks-g2qnr5qn.cjs.map +0 -15
  95. package/dist/shared/stacks-gkf9tsws.js +0 -285
  96. package/dist/shared/stacks-gkf9tsws.js.map +0 -10
  97. package/dist/shared/stacks-jx146qf1.js.map +0 -15
  98. package/dist/shared/stacks-qjgh6pqr.cjs +0 -258
  99. package/dist/shared/stacks-qjgh6pqr.cjs.map +0 -10
  100. package/dist/shared/stacks-z3vztaz1.js.map +0 -10
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/pox5/constants.ts", "../src/pox5/activation.ts", "../src/pox5/cycles.ts", "../src/pox5/script.ts", "../src/pox5/grants.ts", "../src/pox5/abi.ts", "../src/pox5/actions.ts", "../src/pox5/extension.ts"],
3
+ "sources": ["../src/pox5/constants.ts", "../src/pox5/activation.ts", "../src/pox5/errors.ts", "../src/pox5/cycles.ts", "../src/pox5/script.ts", "../src/pox5/grants.ts", "../src/pox5/abi.ts", "../src/pox5/actions.ts", "../src/pox5/extension.ts"],
4
4
  "sourcesContent": [
5
5
  "/**\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",
6
- "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\tcurrent_burnchain_block_height?: number;\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 * 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",
6
+ "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",
7
+ "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",
7
8
  "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 * 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/**\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",
8
9
  "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\";\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 >= 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\treturn concatBytes(pushScriptBytes(pubkey), Uint8Array.of(0xac)); // OP_CHECKSIG\n}\n",
9
- "import { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport type { LocalAccount } from \"../accounts/types.ts\";\nimport { serializeCVBytes } from \"../clarity/serialize.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\nconst SIP018_PREFIX = hexToBytes(\"534950303138\"); // \"SIP018\"\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\tconst domain = serializeCVBytes(\n\t\tCl.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);\n\tconst message = serializeCVBytes(\n\t\tCl.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\treturn sha256(concatBytes(SIP018_PREFIX, sha256(domain), sha256(message)));\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",
10
+ "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",
10
11
  "/**\n * Curated pox-5 ABI — the 25 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\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],\n} as const satisfies AbiContract;\n",
11
- "import { getContract } from \"../actions/getContract.ts\";\nimport type { FeeParam } from \"../actions/wallet/utils.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type { PostCondition } 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?: PostCondition[];\n\tpostConditionMode?: \"allow\" | \"deny\";\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\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\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\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",
12
- "import { multicall } from \"../actions/public/multicall.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 RegisterForBondParams,\n\ttype RevokeSignerGrantParams,\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\tgetFirstPox5RewardCycle,\n\tgetProtocolBond,\n\tgetSignerInfo,\n\tgetStakerCustodiedSbtc,\n\tgetStakerInfo,\n\tgetTotalSbtcStakedForBond,\n\tgrantSignerKey,\n\thasAnnouncedL1EarlyExit,\n\tpox5ContractId,\n\tregisterForBond,\n\trevokeSignerGrant,\n\tsetupBond,\n\tstake,\n\tstakeUpdate,\n\tunstake,\n\tunstakeSbtc,\n\tupdateBondRegistration,\n\tverifySignerKeyGrantOnChain,\n} from \"./actions.ts\";\nimport {\n\ttype Pox5Activation,\n\tgetPox5Activation,\n\tisPox5Active,\n} from \"./activation.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\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\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};\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\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\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},\n\t});\n}\n"
12
+ "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\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",
13
+ "import { multicall } from \"../actions/public/multicall.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 RegisterForBondParams,\n\ttype RevokeSignerGrantParams,\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\tgetFirstPox5RewardCycle,\n\tgetProtocolBond,\n\tgetSignerInfo,\n\tgetStakerCustodiedSbtc,\n\tgetStakerInfo,\n\tgetTotalSbtcStakedForBond,\n\tgrantSignerKey,\n\thasAnnouncedL1EarlyExit,\n\tpox5ContractId,\n\tregisterForBond,\n\trevokeSignerGrant,\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 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\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};\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\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},\n\t});\n}\n"
13
14
  ],
14
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,IAAM,qBAAqB;AAG3B,IAAM,2BAAmC,iCAAiC;AAY1E,IAAM,oBAAoB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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A,IAChE;AAAA,EACD;AAAA;",
16
+ "debugId": "C8CF6DB65C5A821964756E2164756E21",
16
17
  "names": []
17
18
  }
@@ -6,7 +6,7 @@ type LocalAccount = {
6
6
  publicKey: string
7
7
  /** Raw ECDSA sign over a hash */
8
8
  sign(hash: Uint8Array): Uint8Array
9
- /** Sign a structured message (SIP-018) */
9
+ /** Sign a raw UTF-8 / byte message (`sha256(bytes)`). Not SIP-018. */
10
10
  signMessage(message: string | Uint8Array): string
11
11
  };
12
12
  /** Account with a user-provided signing function (sync or async). */
@@ -200,6 +200,24 @@ type Pox5Activation = {
200
200
  firstRewardCycleId: number
201
201
  };
202
202
  /**
203
+ * `/v2/pox` fields a pox-5 integration actually needs. `sbtcContract` is
204
+ * compiled into the boot contract per network — never hardcode it.
205
+ */
206
+ type Pox5Info = {
207
+ contractId?: string
208
+ currentBurnchainBlockHeight?: number
209
+ firstBurnchainBlockHeight?: number
210
+ /** Token principal pox-5 custodies. Read this for sBTC post-conditions. */
211
+ sbtcContract?: string
212
+ sbtcRegistryContract?: string
213
+ contractVersions: Array<{
214
+ contractId: string
215
+ activationBurnchainBlockHeight: number
216
+ firstRewardCycleId: number
217
+ }>
218
+ };
219
+ declare function getPoxInfo2(client: Client): Promise<Pox5Info>;
220
+ /**
203
221
  * Read pox-5's activation entry from the node. Returns `undefined` when the
204
222
  * node doesn't know about pox-5 yet (pre-4.0.0 node software).
205
223
  */
@@ -212,6 +230,67 @@ declare function isPox5Active(client: Client): Promise<boolean>;
212
230
  /** Throw a descriptive error unless pox-5 is active on the client's chain. */
213
231
  declare function assertPox5Active(client: Client): Promise<void>;
214
232
  /**
233
+ * Numeric `(err uN)` codes from pox-5. Missing numbers were never assigned
234
+ * on-chain. Pair with {@link parsePox5Error} / {@link describePox5Error}.
235
+ */
236
+ declare const Pox5ErrorCode: {
237
+ readonly Unauthorized: 1
238
+ readonly CannotSetupBondTooSoon: 2
239
+ readonly CannotSetupBondTooLate: 3
240
+ readonly BondAlreadySetup: 4
241
+ readonly StakerAlreadyAdded: 5
242
+ readonly BondNotFound: 7
243
+ readonly InsufficientStx: 8
244
+ readonly AlreadyRegistered: 9
245
+ readonly TooMuchSats: 10
246
+ readonly NotAllowlisted: 11
247
+ readonly SignerKeyGrantUsed: 12
248
+ readonly InvalidSignatureRecover: 13
249
+ readonly InvalidSignaturePubkey: 14
250
+ readonly SignerKeyGrantNotFound: 17
251
+ readonly AlreadyStaked: 19
252
+ readonly InvalidNumCycles: 20
253
+ readonly SignerNotFound: 23
254
+ readonly InvalidStartBurnHeight: 24
255
+ readonly UnauthorizedSignerRegistration: 26
256
+ readonly NotStaking: 27
257
+ readonly UnstakeInPreparePhase: 28
258
+ readonly InvalidBondPeriodOrdering: 29
259
+ readonly DistributionAlreadyComputed: 30
260
+ readonly BondNotActive: 31
261
+ readonly NoClaimableRewards: 32
262
+ readonly ActiveBondNotIncluded: 33
263
+ readonly NotBondParticipant: 34
264
+ readonly CannotAnnounceL1EarlyUnlock: 35
265
+ readonly InvalidOldSignerManager: 36
266
+ readonly InvalidUnstakeSbtcAmount: 37
267
+ readonly CannotUnstakeSbtc: 38
268
+ readonly ReadTxOutOfBounds: 39
269
+ readonly InvalidBtcHeader: 40
270
+ readonly InvalidMerkleProof: 41
271
+ readonly InvalidLockupScript: 42
272
+ readonly BondAlreadyStarted: 43
273
+ readonly UpdateBondSameSigner: 44
274
+ readonly InvalidLockupAmount: 45
275
+ readonly DuplicateLockupOutpoint: 46
276
+ readonly StakeInPreparePhase: 47
277
+ readonly RolloverTooEarly: 48
278
+ readonly ReentrantCall: 49
279
+ readonly L1EarlyExitAlreadyAnnounced: 50
280
+ readonly InsufficientReserveBalance: 51
281
+ readonly InvalidUnlockHeight: 52
282
+ readonly RewardsPaused: 53
283
+ };
284
+ type Pox5ErrorCode = (typeof Pox5ErrorCode)[keyof typeof Pox5ErrorCode];
285
+ declare const POX5_ERROR_NAMES: Record<Pox5ErrorCode, string>;
286
+ /** Extract `(err uN)` from a Clarity value or Hiro `repr` string. */
287
+ declare function parsePox5Error(result: ClarityValue | string | undefined): number | undefined;
288
+ declare function describePox5Error(code: number | bigint): {
289
+ code: number
290
+ name: string
291
+ description: string
292
+ } | undefined;
293
+ /**
215
294
  * Stacks hard-fork epoch activation heights, as Bitcoin burn block heights.
216
295
  *
217
296
  * Epoch 4.0 carries both SIP-044 (the native Bitcoin SPV built-ins / Clarity 6)
@@ -442,7 +521,7 @@ type FeeTier = "min" | "low" | "mid" | "high";
442
521
  /** Fee input accepted by wallet actions: an explicit amount or a named tier. */
443
522
  type FeeParam = IntegerType | FeeTier;
444
523
  type FungibleComparator = "eq" | "gt" | "gte" | "lt" | "lte";
445
- type NonFungibleComparator = "sent" | "not-sent";
524
+ type NonFungibleComparator = "sent" | "not-sent" | "maybe-sent";
446
525
  type StxPostCondition = {
447
526
  type: "stx-postcondition"
448
527
  address: string
@@ -476,6 +555,9 @@ type PoxPostCondition = {
476
555
  condition: PoxComparator
477
556
  };
478
557
  type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition;
558
+ /** Serialized PC hex is accepted anywhere a `PostCondition` object is. */
559
+ type PostConditionInput = PostCondition | string;
560
+ type PostConditionMode = "allow" | "deny" | "originator";
479
561
  /**
480
562
  * Mapped read-return types for the pox-5 contract — the JS shapes
481
563
  * `getContract` produces from the ABI (camelCase keys, `uint` → `bigint`,
@@ -523,8 +605,8 @@ declare function pox5ContractId(client: Client): string;
523
605
  type TxOptions = {
524
606
  fee?: FeeParam
525
607
  nonce?: IntegerType
526
- postConditions?: PostCondition[]
527
- postConditionMode?: "allow" | "deny"
608
+ postConditions?: PostConditionInput[]
609
+ postConditionMode?: PostConditionMode
528
610
  };
529
611
  /**
530
612
  * One proven L1 timelock output — a Bitcoin SPV inclusion proof of the lockup
@@ -647,6 +729,7 @@ type Pox5Actions = {
647
729
  pox5: {
648
730
  isActive: () => Promise<boolean>
649
731
  getActivation: () => Promise<Pox5Activation | undefined>
732
+ getPoxInfo: () => Promise<Pox5Info>
650
733
  contractId: () => string
651
734
  getStakerState: (staker: string) => Promise<StakerState>
652
735
  getStakerInfo: (staker: string) => Promise<StakerInfo>
@@ -1593,4 +1676,4 @@ declare const POX5_ABI: {
1593
1676
  }
1594
1677
  }]
1595
1678
  };
1596
- export { verifySignerGrant, stakerPreimage, stakerConsensusBuff, signSignerGrant, serializeCScriptNum, rewardCycleToBurnHeight, pushScriptBytes, pushCScriptNum, pox5ContractId, pox5, isPox5Active, isInPreparePhase, getPox5Activation, computeSignerGrantHash, burnHeightToRewardCycle, burnHeightToDistributionIndex, buildLockupScript, buildLockupOutputScript, buildLockupAddress, buildDefaultStakerUnlockBytes, bondUnlockCycle, bondPhaseAtHeight, bondPeriodToRewardCycle, bondPeriodToBurnHeight, assertPox5Active, UpdateBondRegistrationParams, UnstakeSbtcParams, UnstakeParams, StakerState, StakeUpdateParams, StakeParams, SignerGrantOptions, SetupBondParams, RevokeSignerGrantParams, RegisterForBondParams, PoxCycleParams, Pox5EventTopic, Pox5Activation, Pox5Actions, POX5_SIGNER_DOMAIN, POX5_EVENT_TOPICS, POX5_CONTRACT_NAME, POX5_CONTRACT_ID_MAINNET, POX5_ACTIVATION_BURN_HEIGHT_MAINNET, POX5_ABI, MAX_NUM_CYCLES, L1LockupOutput, GrantSignerKeyParams, ClaimStakerRewardsForSignerParams, ClaimRewardsParams, CalculateRewardsParams, C_SCRIPT_NUM_MAX, BuildLockupScriptOptions, BtcLockup, BondPhase, BondCycleParams, BOND_LENGTH_CYCLES, BOND_GAP_CYCLES, BITCOIN_LOCKTIME_THRESHOLD, AnnounceL1EarlyExitParams };
1679
+ export { verifySignerGrant, stakerPreimage, stakerConsensusBuff, signSignerGrant, serializeCScriptNum, rewardCycleToBurnHeight, pushScriptBytes, pushCScriptNum, pox5ContractId, pox5, parsePox5Error, isPox5Active, isInPreparePhase, getPoxInfo2 as getPoxInfo, getPox5Activation, describePox5Error, computeSignerGrantHash, burnHeightToRewardCycle, burnHeightToDistributionIndex, buildLockupScript, buildLockupOutputScript, buildLockupAddress, buildDefaultStakerUnlockBytes, bondUnlockCycle, bondPhaseAtHeight, bondPeriodToRewardCycle, bondPeriodToBurnHeight, assertPox5Active, UpdateBondRegistrationParams, UnstakeSbtcParams, UnstakeParams, StakerState, StakeUpdateParams, StakeParams, SignerGrantOptions, SetupBondParams, RevokeSignerGrantParams, RegisterForBondParams, PoxCycleParams, Pox5Info, Pox5EventTopic, Pox5ErrorCode, Pox5Activation, Pox5Actions, POX5_SIGNER_DOMAIN, POX5_EVENT_TOPICS, POX5_ERROR_NAMES, POX5_CONTRACT_NAME, POX5_CONTRACT_ID_MAINNET, POX5_ACTIVATION_BURN_HEIGHT_MAINNET, POX5_ABI, MAX_NUM_CYCLES, L1LockupOutput, GrantSignerKeyParams, ClaimStakerRewardsForSignerParams, ClaimRewardsParams, CalculateRewardsParams, C_SCRIPT_NUM_MAX, BuildLockupScriptOptions, BtcLockup, BondPhase, BondCycleParams, BOND_LENGTH_CYCLES, BOND_GAP_CYCLES, BITCOIN_LOCKTIME_THRESHOLD, AnnounceL1EarlyExitParams };