@kamino-finance/klend-sdk 5.10.27 → 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.
- 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 +255 -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,163 @@
|
|
|
1
|
+
import { PublicKey, Connection } from '@solana/web3.js';
|
|
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 PoolStateFields {
|
|
8
|
+
admin: PublicKey;
|
|
9
|
+
basePoolAuthority: PublicKey;
|
|
10
|
+
basePoolAuthorityBump: BN;
|
|
11
|
+
unstakingSolMint: PublicKey;
|
|
12
|
+
wsolVault: PublicKey;
|
|
13
|
+
actionAuthority: PublicKey;
|
|
14
|
+
poolLookupTable: PublicKey;
|
|
15
|
+
sharesIssued: BN;
|
|
16
|
+
wsolInVault: BN;
|
|
17
|
+
padding0: BN;
|
|
18
|
+
padding: Array<BN>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PoolStateJSON {
|
|
22
|
+
admin: string;
|
|
23
|
+
basePoolAuthority: string;
|
|
24
|
+
basePoolAuthorityBump: string;
|
|
25
|
+
unstakingSolMint: string;
|
|
26
|
+
wsolVault: string;
|
|
27
|
+
actionAuthority: string;
|
|
28
|
+
poolLookupTable: string;
|
|
29
|
+
sharesIssued: string;
|
|
30
|
+
wsolInVault: string;
|
|
31
|
+
padding0: string;
|
|
32
|
+
padding: Array<string>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class PoolState {
|
|
36
|
+
readonly admin: PublicKey;
|
|
37
|
+
readonly basePoolAuthority: PublicKey;
|
|
38
|
+
readonly basePoolAuthorityBump: BN;
|
|
39
|
+
readonly unstakingSolMint: PublicKey;
|
|
40
|
+
readonly wsolVault: PublicKey;
|
|
41
|
+
readonly actionAuthority: PublicKey;
|
|
42
|
+
readonly poolLookupTable: PublicKey;
|
|
43
|
+
readonly sharesIssued: BN;
|
|
44
|
+
readonly wsolInVault: BN;
|
|
45
|
+
readonly padding0: BN;
|
|
46
|
+
readonly padding: Array<BN>;
|
|
47
|
+
|
|
48
|
+
static readonly discriminator = Buffer.from([247, 237, 227, 245, 215, 195, 222, 70]);
|
|
49
|
+
|
|
50
|
+
static readonly layout = borsh.struct([
|
|
51
|
+
borsh.publicKey('admin'),
|
|
52
|
+
borsh.publicKey('basePoolAuthority'),
|
|
53
|
+
borsh.u64('basePoolAuthorityBump'),
|
|
54
|
+
borsh.publicKey('unstakingSolMint'),
|
|
55
|
+
borsh.publicKey('wsolVault'),
|
|
56
|
+
borsh.publicKey('actionAuthority'),
|
|
57
|
+
borsh.publicKey('poolLookupTable'),
|
|
58
|
+
borsh.u64('sharesIssued'),
|
|
59
|
+
borsh.u64('wsolInVault'),
|
|
60
|
+
borsh.u64('padding0'),
|
|
61
|
+
borsh.array(borsh.u128(), 256, 'padding'),
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
constructor(fields: PoolStateFields) {
|
|
65
|
+
this.admin = fields.admin;
|
|
66
|
+
this.basePoolAuthority = fields.basePoolAuthority;
|
|
67
|
+
this.basePoolAuthorityBump = fields.basePoolAuthorityBump;
|
|
68
|
+
this.unstakingSolMint = fields.unstakingSolMint;
|
|
69
|
+
this.wsolVault = fields.wsolVault;
|
|
70
|
+
this.actionAuthority = fields.actionAuthority;
|
|
71
|
+
this.poolLookupTable = fields.poolLookupTable;
|
|
72
|
+
this.sharesIssued = fields.sharesIssued;
|
|
73
|
+
this.wsolInVault = fields.wsolInVault;
|
|
74
|
+
this.padding0 = fields.padding0;
|
|
75
|
+
this.padding = fields.padding;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static async fetch(c: Connection, address: PublicKey, programId: PublicKey = PROGRAM_ID): Promise<PoolState | null> {
|
|
79
|
+
const info = await c.getAccountInfo(address);
|
|
80
|
+
|
|
81
|
+
if (info === null) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (!info.owner.equals(programId)) {
|
|
85
|
+
throw new Error("account doesn't belong to this program");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return this.decode(info.data);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static async fetchMultiple(
|
|
92
|
+
c: Connection,
|
|
93
|
+
addresses: PublicKey[],
|
|
94
|
+
programId: PublicKey = PROGRAM_ID
|
|
95
|
+
): Promise<Array<PoolState | null>> {
|
|
96
|
+
const infos = await c.getMultipleAccountsInfo(addresses);
|
|
97
|
+
|
|
98
|
+
return infos.map((info) => {
|
|
99
|
+
if (info === null) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
if (!info.owner.equals(programId)) {
|
|
103
|
+
throw new Error("account doesn't belong to this program");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return this.decode(info.data);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static decode(data: Buffer): PoolState {
|
|
111
|
+
if (!data.slice(0, 8).equals(PoolState.discriminator)) {
|
|
112
|
+
throw new Error('invalid account discriminator');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const dec = PoolState.layout.decode(data.slice(8));
|
|
116
|
+
|
|
117
|
+
return new PoolState({
|
|
118
|
+
admin: dec.admin,
|
|
119
|
+
basePoolAuthority: dec.basePoolAuthority,
|
|
120
|
+
basePoolAuthorityBump: dec.basePoolAuthorityBump,
|
|
121
|
+
unstakingSolMint: dec.unstakingSolMint,
|
|
122
|
+
wsolVault: dec.wsolVault,
|
|
123
|
+
actionAuthority: dec.actionAuthority,
|
|
124
|
+
poolLookupTable: dec.poolLookupTable,
|
|
125
|
+
sharesIssued: dec.sharesIssued,
|
|
126
|
+
wsolInVault: dec.wsolInVault,
|
|
127
|
+
padding0: dec.padding0,
|
|
128
|
+
padding: dec.padding,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
toJSON(): PoolStateJSON {
|
|
133
|
+
return {
|
|
134
|
+
admin: this.admin.toString(),
|
|
135
|
+
basePoolAuthority: this.basePoolAuthority.toString(),
|
|
136
|
+
basePoolAuthorityBump: this.basePoolAuthorityBump.toString(),
|
|
137
|
+
unstakingSolMint: this.unstakingSolMint.toString(),
|
|
138
|
+
wsolVault: this.wsolVault.toString(),
|
|
139
|
+
actionAuthority: this.actionAuthority.toString(),
|
|
140
|
+
poolLookupTable: this.poolLookupTable.toString(),
|
|
141
|
+
sharesIssued: this.sharesIssued.toString(),
|
|
142
|
+
wsolInVault: this.wsolInVault.toString(),
|
|
143
|
+
padding0: this.padding0.toString(),
|
|
144
|
+
padding: this.padding.map((item) => item.toString()),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static fromJSON(obj: PoolStateJSON): PoolState {
|
|
149
|
+
return new PoolState({
|
|
150
|
+
admin: new PublicKey(obj.admin),
|
|
151
|
+
basePoolAuthority: new PublicKey(obj.basePoolAuthority),
|
|
152
|
+
basePoolAuthorityBump: new BN(obj.basePoolAuthorityBump),
|
|
153
|
+
unstakingSolMint: new PublicKey(obj.unstakingSolMint),
|
|
154
|
+
wsolVault: new PublicKey(obj.wsolVault),
|
|
155
|
+
actionAuthority: new PublicKey(obj.actionAuthority),
|
|
156
|
+
poolLookupTable: new PublicKey(obj.poolLookupTable),
|
|
157
|
+
sharesIssued: new BN(obj.sharesIssued),
|
|
158
|
+
wsolInVault: new BN(obj.wsolInVault),
|
|
159
|
+
padding0: new BN(obj.padding0),
|
|
160
|
+
padding: obj.padding.map((item) => new BN(item)),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|