@kamino-finance/klend-sdk 5.1.0 → 5.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 (39) hide show
  1. package/README_KAMINO_MANAGER.md +24 -3
  2. package/dist/classes/manager.d.ts +62 -2
  3. package/dist/classes/manager.d.ts.map +1 -1
  4. package/dist/classes/manager.js +76 -0
  5. package/dist/classes/manager.js.map +1 -1
  6. package/dist/classes/vault.d.ts +74 -5
  7. package/dist/classes/vault.d.ts.map +1 -1
  8. package/dist/classes/vault.js +134 -6
  9. package/dist/classes/vault.js.map +1 -1
  10. package/dist/client_kamino_manager.d.ts.map +1 -1
  11. package/dist/client_kamino_manager.js +6 -0
  12. package/dist/client_kamino_manager.js.map +1 -1
  13. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +9 -3
  14. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
  15. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +42 -32
  16. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
  17. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +10 -10
  18. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
  19. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +51 -52
  20. package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
  21. package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts +2 -2
  22. package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts.map +1 -1
  23. package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js +4 -4
  24. package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js.map +1 -1
  25. package/dist/lib.d.ts +3 -0
  26. package/dist/lib.d.ts.map +1 -1
  27. package/dist/lib.js +4 -0
  28. package/dist/lib.js.map +1 -1
  29. package/dist/utils/rpc.js +2 -2
  30. package/dist/utils/rpc.js.map +1 -1
  31. package/package.json +3 -2
  32. package/src/classes/manager.ts +110 -1
  33. package/src/classes/vault.ts +204 -7
  34. package/src/client_kamino_manager.ts +8 -0
  35. package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +178 -175
  36. package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +117 -116
  37. package/src/idl_codegen_kamino_vault/types/WithdrawalCaps.ts +30 -30
  38. package/src/lib.ts +6 -0
  39. package/src/utils/rpc.ts +2 -2
@@ -1,269 +1,270 @@
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';
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
5
 
6
6
  export interface PerformanceFeeBpsJSON {
7
- kind: 'PerformanceFeeBps';
7
+ kind: "PerformanceFeeBps"
8
8
  }
9
9
 
10
10
  export class PerformanceFeeBps {
11
- static readonly discriminator = 0;
12
- static readonly kind = 'PerformanceFeeBps';
13
- readonly discriminator = 0;
14
- readonly kind = 'PerformanceFeeBps';
11
+ static readonly discriminator = 0
12
+ static readonly kind = "PerformanceFeeBps"
13
+ readonly discriminator = 0
14
+ readonly kind = "PerformanceFeeBps"
15
15
 
16
16
  toJSON(): PerformanceFeeBpsJSON {
17
17
  return {
18
- kind: 'PerformanceFeeBps',
19
- };
18
+ kind: "PerformanceFeeBps",
19
+ }
20
20
  }
21
21
 
22
22
  toEncodable() {
23
23
  return {
24
24
  PerformanceFeeBps: {},
25
- };
25
+ }
26
26
  }
27
27
  }
28
28
 
29
29
  export interface ManagementFeeBpsJSON {
30
- kind: 'ManagementFeeBps';
30
+ kind: "ManagementFeeBps"
31
31
  }
32
32
 
33
33
  export class ManagementFeeBps {
34
- static readonly discriminator = 1;
35
- static readonly kind = 'ManagementFeeBps';
36
- readonly discriminator = 1;
37
- readonly kind = 'ManagementFeeBps';
34
+ static readonly discriminator = 1
35
+ static readonly kind = "ManagementFeeBps"
36
+ readonly discriminator = 1
37
+ readonly kind = "ManagementFeeBps"
38
38
 
39
39
  toJSON(): ManagementFeeBpsJSON {
40
40
  return {
41
- kind: 'ManagementFeeBps',
42
- };
41
+ kind: "ManagementFeeBps",
42
+ }
43
43
  }
44
44
 
45
45
  toEncodable() {
46
46
  return {
47
47
  ManagementFeeBps: {},
48
- };
48
+ }
49
49
  }
50
50
  }
51
51
 
52
52
  export interface MinDepositAmountJSON {
53
- kind: 'MinDepositAmount';
53
+ kind: "MinDepositAmount"
54
54
  }
55
55
 
56
56
  export class MinDepositAmount {
57
- static readonly discriminator = 2;
58
- static readonly kind = 'MinDepositAmount';
59
- readonly discriminator = 2;
60
- readonly kind = 'MinDepositAmount';
57
+ static readonly discriminator = 2
58
+ static readonly kind = "MinDepositAmount"
59
+ readonly discriminator = 2
60
+ readonly kind = "MinDepositAmount"
61
61
 
62
62
  toJSON(): MinDepositAmountJSON {
63
63
  return {
64
- kind: 'MinDepositAmount',
65
- };
64
+ kind: "MinDepositAmount",
65
+ }
66
66
  }
67
67
 
68
68
  toEncodable() {
69
69
  return {
70
70
  MinDepositAmount: {},
71
- };
71
+ }
72
72
  }
73
73
  }
74
74
 
75
75
  export interface MinWithdrawAmountJSON {
76
- kind: 'MinWithdrawAmount';
76
+ kind: "MinWithdrawAmount"
77
77
  }
78
78
 
79
79
  export class MinWithdrawAmount {
80
- static readonly discriminator = 3;
81
- static readonly kind = 'MinWithdrawAmount';
82
- readonly discriminator = 3;
83
- readonly kind = 'MinWithdrawAmount';
80
+ static readonly discriminator = 3
81
+ static readonly kind = "MinWithdrawAmount"
82
+ readonly discriminator = 3
83
+ readonly kind = "MinWithdrawAmount"
84
84
 
85
85
  toJSON(): MinWithdrawAmountJSON {
86
86
  return {
87
- kind: 'MinWithdrawAmount',
88
- };
87
+ kind: "MinWithdrawAmount",
88
+ }
89
89
  }
90
90
 
91
91
  toEncodable() {
92
92
  return {
93
93
  MinWithdrawAmount: {},
94
- };
94
+ }
95
95
  }
96
96
  }
97
97
 
98
98
  export interface MintInvestAmountJSON {
99
- kind: 'MintInvestAmount';
99
+ kind: "MintInvestAmount"
100
100
  }
101
101
 
102
102
  export class MintInvestAmount {
103
- static readonly discriminator = 4;
104
- static readonly kind = 'MintInvestAmount';
105
- readonly discriminator = 4;
106
- readonly kind = 'MintInvestAmount';
103
+ static readonly discriminator = 4
104
+ static readonly kind = "MintInvestAmount"
105
+ readonly discriminator = 4
106
+ readonly kind = "MintInvestAmount"
107
107
 
108
108
  toJSON(): MintInvestAmountJSON {
109
109
  return {
110
- kind: 'MintInvestAmount',
111
- };
110
+ kind: "MintInvestAmount",
111
+ }
112
112
  }
113
113
 
114
114
  toEncodable() {
115
115
  return {
116
116
  MintInvestAmount: {},
117
- };
117
+ }
118
118
  }
119
119
  }
120
120
 
121
121
  export interface MinInvestDelaySlotsJSON {
122
- kind: 'MinInvestDelaySlots';
122
+ kind: "MinInvestDelaySlots"
123
123
  }
124
124
 
125
125
  export class MinInvestDelaySlots {
126
- static readonly discriminator = 5;
127
- static readonly kind = 'MinInvestDelaySlots';
128
- readonly discriminator = 5;
129
- readonly kind = 'MinInvestDelaySlots';
126
+ static readonly discriminator = 5
127
+ static readonly kind = "MinInvestDelaySlots"
128
+ readonly discriminator = 5
129
+ readonly kind = "MinInvestDelaySlots"
130
130
 
131
131
  toJSON(): MinInvestDelaySlotsJSON {
132
132
  return {
133
- kind: 'MinInvestDelaySlots',
134
- };
133
+ kind: "MinInvestDelaySlots",
134
+ }
135
135
  }
136
136
 
137
137
  toEncodable() {
138
138
  return {
139
139
  MinInvestDelaySlots: {},
140
- };
140
+ }
141
141
  }
142
142
  }
143
143
 
144
144
  export interface CrankFundFeePerReserveJSON {
145
- kind: 'CrankFundFeePerReserve';
145
+ kind: "CrankFundFeePerReserve"
146
146
  }
147
147
 
148
148
  export class CrankFundFeePerReserve {
149
- static readonly discriminator = 6;
150
- static readonly kind = 'CrankFundFeePerReserve';
151
- readonly discriminator = 6;
152
- readonly kind = 'CrankFundFeePerReserve';
149
+ static readonly discriminator = 6
150
+ static readonly kind = "CrankFundFeePerReserve"
151
+ readonly discriminator = 6
152
+ readonly kind = "CrankFundFeePerReserve"
153
153
 
154
154
  toJSON(): CrankFundFeePerReserveJSON {
155
155
  return {
156
- kind: 'CrankFundFeePerReserve',
157
- };
156
+ kind: "CrankFundFeePerReserve",
157
+ }
158
158
  }
159
159
 
160
160
  toEncodable() {
161
161
  return {
162
162
  CrankFundFeePerReserve: {},
163
- };
163
+ }
164
164
  }
165
165
  }
166
166
 
167
167
  export interface PendingVaultAdminJSON {
168
- kind: 'PendingVaultAdmin';
168
+ kind: "PendingVaultAdmin"
169
169
  }
170
170
 
171
171
  export class PendingVaultAdmin {
172
- static readonly discriminator = 7;
173
- static readonly kind = 'PendingVaultAdmin';
174
- readonly discriminator = 7;
175
- readonly kind = 'PendingVaultAdmin';
172
+ static readonly discriminator = 7
173
+ static readonly kind = "PendingVaultAdmin"
174
+ readonly discriminator = 7
175
+ readonly kind = "PendingVaultAdmin"
176
176
 
177
177
  toJSON(): PendingVaultAdminJSON {
178
178
  return {
179
- kind: 'PendingVaultAdmin',
180
- };
179
+ kind: "PendingVaultAdmin",
180
+ }
181
181
  }
182
182
 
183
183
  toEncodable() {
184
184
  return {
185
185
  PendingVaultAdmin: {},
186
- };
186
+ }
187
187
  }
188
188
  }
189
189
 
190
190
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
191
191
  export function fromDecoded(obj: any): types.VaultConfigFieldKind {
192
- if (typeof obj !== 'object') {
193
- throw new Error('Invalid enum object');
192
+ if (typeof obj !== "object") {
193
+ throw new Error("Invalid enum object")
194
194
  }
195
195
 
196
- console.log('');
197
- if ('PerformanceFeeBps' in obj) {
198
- return new PerformanceFeeBps();
196
+ if ("PerformanceFeeBps" in obj) {
197
+ return new PerformanceFeeBps()
199
198
  }
200
- if ('ManagementFeeBps' in obj) {
201
- return new ManagementFeeBps();
199
+ if ("ManagementFeeBps" in obj) {
200
+ return new ManagementFeeBps()
202
201
  }
203
- if ('MinDepositAmount' in obj) {
204
- return new MinDepositAmount();
202
+ if ("MinDepositAmount" in obj) {
203
+ return new MinDepositAmount()
205
204
  }
206
- if ('MinWithdrawAmount' in obj) {
207
- return new MinWithdrawAmount();
205
+ if ("MinWithdrawAmount" in obj) {
206
+ return new MinWithdrawAmount()
208
207
  }
209
- if ('MintInvestAmount' in obj) {
210
- return new MintInvestAmount();
208
+ if ("MintInvestAmount" in obj) {
209
+ return new MintInvestAmount()
211
210
  }
212
- if ('MinInvestDelaySlots' in obj) {
213
- return new MinInvestDelaySlots();
211
+ if ("MinInvestDelaySlots" in obj) {
212
+ return new MinInvestDelaySlots()
214
213
  }
215
- if ('CrankFundFeePerReserve' in obj) {
216
- return new CrankFundFeePerReserve();
214
+ if ("CrankFundFeePerReserve" in obj) {
215
+ return new CrankFundFeePerReserve()
217
216
  }
218
- if ('PendingVaultAdmin' in obj) {
219
- return new PendingVaultAdmin();
217
+ if ("PendingVaultAdmin" in obj) {
218
+ return new PendingVaultAdmin()
220
219
  }
221
220
 
222
- throw new Error('Invalid enum object');
221
+ throw new Error("Invalid enum object")
223
222
  }
224
223
 
225
- export function fromJSON(obj: types.VaultConfigFieldJSON): types.VaultConfigFieldKind {
224
+ export function fromJSON(
225
+ obj: types.VaultConfigFieldJSON
226
+ ): types.VaultConfigFieldKind {
226
227
  switch (obj.kind) {
227
- case 'PerformanceFeeBps': {
228
- return new PerformanceFeeBps();
228
+ case "PerformanceFeeBps": {
229
+ return new PerformanceFeeBps()
229
230
  }
230
- case 'ManagementFeeBps': {
231
- return new ManagementFeeBps();
231
+ case "ManagementFeeBps": {
232
+ return new ManagementFeeBps()
232
233
  }
233
- case 'MinDepositAmount': {
234
- return new MinDepositAmount();
234
+ case "MinDepositAmount": {
235
+ return new MinDepositAmount()
235
236
  }
236
- case 'MinWithdrawAmount': {
237
- return new MinWithdrawAmount();
237
+ case "MinWithdrawAmount": {
238
+ return new MinWithdrawAmount()
238
239
  }
239
- case 'MintInvestAmount': {
240
- return new MintInvestAmount();
240
+ case "MintInvestAmount": {
241
+ return new MintInvestAmount()
241
242
  }
242
- case 'MinInvestDelaySlots': {
243
- return new MinInvestDelaySlots();
243
+ case "MinInvestDelaySlots": {
244
+ return new MinInvestDelaySlots()
244
245
  }
245
- case 'CrankFundFeePerReserve': {
246
- return new CrankFundFeePerReserve();
246
+ case "CrankFundFeePerReserve": {
247
+ return new CrankFundFeePerReserve()
247
248
  }
248
- case 'PendingVaultAdmin': {
249
- return new PendingVaultAdmin();
249
+ case "PendingVaultAdmin": {
250
+ return new PendingVaultAdmin()
250
251
  }
251
252
  }
252
253
  }
253
254
 
254
255
  export function layout(property?: string) {
255
256
  const ret = borsh.rustEnum([
256
- borsh.struct([], 'PerformanceFeeBps'),
257
- borsh.struct([], 'ManagementFeeBps'),
258
- borsh.struct([], 'MinDepositAmount'),
259
- borsh.struct([], 'MinWithdrawAmount'),
260
- borsh.struct([], 'MintInvestAmount'),
261
- borsh.struct([], 'MinInvestDelaySlots'),
262
- borsh.struct([], 'CrankFundFeePerReserve'),
263
- borsh.struct([], 'PendingVaultAdmin'),
264
- ]);
257
+ borsh.struct([], "PerformanceFeeBps"),
258
+ borsh.struct([], "ManagementFeeBps"),
259
+ borsh.struct([], "MinDepositAmount"),
260
+ borsh.struct([], "MinWithdrawAmount"),
261
+ borsh.struct([], "MintInvestAmount"),
262
+ borsh.struct([], "MinInvestDelaySlots"),
263
+ borsh.struct([], "CrankFundFeePerReserve"),
264
+ borsh.struct([], "PendingVaultAdmin"),
265
+ ])
265
266
  if (property !== undefined) {
266
- return ret.replicate(property);
267
+ return ret.replicate(property)
267
268
  }
268
- return ret;
269
+ return ret
269
270
  }
@@ -1,46 +1,46 @@
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';
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
5
 
6
6
  export interface WithdrawalCapsFields {
7
- configCapacity: BN;
8
- currentTotal: BN;
9
- lastIntervalStartTimestamp: BN;
10
- configIntervalLengthSeconds: BN;
7
+ configCapacity: BN
8
+ currentTotal: BN
9
+ lastIntervalStartTimestamp: BN
10
+ configIntervalLengthSeconds: BN
11
11
  }
12
12
 
13
13
  export interface WithdrawalCapsJSON {
14
- configCapacity: string;
15
- currentTotal: string;
16
- lastIntervalStartTimestamp: string;
17
- configIntervalLengthSeconds: string;
14
+ configCapacity: string
15
+ currentTotal: string
16
+ lastIntervalStartTimestamp: string
17
+ configIntervalLengthSeconds: string
18
18
  }
19
19
 
20
20
  /** Reserve Withdrawal Caps State */
21
21
  export class WithdrawalCaps {
22
- readonly configCapacity: BN;
23
- readonly currentTotal: BN;
24
- readonly lastIntervalStartTimestamp: BN;
25
- readonly configIntervalLengthSeconds: BN;
22
+ readonly configCapacity: BN
23
+ readonly currentTotal: BN
24
+ readonly lastIntervalStartTimestamp: BN
25
+ readonly configIntervalLengthSeconds: BN
26
26
 
27
27
  constructor(fields: WithdrawalCapsFields) {
28
- this.configCapacity = fields.configCapacity;
29
- this.currentTotal = fields.currentTotal;
30
- this.lastIntervalStartTimestamp = fields.lastIntervalStartTimestamp;
31
- this.configIntervalLengthSeconds = fields.configIntervalLengthSeconds;
28
+ this.configCapacity = fields.configCapacity
29
+ this.currentTotal = fields.currentTotal
30
+ this.lastIntervalStartTimestamp = fields.lastIntervalStartTimestamp
31
+ this.configIntervalLengthSeconds = fields.configIntervalLengthSeconds
32
32
  }
33
33
 
34
34
  static layout(property?: string) {
35
35
  return borsh.struct(
36
36
  [
37
- borsh.i64('configCapacity'),
38
- borsh.i64('currentTotal'),
39
- borsh.u64('lastIntervalStartTimestamp'),
40
- borsh.u64('configIntervalLengthSeconds'),
37
+ borsh.i64("configCapacity"),
38
+ borsh.i64("currentTotal"),
39
+ borsh.u64("lastIntervalStartTimestamp"),
40
+ borsh.u64("configIntervalLengthSeconds"),
41
41
  ],
42
42
  property
43
- );
43
+ )
44
44
  }
45
45
 
46
46
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -50,7 +50,7 @@ export class WithdrawalCaps {
50
50
  currentTotal: obj.currentTotal,
51
51
  lastIntervalStartTimestamp: obj.lastIntervalStartTimestamp,
52
52
  configIntervalLengthSeconds: obj.configIntervalLengthSeconds,
53
- });
53
+ })
54
54
  }
55
55
 
56
56
  static toEncodable(fields: WithdrawalCapsFields) {
@@ -59,7 +59,7 @@ export class WithdrawalCaps {
59
59
  currentTotal: fields.currentTotal,
60
60
  lastIntervalStartTimestamp: fields.lastIntervalStartTimestamp,
61
61
  configIntervalLengthSeconds: fields.configIntervalLengthSeconds,
62
- };
62
+ }
63
63
  }
64
64
 
65
65
  toJSON(): WithdrawalCapsJSON {
@@ -68,7 +68,7 @@ export class WithdrawalCaps {
68
68
  currentTotal: this.currentTotal.toString(),
69
69
  lastIntervalStartTimestamp: this.lastIntervalStartTimestamp.toString(),
70
70
  configIntervalLengthSeconds: this.configIntervalLengthSeconds.toString(),
71
- };
71
+ }
72
72
  }
73
73
 
74
74
  static fromJSON(obj: WithdrawalCapsJSON): WithdrawalCaps {
@@ -77,10 +77,10 @@ export class WithdrawalCaps {
77
77
  currentTotal: new BN(obj.currentTotal),
78
78
  lastIntervalStartTimestamp: new BN(obj.lastIntervalStartTimestamp),
79
79
  configIntervalLengthSeconds: new BN(obj.configIntervalLengthSeconds),
80
- });
80
+ })
81
81
  }
82
82
 
83
83
  toEncodable() {
84
- return WithdrawalCaps.toEncodable(this);
84
+ return WithdrawalCaps.toEncodable(this)
85
85
  }
86
86
  }
package/src/lib.ts CHANGED
@@ -2,6 +2,12 @@ export * from './idl_codegen/instructions';
2
2
  export * from './idl_codegen/accounts';
3
3
  export * from './idl_codegen/programId';
4
4
  export * from './idl_codegen/zero_padding';
5
+
6
+ export * from './idl_codegen_kamino_vault/instructions';
7
+ // only export vault state, do not export Reserve as it's the same one in main klend /idl_codegen/accounts
8
+ export * from './idl_codegen_kamino_vault/accounts/VaultState';
9
+ export * from './idl_codegen_kamino_vault/types';
10
+
5
11
  export * from './classes';
6
12
  export * from './utils';
7
13
  export * from './leverage';
package/src/utils/rpc.ts CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  import { Buffer } from 'buffer';
11
11
  import axios from 'axios';
12
12
  import { init, decompress } from '@bokuweb/zstd-wasm';
13
- import { randomUUID } from 'crypto';
13
+ import { v4 as uuidv4 } from 'uuid';
14
14
 
15
15
  (async () => {
16
16
  await init();
@@ -46,7 +46,7 @@ export async function getProgramAccounts(
46
46
  ...configWithoutEncoding,
47
47
  },
48
48
  ],
49
- id: randomUUID(),
49
+ id: uuidv4(),
50
50
  },
51
51
  {
52
52
  headers: {