@aibtc/mcp-server 1.70.0 → 1.71.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.
@@ -1,58 +1,157 @@
1
- import { PoxInfo } from "./hiro-api.js";
1
+ /**
2
+ * PoX-5 stacking.
3
+ *
4
+ * PoX-5 replaced pox-4 at reward cycle 141 on mainnet, and it is not a rename:
5
+ *
6
+ * - Every stake names a SIGNER MANAGER, a contract implementing pox-5's
7
+ * `signer-manager-trait`. There is no pool delegation (`delegate-stx`) and no
8
+ * PoX reward address on the stake itself; the manager's `validate-stake!`
9
+ * decides who may join and reads any payout preferences out of
10
+ * `signer-calldata`.
11
+ * - Rewards are paid in sBTC to the signer manager, not the staker. Getting a
12
+ * staker paid takes the manager pulling its share out of pox-5
13
+ * (`manager.claim-rewards`) and then paying the staker
14
+ * (`manager.claim-staker-rewards`). Each manager implements that second step
15
+ * its own way, and some pay out off-chain, so the claim path is read from the
16
+ * manager's interface rather than assumed.
17
+ * - `stake`, `stake-update` and `unstake` are refused during the prepare phase
18
+ * (the last `prepare-cycle-length` blocks of a cycle).
19
+ *
20
+ * Locking STX is not a transfer, so these calls carry pox-5's own post-condition
21
+ * types (a staking lock amount, or "performs PoX") rather than STX transfer
22
+ * conditions, and they are not metered against the spend limit.
23
+ */
2
24
  import { type Network } from "../config/index.js";
3
25
  import { type Account, type TransferResult } from "../transactions/builder.js";
4
- export interface StackingStatus {
5
- stacked: boolean;
6
- amountMicroStx: string;
7
- amountStx: string;
26
+ /** pox-5 `MAX_NUM_CYCLES`. */
27
+ export declare const MAX_STAKE_CYCLES = 96;
28
+ export interface PoxState {
29
+ contractId: string;
30
+ burnHeight: number;
31
+ rewardCycle: number;
32
+ firstBurnHeight: number;
33
+ rewardCycleLength: number;
34
+ prepareCycleLength: number;
35
+ /** Burn height where the next reward cycle begins. */
36
+ nextCycleStartHeight: number;
37
+ /** Burn height where this cycle's prepare phase begins. */
38
+ preparePhaseStartHeight: number;
39
+ inPreparePhase: boolean;
40
+ /** Minimum a signer needs delegated to join the signer set (not a per-staker minimum). */
41
+ signerSetMinUstx: bigint;
42
+ totalLiquidSupplyUstx: bigint;
43
+ }
44
+ export interface StakerInfo {
45
+ amountUstx: bigint;
8
46
  firstRewardCycle: number;
9
- lockPeriod: number;
10
- unlockHeight: number;
11
- poxAddress?: string;
47
+ numCycles: number;
48
+ /** First cycle in which the STX is unlocked. */
49
+ unlockCycle: number;
50
+ unlockBurnHeight: number;
51
+ signerManager: string;
52
+ }
53
+ export interface BondMembership {
54
+ bondIndex: number;
55
+ amountUstx: bigint;
56
+ amountSats: bigint;
57
+ isL1Lock: boolean;
58
+ signerManager: string;
59
+ }
60
+ export interface StakingStatus {
61
+ address: string;
62
+ pox: PoxState;
63
+ staking: StakerInfo | null;
64
+ bond: BondMembership | null;
65
+ account: {
66
+ balanceUstx: bigint;
67
+ lockedUstx: bigint;
68
+ unlockedUstx: bigint;
69
+ burnchainUnlockHeight: number;
70
+ };
71
+ }
72
+ export interface SignerSetEntry {
73
+ signerManager: string;
74
+ delegatedUstx: bigint;
75
+ }
76
+ /**
77
+ * How a signer manager pays its stakers, read from its public interface.
78
+ * - `staker-arg`: `claim-staker-rewards(staker, reward-cycle, bond-index)`, callable by anyone
79
+ * - `caller`: `claim-staker-rewards(reward-cycle, bond-index)`, pays the caller
80
+ * - `none`: no on-chain staker claim (the manager pays off-chain, or not at all)
81
+ */
82
+ export type ClaimStyle = "staker-arg" | "caller" | "none";
83
+ export interface StakeOptions {
84
+ signerManager: string;
85
+ amountUstx: bigint;
86
+ numCycles: number;
87
+ signerCalldata?: Uint8Array;
12
88
  }
89
+ export interface UpdateStakeOptions {
90
+ /** New signer manager; defaults to the current one. */
91
+ signerManager?: string;
92
+ cyclesToExtend: number;
93
+ amountIncreaseUstx: bigint;
94
+ signerCalldata?: Uint8Array;
95
+ }
96
+ /**
97
+ * Payout calldata in the shape reference signer managers decode:
98
+ * `{ pox-addr: { version, hashbytes }, max-fee }`. Managers derived from the
99
+ * pox-5 reference implementation use it to pay rewards to a Bitcoin address via
100
+ * an sBTC withdrawal, capped at `max-fee` sats of withdrawal fee. Whether a given
101
+ * manager accepts it is up to that manager's `validate-stake!`.
102
+ */
103
+ export declare function buildPayoutCalldata(poxAddr: {
104
+ version: number;
105
+ hashbytesHex: string;
106
+ }, maxFeeSats: bigint): Uint8Array;
13
107
  export declare class StackingService {
14
108
  private network;
15
109
  private hiro;
16
- private contracts;
110
+ private poxContract;
17
111
  constructor(network: Network);
112
+ get contractId(): string;
113
+ private read;
114
+ private readPox;
115
+ getPoxState(): Promise<PoxState>;
116
+ private rewardCycleStartHeight;
117
+ getStakerInfo(address: string, pox?: PoxState): Promise<StakerInfo | null>;
118
+ getBondMembership(address: string): Promise<BondMembership | null>;
119
+ getStakingStatus(address: string): Promise<StakingStatus>;
120
+ /** Whether pox-5 has a signer key registered for this manager. */
121
+ isRegisteredSigner(signerManager: string): Promise<boolean>;
122
+ /** Walk pox-5's signer-set linked list for a reward cycle. */
123
+ getSignerSet(cycle: number): Promise<SignerSetEntry[]>;
124
+ getClaimStyle(signerManager: string): Promise<ClaimStyle>;
125
+ /** sBTC the staker has earned from this signer for a cycle and not yet claimed (before manager fees). */
126
+ getStakerUnclaimedRewards(signerManager: string, rewardCycle: number, staker: string): Promise<bigint>;
127
+ /** sBTC pox-5 still holds for the signer manager for a cycle (not yet pulled by the manager). */
128
+ getSignerUnpulledRewards(signerManager: string, rewardCycle: number): Promise<bigint>;
129
+ private assertNotPreparePhase;
130
+ stake(account: Account, options: StakeOptions): Promise<TransferResult & {
131
+ pox: PoxState;
132
+ unlockCycle: number;
133
+ unlockBurnHeight: number;
134
+ }>;
135
+ updateStake(account: Account, options: UpdateStakeOptions): Promise<TransferResult & {
136
+ previous: StakerInfo;
137
+ newAmountUstx: bigint;
138
+ signerManager: string;
139
+ unlockCycle: number;
140
+ unlockBurnHeight: number;
141
+ }>;
142
+ unstake(account: Account): Promise<TransferResult & {
143
+ previous: StakerInfo;
144
+ unlockCycle: number;
145
+ unlockBurnHeight: number;
146
+ }>;
18
147
  /**
19
- * Get current PoX (Proof of Transfer) info
20
- */
21
- getPoxInfo(): Promise<PoxInfo>;
22
- /**
23
- * Get stacking status for an address
24
- * Note: Returns whether the address is stacking, but detailed amounts require proper CV parsing
25
- */
26
- getStackingStatus(address: string): Promise<StackingStatus>;
27
- /**
28
- * Stack STX tokens
29
- */
30
- stack(account: Account, amount: bigint, poxAddress: {
31
- version: number;
32
- hashbytes: string;
33
- }, startBurnHeight: number, lockPeriod: number): Promise<TransferResult>;
34
- /**
35
- * Extend stacking period
36
- */
37
- extendStacking(account: Account, extendCount: number, poxAddress: {
38
- version: number;
39
- hashbytes: string;
40
- }): Promise<TransferResult>;
41
- /**
42
- * Increase stacking amount
43
- */
44
- increaseStacking(account: Account, increaseAmount: bigint): Promise<TransferResult>;
45
- /**
46
- * Delegate STX to a stacking pool
47
- */
48
- delegateStx(account: Account, amount: bigint, delegateTo: string, untilBurnHeight?: number, poxAddress?: {
49
- version: number;
50
- hashbytes: string;
51
- }): Promise<TransferResult>;
52
- /**
53
- * Revoke delegation
148
+ * Have the signer manager pull its STX-staking rewards for a cycle out of pox-5.
149
+ * Permissionless on reference managers. An empty bond-period list claims the
150
+ * STX-staker bucket only, which is all an STX staker's payout draws on.
54
151
  */
55
- revokeDelegation(account: Account): Promise<TransferResult>;
152
+ pullSignerRewards(account: Account, signerManager: string, rewardCycle: number, unpulledSats: bigint): Promise<TransferResult>;
153
+ /** Pay this staker their share of a cycle's rewards through the signer manager. */
154
+ claimStakerRewards(account: Account, signerManager: string, rewardCycle: number, style: Exclude<ClaimStyle, "none">): Promise<TransferResult>;
56
155
  }
57
156
  export declare function getStackingService(network: Network): StackingService;
58
157
  //# sourceMappingURL=stacking.service.d.ts.map