@ignitionfi/spl-stake-pool 1.1.21 → 1.1.22

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.
@@ -2244,7 +2244,7 @@ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSes
2244
2244
  * Creates instructions required to withdraw stake from a stake pool using a Fogo session.
2245
2245
  * The withdrawn stake account will be authorized to the user's wallet.
2246
2246
  */
2247
- async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, useReserve = false, voteAccountAddress, minimumLamportsOut = 0, payer, validatorComparator) {
2247
+ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, payer, useReserve = false, voteAccountAddress, minimumLamportsOut = 0, validatorComparator) {
2248
2248
  const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
2249
2249
  const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
2250
2250
  const stakePool = stakePoolAccount.account.data;
@@ -2294,7 +2294,6 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
2294
2294
  withdrawAccounts.push(...(await prepareWithdrawAccounts(connection, stakePool, stakePoolAddress, poolAmount, validatorComparator, poolTokenAccount.equals(stakePool.managerFeeAccount))));
2295
2295
  }
2296
2296
  const instructions = [];
2297
- const signers = [];
2298
2297
  const stakeAccountPubkeys = [];
2299
2298
  // Max 5 accounts to prevent an error: "Transaction too large"
2300
2299
  const maxWithdrawAccounts = 5;
@@ -2303,14 +2302,21 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
2303
2302
  if (i >= maxWithdrawAccounts) {
2304
2303
  break;
2305
2304
  }
2306
- // Create a new stake account to receive the withdrawal
2307
- const stakeReceiver = web3_js.Keypair.generate();
2308
- signers.push(stakeReceiver);
2309
- stakeAccountPubkeys.push(stakeReceiver.publicKey);
2310
- // Create the stake account that will receive the split stake
2311
- instructions.push(web3_js.SystemProgram.createAccount({
2312
- fromPubkey: payer !== null && payer !== void 0 ? payer : userPubkey,
2313
- newAccountPubkey: stakeReceiver.publicKey,
2305
+ // Create a deterministic stake account address using a seed
2306
+ // This avoids needing the new account to sign (required for sessions)
2307
+ // We use payer as base so only payer needs to sign (payer = basePubkey)
2308
+ // The seed includes timestamp + random component to ensure uniqueness
2309
+ const uniqueId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
2310
+ const seed = `ws:${uniqueId}:${i}`.slice(0, 32); // Seed max 32 chars
2311
+ const stakeReceiverPubkey = await web3_js.PublicKey.createWithSeed(payer, seed, web3_js.StakeProgram.programId);
2312
+ stakeAccountPubkeys.push(stakeReceiverPubkey);
2313
+ // Create the stake account using createAccountWithSeed
2314
+ // Since basePubkey === fromPubkey (both are payer), only payer needs to sign
2315
+ instructions.push(web3_js.SystemProgram.createAccountWithSeed({
2316
+ fromPubkey: payer,
2317
+ newAccountPubkey: stakeReceiverPubkey,
2318
+ basePubkey: payer,
2319
+ seed,
2314
2320
  lamports: stakeAccountRentExemption,
2315
2321
  space: web3_js.StakeProgram.space,
2316
2322
  programId: web3_js.StakeProgram.programId,
@@ -2322,7 +2328,7 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
2322
2328
  validatorList: stakePool.validatorList,
2323
2329
  withdrawAuthority,
2324
2330
  stakeToSplit: withdrawAccount.stakeAddress,
2325
- stakeToReceive: stakeReceiver.publicKey,
2331
+ stakeToReceive: stakeReceiverPubkey,
2326
2332
  sessionSigner: signerOrSession,
2327
2333
  burnFromPool: poolTokenAccount,
2328
2334
  managerFeeAccount: stakePool.managerFeeAccount,
@@ -2330,13 +2336,12 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
2330
2336
  tokenProgramId: stakePool.tokenProgramId,
2331
2337
  programSigner,
2332
2338
  poolTokensIn: withdrawAccount.poolAmount.toNumber(),
2333
- minimumLamportsOut: solToLamports(minimumLamportsOut),
2339
+ minimumLamportsOut,
2334
2340
  }));
2335
2341
  i++;
2336
2342
  }
2337
2343
  return {
2338
2344
  instructions,
2339
- signers,
2340
2345
  stakeAccountPubkeys,
2341
2346
  };
2342
2347
  }