@kamino-finance/klend-sdk 5.0.7 → 5.1.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/README_KAMINO_MANAGER.md +24 -3
- package/dist/classes/action.d.ts +5 -1
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +39 -26
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +45 -2
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +54 -0
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/vault.d.ts +56 -4
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +107 -3
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +6 -0
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +9 -3
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +42 -32
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +10 -10
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +51 -52
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js +4 -4
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js.map +1 -1
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +3 -9
- package/dist/leverage/operations.js.map +1 -1
- package/dist/referrals/instructions.d.ts +2 -1
- package/dist/referrals/instructions.d.ts.map +1 -1
- package/dist/referrals/instructions.js +13 -8
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/utils/ata.d.ts +1 -2
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +8 -15
- package/dist/utils/ata.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/action.ts +41 -33
- package/src/classes/manager.ts +80 -1
- package/src/classes/vault.ts +158 -4
- package/src/client.ts +4 -20
- package/src/client_kamino_manager.ts +8 -0
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +178 -175
- package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +117 -116
- package/src/idl_codegen_kamino_vault/types/WithdrawalCaps.ts +30 -30
- package/src/leverage/operations.ts +3 -9
- package/src/referrals/instructions.ts +16 -9
- package/src/utils/ata.ts +8 -14
package/src/client.ts
CHANGED
|
@@ -279,11 +279,7 @@ async function deposit(connection: Connection, wallet: Keypair, token: string, d
|
|
|
279
279
|
);
|
|
280
280
|
console.log('User obligation', kaminoAction.obligation!.obligationAddress.toString());
|
|
281
281
|
|
|
282
|
-
const tx = await buildVersionedTransaction(connection, wallet.publicKey,
|
|
283
|
-
...kaminoAction.setupIxs,
|
|
284
|
-
...kaminoAction.lendingIxs,
|
|
285
|
-
...kaminoAction.cleanupIxs,
|
|
286
|
-
]);
|
|
282
|
+
const tx = await buildVersionedTransaction(connection, wallet.publicKey, KaminoAction.actionToIxs(kaminoAction));
|
|
287
283
|
|
|
288
284
|
console.log('Deposit SetupIxns:', kaminoAction.setupIxsLabels);
|
|
289
285
|
console.log('Deposit LendingIxns:', kaminoAction.lendingIxsLabels);
|
|
@@ -303,11 +299,7 @@ async function withdraw(connection: Connection, wallet: Keypair, token: string,
|
|
|
303
299
|
);
|
|
304
300
|
console.log('User obligation', kaminoAction.obligation!.obligationAddress.toString());
|
|
305
301
|
|
|
306
|
-
const tx = await buildVersionedTransaction(connection, wallet.publicKey,
|
|
307
|
-
...kaminoAction.setupIxs,
|
|
308
|
-
...kaminoAction.lendingIxs,
|
|
309
|
-
...kaminoAction.cleanupIxs,
|
|
310
|
-
]);
|
|
302
|
+
const tx = await buildVersionedTransaction(connection, wallet.publicKey, KaminoAction.actionToIxs(kaminoAction));
|
|
311
303
|
|
|
312
304
|
console.log('Withdraw SetupIxns:', kaminoAction.setupIxsLabels);
|
|
313
305
|
console.log('Withdraw LendingIxns:', kaminoAction.lendingIxsLabels);
|
|
@@ -327,11 +319,7 @@ async function borrow(connection: Connection, wallet: Keypair, token: string, bo
|
|
|
327
319
|
);
|
|
328
320
|
console.log('User obligation', kaminoAction.obligation!.obligationAddress.toString());
|
|
329
321
|
|
|
330
|
-
const tx = await buildVersionedTransaction(connection, wallet.publicKey,
|
|
331
|
-
...kaminoAction.setupIxs,
|
|
332
|
-
...kaminoAction.lendingIxs,
|
|
333
|
-
...kaminoAction.cleanupIxs,
|
|
334
|
-
]);
|
|
322
|
+
const tx = await buildVersionedTransaction(connection, wallet.publicKey, KaminoAction.actionToIxs(kaminoAction));
|
|
335
323
|
|
|
336
324
|
console.log('Borrow SetupIxns:', kaminoAction.setupIxsLabels);
|
|
337
325
|
console.log('Borrow LendingIxns:', kaminoAction.lendingIxsLabels);
|
|
@@ -352,11 +340,7 @@ async function repay(connection: Connection, wallet: Keypair, token: string, bor
|
|
|
352
340
|
);
|
|
353
341
|
console.log('User obligation', kaminoAction.obligation!.obligationAddress.toString());
|
|
354
342
|
|
|
355
|
-
const tx = await buildVersionedTransaction(connection, wallet.publicKey,
|
|
356
|
-
...kaminoAction.setupIxs,
|
|
357
|
-
...kaminoAction.lendingIxs,
|
|
358
|
-
...kaminoAction.cleanupIxs,
|
|
359
|
-
]);
|
|
343
|
+
const tx = await buildVersionedTransaction(connection, wallet.publicKey, KaminoAction.actionToIxs(kaminoAction));
|
|
360
344
|
|
|
361
345
|
console.log('Repay SetupIxns:', kaminoAction.setupIxsLabels);
|
|
362
346
|
console.log('Repay LendingIxns:', kaminoAction.lendingIxsLabels);
|
|
@@ -496,6 +496,14 @@ async function main() {
|
|
|
496
496
|
console.log('oracleConfigs', JSON.parse(JSON.stringify(oracleConfigs)));
|
|
497
497
|
});
|
|
498
498
|
|
|
499
|
+
commands.command('get-all-vaults').action(async () => {
|
|
500
|
+
const env = initializeClient(false, false);
|
|
501
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
502
|
+
|
|
503
|
+
const allVaults = await kaminoManager.getAllVaults();
|
|
504
|
+
console.log('all vaults', allVaults);
|
|
505
|
+
});
|
|
506
|
+
|
|
499
507
|
commands
|
|
500
508
|
.command('download-lending-market-config')
|
|
501
509
|
.requiredOption('--lending-market <string>', 'Lending Market Address')
|
|
@@ -1,179 +1,181 @@
|
|
|
1
|
-
import { PublicKey, Connection } from
|
|
2
|
-
import BN from
|
|
3
|
-
import * as borsh from
|
|
4
|
-
import * as types from
|
|
5
|
-
import { PROGRAM_ID } from
|
|
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
6
|
|
|
7
7
|
export interface VaultStateFields {
|
|
8
|
-
adminAuthority: PublicKey
|
|
9
|
-
baseVaultAuthority: PublicKey
|
|
10
|
-
baseVaultAuthorityBump: BN
|
|
11
|
-
tokenMint: PublicKey
|
|
12
|
-
tokenMintDecimals: BN
|
|
13
|
-
tokenVault: PublicKey
|
|
14
|
-
tokenProgram: PublicKey
|
|
15
|
-
sharesMint: PublicKey
|
|
16
|
-
sharesMintDecimals: BN
|
|
17
|
-
tokenAvailable: BN
|
|
18
|
-
sharesIssued: BN
|
|
19
|
-
availableCrankFunds: BN
|
|
20
|
-
padding0: BN
|
|
21
|
-
performanceFeeBps: BN
|
|
22
|
-
managementFeeBps: BN
|
|
23
|
-
lastFeeChargeTimestamp: BN
|
|
24
|
-
prevAumSf: BN
|
|
25
|
-
pendingFeesSf: BN
|
|
26
|
-
vaultAllocationStrategy: Array<types.VaultAllocationFields
|
|
27
|
-
minDepositAmount: BN
|
|
28
|
-
minWithdrawAmount: BN
|
|
29
|
-
minInvestAmount: BN
|
|
30
|
-
minInvestDelaySlots: BN
|
|
31
|
-
crankFundFeePerReserve: BN
|
|
32
|
-
pendingAdmin: PublicKey
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
adminAuthority: PublicKey;
|
|
9
|
+
baseVaultAuthority: PublicKey;
|
|
10
|
+
baseVaultAuthorityBump: BN;
|
|
11
|
+
tokenMint: PublicKey;
|
|
12
|
+
tokenMintDecimals: BN;
|
|
13
|
+
tokenVault: PublicKey;
|
|
14
|
+
tokenProgram: PublicKey;
|
|
15
|
+
sharesMint: PublicKey;
|
|
16
|
+
sharesMintDecimals: BN;
|
|
17
|
+
tokenAvailable: BN;
|
|
18
|
+
sharesIssued: BN;
|
|
19
|
+
availableCrankFunds: BN;
|
|
20
|
+
padding0: BN;
|
|
21
|
+
performanceFeeBps: BN;
|
|
22
|
+
managementFeeBps: BN;
|
|
23
|
+
lastFeeChargeTimestamp: BN;
|
|
24
|
+
prevAumSf: BN;
|
|
25
|
+
pendingFeesSf: BN;
|
|
26
|
+
vaultAllocationStrategy: Array<types.VaultAllocationFields>;
|
|
27
|
+
minDepositAmount: BN;
|
|
28
|
+
minWithdrawAmount: BN;
|
|
29
|
+
minInvestAmount: BN;
|
|
30
|
+
minInvestDelaySlots: BN;
|
|
31
|
+
crankFundFeePerReserve: BN;
|
|
32
|
+
pendingAdmin: PublicKey;
|
|
33
|
+
vaultLookupTable: PublicKey;
|
|
34
|
+
cumulativeNetEarnedYield: BN;
|
|
35
|
+
padding1: BN;
|
|
36
|
+
padding2: Array<BN>;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export interface VaultStateJSON {
|
|
38
|
-
adminAuthority: string
|
|
39
|
-
baseVaultAuthority: string
|
|
40
|
-
baseVaultAuthorityBump: string
|
|
41
|
-
tokenMint: string
|
|
42
|
-
tokenMintDecimals: string
|
|
43
|
-
tokenVault: string
|
|
44
|
-
tokenProgram: string
|
|
45
|
-
sharesMint: string
|
|
46
|
-
sharesMintDecimals: string
|
|
47
|
-
tokenAvailable: string
|
|
48
|
-
sharesIssued: string
|
|
49
|
-
availableCrankFunds: string
|
|
50
|
-
padding0: string
|
|
51
|
-
performanceFeeBps: string
|
|
52
|
-
managementFeeBps: string
|
|
53
|
-
lastFeeChargeTimestamp: string
|
|
54
|
-
prevAumSf: string
|
|
55
|
-
pendingFeesSf: string
|
|
56
|
-
vaultAllocationStrategy: Array<types.VaultAllocationJSON
|
|
57
|
-
minDepositAmount: string
|
|
58
|
-
minWithdrawAmount: string
|
|
59
|
-
minInvestAmount: string
|
|
60
|
-
minInvestDelaySlots: string
|
|
61
|
-
crankFundFeePerReserve: string
|
|
62
|
-
pendingAdmin: string
|
|
63
|
-
|
|
64
|
-
|
|
40
|
+
adminAuthority: string;
|
|
41
|
+
baseVaultAuthority: string;
|
|
42
|
+
baseVaultAuthorityBump: string;
|
|
43
|
+
tokenMint: string;
|
|
44
|
+
tokenMintDecimals: string;
|
|
45
|
+
tokenVault: string;
|
|
46
|
+
tokenProgram: string;
|
|
47
|
+
sharesMint: string;
|
|
48
|
+
sharesMintDecimals: string;
|
|
49
|
+
tokenAvailable: string;
|
|
50
|
+
sharesIssued: string;
|
|
51
|
+
availableCrankFunds: string;
|
|
52
|
+
padding0: string;
|
|
53
|
+
performanceFeeBps: string;
|
|
54
|
+
managementFeeBps: string;
|
|
55
|
+
lastFeeChargeTimestamp: string;
|
|
56
|
+
prevAumSf: string;
|
|
57
|
+
pendingFeesSf: string;
|
|
58
|
+
vaultAllocationStrategy: Array<types.VaultAllocationJSON>;
|
|
59
|
+
minDepositAmount: string;
|
|
60
|
+
minWithdrawAmount: string;
|
|
61
|
+
minInvestAmount: string;
|
|
62
|
+
minInvestDelaySlots: string;
|
|
63
|
+
crankFundFeePerReserve: string;
|
|
64
|
+
pendingAdmin: string;
|
|
65
|
+
vaultLookupTable: string;
|
|
66
|
+
cumulativeNetEarnedYield: string;
|
|
67
|
+
padding1: string;
|
|
68
|
+
padding2: Array<string>;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
export class VaultState {
|
|
68
|
-
readonly adminAuthority: PublicKey
|
|
69
|
-
readonly baseVaultAuthority: PublicKey
|
|
70
|
-
readonly baseVaultAuthorityBump: BN
|
|
71
|
-
readonly tokenMint: PublicKey
|
|
72
|
-
readonly tokenMintDecimals: BN
|
|
73
|
-
readonly tokenVault: PublicKey
|
|
74
|
-
readonly tokenProgram: PublicKey
|
|
75
|
-
readonly sharesMint: PublicKey
|
|
76
|
-
readonly sharesMintDecimals: BN
|
|
77
|
-
readonly tokenAvailable: BN
|
|
78
|
-
readonly sharesIssued: BN
|
|
79
|
-
readonly availableCrankFunds: BN
|
|
80
|
-
readonly padding0: BN
|
|
81
|
-
readonly performanceFeeBps: BN
|
|
82
|
-
readonly managementFeeBps: BN
|
|
83
|
-
readonly lastFeeChargeTimestamp: BN
|
|
84
|
-
readonly prevAumSf: BN
|
|
85
|
-
readonly pendingFeesSf: BN
|
|
86
|
-
readonly vaultAllocationStrategy: Array<types.VaultAllocation
|
|
87
|
-
readonly minDepositAmount: BN
|
|
88
|
-
readonly minWithdrawAmount: BN
|
|
89
|
-
readonly minInvestAmount: BN
|
|
90
|
-
readonly minInvestDelaySlots: BN
|
|
91
|
-
readonly crankFundFeePerReserve: BN
|
|
92
|
-
readonly pendingAdmin: PublicKey
|
|
93
|
-
readonly
|
|
94
|
-
readonly
|
|
72
|
+
readonly adminAuthority: PublicKey;
|
|
73
|
+
readonly baseVaultAuthority: PublicKey;
|
|
74
|
+
readonly baseVaultAuthorityBump: BN;
|
|
75
|
+
readonly tokenMint: PublicKey;
|
|
76
|
+
readonly tokenMintDecimals: BN;
|
|
77
|
+
readonly tokenVault: PublicKey;
|
|
78
|
+
readonly tokenProgram: PublicKey;
|
|
79
|
+
readonly sharesMint: PublicKey;
|
|
80
|
+
readonly sharesMintDecimals: BN;
|
|
81
|
+
readonly tokenAvailable: BN;
|
|
82
|
+
readonly sharesIssued: BN;
|
|
83
|
+
readonly availableCrankFunds: BN;
|
|
84
|
+
readonly padding0: BN;
|
|
85
|
+
readonly performanceFeeBps: BN;
|
|
86
|
+
readonly managementFeeBps: BN;
|
|
87
|
+
readonly lastFeeChargeTimestamp: BN;
|
|
88
|
+
readonly prevAumSf: BN;
|
|
89
|
+
readonly pendingFeesSf: BN;
|
|
90
|
+
readonly vaultAllocationStrategy: Array<types.VaultAllocation>;
|
|
91
|
+
readonly minDepositAmount: BN;
|
|
92
|
+
readonly minWithdrawAmount: BN;
|
|
93
|
+
readonly minInvestAmount: BN;
|
|
94
|
+
readonly minInvestDelaySlots: BN;
|
|
95
|
+
readonly crankFundFeePerReserve: BN;
|
|
96
|
+
readonly pendingAdmin: PublicKey;
|
|
97
|
+
readonly vaultLookupTable: PublicKey;
|
|
98
|
+
readonly cumulativeNetEarnedYield: BN;
|
|
99
|
+
readonly padding1: BN;
|
|
100
|
+
readonly padding2: Array<BN>;
|
|
95
101
|
|
|
96
|
-
static readonly discriminator = Buffer.from([
|
|
97
|
-
228, 196, 82, 165, 98, 210, 235, 152,
|
|
98
|
-
])
|
|
102
|
+
static readonly discriminator = Buffer.from([228, 196, 82, 165, 98, 210, 235, 152]);
|
|
99
103
|
|
|
100
104
|
static readonly layout = borsh.struct([
|
|
101
|
-
borsh.publicKey(
|
|
102
|
-
borsh.publicKey(
|
|
103
|
-
borsh.u64(
|
|
104
|
-
borsh.publicKey(
|
|
105
|
-
borsh.u64(
|
|
106
|
-
borsh.publicKey(
|
|
107
|
-
borsh.publicKey(
|
|
108
|
-
borsh.publicKey(
|
|
109
|
-
borsh.u64(
|
|
110
|
-
borsh.u64(
|
|
111
|
-
borsh.u64(
|
|
112
|
-
borsh.u64(
|
|
113
|
-
borsh.u64(
|
|
114
|
-
borsh.u64(
|
|
115
|
-
borsh.u64(
|
|
116
|
-
borsh.u64(
|
|
117
|
-
borsh.u128(
|
|
118
|
-
borsh.u128(
|
|
119
|
-
borsh.array(types.VaultAllocation.layout(), 10,
|
|
120
|
-
borsh.u64(
|
|
121
|
-
borsh.u64(
|
|
122
|
-
borsh.u64(
|
|
123
|
-
borsh.u64(
|
|
124
|
-
borsh.u64(
|
|
125
|
-
borsh.publicKey(
|
|
126
|
-
borsh.
|
|
127
|
-
borsh.
|
|
128
|
-
|
|
105
|
+
borsh.publicKey('adminAuthority'),
|
|
106
|
+
borsh.publicKey('baseVaultAuthority'),
|
|
107
|
+
borsh.u64('baseVaultAuthorityBump'),
|
|
108
|
+
borsh.publicKey('tokenMint'),
|
|
109
|
+
borsh.u64('tokenMintDecimals'),
|
|
110
|
+
borsh.publicKey('tokenVault'),
|
|
111
|
+
borsh.publicKey('tokenProgram'),
|
|
112
|
+
borsh.publicKey('sharesMint'),
|
|
113
|
+
borsh.u64('sharesMintDecimals'),
|
|
114
|
+
borsh.u64('tokenAvailable'),
|
|
115
|
+
borsh.u64('sharesIssued'),
|
|
116
|
+
borsh.u64('availableCrankFunds'),
|
|
117
|
+
borsh.u64('padding0'),
|
|
118
|
+
borsh.u64('performanceFeeBps'),
|
|
119
|
+
borsh.u64('managementFeeBps'),
|
|
120
|
+
borsh.u64('lastFeeChargeTimestamp'),
|
|
121
|
+
borsh.u128('prevAumSf'),
|
|
122
|
+
borsh.u128('pendingFeesSf'),
|
|
123
|
+
borsh.array(types.VaultAllocation.layout(), 10, 'vaultAllocationStrategy'),
|
|
124
|
+
borsh.u64('minDepositAmount'),
|
|
125
|
+
borsh.u64('minWithdrawAmount'),
|
|
126
|
+
borsh.u64('minInvestAmount'),
|
|
127
|
+
borsh.u64('minInvestDelaySlots'),
|
|
128
|
+
borsh.u64('crankFundFeePerReserve'),
|
|
129
|
+
borsh.publicKey('pendingAdmin'),
|
|
130
|
+
borsh.publicKey('vaultLookupTable'),
|
|
131
|
+
borsh.i128('cumulativeNetEarnedYield'),
|
|
132
|
+
borsh.u64('padding1'),
|
|
133
|
+
borsh.array(borsh.u128(), 251, 'padding2'),
|
|
134
|
+
]);
|
|
129
135
|
|
|
130
136
|
constructor(fields: VaultStateFields) {
|
|
131
|
-
this.adminAuthority = fields.adminAuthority
|
|
132
|
-
this.baseVaultAuthority = fields.baseVaultAuthority
|
|
133
|
-
this.baseVaultAuthorityBump = fields.baseVaultAuthorityBump
|
|
134
|
-
this.tokenMint = fields.tokenMint
|
|
135
|
-
this.tokenMintDecimals = fields.tokenMintDecimals
|
|
136
|
-
this.tokenVault = fields.tokenVault
|
|
137
|
-
this.tokenProgram = fields.tokenProgram
|
|
138
|
-
this.sharesMint = fields.sharesMint
|
|
139
|
-
this.sharesMintDecimals = fields.sharesMintDecimals
|
|
140
|
-
this.tokenAvailable = fields.tokenAvailable
|
|
141
|
-
this.sharesIssued = fields.sharesIssued
|
|
142
|
-
this.availableCrankFunds = fields.availableCrankFunds
|
|
143
|
-
this.padding0 = fields.padding0
|
|
144
|
-
this.performanceFeeBps = fields.performanceFeeBps
|
|
145
|
-
this.managementFeeBps = fields.managementFeeBps
|
|
146
|
-
this.lastFeeChargeTimestamp = fields.lastFeeChargeTimestamp
|
|
147
|
-
this.prevAumSf = fields.prevAumSf
|
|
148
|
-
this.pendingFeesSf = fields.pendingFeesSf
|
|
149
|
-
this.vaultAllocationStrategy = fields.vaultAllocationStrategy.map(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.
|
|
153
|
-
this.
|
|
154
|
-
this.
|
|
155
|
-
this.
|
|
156
|
-
this.
|
|
157
|
-
this.
|
|
158
|
-
this.padding1 = fields.padding1
|
|
159
|
-
this.padding2 = fields.padding2
|
|
137
|
+
this.adminAuthority = fields.adminAuthority;
|
|
138
|
+
this.baseVaultAuthority = fields.baseVaultAuthority;
|
|
139
|
+
this.baseVaultAuthorityBump = fields.baseVaultAuthorityBump;
|
|
140
|
+
this.tokenMint = fields.tokenMint;
|
|
141
|
+
this.tokenMintDecimals = fields.tokenMintDecimals;
|
|
142
|
+
this.tokenVault = fields.tokenVault;
|
|
143
|
+
this.tokenProgram = fields.tokenProgram;
|
|
144
|
+
this.sharesMint = fields.sharesMint;
|
|
145
|
+
this.sharesMintDecimals = fields.sharesMintDecimals;
|
|
146
|
+
this.tokenAvailable = fields.tokenAvailable;
|
|
147
|
+
this.sharesIssued = fields.sharesIssued;
|
|
148
|
+
this.availableCrankFunds = fields.availableCrankFunds;
|
|
149
|
+
this.padding0 = fields.padding0;
|
|
150
|
+
this.performanceFeeBps = fields.performanceFeeBps;
|
|
151
|
+
this.managementFeeBps = fields.managementFeeBps;
|
|
152
|
+
this.lastFeeChargeTimestamp = fields.lastFeeChargeTimestamp;
|
|
153
|
+
this.prevAumSf = fields.prevAumSf;
|
|
154
|
+
this.pendingFeesSf = fields.pendingFeesSf;
|
|
155
|
+
this.vaultAllocationStrategy = fields.vaultAllocationStrategy.map((item) => new types.VaultAllocation({ ...item }));
|
|
156
|
+
this.minDepositAmount = fields.minDepositAmount;
|
|
157
|
+
this.minWithdrawAmount = fields.minWithdrawAmount;
|
|
158
|
+
this.minInvestAmount = fields.minInvestAmount;
|
|
159
|
+
this.minInvestDelaySlots = fields.minInvestDelaySlots;
|
|
160
|
+
this.crankFundFeePerReserve = fields.crankFundFeePerReserve;
|
|
161
|
+
this.pendingAdmin = fields.pendingAdmin;
|
|
162
|
+
this.vaultLookupTable = fields.vaultLookupTable;
|
|
163
|
+
this.cumulativeNetEarnedYield = fields.cumulativeNetEarnedYield;
|
|
164
|
+
this.padding1 = fields.padding1;
|
|
165
|
+
this.padding2 = fields.padding2;
|
|
160
166
|
}
|
|
161
167
|
|
|
162
|
-
static async fetch(
|
|
163
|
-
c
|
|
164
|
-
address: PublicKey,
|
|
165
|
-
programId: PublicKey = PROGRAM_ID
|
|
166
|
-
): Promise<VaultState | null> {
|
|
167
|
-
const info = await c.getAccountInfo(address)
|
|
168
|
+
static async fetch(c: Connection, address: PublicKey, programId: PublicKey = PROGRAM_ID): Promise<VaultState | null> {
|
|
169
|
+
const info = await c.getAccountInfo(address);
|
|
168
170
|
|
|
169
171
|
if (info === null) {
|
|
170
|
-
return null
|
|
172
|
+
return null;
|
|
171
173
|
}
|
|
172
174
|
if (!info.owner.equals(programId)) {
|
|
173
|
-
throw new Error("account doesn't belong to this program")
|
|
175
|
+
throw new Error("account doesn't belong to this program");
|
|
174
176
|
}
|
|
175
177
|
|
|
176
|
-
return this.decode(info.data)
|
|
178
|
+
return this.decode(info.data);
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
static async fetchMultiple(
|
|
@@ -181,26 +183,26 @@ export class VaultState {
|
|
|
181
183
|
addresses: PublicKey[],
|
|
182
184
|
programId: PublicKey = PROGRAM_ID
|
|
183
185
|
): Promise<Array<VaultState | null>> {
|
|
184
|
-
const infos = await c.getMultipleAccountsInfo(addresses)
|
|
186
|
+
const infos = await c.getMultipleAccountsInfo(addresses);
|
|
185
187
|
|
|
186
188
|
return infos.map((info) => {
|
|
187
189
|
if (info === null) {
|
|
188
|
-
return null
|
|
190
|
+
return null;
|
|
189
191
|
}
|
|
190
192
|
if (!info.owner.equals(programId)) {
|
|
191
|
-
throw new Error("account doesn't belong to this program")
|
|
193
|
+
throw new Error("account doesn't belong to this program");
|
|
192
194
|
}
|
|
193
195
|
|
|
194
|
-
return this.decode(info.data)
|
|
195
|
-
})
|
|
196
|
+
return this.decode(info.data);
|
|
197
|
+
});
|
|
196
198
|
}
|
|
197
199
|
|
|
198
200
|
static decode(data: Buffer): VaultState {
|
|
199
|
-
if (!data.slice(0, 8)
|
|
200
|
-
throw new Error(
|
|
201
|
+
if (!VaultState.discriminator.equals(data.slice(0, 8))) {
|
|
202
|
+
throw new Error('invalid account discriminator');
|
|
201
203
|
}
|
|
202
204
|
|
|
203
|
-
const dec = VaultState.layout.decode(data.slice(8))
|
|
205
|
+
const dec = VaultState.layout.decode(data.slice(8));
|
|
204
206
|
|
|
205
207
|
return new VaultState({
|
|
206
208
|
adminAuthority: dec.adminAuthority,
|
|
@@ -222,9 +224,8 @@ export class VaultState {
|
|
|
222
224
|
prevAumSf: dec.prevAumSf,
|
|
223
225
|
pendingFeesSf: dec.pendingFeesSf,
|
|
224
226
|
vaultAllocationStrategy: dec.vaultAllocationStrategy.map(
|
|
225
|
-
(
|
|
226
|
-
item
|
|
227
|
-
) => types.VaultAllocation.fromDecoded(item)
|
|
227
|
+
(item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */) =>
|
|
228
|
+
types.VaultAllocation.fromDecoded(item)
|
|
228
229
|
),
|
|
229
230
|
minDepositAmount: dec.minDepositAmount,
|
|
230
231
|
minWithdrawAmount: dec.minWithdrawAmount,
|
|
@@ -232,9 +233,11 @@ export class VaultState {
|
|
|
232
233
|
minInvestDelaySlots: dec.minInvestDelaySlots,
|
|
233
234
|
crankFundFeePerReserve: dec.crankFundFeePerReserve,
|
|
234
235
|
pendingAdmin: dec.pendingAdmin,
|
|
236
|
+
vaultLookupTable: dec.vaultLookupTable,
|
|
237
|
+
cumulativeNetEarnedYield: dec.cumulativeNetEarnedYield,
|
|
235
238
|
padding1: dec.padding1,
|
|
236
239
|
padding2: dec.padding2,
|
|
237
|
-
})
|
|
240
|
+
});
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
toJSON(): VaultStateJSON {
|
|
@@ -257,18 +260,18 @@ export class VaultState {
|
|
|
257
260
|
lastFeeChargeTimestamp: this.lastFeeChargeTimestamp.toString(),
|
|
258
261
|
prevAumSf: this.prevAumSf.toString(),
|
|
259
262
|
pendingFeesSf: this.pendingFeesSf.toString(),
|
|
260
|
-
vaultAllocationStrategy: this.vaultAllocationStrategy.map((item) =>
|
|
261
|
-
item.toJSON()
|
|
262
|
-
),
|
|
263
|
+
vaultAllocationStrategy: this.vaultAllocationStrategy.map((item) => item.toJSON()),
|
|
263
264
|
minDepositAmount: this.minDepositAmount.toString(),
|
|
264
265
|
minWithdrawAmount: this.minWithdrawAmount.toString(),
|
|
265
266
|
minInvestAmount: this.minInvestAmount.toString(),
|
|
266
267
|
minInvestDelaySlots: this.minInvestDelaySlots.toString(),
|
|
267
268
|
crankFundFeePerReserve: this.crankFundFeePerReserve.toString(),
|
|
268
269
|
pendingAdmin: this.pendingAdmin.toString(),
|
|
270
|
+
vaultLookupTable: this.vaultLookupTable.toString(),
|
|
271
|
+
cumulativeNetEarnedYield: this.cumulativeNetEarnedYield.toString(),
|
|
269
272
|
padding1: this.padding1.toString(),
|
|
270
273
|
padding2: this.padding2.map((item) => item.toString()),
|
|
271
|
-
}
|
|
274
|
+
};
|
|
272
275
|
}
|
|
273
276
|
|
|
274
277
|
static fromJSON(obj: VaultStateJSON): VaultState {
|
|
@@ -291,17 +294,17 @@ export class VaultState {
|
|
|
291
294
|
lastFeeChargeTimestamp: new BN(obj.lastFeeChargeTimestamp),
|
|
292
295
|
prevAumSf: new BN(obj.prevAumSf),
|
|
293
296
|
pendingFeesSf: new BN(obj.pendingFeesSf),
|
|
294
|
-
vaultAllocationStrategy: obj.vaultAllocationStrategy.map((item) =>
|
|
295
|
-
types.VaultAllocation.fromJSON(item)
|
|
296
|
-
),
|
|
297
|
+
vaultAllocationStrategy: obj.vaultAllocationStrategy.map((item) => types.VaultAllocation.fromJSON(item)),
|
|
297
298
|
minDepositAmount: new BN(obj.minDepositAmount),
|
|
298
299
|
minWithdrawAmount: new BN(obj.minWithdrawAmount),
|
|
299
300
|
minInvestAmount: new BN(obj.minInvestAmount),
|
|
300
301
|
minInvestDelaySlots: new BN(obj.minInvestDelaySlots),
|
|
301
302
|
crankFundFeePerReserve: new BN(obj.crankFundFeePerReserve),
|
|
302
303
|
pendingAdmin: new PublicKey(obj.pendingAdmin),
|
|
304
|
+
vaultLookupTable: new PublicKey(obj.vaultLookupTable),
|
|
305
|
+
cumulativeNetEarnedYield: new BN(obj.cumulativeNetEarnedYield),
|
|
303
306
|
padding1: new BN(obj.padding1),
|
|
304
307
|
padding2: obj.padding2.map((item) => new BN(item)),
|
|
305
|
-
})
|
|
308
|
+
});
|
|
306
309
|
}
|
|
307
310
|
}
|