@kamino-finance/klend-sdk 5.10.28-beta.1 → 5.11.0-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/action.d.ts +22 -14
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +585 -132
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/index.d.ts +0 -3
- package/dist/classes/index.d.ts.map +1 -1
- package/dist/classes/index.js +0 -3
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/manager.js +1 -1
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +1 -6
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +2 -4
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/types.d.ts +1 -13
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/idl.json +71 -5
- package/dist/idl_codegen/accounts/Obligation.d.ts +6 -0
- package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.js +8 -1
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +35 -3
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +61 -5
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts +9 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +22 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +2 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +6 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +3 -2
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +7 -6
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +5 -0
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +4 -2
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/calcs.d.ts +1 -1
- package/dist/leverage/calcs.d.ts.map +1 -1
- package/dist/leverage/calcs.js +10 -12
- package/dist/leverage/calcs.js.map +1 -1
- package/dist/leverage/operations.d.ts +8 -8
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +27 -24
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +4 -1
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/utils/seeds.d.ts +5 -0
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +10 -1
- package/dist/utils/seeds.js.map +1 -1
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +6 -9
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +4 -4
- package/src/classes/action.ts +749 -146
- package/src/classes/index.ts +0 -3
- package/src/classes/manager.ts +1 -1
- package/src/classes/obligation.ts +4 -8
- package/src/classes/types.ts +1 -17
- package/src/client.ts +7 -3
- package/src/idl.json +71 -5
- package/src/idl_codegen/accounts/Obligation.ts +12 -1
- package/src/idl_codegen/errors/custom.ts +66 -4
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +31 -1
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +1 -1
- package/src/idl_codegen/zero_padding/ObligationZP.ts +6 -1
- package/src/lending_operations/repay_with_collateral_operations.ts +11 -3
- package/src/lending_operations/swap_collateral_operations.ts +11 -0
- package/src/leverage/calcs.ts +13 -16
- package/src/leverage/operations.ts +38 -11
- package/src/leverage/types.ts +4 -1
- package/src/utils/seeds.ts +13 -0
- package/src/utils/userMetadata.ts +19 -24
- package/dist/classes/stakePool.d.ts +0 -8
- package/dist/classes/stakePool.d.ts.map +0 -1
- package/dist/classes/stakePool.js +0 -18
- package/dist/classes/stakePool.js.map +0 -1
- package/dist/classes/standardStakePool.d.ts +0 -174
- package/dist/classes/standardStakePool.d.ts.map +0 -1
- package/dist/classes/standardStakePool.js +0 -275
- package/dist/classes/standardStakePool.js.map +0 -1
- package/dist/classes/unstakingPool.d.ts +0 -117
- package/dist/classes/unstakingPool.d.ts.map +0 -1
- package/dist/classes/unstakingPool.js +0 -448
- package/dist/classes/unstakingPool.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/accounts/PoolState.d.ts +0 -50
- package/dist/idl_codegen_unstaking_pool/accounts/PoolState.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/accounts/PoolState.js +0 -156
- package/dist/idl_codegen_unstaking_pool/accounts/PoolState.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/accounts/index.d.ts +0 -3
- package/dist/idl_codegen_unstaking_pool/accounts/index.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/accounts/index.js +0 -6
- package/dist/idl_codegen_unstaking_pool/accounts/index.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/errors/anchor.d.ts +0 -435
- package/dist/idl_codegen_unstaking_pool/errors/anchor.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/errors/anchor.js +0 -767
- package/dist/idl_codegen_unstaking_pool/errors/anchor.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/errors/custom.d.ts +0 -163
- package/dist/idl_codegen_unstaking_pool/errors/custom.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/errors/custom.js +0 -290
- package/dist/idl_codegen_unstaking_pool/errors/custom.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/errors/index.d.ts +0 -6
- package/dist/idl_codegen_unstaking_pool/errors/index.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/errors/index.js +0 -75
- package/dist/idl_codegen_unstaking_pool/errors/index.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/burn.d.ts +0 -21
- package/dist/idl_codegen_unstaking_pool/instructions/burn.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/burn.js +0 -73
- package/dist/idl_codegen_unstaking_pool/instructions/burn.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/collect.d.ts +0 -16
- package/dist/idl_codegen_unstaking_pool/instructions/collect.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/collect.js +0 -29
- package/dist/idl_codegen_unstaking_pool/instructions/collect.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/index.d.ts +0 -11
- package/dist/idl_codegen_unstaking_pool/instructions/index.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/index.js +0 -14
- package/dist/idl_codegen_unstaking_pool/instructions/index.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/initializePool.d.ts +0 -15
- package/dist/idl_codegen_unstaking_pool/instructions/initializePool.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/initializePool.js +0 -28
- package/dist/idl_codegen_unstaking_pool/instructions/initializePool.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/mint.d.ts +0 -21
- package/dist/idl_codegen_unstaking_pool/instructions/mint.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/mint.js +0 -77
- package/dist/idl_codegen_unstaking_pool/instructions/mint.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.d.ts +0 -13
- package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.js +0 -58
- package/dist/idl_codegen_unstaking_pool/instructions/updatePoolConfig.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/programId.d.ts +0 -4
- package/dist/idl_codegen_unstaking_pool/programId.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/programId.js +0 -9
- package/dist/idl_codegen_unstaking_pool/programId.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.d.ts +0 -32
- package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.js +0 -105
- package/dist/idl_codegen_unstaking_pool/types/PoolConfigField.js.map +0 -1
- package/dist/idl_codegen_unstaking_pool/types/index.d.ts +0 -5
- package/dist/idl_codegen_unstaking_pool/types/index.d.ts.map +0 -1
- package/dist/idl_codegen_unstaking_pool/types/index.js +0 -39
- package/dist/idl_codegen_unstaking_pool/types/index.js.map +0 -1
- package/src/classes/stakePool.ts +0 -21
- package/src/classes/standardStakePool.ts +0 -358
- package/src/classes/unstakingPool.ts +0 -577
- package/src/idl_codegen_unstaking_pool/accounts/PoolState.ts +0 -163
- package/src/idl_codegen_unstaking_pool/accounts/index.ts +0 -2
- package/src/idl_codegen_unstaking_pool/errors/anchor.ts +0 -764
- package/src/idl_codegen_unstaking_pool/errors/custom.ts +0 -288
- package/src/idl_codegen_unstaking_pool/errors/index.ts +0 -49
- package/src/idl_codegen_unstaking_pool/instructions/burn.ts +0 -60
- package/src/idl_codegen_unstaking_pool/instructions/collect.ts +0 -43
- package/src/idl_codegen_unstaking_pool/instructions/index.ts +0 -10
- package/src/idl_codegen_unstaking_pool/instructions/initializePool.ts +0 -41
- package/src/idl_codegen_unstaking_pool/instructions/mint.ts +0 -64
- package/src/idl_codegen_unstaking_pool/instructions/updatePoolConfig.ts +0 -40
- package/src/idl_codegen_unstaking_pool/programId.ts +0 -7
- package/src/idl_codegen_unstaking_pool/types/PoolConfigField.ts +0 -85
- package/src/idl_codegen_unstaking_pool/types/index.ts +0 -6
- package/src/idl_unstaking_pool.json +0 -456
|
@@ -1,163 +0,0 @@
|
|
|
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
|
-
}
|