@ignitionfi/spl-stake-pool 1.1.10 → 1.1.12

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.
@@ -1104,14 +1104,16 @@ const STAKE_POOL_INSTRUCTION_LAYOUTS = Object.freeze({
1104
1104
  index: 27,
1105
1105
  layout: BufferLayout__namespace.struct([
1106
1106
  BufferLayout__namespace.u8('instruction'),
1107
- BufferLayout__namespace.ns64('lamports'),
1107
+ BufferLayout__namespace.ns64('lamportsIn'),
1108
+ BufferLayout__namespace.ns64('minimumPoolTokensOut'),
1108
1109
  ]),
1109
1110
  },
1110
1111
  WithdrawWsolWithSession: {
1111
1112
  index: 28,
1112
1113
  layout: BufferLayout__namespace.struct([
1113
1114
  BufferLayout__namespace.u8('instruction'),
1114
- BufferLayout__namespace.ns64('poolTokens'),
1115
+ BufferLayout__namespace.ns64('poolTokensIn'),
1116
+ BufferLayout__namespace.ns64('minimumLamportsOut'),
1115
1117
  ]),
1116
1118
  },
1117
1119
  });
@@ -1445,7 +1447,10 @@ class StakePoolInstruction {
1445
1447
  static depositWsolWithSession(params) {
1446
1448
  var _a;
1447
1449
  const type = STAKE_POOL_INSTRUCTION_LAYOUTS.DepositWsolWithSession;
1448
- const data = encodeData(type, { lamports: params.lamports });
1450
+ const data = encodeData(type, {
1451
+ lamportsIn: params.lamportsIn,
1452
+ minimumPoolTokensOut: params.minimumPoolTokensOut,
1453
+ });
1449
1454
  const keys = [
1450
1455
  { pubkey: params.stakePool, isSigner: false, isWritable: true },
1451
1456
  { pubkey: params.withdrawAuthority, isSigner: false, isWritable: false },
@@ -1544,7 +1549,10 @@ class StakePoolInstruction {
1544
1549
  */
1545
1550
  static withdrawWsolWithSession(params) {
1546
1551
  const type = STAKE_POOL_INSTRUCTION_LAYOUTS.WithdrawWsolWithSession;
1547
- const data = encodeData(type, { poolTokens: params.poolTokens });
1552
+ const data = encodeData(type, {
1553
+ poolTokensIn: params.poolTokensIn,
1554
+ minimumLamportsOut: params.minimumLamportsOut,
1555
+ });
1548
1556
  const keys = [
1549
1557
  { pubkey: params.stakePool, isSigner: false, isWritable: true },
1550
1558
  { pubkey: params.withdrawAuthority, isSigner: false, isWritable: false },
@@ -1837,7 +1845,7 @@ async function depositStake(connection, stakePoolAddress, authorizedPubkey, vali
1837
1845
  /**
1838
1846
  * Creates instructions required to deposit sol to stake pool.
1839
1847
  */
1840
- async function depositWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, lamports, destinationTokenAccount, referrerTokenAccount, depositAuthority, payer) {
1848
+ async function depositWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, lamports, minimumPoolTokensOut = 0, destinationTokenAccount, referrerTokenAccount, depositAuthority, payer) {
1841
1849
  const wsolTokenAccount = splToken.getAssociatedTokenAddressSync(splToken.NATIVE_MINT, userPubkey);
1842
1850
  const tokenAccountInfo = await connection.getTokenAccountBalance(wsolTokenAccount, 'confirmed');
1843
1851
  const wsolBalance = tokenAccountInfo
@@ -1849,11 +1857,12 @@ async function depositWsolWithSession(connection, stakePoolAddress, signerOrSess
1849
1857
  const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
1850
1858
  const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
1851
1859
  const stakePool = stakePoolAccount.account.data;
1860
+ // stakePool.tokenProgramId
1852
1861
  const instructions = [];
1853
1862
  // Create token account if not specified
1854
1863
  if (!destinationTokenAccount) {
1855
1864
  const associatedAddress = splToken.getAssociatedTokenAddressSync(stakePool.poolMint, userPubkey);
1856
- instructions.push(splToken.createAssociatedTokenAccountIdempotentInstruction(signerOrSession, associatedAddress, userPubkey, stakePool.poolMint));
1865
+ instructions.push(splToken.createAssociatedTokenAccountIdempotentInstruction(payer !== null && payer !== void 0 ? payer : signerOrSession, associatedAddress, userPubkey, stakePool.poolMint));
1857
1866
  destinationTokenAccount = associatedAddress;
1858
1867
  }
1859
1868
  const withdrawAuthority = await findWithdrawAuthorityProgramAddress(stakePoolProgramId, stakePoolAddress);
@@ -1868,7 +1877,8 @@ async function depositWsolWithSession(connection, stakePoolAddress, signerOrSess
1868
1877
  managerFeeAccount: stakePool.managerFeeAccount,
1869
1878
  referralPoolAccount: referrerTokenAccount !== null && referrerTokenAccount !== void 0 ? referrerTokenAccount : destinationTokenAccount,
1870
1879
  poolMint: stakePool.poolMint,
1871
- lamports,
1880
+ lamportsIn: lamports,
1881
+ minimumPoolTokensOut,
1872
1882
  withdrawAuthority,
1873
1883
  depositAuthority,
1874
1884
  wsolMint: splToken.NATIVE_MINT,
@@ -2140,7 +2150,7 @@ async function withdrawSol(connection, stakePoolAddress, tokenOwner, solReceiver
2140
2150
  /**
2141
2151
  * Creates instructions required to withdraw wSOL from a stake pool.
2142
2152
  */
2143
- async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, solWithdrawAuthority) {
2153
+ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, minimumLamportsOut = 0, solWithdrawAuthority) {
2144
2154
  const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
2145
2155
  const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
2146
2156
  const stakePool = stakePoolAccount.account.data;
@@ -2171,7 +2181,8 @@ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSes
2171
2181
  solWithdrawAuthority,
2172
2182
  wsolMint: splToken.NATIVE_MINT,
2173
2183
  programSigner,
2174
- poolTokens,
2184
+ poolTokensIn: poolTokens,
2185
+ minimumLamportsOut,
2175
2186
  }));
2176
2187
  return {
2177
2188
  instructions,