@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
|
@@ -1083,14 +1083,16 @@ const STAKE_POOL_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
1083
1083
|
index: 27,
|
|
1084
1084
|
layout: BufferLayout.struct([
|
|
1085
1085
|
BufferLayout.u8('instruction'),
|
|
1086
|
-
BufferLayout.ns64('
|
|
1086
|
+
BufferLayout.ns64('lamportsIn'),
|
|
1087
|
+
BufferLayout.ns64('minimumPoolTokensOut'),
|
|
1087
1088
|
]),
|
|
1088
1089
|
},
|
|
1089
1090
|
WithdrawWsolWithSession: {
|
|
1090
1091
|
index: 28,
|
|
1091
1092
|
layout: BufferLayout.struct([
|
|
1092
1093
|
BufferLayout.u8('instruction'),
|
|
1093
|
-
BufferLayout.ns64('
|
|
1094
|
+
BufferLayout.ns64('poolTokensIn'),
|
|
1095
|
+
BufferLayout.ns64('minimumLamportsOut'),
|
|
1094
1096
|
]),
|
|
1095
1097
|
},
|
|
1096
1098
|
});
|
|
@@ -1424,7 +1426,10 @@ class StakePoolInstruction {
|
|
|
1424
1426
|
static depositWsolWithSession(params) {
|
|
1425
1427
|
var _a;
|
|
1426
1428
|
const type = STAKE_POOL_INSTRUCTION_LAYOUTS.DepositWsolWithSession;
|
|
1427
|
-
const data = encodeData(type, {
|
|
1429
|
+
const data = encodeData(type, {
|
|
1430
|
+
lamportsIn: params.lamportsIn,
|
|
1431
|
+
minimumPoolTokensOut: params.minimumPoolTokensOut,
|
|
1432
|
+
});
|
|
1428
1433
|
const keys = [
|
|
1429
1434
|
{ pubkey: params.stakePool, isSigner: false, isWritable: true },
|
|
1430
1435
|
{ pubkey: params.withdrawAuthority, isSigner: false, isWritable: false },
|
|
@@ -1523,7 +1528,10 @@ class StakePoolInstruction {
|
|
|
1523
1528
|
*/
|
|
1524
1529
|
static withdrawWsolWithSession(params) {
|
|
1525
1530
|
const type = STAKE_POOL_INSTRUCTION_LAYOUTS.WithdrawWsolWithSession;
|
|
1526
|
-
const data = encodeData(type, {
|
|
1531
|
+
const data = encodeData(type, {
|
|
1532
|
+
poolTokensIn: params.poolTokensIn,
|
|
1533
|
+
minimumLamportsOut: params.minimumLamportsOut,
|
|
1534
|
+
});
|
|
1527
1535
|
const keys = [
|
|
1528
1536
|
{ pubkey: params.stakePool, isSigner: false, isWritable: true },
|
|
1529
1537
|
{ pubkey: params.withdrawAuthority, isSigner: false, isWritable: false },
|
|
@@ -1816,7 +1824,7 @@ async function depositStake(connection, stakePoolAddress, authorizedPubkey, vali
|
|
|
1816
1824
|
/**
|
|
1817
1825
|
* Creates instructions required to deposit sol to stake pool.
|
|
1818
1826
|
*/
|
|
1819
|
-
async function depositWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, lamports, destinationTokenAccount, referrerTokenAccount, depositAuthority, payer) {
|
|
1827
|
+
async function depositWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, lamports, minimumPoolTokensOut = 0, destinationTokenAccount, referrerTokenAccount, depositAuthority, payer) {
|
|
1820
1828
|
const wsolTokenAccount = getAssociatedTokenAddressSync(NATIVE_MINT, userPubkey);
|
|
1821
1829
|
const tokenAccountInfo = await connection.getTokenAccountBalance(wsolTokenAccount, 'confirmed');
|
|
1822
1830
|
const wsolBalance = tokenAccountInfo
|
|
@@ -1828,11 +1836,12 @@ async function depositWsolWithSession(connection, stakePoolAddress, signerOrSess
|
|
|
1828
1836
|
const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
|
|
1829
1837
|
const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
|
|
1830
1838
|
const stakePool = stakePoolAccount.account.data;
|
|
1839
|
+
// stakePool.tokenProgramId
|
|
1831
1840
|
const instructions = [];
|
|
1832
1841
|
// Create token account if not specified
|
|
1833
1842
|
if (!destinationTokenAccount) {
|
|
1834
1843
|
const associatedAddress = getAssociatedTokenAddressSync(stakePool.poolMint, userPubkey);
|
|
1835
|
-
instructions.push(createAssociatedTokenAccountIdempotentInstruction(signerOrSession, associatedAddress, userPubkey, stakePool.poolMint));
|
|
1844
|
+
instructions.push(createAssociatedTokenAccountIdempotentInstruction(payer !== null && payer !== void 0 ? payer : signerOrSession, associatedAddress, userPubkey, stakePool.poolMint));
|
|
1836
1845
|
destinationTokenAccount = associatedAddress;
|
|
1837
1846
|
}
|
|
1838
1847
|
const withdrawAuthority = await findWithdrawAuthorityProgramAddress(stakePoolProgramId, stakePoolAddress);
|
|
@@ -1847,7 +1856,8 @@ async function depositWsolWithSession(connection, stakePoolAddress, signerOrSess
|
|
|
1847
1856
|
managerFeeAccount: stakePool.managerFeeAccount,
|
|
1848
1857
|
referralPoolAccount: referrerTokenAccount !== null && referrerTokenAccount !== void 0 ? referrerTokenAccount : destinationTokenAccount,
|
|
1849
1858
|
poolMint: stakePool.poolMint,
|
|
1850
|
-
lamports,
|
|
1859
|
+
lamportsIn: lamports,
|
|
1860
|
+
minimumPoolTokensOut,
|
|
1851
1861
|
withdrawAuthority,
|
|
1852
1862
|
depositAuthority,
|
|
1853
1863
|
wsolMint: NATIVE_MINT,
|
|
@@ -2119,7 +2129,7 @@ async function withdrawSol(connection, stakePoolAddress, tokenOwner, solReceiver
|
|
|
2119
2129
|
/**
|
|
2120
2130
|
* Creates instructions required to withdraw wSOL from a stake pool.
|
|
2121
2131
|
*/
|
|
2122
|
-
async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, solWithdrawAuthority) {
|
|
2132
|
+
async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, minimumLamportsOut = 0, solWithdrawAuthority) {
|
|
2123
2133
|
const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
|
|
2124
2134
|
const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
|
|
2125
2135
|
const stakePool = stakePoolAccount.account.data;
|
|
@@ -2150,7 +2160,8 @@ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSes
|
|
|
2150
2160
|
solWithdrawAuthority,
|
|
2151
2161
|
wsolMint: NATIVE_MINT,
|
|
2152
2162
|
programSigner,
|
|
2153
|
-
poolTokens,
|
|
2163
|
+
poolTokensIn: poolTokens,
|
|
2164
|
+
minimumLamportsOut,
|
|
2154
2165
|
}));
|
|
2155
2166
|
return {
|
|
2156
2167
|
instructions,
|