@kamino-finance/klend-sdk 7.1.0 → 7.1.2

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 (154) hide show
  1. package/dist/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +1 -1
  2. package/dist/@codegen/unstaking_pool/accounts/PoolState.d.ts +53 -0
  3. package/dist/@codegen/unstaking_pool/accounts/PoolState.d.ts.map +1 -0
  4. package/dist/@codegen/unstaking_pool/accounts/PoolState.js +167 -0
  5. package/dist/@codegen/unstaking_pool/accounts/PoolState.js.map +1 -0
  6. package/dist/@codegen/unstaking_pool/accounts/UnstakeTicket.d.ts +41 -0
  7. package/dist/@codegen/unstaking_pool/accounts/UnstakeTicket.d.ts.map +1 -0
  8. package/dist/@codegen/unstaking_pool/accounts/UnstakeTicket.js +143 -0
  9. package/dist/@codegen/unstaking_pool/accounts/UnstakeTicket.js.map +1 -0
  10. package/dist/@codegen/unstaking_pool/accounts/index.d.ts +5 -0
  11. package/dist/@codegen/unstaking_pool/accounts/index.d.ts.map +1 -0
  12. package/dist/@codegen/unstaking_pool/accounts/index.js +8 -0
  13. package/dist/@codegen/unstaking_pool/accounts/index.js.map +1 -0
  14. package/dist/@codegen/unstaking_pool/errors/anchor.d.ts +435 -0
  15. package/dist/@codegen/unstaking_pool/errors/anchor.d.ts.map +1 -0
  16. package/dist/@codegen/unstaking_pool/errors/anchor.js +767 -0
  17. package/dist/@codegen/unstaking_pool/errors/anchor.js.map +1 -0
  18. package/dist/@codegen/unstaking_pool/errors/custom.d.ts +259 -0
  19. package/dist/@codegen/unstaking_pool/errors/custom.d.ts.map +1 -0
  20. package/dist/@codegen/unstaking_pool/errors/custom.js +458 -0
  21. package/dist/@codegen/unstaking_pool/errors/custom.js.map +1 -0
  22. package/dist/@codegen/unstaking_pool/errors/index.d.ts +6 -0
  23. package/dist/@codegen/unstaking_pool/errors/index.d.ts.map +1 -0
  24. package/dist/@codegen/unstaking_pool/errors/index.js +86 -0
  25. package/dist/@codegen/unstaking_pool/errors/index.js.map +1 -0
  26. package/dist/@codegen/unstaking_pool/instructions/burn.d.ts +21 -0
  27. package/dist/@codegen/unstaking_pool/instructions/burn.d.ts.map +1 -0
  28. package/dist/@codegen/unstaking_pool/instructions/burn.js +67 -0
  29. package/dist/@codegen/unstaking_pool/instructions/burn.js.map +1 -0
  30. package/dist/@codegen/unstaking_pool/instructions/changeTicketAuthority.d.ts +8 -0
  31. package/dist/@codegen/unstaking_pool/instructions/changeTicketAuthority.d.ts.map +1 -0
  32. package/dist/@codegen/unstaking_pool/instructions/changeTicketAuthority.js +16 -0
  33. package/dist/@codegen/unstaking_pool/instructions/changeTicketAuthority.js.map +1 -0
  34. package/dist/@codegen/unstaking_pool/instructions/collect.d.ts +16 -0
  35. package/dist/@codegen/unstaking_pool/instructions/collect.d.ts.map +1 -0
  36. package/dist/@codegen/unstaking_pool/instructions/collect.js +24 -0
  37. package/dist/@codegen/unstaking_pool/instructions/collect.js.map +1 -0
  38. package/dist/@codegen/unstaking_pool/instructions/index.d.ts +17 -0
  39. package/dist/@codegen/unstaking_pool/instructions/index.d.ts.map +1 -0
  40. package/dist/@codegen/unstaking_pool/instructions/index.js +20 -0
  41. package/dist/@codegen/unstaking_pool/instructions/index.js.map +1 -0
  42. package/dist/@codegen/unstaking_pool/instructions/initializePool.d.ts +14 -0
  43. package/dist/@codegen/unstaking_pool/instructions/initializePool.d.ts.map +1 -0
  44. package/dist/@codegen/unstaking_pool/instructions/initializePool.js +22 -0
  45. package/dist/@codegen/unstaking_pool/instructions/initializePool.js.map +1 -0
  46. package/dist/@codegen/unstaking_pool/instructions/mint.d.ts +24 -0
  47. package/dist/@codegen/unstaking_pool/instructions/mint.d.ts.map +1 -0
  48. package/dist/@codegen/unstaking_pool/instructions/mint.js +74 -0
  49. package/dist/@codegen/unstaking_pool/instructions/mint.js.map +1 -0
  50. package/dist/@codegen/unstaking_pool/instructions/splitTicket.d.ts +15 -0
  51. package/dist/@codegen/unstaking_pool/instructions/splitTicket.d.ts.map +1 -0
  52. package/dist/@codegen/unstaking_pool/instructions/splitTicket.js +62 -0
  53. package/dist/@codegen/unstaking_pool/instructions/splitTicket.js.map +1 -0
  54. package/dist/@codegen/unstaking_pool/instructions/updateAdmin.d.ts +7 -0
  55. package/dist/@codegen/unstaking_pool/instructions/updateAdmin.d.ts.map +1 -0
  56. package/dist/@codegen/unstaking_pool/instructions/updateAdmin.js +19 -0
  57. package/dist/@codegen/unstaking_pool/instructions/updateAdmin.js.map +1 -0
  58. package/dist/@codegen/unstaking_pool/instructions/updatePoolConfig.d.ts +13 -0
  59. package/dist/@codegen/unstaking_pool/instructions/updatePoolConfig.d.ts.map +1 -0
  60. package/dist/@codegen/unstaking_pool/instructions/updatePoolConfig.js +60 -0
  61. package/dist/@codegen/unstaking_pool/instructions/updatePoolConfig.js.map +1 -0
  62. package/dist/@codegen/unstaking_pool/programId.d.ts +4 -0
  63. package/dist/@codegen/unstaking_pool/programId.d.ts.map +1 -0
  64. package/dist/@codegen/unstaking_pool/programId.js +9 -0
  65. package/dist/@codegen/unstaking_pool/programId.js.map +1 -0
  66. package/dist/@codegen/unstaking_pool/types/PoolConfigField.d.ts +45 -0
  67. package/dist/@codegen/unstaking_pool/types/PoolConfigField.d.ts.map +1 -0
  68. package/dist/@codegen/unstaking_pool/types/PoolConfigField.js +132 -0
  69. package/dist/@codegen/unstaking_pool/types/PoolConfigField.js.map +1 -0
  70. package/dist/@codegen/unstaking_pool/types/index.d.ts +5 -0
  71. package/dist/@codegen/unstaking_pool/types/index.d.ts.map +1 -0
  72. package/dist/@codegen/unstaking_pool/types/index.js +39 -0
  73. package/dist/@codegen/unstaking_pool/types/index.js.map +1 -0
  74. package/dist/@codegen/unstaking_pool/utils/borshAddress.d.ts +4 -0
  75. package/dist/@codegen/unstaking_pool/utils/borshAddress.d.ts.map +1 -0
  76. package/dist/@codegen/unstaking_pool/utils/borshAddress.js +30 -0
  77. package/dist/@codegen/unstaking_pool/utils/borshAddress.js.map +1 -0
  78. package/dist/@codegen/unstaking_pool/utils/index.d.ts +2 -0
  79. package/dist/@codegen/unstaking_pool/utils/index.d.ts.map +1 -0
  80. package/dist/@codegen/unstaking_pool/utils/index.js +18 -0
  81. package/dist/@codegen/unstaking_pool/utils/index.js.map +1 -0
  82. package/dist/classes/action.d.ts.map +1 -1
  83. package/dist/classes/action.js +5 -5
  84. package/dist/classes/action.js.map +1 -1
  85. package/dist/classes/index.d.ts +5 -0
  86. package/dist/classes/index.d.ts.map +1 -1
  87. package/dist/classes/index.js +5 -0
  88. package/dist/classes/index.js.map +1 -1
  89. package/dist/classes/manager.d.ts.map +1 -1
  90. package/dist/classes/manager.js +2 -3
  91. package/dist/classes/manager.js.map +1 -1
  92. package/dist/classes/stakePool.d.ts +8 -0
  93. package/dist/classes/stakePool.d.ts.map +1 -0
  94. package/dist/classes/stakePool.js +18 -0
  95. package/dist/classes/stakePool.js.map +1 -0
  96. package/dist/classes/standardStakePool.d.ts +76 -0
  97. package/dist/classes/standardStakePool.d.ts.map +1 -0
  98. package/dist/classes/standardStakePool.js +400 -0
  99. package/dist/classes/standardStakePool.js.map +1 -0
  100. package/dist/classes/unstakingPool.d.ts +115 -0
  101. package/dist/classes/unstakingPool.d.ts.map +1 -0
  102. package/dist/classes/unstakingPool.js +372 -0
  103. package/dist/classes/unstakingPool.js.map +1 -0
  104. package/dist/classes/unstakingPoolTypes.d.ts +10 -0
  105. package/dist/classes/unstakingPoolTypes.d.ts.map +1 -0
  106. package/dist/classes/unstakingPoolTypes.js +3 -0
  107. package/dist/classes/unstakingPoolTypes.js.map +1 -0
  108. package/dist/classes/vault.d.ts +0 -9
  109. package/dist/classes/vault.d.ts.map +1 -1
  110. package/dist/classes/vault.js +6 -41
  111. package/dist/classes/vault.js.map +1 -1
  112. package/dist/idl/klend.json +1 -1
  113. package/dist/lib.d.ts +1 -0
  114. package/dist/lib.d.ts.map +1 -1
  115. package/dist/lib.js +3 -1
  116. package/dist/lib.js.map +1 -1
  117. package/dist/utils/lookupTable.d.ts +9 -0
  118. package/dist/utils/lookupTable.d.ts.map +1 -1
  119. package/dist/utils/lookupTable.js +37 -0
  120. package/dist/utils/lookupTable.js.map +1 -1
  121. package/package.json +3 -1
  122. package/src/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +1 -1
  123. package/src/@codegen/unstaking_pool/accounts/PoolState.ts +188 -0
  124. package/src/@codegen/unstaking_pool/accounts/UnstakeTicket.ts +156 -0
  125. package/src/@codegen/unstaking_pool/accounts/index.ts +4 -0
  126. package/src/@codegen/unstaking_pool/errors/anchor.ts +773 -0
  127. package/src/@codegen/unstaking_pool/errors/custom.ts +477 -0
  128. package/src/@codegen/unstaking_pool/errors/index.ts +68 -0
  129. package/src/@codegen/unstaking_pool/instructions/burn.ts +70 -0
  130. package/src/@codegen/unstaking_pool/instructions/changeTicketAuthority.ts +37 -0
  131. package/src/@codegen/unstaking_pool/instructions/collect.ts +53 -0
  132. package/src/@codegen/unstaking_pool/instructions/index.ts +19 -0
  133. package/src/@codegen/unstaking_pool/instructions/initializePool.ts +49 -0
  134. package/src/@codegen/unstaking_pool/instructions/mint.ts +80 -0
  135. package/src/@codegen/unstaking_pool/instructions/splitTicket.ts +59 -0
  136. package/src/@codegen/unstaking_pool/instructions/updateAdmin.ts +39 -0
  137. package/src/@codegen/unstaking_pool/instructions/updatePoolConfig.ts +58 -0
  138. package/src/@codegen/unstaking_pool/programId.ts +9 -0
  139. package/src/@codegen/unstaking_pool/types/PoolConfigField.ts +121 -0
  140. package/src/@codegen/unstaking_pool/types/index.ts +12 -0
  141. package/src/@codegen/unstaking_pool/utils/borshAddress.ts +43 -0
  142. package/src/@codegen/unstaking_pool/utils/index.ts +1 -0
  143. package/src/classes/action.ts +10 -5
  144. package/src/classes/index.ts +5 -0
  145. package/src/classes/manager.ts +3 -4
  146. package/src/classes/stakePool.ts +21 -0
  147. package/src/classes/standardStakePool.ts +487 -0
  148. package/src/classes/unstakingPool.ts +504 -0
  149. package/src/classes/unstakingPoolTypes.ts +12 -0
  150. package/src/classes/vault.ts +43 -56
  151. package/src/idl/klend.json +2 -2
  152. package/src/idl/unstaking_pool.json +662 -0
  153. package/src/lib.ts +1 -0
  154. package/src/utils/lookupTable.ts +48 -0
@@ -0,0 +1,477 @@
1
+ export type CustomError =
2
+ | IntegerOverflow
3
+ | ConversionFailed
4
+ | StakePoolError
5
+ | InvalidStakePoolAccounts
6
+ | StakePoolDeserializeError
7
+ | InvalidStakePoolProgram
8
+ | InvalidStakePoolSize
9
+ | InvalidStakeAccountProgram
10
+ | InvalidStakeAccountSize
11
+ | InvalidStakeAccountCandidate
12
+ | UnexpectedSolToDestake
13
+ | UnexpectedSolToCollect
14
+ | InvalidStakedSolProgram
15
+ | CannotDepositZeroStakedSol
16
+ | CannotMintZeroShares
17
+ | CannotBurnZeroShares
18
+ | CannotCollectZeroSol
19
+ | NotEnoughWsol
20
+ | NotEnoughSharesIssued
21
+ | NotEnoughSharesInTicket
22
+ | NotEnoughStakedSolToDeposit
23
+ | PoolFeeCannotBe100Percent
24
+ | LessSharesThanExpected
25
+ | LessWsolThanExpected
26
+ | InvalidFeeAccount
27
+ | UnsupportedFeeAccountExtension
28
+ | CannotBurnBeforeTicketAllows
29
+ | WrongTicketAuthority
30
+ | InvalidPendingAdmin
31
+ | CollectingMoreThanUnstaking
32
+ | CannotSplitZeroShares
33
+ | WrongTicketPoolState
34
+
35
+ export class IntegerOverflow extends Error {
36
+ static readonly code = 8000
37
+ readonly code = 8000
38
+ readonly name = "IntegerOverflow"
39
+ readonly msg = "IntegerOverflow"
40
+
41
+ constructor(readonly logs?: string[]) {
42
+ super("8000: IntegerOverflow")
43
+ }
44
+ }
45
+
46
+ export class ConversionFailed extends Error {
47
+ static readonly code = 8001
48
+ readonly code = 8001
49
+ readonly name = "ConversionFailed"
50
+ readonly msg = "ConversionFailed"
51
+
52
+ constructor(readonly logs?: string[]) {
53
+ super("8001: ConversionFailed")
54
+ }
55
+ }
56
+
57
+ export class StakePoolError extends Error {
58
+ static readonly code = 8002
59
+ readonly code = 8002
60
+ readonly name = "StakePoolError"
61
+ readonly msg = "Stake pool specific error"
62
+
63
+ constructor(readonly logs?: string[]) {
64
+ super("8002: Stake pool specific error")
65
+ }
66
+ }
67
+
68
+ export class InvalidStakePoolAccounts extends Error {
69
+ static readonly code = 8003
70
+ readonly code = 8003
71
+ readonly name = "InvalidStakePoolAccounts"
72
+ readonly msg = "Passed stake pool accounts are not valid"
73
+
74
+ constructor(readonly logs?: string[]) {
75
+ super("8003: Passed stake pool accounts are not valid")
76
+ }
77
+ }
78
+
79
+ export class StakePoolDeserializeError extends Error {
80
+ static readonly code = 8004
81
+ readonly code = 8004
82
+ readonly name = "StakePoolDeserializeError"
83
+ readonly msg = "Stake pool deserialization error"
84
+
85
+ constructor(readonly logs?: string[]) {
86
+ super("8004: Stake pool deserialization error")
87
+ }
88
+ }
89
+
90
+ export class InvalidStakePoolProgram extends Error {
91
+ static readonly code = 8005
92
+ readonly code = 8005
93
+ readonly name = "InvalidStakePoolProgram"
94
+ readonly msg = "Stake pool invalid program"
95
+
96
+ constructor(readonly logs?: string[]) {
97
+ super("8005: Stake pool invalid program")
98
+ }
99
+ }
100
+
101
+ export class InvalidStakePoolSize extends Error {
102
+ static readonly code = 8006
103
+ readonly code = 8006
104
+ readonly name = "InvalidStakePoolSize"
105
+ readonly msg = "Stake pool invalid size"
106
+
107
+ constructor(readonly logs?: string[]) {
108
+ super("8006: Stake pool invalid size")
109
+ }
110
+ }
111
+
112
+ export class InvalidStakeAccountProgram extends Error {
113
+ static readonly code = 8007
114
+ readonly code = 8007
115
+ readonly name = "InvalidStakeAccountProgram"
116
+ readonly msg = "Stake account invalid program"
117
+
118
+ constructor(readonly logs?: string[]) {
119
+ super("8007: Stake account invalid program")
120
+ }
121
+ }
122
+
123
+ export class InvalidStakeAccountSize extends Error {
124
+ static readonly code = 8008
125
+ readonly code = 8008
126
+ readonly name = "InvalidStakeAccountSize"
127
+ readonly msg = "Stake account invalid size"
128
+
129
+ constructor(readonly logs?: string[]) {
130
+ super("8008: Stake account invalid size")
131
+ }
132
+ }
133
+
134
+ export class InvalidStakeAccountCandidate extends Error {
135
+ static readonly code = 8009
136
+ readonly code = 8009
137
+ readonly name = "InvalidStakeAccountCandidate"
138
+ readonly msg = "Stake account candidates should be uninitialized accounts"
139
+
140
+ constructor(readonly logs?: string[]) {
141
+ super("8009: Stake account candidates should be uninitialized accounts")
142
+ }
143
+ }
144
+
145
+ export class UnexpectedSolToDestake extends Error {
146
+ static readonly code = 8010
147
+ readonly code = 8010
148
+ readonly name = "UnexpectedSolToDestake"
149
+ readonly msg =
150
+ "Simulation and actual cpi call have different results for withdrawing sol from stake pool"
151
+
152
+ constructor(readonly logs?: string[]) {
153
+ super(
154
+ "8010: Simulation and actual cpi call have different results for withdrawing sol from stake pool"
155
+ )
156
+ }
157
+ }
158
+
159
+ export class UnexpectedSolToCollect extends Error {
160
+ static readonly code = 8011
161
+ readonly code = 8011
162
+ readonly name = "UnexpectedSolToCollect"
163
+ readonly msg =
164
+ "Simulation and actual cpi call have different results for collecting sol from stake account"
165
+
166
+ constructor(readonly logs?: string[]) {
167
+ super(
168
+ "8011: Simulation and actual cpi call have different results for collecting sol from stake account"
169
+ )
170
+ }
171
+ }
172
+
173
+ export class InvalidStakedSolProgram extends Error {
174
+ static readonly code = 8012
175
+ readonly code = 8012
176
+ readonly name = "InvalidStakedSolProgram"
177
+ readonly msg = "Staked sol program not support"
178
+
179
+ constructor(readonly logs?: string[]) {
180
+ super("8012: Staked sol program not support")
181
+ }
182
+ }
183
+
184
+ export class CannotDepositZeroStakedSol extends Error {
185
+ static readonly code = 8013
186
+ readonly code = 8013
187
+ readonly name = "CannotDepositZeroStakedSol"
188
+ readonly msg = "Cannot deposit 0 staked sol"
189
+
190
+ constructor(readonly logs?: string[]) {
191
+ super("8013: Cannot deposit 0 staked sol")
192
+ }
193
+ }
194
+
195
+ export class CannotMintZeroShares extends Error {
196
+ static readonly code = 8014
197
+ readonly code = 8014
198
+ readonly name = "CannotMintZeroShares"
199
+ readonly msg = "Cannot mint 0 shares"
200
+
201
+ constructor(readonly logs?: string[]) {
202
+ super("8014: Cannot mint 0 shares")
203
+ }
204
+ }
205
+
206
+ export class CannotBurnZeroShares extends Error {
207
+ static readonly code = 8015
208
+ readonly code = 8015
209
+ readonly name = "CannotBurnZeroShares"
210
+ readonly msg = "Cannot burn 0 shares"
211
+
212
+ constructor(readonly logs?: string[]) {
213
+ super("8015: Cannot burn 0 shares")
214
+ }
215
+ }
216
+
217
+ export class CannotCollectZeroSol extends Error {
218
+ static readonly code = 8016
219
+ readonly code = 8016
220
+ readonly name = "CannotCollectZeroSol"
221
+ readonly msg = "Cannot collect 0"
222
+
223
+ constructor(readonly logs?: string[]) {
224
+ super("8016: Cannot collect 0")
225
+ }
226
+ }
227
+
228
+ export class NotEnoughWsol extends Error {
229
+ static readonly code = 8017
230
+ readonly code = 8017
231
+ readonly name = "NotEnoughWsol"
232
+ readonly msg = "Not enough wsol in vault"
233
+
234
+ constructor(readonly logs?: string[]) {
235
+ super("8017: Not enough wsol in vault")
236
+ }
237
+ }
238
+
239
+ export class NotEnoughSharesIssued extends Error {
240
+ static readonly code = 8018
241
+ readonly code = 8018
242
+ readonly name = "NotEnoughSharesIssued"
243
+ readonly msg = "Not enough shares issued"
244
+
245
+ constructor(readonly logs?: string[]) {
246
+ super("8018: Not enough shares issued")
247
+ }
248
+ }
249
+
250
+ export class NotEnoughSharesInTicket extends Error {
251
+ static readonly code = 8019
252
+ readonly code = 8019
253
+ readonly name = "NotEnoughSharesInTicket"
254
+ readonly msg = "Not enough shares left for ticket"
255
+
256
+ constructor(readonly logs?: string[]) {
257
+ super("8019: Not enough shares left for ticket")
258
+ }
259
+ }
260
+
261
+ export class NotEnoughStakedSolToDeposit extends Error {
262
+ static readonly code = 8020
263
+ readonly code = 8020
264
+ readonly name = "NotEnoughStakedSolToDeposit"
265
+ readonly msg =
266
+ "Not enough staked sol to deposit (must be at least equivalent to minimum pool delegation)"
267
+
268
+ constructor(readonly logs?: string[]) {
269
+ super(
270
+ "8020: Not enough staked sol to deposit (must be at least equivalent to minimum pool delegation)"
271
+ )
272
+ }
273
+ }
274
+
275
+ export class PoolFeeCannotBe100Percent extends Error {
276
+ static readonly code = 8021
277
+ readonly code = 8021
278
+ readonly name = "PoolFeeCannotBe100Percent"
279
+ readonly msg = "We cannot compute the inverse with fee when value is 100%"
280
+
281
+ constructor(readonly logs?: string[]) {
282
+ super("8021: We cannot compute the inverse with fee when value is 100%")
283
+ }
284
+ }
285
+
286
+ export class LessSharesThanExpected extends Error {
287
+ static readonly code = 8022
288
+ readonly code = 8022
289
+ readonly name = "LessSharesThanExpected"
290
+ readonly msg = "Received less shares than minimum expected"
291
+
292
+ constructor(readonly logs?: string[]) {
293
+ super("8022: Received less shares than minimum expected")
294
+ }
295
+ }
296
+
297
+ export class LessWsolThanExpected extends Error {
298
+ static readonly code = 8023
299
+ readonly code = 8023
300
+ readonly name = "LessWsolThanExpected"
301
+ readonly msg = "Received less wsol than minimum expected"
302
+
303
+ constructor(readonly logs?: string[]) {
304
+ super("8023: Received less wsol than minimum expected")
305
+ }
306
+ }
307
+
308
+ export class InvalidFeeAccount extends Error {
309
+ static readonly code = 8024
310
+ readonly code = 8024
311
+ readonly name = "InvalidFeeAccount"
312
+ readonly msg =
313
+ "Manager fee account passed is not valid (wrong token program / account not initialized / wrong mint)"
314
+
315
+ constructor(readonly logs?: string[]) {
316
+ super(
317
+ "8024: Manager fee account passed is not valid (wrong token program / account not initialized / wrong mint)"
318
+ )
319
+ }
320
+ }
321
+
322
+ export class UnsupportedFeeAccountExtension extends Error {
323
+ static readonly code = 8025
324
+ readonly code = 8025
325
+ readonly name = "UnsupportedFeeAccountExtension"
326
+ readonly msg =
327
+ "Manager fee account passed has unsupported extensions by standard stake pool"
328
+
329
+ constructor(readonly logs?: string[]) {
330
+ super(
331
+ "8025: Manager fee account passed has unsupported extensions by standard stake pool"
332
+ )
333
+ }
334
+ }
335
+
336
+ export class CannotBurnBeforeTicketAllows extends Error {
337
+ static readonly code = 8026
338
+ readonly code = 8026
339
+ readonly name = "CannotBurnBeforeTicketAllows"
340
+ readonly msg = "Cannot burn shares before unstake ticket allows"
341
+
342
+ constructor(readonly logs?: string[]) {
343
+ super("8026: Cannot burn shares before unstake ticket allows")
344
+ }
345
+ }
346
+
347
+ export class WrongTicketAuthority extends Error {
348
+ static readonly code = 8027
349
+ readonly code = 8027
350
+ readonly name = "WrongTicketAuthority"
351
+ readonly msg =
352
+ "Cannot burn shares from a ticket if user is not the burn authority"
353
+
354
+ constructor(readonly logs?: string[]) {
355
+ super(
356
+ "8027: Cannot burn shares from a ticket if user is not the burn authority"
357
+ )
358
+ }
359
+ }
360
+
361
+ export class InvalidPendingAdmin extends Error {
362
+ static readonly code = 8028
363
+ readonly code = 8028
364
+ readonly name = "InvalidPendingAdmin"
365
+ readonly msg = "Invalid pending admin"
366
+
367
+ constructor(readonly logs?: string[]) {
368
+ super("8028: Invalid pending admin")
369
+ }
370
+ }
371
+
372
+ export class CollectingMoreThanUnstaking extends Error {
373
+ static readonly code = 8029
374
+ readonly code = 8029
375
+ readonly name = "CollectingMoreThanUnstaking"
376
+ readonly msg = "We are trying to collect more SOL than there is unstaking"
377
+
378
+ constructor(readonly logs?: string[]) {
379
+ super("8029: We are trying to collect more SOL than there is unstaking")
380
+ }
381
+ }
382
+
383
+ export class CannotSplitZeroShares extends Error {
384
+ static readonly code = 8030
385
+ readonly code = 8030
386
+ readonly name = "CannotSplitZeroShares"
387
+ readonly msg = "Cannot split 0 shares"
388
+
389
+ constructor(readonly logs?: string[]) {
390
+ super("8030: Cannot split 0 shares")
391
+ }
392
+ }
393
+
394
+ export class WrongTicketPoolState extends Error {
395
+ static readonly code = 8031
396
+ readonly code = 8031
397
+ readonly name = "WrongTicketPoolState"
398
+ readonly msg =
399
+ "Cannot burn shares from a ticket if it's not linked to the pool"
400
+
401
+ constructor(readonly logs?: string[]) {
402
+ super(
403
+ "8031: Cannot burn shares from a ticket if it's not linked to the pool"
404
+ )
405
+ }
406
+ }
407
+
408
+ export function fromCode(code: number, logs?: string[]): CustomError | null {
409
+ switch (code) {
410
+ case 8000:
411
+ return new IntegerOverflow(logs)
412
+ case 8001:
413
+ return new ConversionFailed(logs)
414
+ case 8002:
415
+ return new StakePoolError(logs)
416
+ case 8003:
417
+ return new InvalidStakePoolAccounts(logs)
418
+ case 8004:
419
+ return new StakePoolDeserializeError(logs)
420
+ case 8005:
421
+ return new InvalidStakePoolProgram(logs)
422
+ case 8006:
423
+ return new InvalidStakePoolSize(logs)
424
+ case 8007:
425
+ return new InvalidStakeAccountProgram(logs)
426
+ case 8008:
427
+ return new InvalidStakeAccountSize(logs)
428
+ case 8009:
429
+ return new InvalidStakeAccountCandidate(logs)
430
+ case 8010:
431
+ return new UnexpectedSolToDestake(logs)
432
+ case 8011:
433
+ return new UnexpectedSolToCollect(logs)
434
+ case 8012:
435
+ return new InvalidStakedSolProgram(logs)
436
+ case 8013:
437
+ return new CannotDepositZeroStakedSol(logs)
438
+ case 8014:
439
+ return new CannotMintZeroShares(logs)
440
+ case 8015:
441
+ return new CannotBurnZeroShares(logs)
442
+ case 8016:
443
+ return new CannotCollectZeroSol(logs)
444
+ case 8017:
445
+ return new NotEnoughWsol(logs)
446
+ case 8018:
447
+ return new NotEnoughSharesIssued(logs)
448
+ case 8019:
449
+ return new NotEnoughSharesInTicket(logs)
450
+ case 8020:
451
+ return new NotEnoughStakedSolToDeposit(logs)
452
+ case 8021:
453
+ return new PoolFeeCannotBe100Percent(logs)
454
+ case 8022:
455
+ return new LessSharesThanExpected(logs)
456
+ case 8023:
457
+ return new LessWsolThanExpected(logs)
458
+ case 8024:
459
+ return new InvalidFeeAccount(logs)
460
+ case 8025:
461
+ return new UnsupportedFeeAccountExtension(logs)
462
+ case 8026:
463
+ return new CannotBurnBeforeTicketAllows(logs)
464
+ case 8027:
465
+ return new WrongTicketAuthority(logs)
466
+ case 8028:
467
+ return new InvalidPendingAdmin(logs)
468
+ case 8029:
469
+ return new CollectingMoreThanUnstaking(logs)
470
+ case 8030:
471
+ return new CannotSplitZeroShares(logs)
472
+ case 8031:
473
+ return new WrongTicketPoolState(logs)
474
+ }
475
+
476
+ return null
477
+ }
@@ -0,0 +1,68 @@
1
+ import { Address } from "@solana/kit"
2
+ import { PROGRAM_ID } from "../programId"
3
+ import * as anchor from "./anchor"
4
+ import * as custom from "./custom"
5
+
6
+ export function fromCode(
7
+ code: number,
8
+ logs?: string[]
9
+ ): custom.CustomError | anchor.AnchorError | null {
10
+ return code >= 6000
11
+ ? custom.fromCode(code, logs)
12
+ : anchor.fromCode(code, logs)
13
+ }
14
+
15
+ function hasOwnProperty<X extends object, Y extends PropertyKey>(
16
+ obj: X,
17
+ prop: Y
18
+ ): obj is X & Record<Y, unknown> {
19
+ return Object.hasOwnProperty.call(obj, prop)
20
+ }
21
+
22
+ const errorRe = /Program (\w+) failed: custom program error: (\w+)/
23
+
24
+ export function fromTxError(
25
+ err: unknown,
26
+ programId: Address = PROGRAM_ID
27
+ ): custom.CustomError | anchor.AnchorError | null {
28
+ if (
29
+ typeof err !== "object" ||
30
+ err === null ||
31
+ !hasOwnProperty(err, "context")
32
+ ) {
33
+ return null
34
+ }
35
+
36
+ const context = err.context as { code?: number; logs?: string[] }
37
+ if (hasOwnProperty(context, "code") && context.code) {
38
+ return fromCode(context.code, context.logs)
39
+ }
40
+ if (!hasOwnProperty(context, "logs") || !context.logs) {
41
+ return null
42
+ }
43
+ let firstMatch: RegExpExecArray | null = null
44
+ for (const logLine of context.logs) {
45
+ firstMatch = errorRe.exec(logLine)
46
+ if (firstMatch !== null) {
47
+ break
48
+ }
49
+ }
50
+
51
+ if (firstMatch === null) {
52
+ return null
53
+ }
54
+
55
+ const [programIdRaw, codeRaw] = firstMatch.slice(1)
56
+ if (programIdRaw !== programId.toString()) {
57
+ return null
58
+ }
59
+
60
+ let errorCode: number
61
+ try {
62
+ errorCode = parseInt(codeRaw, 16)
63
+ } catch (parseErr) {
64
+ return null
65
+ }
66
+
67
+ return fromCode(errorCode, context.logs)
68
+ }
@@ -0,0 +1,70 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Address,
4
+ isSome,
5
+ IAccountMeta,
6
+ IAccountSignerMeta,
7
+ IInstruction,
8
+ Option,
9
+ TransactionSigner,
10
+ } from "@solana/kit"
11
+ /* eslint-enable @typescript-eslint/no-unused-vars */
12
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ import { PROGRAM_ID } from "../programId"
17
+
18
+ export interface BurnArgs {
19
+ sharesToBurn: BN
20
+ minWsolToReceive: BN
21
+ }
22
+
23
+ export interface BurnAccounts {
24
+ user: TransactionSigner
25
+ userWsolToken: Address
26
+ userUnstakingSolToken: Address
27
+ wsolVault: Address
28
+ wsolMint: Address
29
+ poolState: Address
30
+ unstakeTicket: Address
31
+ unstakingSolMint: Address
32
+ basePoolAuthority: Address
33
+ tokenProgram: Address
34
+ }
35
+
36
+ export const layout = borsh.struct([
37
+ borsh.u64("sharesToBurn"),
38
+ borsh.u64("minWsolToReceive"),
39
+ ])
40
+
41
+ export function burn(
42
+ args: BurnArgs,
43
+ accounts: BurnAccounts,
44
+ programAddress: Address = PROGRAM_ID
45
+ ) {
46
+ const keys: Array<IAccountMeta | IAccountSignerMeta> = [
47
+ { address: accounts.user.address, role: 3, signer: accounts.user },
48
+ { address: accounts.userWsolToken, role: 1 },
49
+ { address: accounts.userUnstakingSolToken, role: 1 },
50
+ { address: accounts.wsolVault, role: 1 },
51
+ { address: accounts.wsolMint, role: 1 },
52
+ { address: accounts.poolState, role: 1 },
53
+ { address: accounts.unstakeTicket, role: 1 },
54
+ { address: accounts.unstakingSolMint, role: 1 },
55
+ { address: accounts.basePoolAuthority, role: 0 },
56
+ { address: accounts.tokenProgram, role: 0 },
57
+ ]
58
+ const identifier = Buffer.from([116, 110, 29, 56, 107, 219, 42, 93])
59
+ const buffer = Buffer.alloc(1000)
60
+ const len = layout.encode(
61
+ {
62
+ sharesToBurn: args.sharesToBurn,
63
+ minWsolToReceive: args.minWsolToReceive,
64
+ },
65
+ buffer
66
+ )
67
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
68
+ const ix: IInstruction = { accounts: keys, programAddress, data }
69
+ return ix
70
+ }
@@ -0,0 +1,37 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Address,
4
+ isSome,
5
+ IAccountMeta,
6
+ IAccountSignerMeta,
7
+ IInstruction,
8
+ Option,
9
+ TransactionSigner,
10
+ } from "@solana/kit"
11
+ /* eslint-enable @typescript-eslint/no-unused-vars */
12
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ import { PROGRAM_ID } from "../programId"
17
+
18
+ export interface ChangeTicketAuthorityAccounts {
19
+ user: TransactionSigner
20
+ newAuthority: Address
21
+ unstakeTicket: Address
22
+ }
23
+
24
+ export function changeTicketAuthority(
25
+ accounts: ChangeTicketAuthorityAccounts,
26
+ programAddress: Address = PROGRAM_ID
27
+ ) {
28
+ const keys: Array<IAccountMeta | IAccountSignerMeta> = [
29
+ { address: accounts.user.address, role: 2, signer: accounts.user },
30
+ { address: accounts.newAuthority, role: 0 },
31
+ { address: accounts.unstakeTicket, role: 1 },
32
+ ]
33
+ const identifier = Buffer.from([186, 77, 121, 131, 25, 104, 255, 108])
34
+ const data = identifier
35
+ const ix: IInstruction = { accounts: keys, programAddress, data }
36
+ return ix
37
+ }
@@ -0,0 +1,53 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Address,
4
+ isSome,
5
+ IAccountMeta,
6
+ IAccountSignerMeta,
7
+ IInstruction,
8
+ Option,
9
+ TransactionSigner,
10
+ } from "@solana/kit"
11
+ /* eslint-enable @typescript-eslint/no-unused-vars */
12
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ import { borshAddress } from "../utils" // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ import { PROGRAM_ID } from "../programId"
17
+
18
+ export interface CollectAccounts {
19
+ payer: TransactionSigner
20
+ stakeAccount: Address
21
+ poolState: Address
22
+ basePoolAuthority: Address
23
+ wsolVault: Address
24
+ wsolMint: Address
25
+ tokenProgram: Address
26
+ systemProgram: Address
27
+ clockProgramId: Address
28
+ stakeProgramId: Address
29
+ stakeHistoryProgramId: Address
30
+ }
31
+
32
+ export function collect(
33
+ accounts: CollectAccounts,
34
+ programAddress: Address = PROGRAM_ID
35
+ ) {
36
+ const keys: Array<IAccountMeta | IAccountSignerMeta> = [
37
+ { address: accounts.payer.address, role: 3, signer: accounts.payer },
38
+ { address: accounts.stakeAccount, role: 1 },
39
+ { address: accounts.poolState, role: 1 },
40
+ { address: accounts.basePoolAuthority, role: 1 },
41
+ { address: accounts.wsolVault, role: 1 },
42
+ { address: accounts.wsolMint, role: 0 },
43
+ { address: accounts.tokenProgram, role: 0 },
44
+ { address: accounts.systemProgram, role: 0 },
45
+ { address: accounts.clockProgramId, role: 0 },
46
+ { address: accounts.stakeProgramId, role: 0 },
47
+ { address: accounts.stakeHistoryProgramId, role: 0 },
48
+ ]
49
+ const identifier = Buffer.from([208, 47, 194, 155, 17, 98, 82, 236])
50
+ const data = identifier
51
+ const ix: IInstruction = { accounts: keys, programAddress, data }
52
+ return ix
53
+ }