@kamino-finance/klend-sdk 5.3.0 → 5.4.1
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 +0 -3
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +7 -10
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +17 -5
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +25 -15
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +2 -2
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +52 -20
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/vault.d.ts +24 -4
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +54 -15
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +14 -1
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +6 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +13 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts +5 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js +8 -1
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js.map +1 -1
- package/dist/utils/constants.d.ts +4 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +5 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/rpc.d.ts +2 -1
- package/dist/utils/rpc.d.ts.map +1 -1
- package/dist/utils/rpc.js +8 -6
- package/dist/utils/rpc.js.map +1 -1
- package/package.json +9 -4
- package/src/classes/action.ts +1 -4
- package/src/classes/manager.ts +38 -13
- package/src/classes/market.ts +73 -21
- package/src/classes/vault.ts +86 -15
- package/src/client_kamino_manager.ts +21 -1
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +17 -1
- package/src/idl_codegen_kamino_vault/types/VaultAllocation.ts +10 -1
- package/src/utils/constants.ts +6 -0
- package/src/utils/rpc.ts +8 -5
|
@@ -9,6 +9,7 @@ export interface VaultAllocationFields {
|
|
|
9
9
|
targetAllocationWeight: BN
|
|
10
10
|
/** Maximum token invested in this reserve */
|
|
11
11
|
tokenAllocationCap: BN
|
|
12
|
+
ctokenVaultBump: BN
|
|
12
13
|
configPadding: Array<BN>
|
|
13
14
|
ctokenAllocation: BN
|
|
14
15
|
lastInvestSlot: BN
|
|
@@ -22,6 +23,7 @@ export interface VaultAllocationJSON {
|
|
|
22
23
|
targetAllocationWeight: string
|
|
23
24
|
/** Maximum token invested in this reserve */
|
|
24
25
|
tokenAllocationCap: string
|
|
26
|
+
ctokenVaultBump: string
|
|
25
27
|
configPadding: Array<string>
|
|
26
28
|
ctokenAllocation: string
|
|
27
29
|
lastInvestSlot: string
|
|
@@ -35,6 +37,7 @@ export class VaultAllocation {
|
|
|
35
37
|
readonly targetAllocationWeight: BN
|
|
36
38
|
/** Maximum token invested in this reserve */
|
|
37
39
|
readonly tokenAllocationCap: BN
|
|
40
|
+
readonly ctokenVaultBump: BN
|
|
38
41
|
readonly configPadding: Array<BN>
|
|
39
42
|
readonly ctokenAllocation: BN
|
|
40
43
|
readonly lastInvestSlot: BN
|
|
@@ -46,6 +49,7 @@ export class VaultAllocation {
|
|
|
46
49
|
this.ctokenVault = fields.ctokenVault
|
|
47
50
|
this.targetAllocationWeight = fields.targetAllocationWeight
|
|
48
51
|
this.tokenAllocationCap = fields.tokenAllocationCap
|
|
52
|
+
this.ctokenVaultBump = fields.ctokenVaultBump
|
|
49
53
|
this.configPadding = fields.configPadding
|
|
50
54
|
this.ctokenAllocation = fields.ctokenAllocation
|
|
51
55
|
this.lastInvestSlot = fields.lastInvestSlot
|
|
@@ -60,7 +64,8 @@ export class VaultAllocation {
|
|
|
60
64
|
borsh.publicKey("ctokenVault"),
|
|
61
65
|
borsh.u64("targetAllocationWeight"),
|
|
62
66
|
borsh.u64("tokenAllocationCap"),
|
|
63
|
-
borsh.
|
|
67
|
+
borsh.u64("ctokenVaultBump"),
|
|
68
|
+
borsh.array(borsh.u64(), 127, "configPadding"),
|
|
64
69
|
borsh.u64("ctokenAllocation"),
|
|
65
70
|
borsh.u64("lastInvestSlot"),
|
|
66
71
|
borsh.u128("tokenTargetAllocationSf"),
|
|
@@ -77,6 +82,7 @@ export class VaultAllocation {
|
|
|
77
82
|
ctokenVault: obj.ctokenVault,
|
|
78
83
|
targetAllocationWeight: obj.targetAllocationWeight,
|
|
79
84
|
tokenAllocationCap: obj.tokenAllocationCap,
|
|
85
|
+
ctokenVaultBump: obj.ctokenVaultBump,
|
|
80
86
|
configPadding: obj.configPadding,
|
|
81
87
|
ctokenAllocation: obj.ctokenAllocation,
|
|
82
88
|
lastInvestSlot: obj.lastInvestSlot,
|
|
@@ -91,6 +97,7 @@ export class VaultAllocation {
|
|
|
91
97
|
ctokenVault: fields.ctokenVault,
|
|
92
98
|
targetAllocationWeight: fields.targetAllocationWeight,
|
|
93
99
|
tokenAllocationCap: fields.tokenAllocationCap,
|
|
100
|
+
ctokenVaultBump: fields.ctokenVaultBump,
|
|
94
101
|
configPadding: fields.configPadding,
|
|
95
102
|
ctokenAllocation: fields.ctokenAllocation,
|
|
96
103
|
lastInvestSlot: fields.lastInvestSlot,
|
|
@@ -105,6 +112,7 @@ export class VaultAllocation {
|
|
|
105
112
|
ctokenVault: this.ctokenVault.toString(),
|
|
106
113
|
targetAllocationWeight: this.targetAllocationWeight.toString(),
|
|
107
114
|
tokenAllocationCap: this.tokenAllocationCap.toString(),
|
|
115
|
+
ctokenVaultBump: this.ctokenVaultBump.toString(),
|
|
108
116
|
configPadding: this.configPadding.map((item) => item.toString()),
|
|
109
117
|
ctokenAllocation: this.ctokenAllocation.toString(),
|
|
110
118
|
lastInvestSlot: this.lastInvestSlot.toString(),
|
|
@@ -119,6 +127,7 @@ export class VaultAllocation {
|
|
|
119
127
|
ctokenVault: new PublicKey(obj.ctokenVault),
|
|
120
128
|
targetAllocationWeight: new BN(obj.targetAllocationWeight),
|
|
121
129
|
tokenAllocationCap: new BN(obj.tokenAllocationCap),
|
|
130
|
+
ctokenVaultBump: new BN(obj.ctokenVaultBump),
|
|
122
131
|
configPadding: obj.configPadding.map((item) => new BN(item)),
|
|
123
132
|
ctokenAllocation: new BN(obj.ctokenAllocation),
|
|
124
133
|
lastInvestSlot: new BN(obj.lastInvestSlot),
|
package/src/utils/constants.ts
CHANGED
|
@@ -8,6 +8,8 @@ export const U64_MAX = '18446744073709551615';
|
|
|
8
8
|
const INITIAL_COLLATERAL_RATIO = 1;
|
|
9
9
|
export const INITIAL_COLLATERAL_RATE = new Decimal(INITIAL_COLLATERAL_RATIO);
|
|
10
10
|
|
|
11
|
+
export const SECONDS_PER_YEAR = 365.242_199 * 24.0 * 60.0 * 60.0;
|
|
12
|
+
|
|
11
13
|
export type ENV = 'mainnet-beta' | 'devnet' | 'localnet';
|
|
12
14
|
|
|
13
15
|
export function isENV(value: any): value is ENV {
|
|
@@ -81,3 +83,7 @@ export const SOL_DECIMALS = 9;
|
|
|
81
83
|
export const USDC_MAINNET_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
|
|
82
84
|
|
|
83
85
|
export const MAINNET_BETA_CHAIN_ID = 101;
|
|
86
|
+
|
|
87
|
+
export const POSITION_LIMIT = 10;
|
|
88
|
+
export const BORROWS_LIMIT = 5;
|
|
89
|
+
export const DEPOSITS_LIMIT = 8;
|
package/src/utils/rpc.ts
CHANGED
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
} from '@solana/web3.js';
|
|
10
10
|
import { Buffer } from 'buffer';
|
|
11
11
|
import axios from 'axios';
|
|
12
|
-
import { init, decompress } from '@bokuweb/zstd-wasm';
|
|
13
12
|
import { v4 as uuidv4 } from 'uuid';
|
|
13
|
+
import { ZSTDDecoder } from 'zstddec';
|
|
14
14
|
|
|
15
|
+
const decoder = new ZSTDDecoder();
|
|
15
16
|
(async () => {
|
|
16
|
-
await init();
|
|
17
|
+
await decoder.init();
|
|
17
18
|
})();
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -21,11 +22,13 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
21
22
|
* Uses axios instead of node-fetch to work around a bug in node-fetch that causes subsequent requests with different encoding to fail
|
|
22
23
|
* @param connection
|
|
23
24
|
* @param programId
|
|
25
|
+
* @param structSize - the size of the decompressed account data struct
|
|
24
26
|
* @param configOrCommitment
|
|
25
27
|
*/
|
|
26
28
|
export async function getProgramAccounts(
|
|
27
29
|
connection: Connection,
|
|
28
30
|
programId: PublicKey,
|
|
31
|
+
structSize: number,
|
|
29
32
|
configOrCommitment?: GetProgramAccountsConfig | Commitment
|
|
30
33
|
): Promise<GetProgramAccountsResponse> {
|
|
31
34
|
const programIdStr = programId.toBase58();
|
|
@@ -65,7 +68,7 @@ export async function getProgramAccounts(
|
|
|
65
68
|
|
|
66
69
|
const res = unsafeRes as RpcResult;
|
|
67
70
|
const deser = res.result.map(async (account) => ({
|
|
68
|
-
account: await deserializeAccountInfo(account.account),
|
|
71
|
+
account: await deserializeAccountInfo(account.account, structSize),
|
|
69
72
|
pubkey: new PublicKey(account.pubkey),
|
|
70
73
|
}));
|
|
71
74
|
const x = await Promise.all(deser);
|
|
@@ -80,8 +83,8 @@ export async function getAccountOwner(connection: Connection, address: PublicKey
|
|
|
80
83
|
return acc.owner;
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
async function deserializeAccountInfo(accountInfo: AccountInfo<string[]
|
|
84
|
-
const data =
|
|
86
|
+
async function deserializeAccountInfo(accountInfo: AccountInfo<string[]>, size: number): Promise<AccountInfo<Buffer>> {
|
|
87
|
+
const data = decoder.decode(Buffer.from(accountInfo.data[0], 'base64'), size);
|
|
85
88
|
return {
|
|
86
89
|
owner: accountInfo.owner,
|
|
87
90
|
lamports: accountInfo.lamports,
|