@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.
- package/dist/index.browser.cjs.js +20 -9
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.browser.esm.js +20 -9
- package/dist/index.browser.esm.js.map +1 -1
- package/dist/index.cjs.js +20 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +20 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +20 -9
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/instructions.d.ts +5 -2
- package/package.json +1 -1
- package/src/index.ts +10 -8
- package/src/instructions.ts +17 -6
package/dist/instructions.d.ts
CHANGED
|
@@ -158,7 +158,8 @@ export type WithdrawWsolWithSessionParams = {
|
|
|
158
158
|
solWithdrawAuthority?: PublicKey;
|
|
159
159
|
wsolMint: PublicKey;
|
|
160
160
|
programSigner: PublicKey;
|
|
161
|
-
|
|
161
|
+
poolTokensIn: number;
|
|
162
|
+
minimumLamportsOut: number;
|
|
162
163
|
};
|
|
163
164
|
/**
|
|
164
165
|
* Deposit SOL directly into the pool's reserve account. The output is a "pool" token
|
|
@@ -279,7 +280,7 @@ export declare class StakePoolInstruction {
|
|
|
279
280
|
/**
|
|
280
281
|
* Creates a transaction instruction to deposit WSOL into a stake pool.
|
|
281
282
|
*/
|
|
282
|
-
static depositWsolWithSession(params: DepositSolParams & {
|
|
283
|
+
static depositWsolWithSession(params: Omit<DepositSolParams, 'lamports'> & {
|
|
283
284
|
wsolMint: PublicKey;
|
|
284
285
|
wsolTokenAccount: PublicKey;
|
|
285
286
|
wsolTransientAccount: PublicKey;
|
|
@@ -287,6 +288,8 @@ export declare class StakePoolInstruction {
|
|
|
287
288
|
tokenProgramId: PublicKey;
|
|
288
289
|
programId: PublicKey;
|
|
289
290
|
payer?: PublicKey;
|
|
291
|
+
lamportsIn: number;
|
|
292
|
+
minimumPoolTokensOut: number;
|
|
290
293
|
}): TransactionInstruction;
|
|
291
294
|
/**
|
|
292
295
|
* Creates a transaction instruction to withdraw active stake from a stake pool.
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -295,6 +295,7 @@ export async function depositWsolWithSession(
|
|
|
295
295
|
signerOrSession: PublicKey,
|
|
296
296
|
userPubkey: PublicKey,
|
|
297
297
|
lamports: number,
|
|
298
|
+
minimumPoolTokensOut: number = 0,
|
|
298
299
|
destinationTokenAccount?: PublicKey,
|
|
299
300
|
referrerTokenAccount?: PublicKey,
|
|
300
301
|
depositAuthority?: PublicKey,
|
|
@@ -318,13 +319,12 @@ export async function depositWsolWithSession(
|
|
|
318
319
|
)
|
|
319
320
|
}
|
|
320
321
|
|
|
321
|
-
const stakePoolAccount = await getStakePoolAccount(
|
|
322
|
-
connection,
|
|
323
|
-
stakePoolAddress,
|
|
324
|
-
)
|
|
322
|
+
const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress)
|
|
325
323
|
const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint)
|
|
326
324
|
const stakePool = stakePoolAccount.account.data
|
|
327
325
|
|
|
326
|
+
// stakePool.tokenProgramId
|
|
327
|
+
|
|
328
328
|
const instructions: TransactionInstruction[] = []
|
|
329
329
|
|
|
330
330
|
// Create token account if not specified
|
|
@@ -335,7 +335,7 @@ export async function depositWsolWithSession(
|
|
|
335
335
|
)
|
|
336
336
|
instructions.push(
|
|
337
337
|
createAssociatedTokenAccountIdempotentInstruction(
|
|
338
|
-
signerOrSession,
|
|
338
|
+
payer ?? signerOrSession,
|
|
339
339
|
associatedAddress,
|
|
340
340
|
userPubkey,
|
|
341
341
|
stakePool.poolMint,
|
|
@@ -369,10 +369,10 @@ export async function depositWsolWithSession(
|
|
|
369
369
|
managerFeeAccount: stakePool.managerFeeAccount,
|
|
370
370
|
referralPoolAccount: referrerTokenAccount ?? destinationTokenAccount,
|
|
371
371
|
poolMint: stakePool.poolMint,
|
|
372
|
-
lamports,
|
|
372
|
+
lamportsIn: lamports,
|
|
373
|
+
minimumPoolTokensOut,
|
|
373
374
|
withdrawAuthority,
|
|
374
375
|
depositAuthority,
|
|
375
|
-
|
|
376
376
|
wsolMint: NATIVE_MINT,
|
|
377
377
|
wsolTokenAccount,
|
|
378
378
|
wsolTransientAccount,
|
|
@@ -834,6 +834,7 @@ export async function withdrawWsolWithSession(
|
|
|
834
834
|
signerOrSession: PublicKey,
|
|
835
835
|
userPubkey: PublicKey,
|
|
836
836
|
amount: number,
|
|
837
|
+
minimumLamportsOut: number = 0,
|
|
837
838
|
solWithdrawAuthority?: PublicKey,
|
|
838
839
|
) {
|
|
839
840
|
const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress)
|
|
@@ -890,7 +891,8 @@ export async function withdrawWsolWithSession(
|
|
|
890
891
|
solWithdrawAuthority,
|
|
891
892
|
wsolMint: NATIVE_MINT,
|
|
892
893
|
programSigner,
|
|
893
|
-
poolTokens,
|
|
894
|
+
poolTokensIn: poolTokens,
|
|
895
|
+
minimumLamportsOut,
|
|
894
896
|
}),
|
|
895
897
|
)
|
|
896
898
|
|
package/src/instructions.ts
CHANGED
|
@@ -214,14 +214,16 @@ export const STAKE_POOL_INSTRUCTION_LAYOUTS: {
|
|
|
214
214
|
index: 27,
|
|
215
215
|
layout: BufferLayout.struct<any>([
|
|
216
216
|
BufferLayout.u8('instruction'),
|
|
217
|
-
BufferLayout.ns64('
|
|
217
|
+
BufferLayout.ns64('lamportsIn'),
|
|
218
|
+
BufferLayout.ns64('minimumPoolTokensOut'),
|
|
218
219
|
]),
|
|
219
220
|
},
|
|
220
221
|
WithdrawWsolWithSession: {
|
|
221
222
|
index: 28,
|
|
222
223
|
layout: BufferLayout.struct<any>([
|
|
223
224
|
BufferLayout.u8('instruction'),
|
|
224
|
-
BufferLayout.ns64('
|
|
225
|
+
BufferLayout.ns64('poolTokensIn'),
|
|
226
|
+
BufferLayout.ns64('minimumLamportsOut'),
|
|
225
227
|
]),
|
|
226
228
|
},
|
|
227
229
|
})
|
|
@@ -383,7 +385,8 @@ export type WithdrawWsolWithSessionParams = {
|
|
|
383
385
|
solWithdrawAuthority?: PublicKey
|
|
384
386
|
wsolMint: PublicKey
|
|
385
387
|
programSigner: PublicKey
|
|
386
|
-
|
|
388
|
+
poolTokensIn: number
|
|
389
|
+
minimumLamportsOut: number
|
|
387
390
|
}
|
|
388
391
|
|
|
389
392
|
/**
|
|
@@ -954,7 +957,7 @@ export class StakePoolInstruction {
|
|
|
954
957
|
/**
|
|
955
958
|
* Creates a transaction instruction to deposit WSOL into a stake pool.
|
|
956
959
|
*/
|
|
957
|
-
static depositWsolWithSession(params: DepositSolParams & {
|
|
960
|
+
static depositWsolWithSession(params: Omit<DepositSolParams, 'lamports'> & {
|
|
958
961
|
wsolMint: PublicKey
|
|
959
962
|
wsolTokenAccount: PublicKey
|
|
960
963
|
wsolTransientAccount: PublicKey
|
|
@@ -962,9 +965,14 @@ export class StakePoolInstruction {
|
|
|
962
965
|
tokenProgramId: PublicKey
|
|
963
966
|
programId: PublicKey
|
|
964
967
|
payer?: PublicKey
|
|
968
|
+
lamportsIn: number
|
|
969
|
+
minimumPoolTokensOut: number
|
|
965
970
|
}): TransactionInstruction {
|
|
966
971
|
const type = STAKE_POOL_INSTRUCTION_LAYOUTS.DepositWsolWithSession
|
|
967
|
-
const data = encodeData(type, {
|
|
972
|
+
const data = encodeData(type, {
|
|
973
|
+
lamportsIn: params.lamportsIn,
|
|
974
|
+
minimumPoolTokensOut: params.minimumPoolTokensOut,
|
|
975
|
+
})
|
|
968
976
|
|
|
969
977
|
const keys = [
|
|
970
978
|
{ pubkey: params.stakePool, isSigner: false, isWritable: true },
|
|
@@ -1104,7 +1112,10 @@ export class StakePoolInstruction {
|
|
|
1104
1112
|
params: WithdrawWsolWithSessionParams,
|
|
1105
1113
|
): TransactionInstruction {
|
|
1106
1114
|
const type = STAKE_POOL_INSTRUCTION_LAYOUTS.WithdrawWsolWithSession
|
|
1107
|
-
const data = encodeData(type, {
|
|
1115
|
+
const data = encodeData(type, {
|
|
1116
|
+
poolTokensIn: params.poolTokensIn,
|
|
1117
|
+
minimumLamportsOut: params.minimumLamportsOut,
|
|
1118
|
+
})
|
|
1108
1119
|
|
|
1109
1120
|
const keys = [
|
|
1110
1121
|
{ pubkey: params.stakePool, isSigner: false, isWritable: true },
|