@kamino-finance/klend-sdk 5.10.26 → 5.10.28-beta.0

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.
Files changed (99) hide show
  1. package/dist/classes/index.d.ts +3 -0
  2. package/dist/classes/index.d.ts.map +1 -1
  3. package/dist/classes/index.js +3 -0
  4. package/dist/classes/index.js.map +1 -1
  5. package/dist/classes/obligation.d.ts +5 -1
  6. package/dist/classes/obligation.d.ts.map +1 -1
  7. package/dist/classes/obligation.js.map +1 -1
  8. package/dist/classes/stakePool.d.ts +8 -0
  9. package/dist/classes/stakePool.d.ts.map +1 -0
  10. package/dist/classes/stakePool.js +18 -0
  11. package/dist/classes/stakePool.js.map +1 -0
  12. package/dist/classes/standardStakePool.d.ts +255 -0
  13. package/dist/classes/standardStakePool.d.ts.map +1 -0
  14. package/dist/classes/standardStakePool.js +275 -0
  15. package/dist/classes/standardStakePool.js.map +1 -0
  16. package/dist/classes/types.d.ts +13 -1
  17. package/dist/classes/types.d.ts.map +1 -1
  18. package/dist/classes/unstakingPool.d.ts +111 -0
  19. package/dist/classes/unstakingPool.d.ts.map +1 -0
  20. package/dist/classes/unstakingPool.js +437 -0
  21. package/dist/classes/unstakingPool.js.map +1 -0
  22. package/dist/idl_codegen_unstaking_pool/accounts/PoolState.d.ts +50 -0
  23. package/dist/idl_codegen_unstaking_pool/accounts/PoolState.d.ts.map +1 -0
  24. package/dist/idl_codegen_unstaking_pool/accounts/PoolState.js +156 -0
  25. package/dist/idl_codegen_unstaking_pool/accounts/PoolState.js.map +1 -0
  26. package/dist/idl_codegen_unstaking_pool/accounts/index.d.ts +3 -0
  27. package/dist/idl_codegen_unstaking_pool/accounts/index.d.ts.map +1 -0
  28. package/dist/idl_codegen_unstaking_pool/accounts/index.js +6 -0
  29. package/dist/idl_codegen_unstaking_pool/accounts/index.js.map +1 -0
  30. package/dist/idl_codegen_unstaking_pool/errors/anchor.d.ts +435 -0
  31. package/dist/idl_codegen_unstaking_pool/errors/anchor.d.ts.map +1 -0
  32. package/dist/idl_codegen_unstaking_pool/errors/anchor.js +767 -0
  33. package/dist/idl_codegen_unstaking_pool/errors/anchor.js.map +1 -0
  34. package/dist/idl_codegen_unstaking_pool/errors/custom.d.ts +163 -0
  35. package/dist/idl_codegen_unstaking_pool/errors/custom.d.ts.map +1 -0
  36. package/dist/idl_codegen_unstaking_pool/errors/custom.js +290 -0
  37. package/dist/idl_codegen_unstaking_pool/errors/custom.js.map +1 -0
  38. package/dist/idl_codegen_unstaking_pool/errors/index.d.ts +6 -0
  39. package/dist/idl_codegen_unstaking_pool/errors/index.d.ts.map +1 -0
  40. package/dist/idl_codegen_unstaking_pool/errors/index.js +75 -0
  41. package/dist/idl_codegen_unstaking_pool/errors/index.js.map +1 -0
  42. package/dist/idl_codegen_unstaking_pool/instructions/burn.d.ts +21 -0
  43. package/dist/idl_codegen_unstaking_pool/instructions/burn.d.ts.map +1 -0
  44. package/dist/idl_codegen_unstaking_pool/instructions/burn.js +73 -0
  45. package/dist/idl_codegen_unstaking_pool/instructions/burn.js.map +1 -0
  46. package/dist/idl_codegen_unstaking_pool/instructions/collect.d.ts +16 -0
  47. package/dist/idl_codegen_unstaking_pool/instructions/collect.d.ts.map +1 -0
  48. package/dist/idl_codegen_unstaking_pool/instructions/collect.js +29 -0
  49. package/dist/idl_codegen_unstaking_pool/instructions/collect.js.map +1 -0
  50. package/dist/idl_codegen_unstaking_pool/instructions/index.d.ts +11 -0
  51. package/dist/idl_codegen_unstaking_pool/instructions/index.d.ts.map +1 -0
  52. package/dist/idl_codegen_unstaking_pool/instructions/index.js +14 -0
  53. package/dist/idl_codegen_unstaking_pool/instructions/index.js.map +1 -0
  54. package/dist/idl_codegen_unstaking_pool/instructions/initializePool.d.ts +15 -0
  55. package/dist/idl_codegen_unstaking_pool/instructions/initializePool.d.ts.map +1 -0
  56. package/dist/idl_codegen_unstaking_pool/instructions/initializePool.js +28 -0
  57. package/dist/idl_codegen_unstaking_pool/instructions/initializePool.js.map +1 -0
  58. package/dist/idl_codegen_unstaking_pool/instructions/mint.d.ts +21 -0
  59. package/dist/idl_codegen_unstaking_pool/instructions/mint.d.ts.map +1 -0
  60. package/dist/idl_codegen_unstaking_pool/instructions/mint.js +77 -0
  61. package/dist/idl_codegen_unstaking_pool/instructions/mint.js.map +1 -0
  62. package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.d.ts +13 -0
  63. package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.d.ts.map +1 -0
  64. package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.js +58 -0
  65. package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.js.map +1 -0
  66. package/dist/idl_codegen_unstaking_pool/programId.d.ts +4 -0
  67. package/dist/idl_codegen_unstaking_pool/programId.d.ts.map +1 -0
  68. package/dist/idl_codegen_unstaking_pool/programId.js +9 -0
  69. package/dist/idl_codegen_unstaking_pool/programId.js.map +1 -0
  70. package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.d.ts +32 -0
  71. package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.d.ts.map +1 -0
  72. package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.js +105 -0
  73. package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.js.map +1 -0
  74. package/dist/idl_codegen_unstaking_pool/types/index.d.ts +5 -0
  75. package/dist/idl_codegen_unstaking_pool/types/index.d.ts.map +1 -0
  76. package/dist/idl_codegen_unstaking_pool/types/index.js +39 -0
  77. package/dist/idl_codegen_unstaking_pool/types/index.js.map +1 -0
  78. package/package.json +4 -1
  79. package/src/classes/index.ts +3 -0
  80. package/src/classes/obligation.ts +1 -1
  81. package/src/classes/stakePool.ts +21 -0
  82. package/src/classes/standardStakePool.ts +361 -0
  83. package/src/classes/types.ts +17 -1
  84. package/src/classes/unstakingPool.ts +565 -0
  85. package/src/idl_codegen_unstaking_pool/accounts/PoolState.ts +163 -0
  86. package/src/idl_codegen_unstaking_pool/accounts/index.ts +2 -0
  87. package/src/idl_codegen_unstaking_pool/errors/anchor.ts +764 -0
  88. package/src/idl_codegen_unstaking_pool/errors/custom.ts +288 -0
  89. package/src/idl_codegen_unstaking_pool/errors/index.ts +49 -0
  90. package/src/idl_codegen_unstaking_pool/instructions/burn.ts +60 -0
  91. package/src/idl_codegen_unstaking_pool/instructions/collect.ts +43 -0
  92. package/src/idl_codegen_unstaking_pool/instructions/index.ts +10 -0
  93. package/src/idl_codegen_unstaking_pool/instructions/initializePool.ts +41 -0
  94. package/src/idl_codegen_unstaking_pool/instructions/mint.ts +64 -0
  95. package/src/idl_codegen_unstaking_pool/instructions/updatePoolConfig.ts +40 -0
  96. package/src/idl_codegen_unstaking_pool/programId.ts +7 -0
  97. package/src/idl_codegen_unstaking_pool/types/PoolConfigField.ts +85 -0
  98. package/src/idl_codegen_unstaking_pool/types/index.ts +6 -0
  99. package/src/idl_unstaking_pool.json +456 -0
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StakeAccount = exports.StakeAccountInfo = exports.StakeMeta = exports.StakeAccountType = exports.STAKE_ACCOUNT_RENT_EXEMPTION = exports.TRANSIENT_STAKE_SEED_PREFIX = void 0;
7
+ exports.getStandardPoolState = getStandardPoolState;
8
+ exports.getValidatorList = getValidatorList;
9
+ exports.maybeGetStakedPoolByMint = maybeGetStakedPoolByMint;
10
+ exports.getStandardPoolMintRemainingAccounts = getStandardPoolMintRemainingAccounts;
11
+ exports.getWithdrawCandidates = getWithdrawCandidates;
12
+ exports.findWithdrawAuthorityProgramAddress = findWithdrawAuthorityProgramAddress;
13
+ exports.findStakeProgramAddress = findStakeProgramAddress;
14
+ exports.findTransientStakeProgramAddress = findTransientStakeProgramAddress;
15
+ exports.calcLamportsWithdrawAmount = calcLamportsWithdrawAmount;
16
+ const spl_stake_pool_1 = require("@solana/spl-stake-pool");
17
+ const spl_stake_pool_2 = require("@solana/spl-stake-pool");
18
+ const web3_js_1 = require("@solana/web3.js");
19
+ const unstakingPool_1 = require("./unstakingPool");
20
+ const bn_js_1 = __importDefault(require("bn.js"));
21
+ const assert_1 = __importDefault(require("assert"));
22
+ const superstruct_1 = require("superstruct");
23
+ exports.TRANSIENT_STAKE_SEED_PREFIX = Buffer.from('transient');
24
+ exports.STAKE_ACCOUNT_RENT_EXEMPTION = 2_282_880;
25
+ const MINIMUM_ACTIVE_STAKE = 1_000_000;
26
+ // This represents the minimum each validator stake account must have and cannot be withdrawn
27
+ const TRANSIENT_STAKE_ACCOUNT_RENT_EXEMPTION = exports.STAKE_ACCOUNT_RENT_EXEMPTION + MINIMUM_ACTIVE_STAKE;
28
+ async function getStandardPoolState(address, connection) {
29
+ const accountInfo = await connection.getAccountInfo(address);
30
+ if (!accountInfo) {
31
+ throw new Error(`Cannot fetch standard stake pool account ${address.toString()}`);
32
+ }
33
+ return spl_stake_pool_2.StakePoolLayout.decode(accountInfo.data);
34
+ }
35
+ async function getValidatorList(address, connection) {
36
+ const accountInfo = await connection.getAccountInfo(address);
37
+ if (!accountInfo) {
38
+ throw new Error(`Cannot fetch standard stake pool account ${address.toString()}`);
39
+ }
40
+ return spl_stake_pool_1.ValidatorListLayout.decode(accountInfo.data);
41
+ }
42
+ async function maybeGetStakedPoolByMint(connection, mint) {
43
+ const results = await connection.getProgramAccounts(spl_stake_pool_1.STAKE_POOL_PROGRAM_ID, {
44
+ filters: [{ memcmp: { offset: 162, bytes: mint.toBase58() } }],
45
+ });
46
+ // There should be only 1 stake pool for mint
47
+ if (results.length === 0) {
48
+ return undefined;
49
+ }
50
+ if (results.length === 1) {
51
+ return [spl_stake_pool_2.StakePoolLayout.decode(results[0].account.data), results[0].pubkey];
52
+ }
53
+ throw new Error(`Got ${results.length} stake pools for mint ${mint.toString()} and not sure which one is correct.`);
54
+ }
55
+ async function getStandardPoolMintRemainingAccounts(connection, stakedSolPool, stakedSolPoolPk, stakedSolToDeposit) {
56
+ let withdrawAuthority = await findWithdrawAuthorityProgramAddress(spl_stake_pool_1.STAKE_POOL_PROGRAM_ID, stakedSolPoolPk);
57
+ const remainingAccounts = [
58
+ { pubkey: stakedSolPoolPk, isSigner: false, isWritable: true },
59
+ { pubkey: stakedSolPool.validatorList, isSigner: false, isWritable: true },
60
+ { pubkey: withdrawAuthority, isSigner: false, isWritable: true },
61
+ { pubkey: stakedSolPool.managerFeeAccount, isSigner: false, isWritable: true },
62
+ { pubkey: unstakingPool_1.CLOCK_PROGRAM_ID, isSigner: false, isWritable: false },
63
+ { pubkey: unstakingPool_1.STAKE_PROGRAM_ID, isSigner: false, isWritable: false },
64
+ { pubkey: spl_stake_pool_1.STAKE_POOL_PROGRAM_ID, isSigner: false, isWritable: false },
65
+ ];
66
+ const withdrawCandidates = await getWithdrawCandidates(connection, stakedSolPool, stakedSolPoolPk, stakedSolToDeposit);
67
+ // Each withdraw candidate should also create a new keypair for the stake account
68
+ const withdrawCandidatesTo = [];
69
+ for (const withdrawCandidateFrom of withdrawCandidates) {
70
+ remainingAccounts.push({ pubkey: withdrawCandidateFrom, isSigner: false, isWritable: true });
71
+ const withdrawCandidateTo = web3_js_1.Keypair.generate();
72
+ remainingAccounts.push({ pubkey: withdrawCandidateTo.publicKey, isSigner: true, isWritable: true });
73
+ withdrawCandidatesTo.push(withdrawCandidateTo);
74
+ }
75
+ return [remainingAccounts, withdrawCandidatesTo];
76
+ }
77
+ async function getAllWithdrawCandidatesSorted(connection, stakedSolPool, stakedSolPoolPk) {
78
+ const activeValidators = [];
79
+ const transientValidators = [];
80
+ const validatorList = await getValidatorList(stakedSolPool.validatorList, connection);
81
+ const accountsToFetch = [];
82
+ // Add all accounts to be fetched to an array so that we can use getMultipleAccounts
83
+ for (const validator of validatorList.validators) {
84
+ const stakeAccount = await findStakeProgramAddress(spl_stake_pool_1.STAKE_POOL_PROGRAM_ID, validator.voteAccountAddress, stakedSolPoolPk, validator.transientSeedSuffixStart.toNumber());
85
+ const transientAccount = await findTransientStakeProgramAddress(spl_stake_pool_1.STAKE_POOL_PROGRAM_ID, validator.voteAccountAddress, stakedSolPoolPk, validator.transientSeedSuffixEnd);
86
+ accountsToFetch.push(stakeAccount);
87
+ accountsToFetch.push(transientAccount);
88
+ }
89
+ let accountsBalances = [];
90
+ // TODO: if this is still too slow we can also start all getMultipleAccounts in parallel and do Promise.all
91
+ for (let i = 0; i < accountsToFetch.length; i += 100) {
92
+ const accountInfos = await connection.getMultipleAccountsInfo(accountsToFetch.slice(i, i + 100));
93
+ accountsBalances = accountsBalances.concat(accountInfos.map((accountInfo) => (accountInfo ? accountInfo.lamports : 0)));
94
+ }
95
+ (0, assert_1.default)(accountsBalances.length === accountsToFetch.length);
96
+ let i = 0;
97
+ for (const validator of validatorList.validators) {
98
+ const isPreferred = stakedSolPool.preferredWithdrawValidatorVoteAddress
99
+ ? validator.voteAccountAddress.equals(stakedSolPool.preferredWithdrawValidatorVoteAddress)
100
+ : false;
101
+ const stakeAccount = accountsToFetch[i];
102
+ const stakeAccountBalance = accountsBalances[i] - TRANSIENT_STAKE_ACCOUNT_RENT_EXEMPTION;
103
+ if (stakeAccountBalance > 0) {
104
+ activeValidators.push({ isPreferred, balance: stakeAccountBalance, pk: stakeAccount });
105
+ }
106
+ const transientAccount = accountsToFetch[i + 1];
107
+ const transientAccountBalance = accountsBalances[i + 1] - TRANSIENT_STAKE_ACCOUNT_RENT_EXEMPTION;
108
+ if (transientAccountBalance > 0) {
109
+ transientValidators.push({ isPreferred, balance: transientAccountBalance, pk: transientAccount });
110
+ }
111
+ i += 2;
112
+ }
113
+ // Sorting descending based on balance, but preferred validators should always be used first
114
+ activeValidators.sort((a, b) => {
115
+ if (a.isPreferred) {
116
+ return -1;
117
+ }
118
+ if (b.isPreferred) {
119
+ return 1;
120
+ }
121
+ return b.balance - a.balance;
122
+ });
123
+ transientValidators.sort((a, b) => {
124
+ if (a.isPreferred) {
125
+ return -1;
126
+ }
127
+ if (b.isPreferred) {
128
+ return 1;
129
+ }
130
+ return b.balance - a.balance;
131
+ });
132
+ const allCandidates = activeValidators.concat(transientValidators);
133
+ // Add reserve stake account at the end as that should be used only if no validators have enough stake
134
+ const reserveStakeBalance = (await connection.getBalance(stakedSolPool.reserveStake)) - exports.STAKE_ACCOUNT_RENT_EXEMPTION;
135
+ if (reserveStakeBalance > 0) {
136
+ allCandidates.push({
137
+ isPreferred: false,
138
+ balance: reserveStakeBalance,
139
+ pk: stakedSolPool.reserveStake,
140
+ });
141
+ }
142
+ return allCandidates;
143
+ }
144
+ async function getWithdrawCandidates(connection, stakedSolPool, stakedSolPoolPk, stakedSolToDeposit) {
145
+ const allCandidates = await getAllWithdrawCandidatesSorted(connection, stakedSolPool, stakedSolPoolPk);
146
+ let stakedSolRemaining = stakedSolToDeposit;
147
+ let solToWithdraw = new bn_js_1.default(0);
148
+ const withdrawCandidates = [];
149
+ // Try to withdraw all of the SOL from validators' active/transient accounts
150
+ for (const candidate of allCandidates) {
151
+ if (stakedSolRemaining.isZero()) {
152
+ break;
153
+ }
154
+ // See how much the validator balance is worth in staked sol
155
+ // but limit to amount of needed stake sol
156
+ let stakedSolAmountToWithdraw = bn_js_1.default.min(stakedSolRemaining, solToStakePoolTokensWithInverseFee(stakedSolPool, new bn_js_1.default(candidate.balance)));
157
+ // Convert it back to staked sol so we get the real amount
158
+ let actualSolAmount = calcLamportsWithdrawAmount(stakedSolPool, stakedSolAmountToWithdraw);
159
+ const remainingSolAmount = calcLamportsWithdrawAmount(stakedSolPool, stakedSolRemaining.sub(stakedSolAmountToWithdraw));
160
+ // If the current validator uses up all of the remaining staked sol except some minimum that we need
161
+ // in order to split_stake, then leave at least the minimum required to be consumed by another validator
162
+ if (!remainingSolAmount.isZero() && remainingSolAmount < new bn_js_1.default(MINIMUM_ACTIVE_STAKE)) {
163
+ stakedSolAmountToWithdraw = stakedSolAmountToWithdraw.sub(solToStakePoolTokensWithInverseFee(stakedSolPool, new bn_js_1.default(MINIMUM_ACTIVE_STAKE)));
164
+ actualSolAmount = calcLamportsWithdrawAmount(stakedSolPool, stakedSolAmountToWithdraw);
165
+ }
166
+ if (actualSolAmount < new bn_js_1.default(MINIMUM_ACTIVE_STAKE) && !candidate.pk.equals(stakedSolPool.reserveStake)) {
167
+ // Skip if the amount to withdraw is less than the minimum required for a valid stake
168
+ continue;
169
+ }
170
+ // Update stake_pool so simulation stays true to what happens on chain
171
+ stakedSolRemaining = stakedSolRemaining.sub(stakedSolAmountToWithdraw);
172
+ solToWithdraw = solToWithdraw.add(actualSolAmount);
173
+ stakedSolPool.totalLamports = stakedSolPool.totalLamports.sub(actualSolAmount);
174
+ stakedSolPool.poolTokenSupply = stakedSolPool.poolTokenSupply.sub(stakePoolTokensMinusFee(stakedSolPool, stakedSolAmountToWithdraw));
175
+ withdrawCandidates.push(candidate.pk);
176
+ }
177
+ return withdrawCandidates;
178
+ }
179
+ function calcPoolTokensStakeWithdrawalFee(stakedSolPool, stakedSolAmountToWithdraw) {
180
+ const denominator = stakedSolPool.stakeWithdrawalFee.denominator;
181
+ if (denominator.isZero()) {
182
+ return new bn_js_1.default(0);
183
+ }
184
+ const numerator = stakedSolAmountToWithdraw.mul(stakedSolPool.stakeWithdrawalFee.numerator);
185
+ const poolTokens = numerator.add(denominator).sub(new bn_js_1.default(1)).div(denominator);
186
+ return poolTokens;
187
+ }
188
+ function stakePoolTokensMinusFee(stakedSolPool, stakedSolAmountToWithdraw) {
189
+ const stakedSolFee = calcPoolTokensStakeWithdrawalFee(stakedSolPool, stakedSolAmountToWithdraw);
190
+ return stakedSolAmountToWithdraw.sub(stakedSolFee);
191
+ }
192
+ function solToStakePoolTokensWithInverseFee(stakedSolPool, sol) {
193
+ let poolTokens = calcPoolTokensForDeposit(stakedSolPool, sol);
194
+ if (!stakedSolPool.stakeWithdrawalFee.numerator.isZero()) {
195
+ const numerator = poolTokens.mul(stakedSolPool.stakeWithdrawalFee.denominator);
196
+ const denominator = stakedSolPool.stakeWithdrawalFee.denominator.sub(stakedSolPool.stakeWithdrawalFee.numerator);
197
+ if (denominator.isZero()) {
198
+ // If the pool has 100% fee for some reason just fail it, we cannot compute the inverse
199
+ throw new Error('Pool fee cannot be 100%');
200
+ }
201
+ poolTokens = numerator.div(denominator);
202
+ }
203
+ return poolTokens;
204
+ }
205
+ // Below functions/types are not exported from spl-stake-pool
206
+ /**
207
+ * Generates the withdraw authority program address for the stake pool
208
+ */
209
+ async function findWithdrawAuthorityProgramAddress(programId, stakePoolAddress) {
210
+ const [publicKey] = await web3_js_1.PublicKey.findProgramAddress([stakePoolAddress.toBuffer(), Buffer.from('withdraw')], programId);
211
+ return publicKey;
212
+ }
213
+ async function findStakeProgramAddress(programId, voteAccountAddress, stakedSolPoolPk, seed) {
214
+ const [publicKey] = await web3_js_1.PublicKey.findProgramAddress([
215
+ voteAccountAddress.toBuffer(),
216
+ stakedSolPoolPk.toBuffer(),
217
+ seed ? new bn_js_1.default(seed).toArrayLike(Buffer, 'le', 4) : Buffer.alloc(0),
218
+ ], programId);
219
+ return publicKey;
220
+ }
221
+ async function findTransientStakeProgramAddress(programId, voteAccountAddress, stakePoolAddress, seed) {
222
+ const [publicKey] = await web3_js_1.PublicKey.findProgramAddress([
223
+ exports.TRANSIENT_STAKE_SEED_PREFIX,
224
+ voteAccountAddress.toBuffer(),
225
+ stakePoolAddress.toBuffer(),
226
+ seed.toArrayLike(Buffer, 'le', 8),
227
+ ], programId);
228
+ return publicKey;
229
+ }
230
+ function calcPoolTokensForDeposit(stakePool, stakeLamports) {
231
+ if (stakePool.poolTokenSupply.isZero() || stakePool.totalLamports.isZero()) {
232
+ return stakeLamports;
233
+ }
234
+ const numerator = stakeLamports.mul(stakePool.poolTokenSupply);
235
+ return numerator.div(stakePool.totalLamports);
236
+ }
237
+ function calcLamportsWithdrawAmount(stakePool, poolTokens) {
238
+ const numerator = poolTokens.mul(stakePool.totalLamports);
239
+ const denominator = stakePool.poolTokenSupply;
240
+ if (numerator.lt(denominator)) {
241
+ return new bn_js_1.default(0);
242
+ }
243
+ return numerator.div(denominator);
244
+ }
245
+ exports.StakeAccountType = (0, superstruct_1.enums)(['uninitialized', 'initialized', 'delegated', 'rewardsPool']);
246
+ exports.StakeMeta = (0, superstruct_1.type)({
247
+ rentExemptReserve: exports.BigNumFromString,
248
+ authorized: (0, superstruct_1.type)({
249
+ staker: exports.PublicKeyFromString,
250
+ withdrawer: exports.PublicKeyFromString,
251
+ }),
252
+ lockup: (0, superstruct_1.type)({
253
+ unixTimestamp: (0, superstruct_1.number)(),
254
+ epoch: (0, superstruct_1.number)(),
255
+ custodian: exports.PublicKeyFromString,
256
+ }),
257
+ });
258
+ exports.StakeAccountInfo = (0, superstruct_1.type)({
259
+ meta: exports.StakeMeta,
260
+ stake: (0, superstruct_1.nullable)((0, superstruct_1.type)({
261
+ delegation: (0, superstruct_1.type)({
262
+ voter: exports.PublicKeyFromString,
263
+ stake: exports.BigNumFromString,
264
+ activationEpoch: exports.BigNumFromString,
265
+ deactivationEpoch: exports.BigNumFromString,
266
+ warmupCooldownRate: (0, superstruct_1.number)(),
267
+ }),
268
+ creditsObserved: (0, superstruct_1.number)(),
269
+ })),
270
+ });
271
+ exports.StakeAccount = (0, superstruct_1.type)({
272
+ type: exports.StakeAccountType,
273
+ info: exports.StakeAccountInfo,
274
+ });
275
+ //# sourceMappingURL=standardStakePool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardStakePool.js","sourceRoot":"","sources":["../../src/classes/standardStakePool.ts"],"names":[],"mappings":";;;;;;AAcA,oDAMC;AAED,4CAMC;AAED,4DAeC;AAED,oFA+BC;AAuFD,sDAyDC;AAoCD,kFASC;AAED,0DAeC;AAED,4EAgBC;AAUD,gEAOC;AA/TD,2DAAmG;AACnG,2DAAoE;AACpE,6CAA8E;AAC9E,mDAAqE;AACrE,kDAAuB;AACvB,oDAA4B;AAC5B,6CAAmE;AAEtD,QAAA,2BAA2B,GA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actionInstruction } from '@solana/web3.js';
1
+ import { Keypair, TransactionInstruction } from '@solana/web3.js';
2
2
  import Decimal from 'decimal.js/decimal';
3
3
  /** the populateLUTIxs should be executed in a separate transaction as we cannot create and populate a lookup table in the same tx */
4
4
  export type InitVaultIxs = {
@@ -45,4 +45,16 @@ export type ReserveAllocationOverview = {
45
45
  tokenAllocationCap: Decimal;
46
46
  ctokenAllocation: Decimal;
47
47
  };
48
+ export type InitPoolIxs = {
49
+ initPoolIxs: TransactionInstruction[];
50
+ populateLUTIxs: TransactionInstruction[];
51
+ };
52
+ export type UpdatePoolConfigIxs = {
53
+ updatePoolConfigIx: TransactionInstruction;
54
+ updateLUTIxs: TransactionInstruction[];
55
+ };
56
+ export type MintIxs = {
57
+ mintIx: TransactionInstruction;
58
+ additionalSigners: Keypair[];
59
+ };
48
60
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/classes/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,qIAAqI;AACrI,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,sBAAsB,EAAE,CAAC;IACvC,WAAW,EAAE,sBAAsB,CAAC;IACpC,cAAc,EAAE,sBAAsB,EAAE,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,YAAY,EAAE,sBAAsB,CAAC;IACrC,YAAY,EAAE,sBAAsB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,yBAAyB,EAAE,sBAAsB,CAAC;IAClD,YAAY,EAAE,sBAAsB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,mBAAmB,EAAE,sBAAsB,CAAC;IAC5C,YAA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MAAM,EAAE,sBAAsB,CAAC;IAC/B,iBAAiB,EAAE,OAAO,EAAE,CAAC;CAC9B,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { Connection, Keypair, PublicKey, TransactionInstruction } from '@solana/web3.js';
2
+ import { PoolState } from '../idl_codegen_unstaking_pool/accounts';
3
+ import { InitPoolIxs, MintIxs, SyncVaultLUTIxs, UpdatePoolConfigIxs } from './types';
4
+ import { PoolConfigFieldKind } from '../idl_codegen_unstaking_pool/types';
5
+ import BN from 'bn.js';
6
+ import { StakeAccount } from './standardStakePool';
7
+ export declare const unstakingPoolId: PublicKey;
8
+ export declare const unstakingPoolStagingId: PublicKey;
9
+ export declare const STAKE_PROGRAM_ID: PublicKey;
10
+ export declare const CLOCK_PROGRAM_ID: PublicKey;
11
+ /**
12
+ * KaminoPoolClient is a class that provides a high-level interface to interact with the Kamino Pool program.
13
+ */
14
+ export declare class UnstakingPoolClient {
15
+ private readonly _connection;
16
+ private readonly _unstakingPoolProgramId;
17
+ constructor(connection: Connection, unstakingPoolprogramId?: PublicKey);
18
+ getConnection(): Connection;
19
+ getProgramID(): PublicKey;
20
+ /**
21
+ * This method will create a pool with a given config. The config can be changed later on, but it is recommended to set it up correctly from the start
22
+ * @param poolConfig - the config object used to create a pool
23
+ * @returns pool - keypair, should be used to sign the transaction which creates the pool account
24
+ * @returns pool: the keypair of the pool, used to sign the initialization transaction; initPoolIxs: a struct with ixs to initialize the pool and its lookup table + populateLUTIxs, a list to populate the lookup table which has to be executed in a separate transaction
25
+ */
26
+ createPoolIxs(poolConfig: UnstakingPoolConfig): Promise<{
27
+ pool: Keypair;
28
+ initPoolIxs: InitPoolIxs;
29
+ }>;
30
+ /**
31
+ * Update pool configuration such as admin authority (or fees/minimum depositable in the future)
32
+ * @param poolState - the pool to update and set the LUT for if needed or only the pool pubkey if updating LUT is not needed
33
+ * @param admin - admin of the specified pool
34
+ * @param mode - what field to update for pool
35
+ * @param value - new value that is converted .toString()
36
+ * @returns a struct that contains a list of ix to update the pool config + a list of ixs to insert all new accounts in the LUT
37
+ */
38
+ updatePoolConfigIxs(poolState: UnstakingPool | PublicKey, admin: PublicKey, mode: PoolConfigFieldKind, value: string): Promise<UpdatePoolConfigIxs>;
39
+ /**
40
+ * Collect a stake account SOL if the needed epoch was reached
41
+ * @param poolState - the pool to collect SOL into
42
+ * @param payer - payer for the operation (ix is permissionless)
43
+ * @param stakeAccount - stake account that was deactivated this epoch and has base pool authority as owner
44
+ * @returns collect instruction
45
+ */
46
+ collectIx(poolState: UnstakingPool, payer: PublicKey, stakeAccount: PublicKey): Promise<TransactionInstruction>;
47
+ /**
48
+ * Burn a number of shares (USOL) in exchange for SOL
49
+ * @param poolState - the pool to burn USOL from
50
+ * @param user - user that burns (ix is not gated by action authority)
51
+ * @param sharesToBurn - number of shares that are equivalent 1:1 with SOL
52
+ * @returns burn instruction
53
+ */
54
+ burnIx(poolState: UnstakingPool, user: PublicKey, sharesToBurn: BN): Promise<TransactionInstruction>;
55
+ /**
56
+ * Mints a number of unstaking sol (USOL) in exchange for staked SOL
57
+ * NOTE: this ix is permissioned by action authority
58
+ * @param poolState - the pool to mint USOL from
59
+ * @param user - user that mints
60
+ * @param stakedSolMint - staked sol mint
61
+ * @param stakedSolToDeposit - staked sol to convert to USOL (at the pool ratio)
62
+ * @returns burn instruction
63
+ */
64
+ mintIx(poolState: UnstakingPool, user: PublicKey, stakedSolMint: PublicKey, stakedSolToDeposit: BN): Promise<MintIxs>;
65
+ /**
66
+ * Sync a pool for lookup table; create and set the LUT for the pool if needed and fill it with all the needed accounts
67
+ * @param pool the pool to sync and set the LUT for if needed
68
+ * @param poolReserves optional; the state of the reserves in the pool allocation
69
+ * @returns a struct that contains a list of ix to create the LUT and assign it to the pool if needed + a list of ixs to insert all the accounts in the LUT
70
+ */
71
+ syncPoolLookupTable(pool: UnstakingPool): Promise<SyncVaultLUTIxs>;
72
+ getInitLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey];
73
+ insertIntoLookupTableIxs(payer: PublicKey, lookupTable: PublicKey, keys: PublicKey[], accountsInLUT?: PublicKey[]): Promise<TransactionInstruction[]>;
74
+ /**
75
+ *
76
+ * @param connection
77
+ * @param lookupTable
78
+ * @returns
79
+ */
80
+ getAccountsInLUT(lookupTable: PublicKey): Promise<PublicKey[]>;
81
+ deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction;
82
+ closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction;
83
+ /**
84
+ * Get all pools
85
+ * @returns an array of all pools
86
+ */
87
+ getAllPools(): Promise<UnstakingPool[]>;
88
+ }
89
+ export declare class UnstakingPool {
90
+ readonly address: PublicKey;
91
+ state: PoolState | undefined | null;
92
+ programId: PublicKey;
93
+ constructor(poolAddress: PublicKey, state?: PoolState, programId?: PublicKey);
94
+ getState(connection: Connection): Promise<PoolState>;
95
+ reloadState(connection: Connection): Promise<PoolState>;
96
+ getStakeAccountsForPool(connection: Connection): Promise<Array<[StakeAccount, PublicKey]>>;
97
+ }
98
+ /**
99
+ * Used to initialize a Kamino Pool
100
+ */
101
+ export declare class UnstakingPoolConfig {
102
+ /** The admin of the pool */
103
+ readonly admin: PublicKey;
104
+ /** Pubkey that can mint new tokens */
105
+ readonly actionAuthority: PublicKey | null;
106
+ constructor(args: {
107
+ admin: PublicKey;
108
+ actionAuthority: PublicKey | null;
109
+ });
110
+ }
111
+ //# sourceMappingURL=unstakingPool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unstakingPool.d.ts","sourceRoot":"","sources":["../../src/classes/unstakingPool.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,OAAO,EACP,SAAS,EAKT,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAkBzB,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,SAAS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