@ignitionfi/spl-stake-pool 1.1.18 → 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.
@@ -155,11 +155,13 @@ export type WithdrawWsolWithSessionParams = {
155
155
  managerFeeAccount: PublicKey;
156
156
  poolMint: PublicKey;
157
157
  tokenProgramId: PublicKey;
158
- solWithdrawAuthority?: PublicKey;
159
158
  wsolMint: PublicKey;
160
159
  programSigner: PublicKey;
160
+ userWallet: PublicKey;
161
161
  poolTokensIn: number;
162
162
  minimumLamportsOut: number;
163
+ payer?: PublicKey;
164
+ solWithdrawAuthority?: PublicKey;
163
165
  };
164
166
  /**
165
167
  * Deposit SOL directly into the pool's reserve account. The output is a "pool" token
@@ -287,10 +289,10 @@ export declare class StakePoolInstruction {
287
289
  programSigner: PublicKey;
288
290
  tokenProgramId: PublicKey;
289
291
  programId: PublicKey;
290
- payer?: PublicKey;
291
292
  userWallet: PublicKey;
292
293
  lamportsIn: number;
293
294
  minimumPoolTokensOut: number;
295
+ payer?: PublicKey;
294
296
  }): TransactionInstruction;
295
297
  /**
296
298
  * Creates a transaction instruction to withdraw active stake from a stake pool.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ignitionfi/spl-stake-pool",
3
- "version": "1.1.18",
3
+ "version": "1.1.20",
4
4
  "description": "Ignition Stake Pool SDK for FOGO",
5
5
  "contributors": [
6
6
  "Anza Maintainers <maintainers@anza.xyz>",
package/src/index.ts CHANGED
@@ -827,6 +827,7 @@ export async function withdrawWsolWithSession(
827
827
  amount: number,
828
828
  minimumLamportsOut: number = 0,
829
829
  solWithdrawAuthority?: PublicKey,
830
+ payer?: PublicKey,
830
831
  ) {
831
832
  const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress)
832
833
  const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint)
@@ -848,14 +849,8 @@ export async function withdrawWsolWithSession(
848
849
  const instructions: TransactionInstruction[] = []
849
850
  const signers: Signer[] = []
850
851
 
851
- instructions.push(
852
- createAssociatedTokenAccountIdempotentInstruction(
853
- signerOrSession,
854
- userWsolAccount,
855
- userPubkey,
856
- NATIVE_MINT,
857
- ),
858
- )
852
+ // The program handles wSOL ATA creation internally
853
+ // This prevents rent drain attacks where paymaster pays for ATA and user reclaims rent
859
854
 
860
855
  const [programSigner] = PublicKey.findProgramAddressSync(
861
856
  [Buffer.from('fogo_session_program_signer')],
@@ -882,6 +877,8 @@ export async function withdrawWsolWithSession(
882
877
  solWithdrawAuthority,
883
878
  wsolMint: NATIVE_MINT,
884
879
  programSigner,
880
+ userWallet: userPubkey,
881
+ payer,
885
882
  poolTokensIn: poolTokens,
886
883
  minimumLamportsOut,
887
884
  }),
@@ -382,11 +382,13 @@ export type WithdrawWsolWithSessionParams = {
382
382
  managerFeeAccount: PublicKey
383
383
  poolMint: PublicKey
384
384
  tokenProgramId: PublicKey
385
- solWithdrawAuthority?: PublicKey
386
385
  wsolMint: PublicKey
387
386
  programSigner: PublicKey
387
+ userWallet: PublicKey
388
388
  poolTokensIn: number
389
389
  minimumLamportsOut: number
390
+ payer?: PublicKey
391
+ solWithdrawAuthority?: PublicKey
390
392
  }
391
393
 
392
394
  /**
@@ -964,10 +966,10 @@ export class StakePoolInstruction {
964
966
  programSigner: PublicKey
965
967
  tokenProgramId: PublicKey
966
968
  programId: PublicKey
967
- payer?: PublicKey
968
969
  userWallet: PublicKey
969
970
  lamportsIn: number
970
971
  minimumPoolTokensOut: number
972
+ payer?: PublicKey
971
973
  }): TransactionInstruction {
972
974
  const type = STAKE_POOL_INSTRUCTION_LAYOUTS.DepositWsolWithSession
973
975
  const data = encodeData(type, {
@@ -993,7 +995,6 @@ export class StakePoolInstruction {
993
995
  { pubkey: params.wsolTransientAccount, isSigner: false, isWritable: true },
994
996
  { pubkey: params.programSigner, isSigner: false, isWritable: true },
995
997
  { pubkey: params.payer ?? params.fundingAccount, isSigner: true, isWritable: true },
996
- { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
997
998
  { pubkey: params.userWallet, isSigner: false, isWritable: false },
998
999
  ]
999
1000
 
@@ -1005,6 +1006,9 @@ export class StakePoolInstruction {
1005
1006
  })
1006
1007
  }
1007
1008
 
1009
+ // Associated Token Program must be last - only needed in transaction for CPI routing
1010
+ keys.push({ pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false })
1011
+
1008
1012
  return new TransactionInstruction({
1009
1013
  programId: params.programId,
1010
1014
  keys,
@@ -1136,6 +1140,9 @@ export class StakePoolInstruction {
1136
1140
 
1137
1141
  { pubkey: params.wsolMint, isSigner: false, isWritable: false },
1138
1142
  { pubkey: params.programSigner, isSigner: false, isWritable: true },
1143
+ { pubkey: params.payer ?? params.userTransferAuthority, isSigner: true, isWritable: true },
1144
+ { pubkey: params.userWallet, isSigner: false, isWritable: false },
1145
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
1139
1146
  ]
1140
1147
 
1141
1148
  if (params.solWithdrawAuthority) {
@@ -1146,6 +1153,9 @@ export class StakePoolInstruction {
1146
1153
  })
1147
1154
  }
1148
1155
 
1156
+ // Associated Token Program must be last - only needed in transaction for CPI routing
1157
+ keys.push({ pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false })
1158
+
1149
1159
  return new TransactionInstruction({
1150
1160
  programId: params.programId,
1151
1161
  keys,