@ignitionfi/fogo-stake-pool 1.0.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.
@@ -0,0 +1,268 @@
1
+ import { AccountInfo, Connection, PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
2
+ import BN from 'bn.js';
3
+ import { StakeAccount, StakePool, ValidatorList } from './layouts';
4
+ import { ValidatorAccount } from './utils';
5
+ export { DEVNET_STAKE_POOL_PROGRAM_ID, STAKE_POOL_PROGRAM_ID, } from './constants';
6
+ export * from './instructions';
7
+ export type { AccountType, StakePool, ValidatorList, ValidatorStakeInfo, } from './layouts';
8
+ export { StakePoolLayout, ValidatorListLayout, ValidatorStakeInfoLayout, } from './layouts';
9
+ export { findEphemeralStakeProgramAddress, findStakeProgramAddress, findTransientStakeProgramAddress, findUserStakeProgramAddress, findWithdrawAuthorityProgramAddress, findWsolTransientProgramAddress, } from './utils';
10
+ export interface ValidatorListAccount {
11
+ pubkey: PublicKey;
12
+ account: AccountInfo<ValidatorList>;
13
+ }
14
+ export interface StakePoolAccount {
15
+ pubkey: PublicKey;
16
+ account: AccountInfo<StakePool>;
17
+ }
18
+ export interface WithdrawAccount {
19
+ stakeAddress: PublicKey;
20
+ voteAddress?: PublicKey;
21
+ poolAmount: BN;
22
+ }
23
+ /**
24
+ * Wrapper class for a stake pool.
25
+ * Each stake pool has a stake pool account and a validator list account.
26
+ */
27
+ export interface StakePoolAccounts {
28
+ stakePool: StakePoolAccount | undefined;
29
+ validatorList: ValidatorListAccount | undefined;
30
+ }
31
+ export declare function getStakePoolProgramId(rpcEndpoint: string): PublicKey;
32
+ /**
33
+ * Retrieves and deserializes a StakePool account using a web3js connection and the stake pool address.
34
+ * @param connection An active web3js connection.
35
+ * @param stakePoolAddress The public key (address) of the stake pool account.
36
+ */
37
+ export declare function getStakePoolAccount(connection: Connection, stakePoolAddress: PublicKey): Promise<StakePoolAccount>;
38
+ /**
39
+ * Retrieves and deserializes a Stake account using a web3js connection and the stake address.
40
+ * @param connection An active web3js connection.
41
+ * @param stakeAccount The public key (address) of the stake account.
42
+ */
43
+ export declare function getStakeAccount(connection: Connection, stakeAccount: PublicKey): Promise<StakeAccount>;
44
+ /**
45
+ * Retrieves all StakePool and ValidatorList accounts that are running a particular StakePool program.
46
+ * @param connection An active web3js connection.
47
+ * @param stakePoolProgramAddress The public key (address) of the StakePool program.
48
+ */
49
+ export declare function getStakePoolAccounts(connection: Connection, stakePoolProgramAddress: PublicKey): Promise<(StakePoolAccount | ValidatorListAccount | undefined)[] | undefined>;
50
+ /**
51
+ * Creates instructions required to deposit stake to stake pool.
52
+ */
53
+ export declare function depositStake(connection: Connection, stakePoolAddress: PublicKey, authorizedPubkey: PublicKey, validatorVote: PublicKey, depositStake: PublicKey, poolTokenReceiverAccount?: PublicKey): Promise<{
54
+ instructions: TransactionInstruction[];
55
+ signers: Signer[];
56
+ }>;
57
+ /**
58
+ * Creates instructions required to deposit sol to stake pool.
59
+ */
60
+ export declare function depositWsolWithSession(connection: Connection, stakePoolAddress: PublicKey, signerOrSession: PublicKey, userPubkey: PublicKey, lamports: number, minimumPoolTokensOut?: number, destinationTokenAccount?: PublicKey, referrerTokenAccount?: PublicKey, depositAuthority?: PublicKey, payer?: PublicKey,
61
+ /**
62
+ * Skip WSOL balance validation. Set to true when adding wrap instructions
63
+ * in the same transaction that will fund the WSOL account before deposit.
64
+ */
65
+ skipBalanceCheck?: boolean): Promise<{
66
+ instructions: TransactionInstruction[];
67
+ signers: never[];
68
+ }>;
69
+ /**
70
+ * Creates instructions required to deposit sol to stake pool.
71
+ */
72
+ export declare function depositSol(connection: Connection, stakePoolAddress: PublicKey, from: PublicKey, lamports: number, destinationTokenAccount?: PublicKey, referrerTokenAccount?: PublicKey, depositAuthority?: PublicKey): Promise<{
73
+ instructions: TransactionInstruction[];
74
+ signers: Signer[];
75
+ }>;
76
+ /**
77
+ * Creates instructions required to withdraw stake from a stake pool.
78
+ */
79
+ export declare function withdrawStake(connection: Connection, stakePoolAddress: PublicKey, tokenOwner: PublicKey, amount: number, useReserve?: boolean, voteAccountAddress?: PublicKey, stakeReceiver?: PublicKey, poolTokenAccount?: PublicKey, validatorComparator?: (_a: ValidatorAccount, _b: ValidatorAccount) => number): Promise<{
80
+ instructions: TransactionInstruction[];
81
+ signers: Signer[];
82
+ stakeReceiver: PublicKey | undefined;
83
+ totalRentFreeBalances: number;
84
+ }>;
85
+ /**
86
+ * Creates instructions required to withdraw SOL directly from a stake pool.
87
+ */
88
+ export declare function withdrawSol(connection: Connection, stakePoolAddress: PublicKey, tokenOwner: PublicKey, solReceiver: PublicKey, amount: number, solWithdrawAuthority?: PublicKey): Promise<{
89
+ instructions: TransactionInstruction[];
90
+ signers: Signer[];
91
+ }>;
92
+ /**
93
+ * Creates instructions required to withdraw wSOL from a stake pool.
94
+ * Rent for ATA creation (if needed) is paid from the withdrawal amount.
95
+ */
96
+ export declare function withdrawWsolWithSession(connection: Connection, stakePoolAddress: PublicKey, signerOrSession: PublicKey, userPubkey: PublicKey, amount: number, minimumLamportsOut?: number, solWithdrawAuthority?: PublicKey): Promise<{
97
+ instructions: TransactionInstruction[];
98
+ signers: Signer[];
99
+ }>;
100
+ /**
101
+ * Finds the next available seed for creating a user stake PDA.
102
+ * Scans from startSeed until an unused PDA is found.
103
+ *
104
+ * @param connection - Solana connection
105
+ * @param programId - The stake pool program ID
106
+ * @param userPubkey - User's wallet (used for PDA derivation)
107
+ * @param startSeed - Starting seed to search from (default: 0)
108
+ * @param maxSeed - Maximum seed to check before giving up (default: 1000)
109
+ * @returns The next available seed
110
+ * @throws Error if no available seed found within maxSeed
111
+ */
112
+ export declare function findNextUserStakeSeed(connection: Connection, programId: PublicKey, userPubkey: PublicKey, startSeed?: number, maxSeed?: number): Promise<number>;
113
+ /**
114
+ * Represents a user stake account with its details
115
+ */
116
+ export interface UserStakeAccount {
117
+ /** The stake account public key (PDA) */
118
+ pubkey: PublicKey;
119
+ /** The seed used to derive this PDA */
120
+ seed: number;
121
+ /** Lamports in the stake account */
122
+ lamports: number;
123
+ /** Parsed stake state */
124
+ state: 'inactive' | 'activating' | 'active' | 'deactivating';
125
+ /** Validator vote account (if delegated) */
126
+ voter?: PublicKey;
127
+ /** Activation epoch (if active/activating) */
128
+ activationEpoch?: number;
129
+ /** Deactivation epoch (if deactivating) */
130
+ deactivationEpoch?: number;
131
+ }
132
+ /**
133
+ * Fetches all user stake accounts created via WithdrawStakeWithSession.
134
+ * These are PDAs derived from [b"user_stake", user_wallet, seed].
135
+ *
136
+ * @param connection - Solana connection
137
+ * @param programId - The stake pool program ID
138
+ * @param userPubkey - User's wallet address
139
+ * @param maxSeed - Maximum seed to check (default: 100)
140
+ * @returns Array of user stake accounts with their details
141
+ */
142
+ export declare function getUserStakeAccounts(connection: Connection, programId: PublicKey, userPubkey: PublicKey, maxSeed?: number): Promise<UserStakeAccount[]>;
143
+ /**
144
+ * Withdraws stake from a stake pool using a Fogo session.
145
+ *
146
+ * The on-chain program creates stake account PDAs. The rent for these accounts
147
+ * is paid by the payer (typically the paymaster), not deducted from the user's withdrawal.
148
+ *
149
+ * @param connection - Solana connection
150
+ * @param stakePoolAddress - The stake pool to withdraw from
151
+ * @param signerOrSession - The session signer public key
152
+ * @param userPubkey - User's wallet (used for PDA derivation and token ownership)
153
+ * @param payer - Payer for stake account rent (typically paymaster)
154
+ * @param amount - Amount of pool tokens to withdraw
155
+ * @param userStakeSeedStart - Starting seed for user stake PDA derivation (default: 0)
156
+ * @param useReserve - Whether to withdraw from reserve (default: false)
157
+ * @param voteAccountAddress - Optional specific validator to withdraw from
158
+ * @param minimumLamportsOut - Minimum lamports to receive (slippage protection)
159
+ * @param validatorComparator - Optional comparator for validator selection
160
+ */
161
+ export declare function withdrawStakeWithSession(connection: Connection, stakePoolAddress: PublicKey, signerOrSession: PublicKey, userPubkey: PublicKey, payer: PublicKey, amount: number, userStakeSeedStart?: number, useReserve?: boolean, voteAccountAddress?: PublicKey, minimumLamportsOut?: number, validatorComparator?: (_a: ValidatorAccount, _b: ValidatorAccount) => number): Promise<{
162
+ instructions: TransactionInstruction[];
163
+ stakeAccountPubkeys: PublicKey[];
164
+ userStakeSeeds: number[];
165
+ }>;
166
+ export declare function addValidatorToPool(connection: Connection, stakePoolAddress: PublicKey, validatorVote: PublicKey, seed?: number): Promise<{
167
+ instructions: TransactionInstruction[];
168
+ }>;
169
+ export declare function removeValidatorFromPool(connection: Connection, stakePoolAddress: PublicKey, validatorVote: PublicKey, seed?: number): Promise<{
170
+ instructions: TransactionInstruction[];
171
+ }>;
172
+ /**
173
+ * Creates instructions required to increase validator stake.
174
+ */
175
+ export declare function increaseValidatorStake(connection: Connection, stakePoolAddress: PublicKey, validatorVote: PublicKey, lamports: number, ephemeralStakeSeed?: number): Promise<{
176
+ instructions: TransactionInstruction[];
177
+ }>;
178
+ /**
179
+ * Creates instructions required to decrease validator stake.
180
+ */
181
+ export declare function decreaseValidatorStake(connection: Connection, stakePoolAddress: PublicKey, validatorVote: PublicKey, lamports: number, ephemeralStakeSeed?: number): Promise<{
182
+ instructions: TransactionInstruction[];
183
+ }>;
184
+ /**
185
+ * Creates instructions required to completely update a stake pool after epoch change.
186
+ */
187
+ export declare function updateStakePool(connection: Connection, stakePool: StakePoolAccount, noMerge?: boolean): Promise<{
188
+ updateListInstructions: TransactionInstruction[];
189
+ finalInstructions: TransactionInstruction[];
190
+ }>;
191
+ /**
192
+ * Retrieves detailed information about the StakePool.
193
+ */
194
+ export declare function stakePoolInfo(connection: Connection, stakePoolAddress: PublicKey): Promise<{
195
+ address: string;
196
+ poolWithdrawAuthority: string;
197
+ manager: string;
198
+ staker: string;
199
+ stakeDepositAuthority: string;
200
+ stakeWithdrawBumpSeed: number;
201
+ maxValidators: number;
202
+ validatorList: {
203
+ activeStakeLamports: string;
204
+ transientStakeLamports: string;
205
+ lastUpdateEpoch: string;
206
+ transientSeedSuffixStart: string;
207
+ transientSeedSuffixEnd: string;
208
+ status: string;
209
+ voteAccountAddress: string;
210
+ }[];
211
+ validatorListStorageAccount: string;
212
+ reserveStake: string;
213
+ poolMint: string;
214
+ managerFeeAccount: string;
215
+ tokenProgramId: string;
216
+ totalLamports: string;
217
+ poolTokenSupply: string;
218
+ lastUpdateEpoch: string;
219
+ lockup: import("./layouts").Lockup;
220
+ epochFee: import("./layouts").Fee;
221
+ nextEpochFee: import("./layouts").Fee | undefined;
222
+ preferredDepositValidatorVoteAddress: PublicKey | undefined;
223
+ preferredWithdrawValidatorVoteAddress: PublicKey | undefined;
224
+ stakeDepositFee: import("./layouts").Fee;
225
+ stakeWithdrawalFee: import("./layouts").Fee;
226
+ nextStakeWithdrawalFee: import("./layouts").Fee | undefined;
227
+ stakeReferralFee: number;
228
+ solDepositAuthority: string | undefined;
229
+ solDepositFee: import("./layouts").Fee;
230
+ solReferralFee: number;
231
+ solWithdrawAuthority: string | undefined;
232
+ solWithdrawalFee: import("./layouts").Fee;
233
+ nextSolWithdrawalFee: import("./layouts").Fee | undefined;
234
+ lastEpochPoolTokenSupply: string;
235
+ lastEpochTotalLamports: string;
236
+ details: {
237
+ reserveStakeLamports: number | undefined;
238
+ reserveAccountStakeAddress: string;
239
+ minimumReserveStakeBalance: number;
240
+ stakeAccounts: {
241
+ voteAccountAddress: string;
242
+ stakeAccountAddress: string;
243
+ validatorActiveStakeLamports: string;
244
+ validatorLastUpdateEpoch: string;
245
+ validatorLamports: string;
246
+ validatorTransientStakeAccountAddress: string;
247
+ validatorTransientStakeLamports: string;
248
+ updateRequired: boolean;
249
+ }[];
250
+ totalLamports: BN;
251
+ totalPoolTokens: number;
252
+ currentNumberOfValidators: number;
253
+ maxNumberOfValidators: number;
254
+ updateRequired: boolean;
255
+ };
256
+ }>;
257
+ /**
258
+ * Creates instructions required to create pool token metadata.
259
+ */
260
+ export declare function createPoolTokenMetadata(connection: Connection, stakePoolAddress: PublicKey, payer: PublicKey, name: string, symbol: string, uri: string): Promise<{
261
+ instructions: TransactionInstruction[];
262
+ }>;
263
+ /**
264
+ * Creates instructions required to update pool token metadata.
265
+ */
266
+ export declare function updatePoolTokenMetadata(connection: Connection, stakePoolAddress: PublicKey, name: string, symbol: string, uri: string): Promise<{
267
+ instructions: TransactionInstruction[];
268
+ }>;