@ignitionfi/spl-stake-pool 1.1.19 → 1.1.20

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.
package/dist/index.cjs.js CHANGED
@@ -1551,6 +1551,7 @@ class StakePoolInstruction {
1551
1551
  * Creates a transaction instruction to withdraw WSOL from a stake pool using a session.
1552
1552
  */
1553
1553
  static withdrawWsolWithSession(params) {
1554
+ var _a;
1554
1555
  const type = STAKE_POOL_INSTRUCTION_LAYOUTS.WithdrawWsolWithSession;
1555
1556
  const data = encodeData(type, {
1556
1557
  poolTokensIn: params.poolTokensIn,
@@ -1571,6 +1572,9 @@ class StakePoolInstruction {
1571
1572
  { pubkey: params.tokenProgramId, isSigner: false, isWritable: false },
1572
1573
  { pubkey: params.wsolMint, isSigner: false, isWritable: false },
1573
1574
  { pubkey: params.programSigner, isSigner: false, isWritable: true },
1575
+ { pubkey: (_a = params.payer) !== null && _a !== void 0 ? _a : params.userTransferAuthority, isSigner: true, isWritable: true },
1576
+ { pubkey: params.userWallet, isSigner: false, isWritable: false },
1577
+ { pubkey: web3_js.SystemProgram.programId, isSigner: false, isWritable: false },
1574
1578
  ];
1575
1579
  if (params.solWithdrawAuthority) {
1576
1580
  keys.push({
@@ -1579,6 +1583,8 @@ class StakePoolInstruction {
1579
1583
  isWritable: false,
1580
1584
  });
1581
1585
  }
1586
+ // Associated Token Program must be last - only needed in transaction for CPI routing
1587
+ keys.push({ pubkey: splToken.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false });
1582
1588
  return new web3_js.TransactionInstruction({
1583
1589
  programId: params.programId,
1584
1590
  keys,
@@ -2152,7 +2158,7 @@ async function withdrawSol(connection, stakePoolAddress, tokenOwner, solReceiver
2152
2158
  /**
2153
2159
  * Creates instructions required to withdraw wSOL from a stake pool.
2154
2160
  */
2155
- async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, minimumLamportsOut = 0, solWithdrawAuthority) {
2161
+ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, minimumLamportsOut = 0, solWithdrawAuthority, payer) {
2156
2162
  const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
2157
2163
  const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
2158
2164
  const stakePool = stakePoolAccount.account.data;
@@ -2166,7 +2172,8 @@ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSes
2166
2172
  const userWsolAccount = splToken.getAssociatedTokenAddressSync(splToken.NATIVE_MINT, userPubkey);
2167
2173
  const instructions = [];
2168
2174
  const signers = [];
2169
- instructions.push(splToken.createAssociatedTokenAccountIdempotentInstruction(signerOrSession, userWsolAccount, userPubkey, splToken.NATIVE_MINT));
2175
+ // The program handles wSOL ATA creation internally
2176
+ // This prevents rent drain attacks where paymaster pays for ATA and user reclaims rent
2170
2177
  const [programSigner] = web3_js.PublicKey.findProgramAddressSync([Buffer.from('fogo_session_program_signer')], stakePoolProgramId);
2171
2178
  const withdrawAuthority = await findWithdrawAuthorityProgramAddress(stakePoolProgramId, stakePoolAddress);
2172
2179
  instructions.push(StakePoolInstruction.withdrawWsolWithSession({
@@ -2183,6 +2190,8 @@ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSes
2183
2190
  solWithdrawAuthority,
2184
2191
  wsolMint: splToken.NATIVE_MINT,
2185
2192
  programSigner,
2193
+ userWallet: userPubkey,
2194
+ payer,
2186
2195
  poolTokensIn: poolTokens,
2187
2196
  minimumLamportsOut,
2188
2197
  }));