@kamino-finance/klend-sdk 5.10.25 → 5.10.26-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.
- package/dist/classes/index.d.ts +3 -0
- package/dist/classes/index.d.ts.map +1 -1
- package/dist/classes/index.js +3 -0
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/stakePool.d.ts +8 -0
- package/dist/classes/stakePool.d.ts.map +1 -0
- package/dist/classes/stakePool.js +18 -0
- package/dist/classes/stakePool.js.map +1 -0
- package/dist/classes/standardStakePool.d.ts +254 -0
- package/dist/classes/standardStakePool.d.ts.map +1 -0
- package/dist/classes/standardStakePool.js +275 -0
- package/dist/classes/standardStakePool.js.map +1 -0
- package/dist/classes/types.d.ts +13 -1
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/unstakingPool.d.ts +111 -0
- package/dist/classes/unstakingPool.d.ts.map +1 -0
- package/dist/classes/unstakingPool.js +437 -0
- package/dist/classes/unstakingPool.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/accounts/PoolState.d.ts +50 -0
- package/dist/idl_codegen_unstaking_pool/accounts/PoolState.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/accounts/PoolState.js +156 -0
- package/dist/idl_codegen_unstaking_pool/accounts/PoolState.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/accounts/index.d.ts +3 -0
- package/dist/idl_codegen_unstaking_pool/accounts/index.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/accounts/index.js +6 -0
- package/dist/idl_codegen_unstaking_pool/accounts/index.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/errors/anchor.d.ts +435 -0
- package/dist/idl_codegen_unstaking_pool/errors/anchor.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/errors/anchor.js +767 -0
- package/dist/idl_codegen_unstaking_pool/errors/anchor.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/errors/custom.d.ts +163 -0
- package/dist/idl_codegen_unstaking_pool/errors/custom.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/errors/custom.js +290 -0
- package/dist/idl_codegen_unstaking_pool/errors/custom.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/errors/index.d.ts +6 -0
- package/dist/idl_codegen_unstaking_pool/errors/index.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/errors/index.js +75 -0
- package/dist/idl_codegen_unstaking_pool/errors/index.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/burn.d.ts +21 -0
- package/dist/idl_codegen_unstaking_pool/instructions/burn.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/burn.js +73 -0
- package/dist/idl_codegen_unstaking_pool/instructions/burn.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/collect.d.ts +16 -0
- package/dist/idl_codegen_unstaking_pool/instructions/collect.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/collect.js +29 -0
- package/dist/idl_codegen_unstaking_pool/instructions/collect.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/index.d.ts +11 -0
- package/dist/idl_codegen_unstaking_pool/instructions/index.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/index.js +14 -0
- package/dist/idl_codegen_unstaking_pool/instructions/index.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/initializePool.d.ts +15 -0
- package/dist/idl_codegen_unstaking_pool/instructions/initializePool.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/initializePool.js +28 -0
- package/dist/idl_codegen_unstaking_pool/instructions/initializePool.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/mint.d.ts +21 -0
- package/dist/idl_codegen_unstaking_pool/instructions/mint.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/mint.js +77 -0
- package/dist/idl_codegen_unstaking_pool/instructions/mint.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.d.ts +13 -0
- package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.js +58 -0
- package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/programId.d.ts +4 -0
- package/dist/idl_codegen_unstaking_pool/programId.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/programId.js +9 -0
- package/dist/idl_codegen_unstaking_pool/programId.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.d.ts +32 -0
- package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.js +105 -0
- package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.js.map +1 -0
- package/dist/idl_codegen_unstaking_pool/types/index.d.ts +5 -0
- package/dist/idl_codegen_unstaking_pool/types/index.d.ts.map +1 -0
- package/dist/idl_codegen_unstaking_pool/types/index.js +39 -0
- package/dist/idl_codegen_unstaking_pool/types/index.js.map +1 -0
- package/package.json +4 -1
- package/src/classes/index.ts +3 -0
- package/src/classes/stakePool.ts +21 -0
- package/src/classes/standardStakePool.ts +361 -0
- package/src/classes/types.ts +17 -1
- package/src/classes/unstakingPool.ts +565 -0
- package/src/idl_codegen_unstaking_pool/accounts/PoolState.ts +163 -0
- package/src/idl_codegen_unstaking_pool/accounts/index.ts +2 -0
- package/src/idl_codegen_unstaking_pool/errors/anchor.ts +764 -0
- package/src/idl_codegen_unstaking_pool/errors/custom.ts +288 -0
- package/src/idl_codegen_unstaking_pool/errors/index.ts +49 -0
- package/src/idl_codegen_unstaking_pool/instructions/burn.ts +60 -0
- package/src/idl_codegen_unstaking_pool/instructions/collect.ts +43 -0
- package/src/idl_codegen_unstaking_pool/instructions/index.ts +10 -0
- package/src/idl_codegen_unstaking_pool/instructions/initializePool.ts +41 -0
- package/src/idl_codegen_unstaking_pool/instructions/mint.ts +64 -0
- package/src/idl_codegen_unstaking_pool/instructions/updatePoolConfig.ts +40 -0
- package/src/idl_codegen_unstaking_pool/programId.ts +7 -0
- package/src/idl_codegen_unstaking_pool/types/PoolConfigField.ts +85 -0
- package/src/idl_codegen_unstaking_pool/types/index.ts +6 -0
- package/src/idl_unstaking_pool.json +456 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
export type CustomError =
|
|
2
|
+
| IntegerOverflow
|
|
3
|
+
| StakePoolError
|
|
4
|
+
| InvalidStakePoolAccounts
|
|
5
|
+
| StakePoolDeserializeError
|
|
6
|
+
| InvalidStakePoolProgram
|
|
7
|
+
| InvalidStakePoolSize
|
|
8
|
+
| InvalidStakeAccountProgram
|
|
9
|
+
| InvalidStakeAccountSize
|
|
10
|
+
| InvalidStakeAccountCandidate
|
|
11
|
+
| StakeAccountDeserializeError
|
|
12
|
+
| UnexpectedSolToDestake
|
|
13
|
+
| UnexpectedSolToCollect
|
|
14
|
+
| InvalidStakedSolProgram
|
|
15
|
+
| CannotDepositZeroStakedSol
|
|
16
|
+
| CannotMintZeroShares
|
|
17
|
+
| CannotBurnZeroShares
|
|
18
|
+
| CannotCollectZeroSol
|
|
19
|
+
| NotEnoughWsol
|
|
20
|
+
| NotEnoughSharesIssued
|
|
21
|
+
| NotEnoughStakedSolToDeposit;
|
|
22
|
+
|
|
23
|
+
export class IntegerOverflow extends Error {
|
|
24
|
+
static readonly code = 6000;
|
|
25
|
+
readonly code = 6000;
|
|
26
|
+
readonly name = 'IntegerOverflow';
|
|
27
|
+
readonly msg = 'IntegerOverflow';
|
|
28
|
+
|
|
29
|
+
constructor(readonly logs?: string[]) {
|
|
30
|
+
super('6000: IntegerOverflow');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class StakePoolError extends Error {
|
|
35
|
+
static readonly code = 6001;
|
|
36
|
+
readonly code = 6001;
|
|
37
|
+
readonly name = 'StakePoolError';
|
|
38
|
+
readonly msg = 'Stake pool specific error';
|
|
39
|
+
|
|
40
|
+
constructor(readonly logs?: string[]) {
|
|
41
|
+
super('6001: Stake pool specific error');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class InvalidStakePoolAccounts extends Error {
|
|
46
|
+
static readonly code = 6002;
|
|
47
|
+
readonly code = 6002;
|
|
48
|
+
readonly name = 'InvalidStakePoolAccounts';
|
|
49
|
+
readonly msg = 'Passed stake pool accounts are not valid';
|
|
50
|
+
|
|
51
|
+
constructor(readonly logs?: string[]) {
|
|
52
|
+
super('6002: Passed stake pool accounts are not valid');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class StakePoolDeserializeError extends Error {
|
|
57
|
+
static readonly code = 6003;
|
|
58
|
+
readonly code = 6003;
|
|
59
|
+
readonly name = 'StakePoolDeserializeError';
|
|
60
|
+
readonly msg = 'Stake pool deserialization error';
|
|
61
|
+
|
|
62
|
+
constructor(readonly logs?: string[]) {
|
|
63
|
+
super('6003: Stake pool deserialization error');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class InvalidStakePoolProgram extends Error {
|
|
68
|
+
static readonly code = 6004;
|
|
69
|
+
readonly code = 6004;
|
|
70
|
+
readonly name = 'InvalidStakePoolProgram';
|
|
71
|
+
readonly msg = 'Stake pool invalid program';
|
|
72
|
+
|
|
73
|
+
constructor(readonly logs?: string[]) {
|
|
74
|
+
super('6004: Stake pool invalid program');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class InvalidStakePoolSize extends Error {
|
|
79
|
+
static readonly code = 6005;
|
|
80
|
+
readonly code = 6005;
|
|
81
|
+
readonly name = 'InvalidStakePoolSize';
|
|
82
|
+
readonly msg = 'Stake pool invalid size';
|
|
83
|
+
|
|
84
|
+
constructor(readonly logs?: string[]) {
|
|
85
|
+
super('6005: Stake pool invalid size');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class InvalidStakeAccountProgram extends Error {
|
|
90
|
+
static readonly code = 6006;
|
|
91
|
+
readonly code = 6006;
|
|
92
|
+
readonly name = 'InvalidStakeAccountProgram';
|
|
93
|
+
readonly msg = 'Stake account invalid program';
|
|
94
|
+
|
|
95
|
+
constructor(readonly logs?: string[]) {
|
|
96
|
+
super('6006: Stake account invalid program');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class InvalidStakeAccountSize extends Error {
|
|
101
|
+
static readonly code = 6007;
|
|
102
|
+
readonly code = 6007;
|
|
103
|
+
readonly name = 'InvalidStakeAccountSize';
|
|
104
|
+
readonly msg = 'Stake account invalid size';
|
|
105
|
+
|
|
106
|
+
constructor(readonly logs?: string[]) {
|
|
107
|
+
super('6007: Stake account invalid size');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class InvalidStakeAccountCandidate extends Error {
|
|
112
|
+
static readonly code = 6008;
|
|
113
|
+
readonly code = 6008;
|
|
114
|
+
readonly name = 'InvalidStakeAccountCandidate';
|
|
115
|
+
readonly msg = 'Stake account candidates should be uninitialized accounts';
|
|
116
|
+
|
|
117
|
+
constructor(readonly logs?: string[]) {
|
|
118
|
+
super('6008: Stake account candidates should be uninitialized accounts');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class StakeAccountDeserializeError extends Error {
|
|
123
|
+
static readonly code = 6009;
|
|
124
|
+
readonly code = 6009;
|
|
125
|
+
readonly name = 'StakeAccountDeserializeError';
|
|
126
|
+
readonly msg = 'Stake account deserialization error';
|
|
127
|
+
|
|
128
|
+
constructor(readonly logs?: string[]) {
|
|
129
|
+
super('6009: Stake account deserialization error');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export class UnexpectedSolToDestake extends Error {
|
|
134
|
+
static readonly code = 6010;
|
|
135
|
+
readonly code = 6010;
|
|
136
|
+
readonly name = 'UnexpectedSolToDestake';
|
|
137
|
+
readonly msg = 'Simulation and actual cpi call have different results for withdrawing sol from stake pool';
|
|
138
|
+
|
|
139
|
+
constructor(readonly logs?: string[]) {
|
|
140
|
+
super('6010: Simulation and actual cpi call have different results for withdrawing sol from stake pool');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export class UnexpectedSolToCollect extends Error {
|
|
145
|
+
static readonly code = 6011;
|
|
146
|
+
readonly code = 6011;
|
|
147
|
+
readonly name = 'UnexpectedSolToCollect';
|
|
148
|
+
readonly msg = 'Simulation and actual cpi call have different results for collecting sol from stake account';
|
|
149
|
+
|
|
150
|
+
constructor(readonly logs?: string[]) {
|
|
151
|
+
super('6011: Simulation and actual cpi call have different results for collecting sol from stake account');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export class InvalidStakedSolProgram extends Error {
|
|
156
|
+
static readonly code = 6012;
|
|
157
|
+
readonly code = 6012;
|
|
158
|
+
readonly name = 'InvalidStakedSolProgram';
|
|
159
|
+
readonly msg = 'Staked sol program not support';
|
|
160
|
+
|
|
161
|
+
constructor(readonly logs?: string[]) {
|
|
162
|
+
super('6012: Staked sol program not support');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export class CannotDepositZeroStakedSol extends Error {
|
|
167
|
+
static readonly code = 6013;
|
|
168
|
+
readonly code = 6013;
|
|
169
|
+
readonly name = 'CannotDepositZeroStakedSol';
|
|
170
|
+
readonly msg = 'Cannot deposit 0 staked sol';
|
|
171
|
+
|
|
172
|
+
constructor(readonly logs?: string[]) {
|
|
173
|
+
super('6013: Cannot deposit 0 staked sol');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export class CannotMintZeroShares extends Error {
|
|
178
|
+
static readonly code = 6014;
|
|
179
|
+
readonly code = 6014;
|
|
180
|
+
readonly name = 'CannotMintZeroShares';
|
|
181
|
+
readonly msg = 'Cannot mint 0 shares';
|
|
182
|
+
|
|
183
|
+
constructor(readonly logs?: string[]) {
|
|
184
|
+
super('6014: Cannot mint 0 shares');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export class CannotBurnZeroShares extends Error {
|
|
189
|
+
static readonly code = 6015;
|
|
190
|
+
readonly code = 6015;
|
|
191
|
+
readonly name = 'CannotBurnZeroShares';
|
|
192
|
+
readonly msg = 'Cannot burn 0 shares';
|
|
193
|
+
|
|
194
|
+
constructor(readonly logs?: string[]) {
|
|
195
|
+
super('6015: Cannot burn 0 shares');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export class CannotCollectZeroSol extends Error {
|
|
200
|
+
static readonly code = 6016;
|
|
201
|
+
readonly code = 6016;
|
|
202
|
+
readonly name = 'CannotCollectZeroSol';
|
|
203
|
+
readonly msg = 'Cannot collect 0';
|
|
204
|
+
|
|
205
|
+
constructor(readonly logs?: string[]) {
|
|
206
|
+
super('6016: Cannot collect 0');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export class NotEnoughWsol extends Error {
|
|
211
|
+
static readonly code = 6017;
|
|
212
|
+
readonly code = 6017;
|
|
213
|
+
readonly name = 'NotEnoughWsol';
|
|
214
|
+
readonly msg = 'Not enough wsol in vault';
|
|
215
|
+
|
|
216
|
+
constructor(readonly logs?: string[]) {
|
|
217
|
+
super('6017: Not enough wsol in vault');
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export class NotEnoughSharesIssued extends Error {
|
|
222
|
+
static readonly code = 6018;
|
|
223
|
+
readonly code = 6018;
|
|
224
|
+
readonly name = 'NotEnoughSharesIssued';
|
|
225
|
+
readonly msg = 'Not enough shares issued';
|
|
226
|
+
|
|
227
|
+
constructor(readonly logs?: string[]) {
|
|
228
|
+
super('6018: Not enough shares issued');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export class NotEnoughStakedSolToDeposit extends Error {
|
|
233
|
+
static readonly code = 6019;
|
|
234
|
+
readonly code = 6019;
|
|
235
|
+
readonly name = 'NotEnoughStakedSolToDeposit';
|
|
236
|
+
readonly msg = 'Not enough staked sol to deposit (must be at least equivalent to minimum pool delegation)';
|
|
237
|
+
|
|
238
|
+
constructor(readonly logs?: string[]) {
|
|
239
|
+
super('6019: Not enough staked sol to deposit (must be at least equivalent to minimum pool delegation)');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
244
|
+
switch (code) {
|
|
245
|
+
case 6000:
|
|
246
|
+
return new IntegerOverflow(logs);
|
|
247
|
+
case 6001:
|
|
248
|
+
return new StakePoolError(logs);
|
|
249
|
+
case 6002:
|
|
250
|
+
return new InvalidStakePoolAccounts(logs);
|
|
251
|
+
case 6003:
|
|
252
|
+
return new StakePoolDeserializeError(logs);
|
|
253
|
+
case 6004:
|
|
254
|
+
return new InvalidStakePoolProgram(logs);
|
|
255
|
+
case 6005:
|
|
256
|
+
return new InvalidStakePoolSize(logs);
|
|
257
|
+
case 6006:
|
|
258
|
+
return new InvalidStakeAccountProgram(logs);
|
|
259
|
+
case 6007:
|
|
260
|
+
return new InvalidStakeAccountSize(logs);
|
|
261
|
+
case 6008:
|
|
262
|
+
return new InvalidStakeAccountCandidate(logs);
|
|
263
|
+
case 6009:
|
|
264
|
+
return new StakeAccountDeserializeError(logs);
|
|
265
|
+
case 6010:
|
|
266
|
+
return new UnexpectedSolToDestake(logs);
|
|
267
|
+
case 6011:
|
|
268
|
+
return new UnexpectedSolToCollect(logs);
|
|
269
|
+
case 6012:
|
|
270
|
+
return new InvalidStakedSolProgram(logs);
|
|
271
|
+
case 6013:
|
|
272
|
+
return new CannotDepositZeroStakedSol(logs);
|
|
273
|
+
case 6014:
|
|
274
|
+
return new CannotMintZeroShares(logs);
|
|
275
|
+
case 6015:
|
|
276
|
+
return new CannotBurnZeroShares(logs);
|
|
277
|
+
case 6016:
|
|
278
|
+
return new CannotCollectZeroSol(logs);
|
|
279
|
+
case 6017:
|
|
280
|
+
return new NotEnoughWsol(logs);
|
|
281
|
+
case 6018:
|
|
282
|
+
return new NotEnoughSharesIssued(logs);
|
|
283
|
+
case 6019:
|
|
284
|
+
return new NotEnoughStakedSolToDeposit(logs);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { PROGRAM_ID } from '../programId';
|
|
3
|
+
import * as anchor from './anchor';
|
|
4
|
+
import * as custom from './custom';
|
|
5
|
+
|
|
6
|
+
export function fromCode(code: number, logs?: string[]): custom.CustomError | anchor.AnchorError | null {
|
|
7
|
+
return code >= 6000 ? custom.fromCode(code, logs) : anchor.fromCode(code, logs);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function hasOwnProperty<X extends object, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {
|
|
11
|
+
return Object.hasOwnProperty.call(obj, prop);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const errorRe = /Program (\w+) failed: custom program error: (\w+)/;
|
|
15
|
+
|
|
16
|
+
export function fromTxError(
|
|
17
|
+
err: unknown,
|
|
18
|
+
programId: PublicKey = PROGRAM_ID
|
|
19
|
+
): custom.CustomError | anchor.AnchorError | null {
|
|
20
|
+
if (typeof err !== 'object' || err === null || !hasOwnProperty(err, 'logs') || !Array.isArray(err.logs)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let firstMatch: RegExpExecArray | null = null;
|
|
25
|
+
for (const logLine of err.logs) {
|
|
26
|
+
firstMatch = errorRe.exec(logLine);
|
|
27
|
+
if (firstMatch !== null) {
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (firstMatch === null) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const [programIdRaw, codeRaw] = firstMatch.slice(1);
|
|
37
|
+
if (programIdRaw !== programId.toString()) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let errorCode: number;
|
|
42
|
+
try {
|
|
43
|
+
errorCode = parseInt(codeRaw, 16);
|
|
44
|
+
} catch (parseErr) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return fromCode(errorCode, err.logs);
|
|
49
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from '../programId';
|
|
6
|
+
|
|
7
|
+
export interface BurnArgs {
|
|
8
|
+
sharesToBurn: BN;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface BurnAccounts {
|
|
12
|
+
user: PublicKey;
|
|
13
|
+
userWsolToken: PublicKey;
|
|
14
|
+
userUnstakingSolToken: PublicKey;
|
|
15
|
+
wsolVault: PublicKey;
|
|
16
|
+
wsolMint: PublicKey;
|
|
17
|
+
poolState: PublicKey;
|
|
18
|
+
unstakingSolMint: PublicKey;
|
|
19
|
+
basePoolAuthority: PublicKey;
|
|
20
|
+
systemProgram: PublicKey;
|
|
21
|
+
unstakingSolTokenProgram: PublicKey;
|
|
22
|
+
wsolTokenProgram: PublicKey;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const layout = borsh.struct([borsh.u64('sharesToBurn')]);
|
|
26
|
+
|
|
27
|
+
export function burn(args: BurnArgs, accounts: BurnAccounts, programId: PublicKey = PROGRAM_ID) {
|
|
28
|
+
const keys: Array<AccountMeta> = [
|
|
29
|
+
{ pubkey: accounts.user, isSigner: true, isWritable: false },
|
|
30
|
+
{ pubkey: accounts.userWsolToken, isSigner: false, isWritable: true },
|
|
31
|
+
{
|
|
32
|
+
pubkey: accounts.userUnstakingSolToken,
|
|
33
|
+
isSigner: false,
|
|
34
|
+
isWritable: true,
|
|
35
|
+
},
|
|
36
|
+
{ pubkey: accounts.wsolVault, isSigner: false, isWritable: true },
|
|
37
|
+
{ pubkey: accounts.wsolMint, isSigner: false, isWritable: true },
|
|
38
|
+
{ pubkey: accounts.poolState, isSigner: false, isWritable: true },
|
|
39
|
+
{ pubkey: accounts.unstakingSolMint, isSigner: false, isWritable: true },
|
|
40
|
+
{ pubkey: accounts.basePoolAuthority, isSigner: false, isWritable: true },
|
|
41
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
42
|
+
{
|
|
43
|
+
pubkey: accounts.unstakingSolTokenProgram,
|
|
44
|
+
isSigner: false,
|
|
45
|
+
isWritable: false,
|
|
46
|
+
},
|
|
47
|
+
{ pubkey: accounts.wsolTokenProgram, isSigner: false, isWritable: false },
|
|
48
|
+
];
|
|
49
|
+
const identifier = Buffer.from([116, 110, 29, 56, 107, 219, 42, 93]);
|
|
50
|
+
const buffer = Buffer.alloc(1000);
|
|
51
|
+
const len = layout.encode(
|
|
52
|
+
{
|
|
53
|
+
sharesToBurn: args.sharesToBurn,
|
|
54
|
+
},
|
|
55
|
+
buffer
|
|
56
|
+
);
|
|
57
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
58
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
59
|
+
return ix;
|
|
60
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from '../programId';
|
|
6
|
+
|
|
7
|
+
export interface CollectAccounts {
|
|
8
|
+
payer: PublicKey;
|
|
9
|
+
stakeAccount: PublicKey;
|
|
10
|
+
poolState: PublicKey;
|
|
11
|
+
basePoolAuthority: PublicKey;
|
|
12
|
+
wsolVault: PublicKey;
|
|
13
|
+
wsolMint: PublicKey;
|
|
14
|
+
tokenProgram: PublicKey;
|
|
15
|
+
systemProgram: PublicKey;
|
|
16
|
+
clockProgramId: PublicKey;
|
|
17
|
+
stakeProgramId: PublicKey;
|
|
18
|
+
stakeHistoryProgramId: PublicKey;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function collect(accounts: CollectAccounts, programId: PublicKey = PROGRAM_ID) {
|
|
22
|
+
const keys: Array<AccountMeta> = [
|
|
23
|
+
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
|
|
24
|
+
{ pubkey: accounts.stakeAccount, isSigner: false, isWritable: true },
|
|
25
|
+
{ pubkey: accounts.poolState, isSigner: false, isWritable: true },
|
|
26
|
+
{ pubkey: accounts.basePoolAuthority, isSigner: false, isWritable: true },
|
|
27
|
+
{ pubkey: accounts.wsolVault, isSigner: false, isWritable: true },
|
|
28
|
+
{ pubkey: accounts.wsolMint, isSigner: false, isWritable: false },
|
|
29
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
30
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
31
|
+
{ pubkey: accounts.clockProgramId, isSigner: false, isWritable: false },
|
|
32
|
+
{ pubkey: accounts.stakeProgramId, isSigner: false, isWritable: false },
|
|
33
|
+
{
|
|
34
|
+
pubkey: accounts.stakeHistoryProgramId,
|
|
35
|
+
isSigner: false,
|
|
36
|
+
isWritable: false,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
const identifier = Buffer.from([208, 47, 194, 155, 17, 98, 82, 236]);
|
|
40
|
+
const data = identifier;
|
|
41
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
42
|
+
return ix;
|
|
43
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { initializePool } from './initializePool';
|
|
2
|
+
export type { InitializePoolAccounts } from './initializePool';
|
|
3
|
+
export { mint } from './mint';
|
|
4
|
+
export type { MintArgs, MintAccounts } from './mint';
|
|
5
|
+
export { collect } from './collect';
|
|
6
|
+
export type { CollectAccounts } from './collect';
|
|
7
|
+
export { burn } from './burn';
|
|
8
|
+
export type { BurnArgs, BurnAccounts } from './burn';
|
|
9
|
+
export { updatePoolConfig } from './updatePoolConfig';
|
|
10
|
+
export type { UpdatePoolConfigArgs, UpdatePoolConfigAccounts } from './updatePoolConfig';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from '../programId';
|
|
6
|
+
|
|
7
|
+
export interface InitializePoolAccounts {
|
|
8
|
+
admin: PublicKey;
|
|
9
|
+
poolState: PublicKey;
|
|
10
|
+
unstakingSolMint: PublicKey;
|
|
11
|
+
wsolMint: PublicKey;
|
|
12
|
+
basePoolAuthority: PublicKey;
|
|
13
|
+
wsolVault: PublicKey;
|
|
14
|
+
systemProgram: PublicKey;
|
|
15
|
+
rent: PublicKey;
|
|
16
|
+
tokenProgram: PublicKey;
|
|
17
|
+
associatedTokenProgram: PublicKey;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function initializePool(accounts: InitializePoolAccounts, programId: PublicKey = PROGRAM_ID) {
|
|
21
|
+
const keys: Array<AccountMeta> = [
|
|
22
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
23
|
+
{ pubkey: accounts.poolState, isSigner: false, isWritable: true },
|
|
24
|
+
{ pubkey: accounts.unstakingSolMint, isSigner: false, isWritable: true },
|
|
25
|
+
{ pubkey: accounts.wsolMint, isSigner: false, isWritable: false },
|
|
26
|
+
{ pubkey: accounts.basePoolAuthority, isSigner: false, isWritable: false },
|
|
27
|
+
{ pubkey: accounts.wsolVault, isSigner: false, isWritable: true },
|
|
28
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
29
|
+
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
30
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
31
|
+
{
|
|
32
|
+
pubkey: accounts.associatedTokenProgram,
|
|
33
|
+
isSigner: false,
|
|
34
|
+
isWritable: false,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
const identifier = Buffer.from([95, 180, 10, 172, 84, 174, 232, 40]);
|
|
38
|
+
const data = identifier;
|
|
39
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
40
|
+
return ix;
|
|
41
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from '../programId';
|
|
6
|
+
|
|
7
|
+
export interface MintArgs {
|
|
8
|
+
stakedSolToDeposit: BN;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface MintAccounts {
|
|
12
|
+
user: PublicKey;
|
|
13
|
+
actionAuthority: PublicKey;
|
|
14
|
+
userStakedSolToken: PublicKey;
|
|
15
|
+
userUnstakingSolToken: PublicKey;
|
|
16
|
+
stakedSolMint: PublicKey;
|
|
17
|
+
poolState: PublicKey;
|
|
18
|
+
unstakingSolMint: PublicKey;
|
|
19
|
+
basePoolAuthority: PublicKey;
|
|
20
|
+
systemProgram: PublicKey;
|
|
21
|
+
unstakingSolTokenProgram: PublicKey;
|
|
22
|
+
stakedSolTokenProgram: PublicKey;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const layout = borsh.struct([borsh.u64('stakedSolToDeposit')]);
|
|
26
|
+
|
|
27
|
+
export function mint(args: MintArgs, accounts: MintAccounts, programId: PublicKey = PROGRAM_ID) {
|
|
28
|
+
const keys: Array<AccountMeta> = [
|
|
29
|
+
{ pubkey: accounts.user, isSigner: true, isWritable: true },
|
|
30
|
+
{ pubkey: accounts.actionAuthority, isSigner: true, isWritable: false },
|
|
31
|
+
{ pubkey: accounts.userStakedSolToken, isSigner: false, isWritable: true },
|
|
32
|
+
{
|
|
33
|
+
pubkey: accounts.userUnstakingSolToken,
|
|
34
|
+
isSigner: false,
|
|
35
|
+
isWritable: true,
|
|
36
|
+
},
|
|
37
|
+
{ pubkey: accounts.stakedSolMint, isSigner: false, isWritable: true },
|
|
38
|
+
{ pubkey: accounts.poolState, isSigner: false, isWritable: true },
|
|
39
|
+
{ pubkey: accounts.unstakingSolMint, isSigner: false, isWritable: true },
|
|
40
|
+
{ pubkey: accounts.basePoolAuthority, isSigner: false, isWritable: true },
|
|
41
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
42
|
+
{
|
|
43
|
+
pubkey: accounts.unstakingSolTokenProgram,
|
|
44
|
+
isSigner: false,
|
|
45
|
+
isWritable: false,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
pubkey: accounts.stakedSolTokenProgram,
|
|
49
|
+
isSigner: false,
|
|
50
|
+
isWritable: false,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
const identifier = Buffer.from([51, 57, 225, 47, 182, 146, 137, 166]);
|
|
54
|
+
const buffer = Buffer.alloc(1000);
|
|
55
|
+
const len = layout.encode(
|
|
56
|
+
{
|
|
57
|
+
stakedSolToDeposit: args.stakedSolToDeposit,
|
|
58
|
+
},
|
|
59
|
+
buffer
|
|
60
|
+
);
|
|
61
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
62
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
63
|
+
return ix;
|
|
64
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from '@coral-xyz/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from '../programId';
|
|
6
|
+
|
|
7
|
+
export interface UpdatePoolConfigArgs {
|
|
8
|
+
entry: types.PoolConfigFieldKind;
|
|
9
|
+
data: Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UpdatePoolConfigAccounts {
|
|
13
|
+
admin: PublicKey;
|
|
14
|
+
poolState: PublicKey;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const layout = borsh.struct([types.PoolConfigField.layout('entry'), borsh.vecU8('data')]);
|
|
18
|
+
|
|
19
|
+
export function updatePoolConfig(
|
|
20
|
+
args: UpdatePoolConfigArgs,
|
|
21
|
+
accounts: UpdatePoolConfigAccounts,
|
|
22
|
+
programId: PublicKey = PROGRAM_ID
|
|
23
|
+
) {
|
|
24
|
+
const keys: Array<AccountMeta> = [
|
|
25
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: false },
|
|
26
|
+
{ pubkey: accounts.poolState, isSigner: false, isWritable: true },
|
|
27
|
+
];
|
|
28
|
+
const identifier = Buffer.from([68, 236, 203, 122, 179, 62, 234, 252]);
|
|
29
|
+
const buffer = Buffer.alloc(1000);
|
|
30
|
+
const len = layout.encode(
|
|
31
|
+
{
|
|
32
|
+
entry: args.entry.toEncodable(),
|
|
33
|
+
data: Buffer.from(args.data.buffer, args.data.byteOffset, args.data.length),
|
|
34
|
+
},
|
|
35
|
+
buffer
|
|
36
|
+
);
|
|
37
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
38
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
39
|
+
return ix;
|
|
40
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
|
|
3
|
+
// Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten.
|
|
4
|
+
export const PROGRAM_ID_CLI = new PublicKey('USo1uB8RsRuM8y8e8vbL3mwR22EzSTLyZqaJPoZvn3a');
|
|
5
|
+
|
|
6
|
+
// This constant will not get overwritten on subsequent code generations and it's safe to modify it's value.
|
|
7
|
+
export const PROGRAM_ID: PublicKey = PROGRAM_ID_CLI;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from 'bn.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from '@coral-xyz/borsh';
|
|
5
|
+
|
|
6
|
+
export interface ActionAuthorityJSON {
|
|
7
|
+
kind: 'ActionAuthority';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class ActionAuthority {
|
|
11
|
+
static readonly discriminator = 0;
|
|
12
|
+
static readonly kind = 'ActionAuthority';
|
|
13
|
+
readonly discriminator = 0;
|
|
14
|
+
readonly kind = 'ActionAuthority';
|
|
15
|
+
|
|
16
|
+
toJSON(): ActionAuthorityJSON {
|
|
17
|
+
return {
|
|
18
|
+
kind: 'ActionAuthority',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toEncodable() {
|
|
23
|
+
return {
|
|
24
|
+
ActionAuthority: {},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface LookupTableJSON {
|
|
30
|
+
kind: 'LookupTable';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class LookupTable {
|
|
34
|
+
static readonly discriminator = 1;
|
|
35
|
+
static readonly kind = 'LookupTable';
|
|
36
|
+
readonly discriminator = 1;
|
|
37
|
+
readonly kind = 'LookupTable';
|
|
38
|
+
|
|
39
|
+
toJSON(): LookupTableJSON {
|
|
40
|
+
return {
|
|
41
|
+
kind: 'LookupTable',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
toEncodable() {
|
|
46
|
+
return {
|
|
47
|
+
LookupTable: {},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
export function fromDecoded(obj: any): types.PoolConfigFieldKind {
|
|
54
|
+
if (typeof obj !== 'object') {
|
|
55
|
+
throw new Error('Invalid enum object');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ('ActionAuthority' in obj) {
|
|
59
|
+
return new ActionAuthority();
|
|
60
|
+
}
|
|
61
|
+
if ('LookupTable' in obj) {
|
|
62
|
+
return new LookupTable();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
throw new Error('Invalid enum object');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function fromJSON(obj: types.PoolConfigFieldJSON): types.PoolConfigFieldKind {
|
|
69
|
+
switch (obj.kind) {
|
|
70
|
+
case 'ActionAuthority': {
|
|
71
|
+
return new ActionAuthority();
|
|
72
|
+
}
|
|
73
|
+
case 'LookupTable': {
|
|
74
|
+
return new LookupTable();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function layout(property?: string) {
|
|
80
|
+
const ret = borsh.rustEnum([borsh.struct([], 'ActionAuthority'), borsh.struct([], 'LookupTable')]);
|
|
81
|
+
if (property !== undefined) {
|
|
82
|
+
return ret.replicate(property);
|
|
83
|
+
}
|
|
84
|
+
return ret;
|
|
85
|
+
}
|