@kamino-finance/klend-sdk 7.2.2 → 7.2.3

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.
@@ -48,7 +48,7 @@ import { initEnv, ManagerEnv } from './tx/ManagerEnv';
48
48
  import { processTx } from './tx/processor';
49
49
  import { getPriorityFeeAndCuIxs } from '../client/tx/priorityFee';
50
50
  import { fetchAddressLookupTable, fetchAllAddressLookupTable } from '@solana-program/address-lookup-table';
51
- import { noopSigner } from '../utils/signer';
51
+ import { noopSigner, parseKeypairFile } from '../utils/signer';
52
52
 
53
53
  dotenv.config({
54
54
  path: `.env${process.env.ENV ? '.' + process.env.ENV : ''}`,
@@ -455,7 +455,9 @@ async function main() {
455
455
  kaminoVault,
456
456
  new PendingVaultAdmin(),
457
457
  newAdmin,
458
- signer
458
+ signer,
459
+ undefined,
460
+ true
459
461
  );
460
462
 
461
463
  await processTx(
@@ -485,7 +487,12 @@ async function main() {
485
487
  'simulate|multisig|execute - simulate - to print txn simulation and to get tx simulation link in explorer, execute - execute tx, multisig - to get bs58 tx for multisig usage'
486
488
  )
487
489
  .option(`--staging`, 'If true, will use the staging programs')
488
- .action(async ({ vault, field, value, mode, staging }) => {
490
+ .option(`--skip-lut-update`, 'If set, it will skip the LUT update')
491
+ .option(
492
+ `--lutSigner <string>`,
493
+ 'If set, it will use the provided signer instead of the default one for the LUT update'
494
+ )
495
+ .action(async ({ vault, field, value, mode, staging, skipLutUpdate, lutSigner }) => {
489
496
  const env = await initEnv(staging);
490
497
  const vaultAddress = address(vault);
491
498
 
@@ -500,7 +507,20 @@ async function main() {
500
507
  const vaultState = await kaminoVault.getState();
501
508
  const signer = await env.getSigner({ vaultState });
502
509
 
503
- const instructions = await kaminoManager.updateVaultConfigIxs(kaminoVault, field, value, signer);
510
+ let lutSignerOrUndefined = undefined;
511
+ if (lutSigner) {
512
+ lutSignerOrUndefined = await parseKeypairFile(lutSigner as string);
513
+ }
514
+
515
+ const shouldSkipLutUpdate = !!skipLutUpdate;
516
+ const instructions = await kaminoManager.updateVaultConfigIxs(
517
+ kaminoVault,
518
+ field,
519
+ value,
520
+ signer,
521
+ lutSignerOrUndefined,
522
+ shouldSkipLutUpdate
523
+ );
504
524
 
505
525
  await processTx(
506
526
  env.c,
@@ -576,10 +596,15 @@ async function main() {
576
596
  )
577
597
  .option(`--staging`, 'If true, will use the staging programs')
578
598
  .option(`--multisig <string>`, 'If using multisig mode this is required, otherwise will be ignored')
579
- .action(async ({ lut, addresses, mode, staging, multisig }) => {
599
+ .option(`--signer <string>`, 'If set, it will use the provided signer instead of the default one')
600
+ .action(async ({ lut, addresses, mode, staging, multisig, signer }) => {
580
601
  const env = await initEnv(multisig, staging);
581
602
  const lutAddress = address(lut);
582
-
603
+ let txSigner = await env.getSigner();
604
+ // if the signer is provided (path to a keypair) we use it, otherwise we use the default one
605
+ if (signer) {
606
+ txSigner = await parseKeypairFile(signer as string);
607
+ }
583
608
  const addressesArr = addresses.split(' ').map((a: string) => address(a));
584
609
 
585
610
  if (mode === 'multisig' && !multisig) {
@@ -593,12 +618,11 @@ async function main() {
593
618
  env.kvaultProgramId
594
619
  );
595
620
 
596
- const signer = await env.getSigner();
597
- const instructions = await kaminoManager.insertIntoLutIxs(signer, lutAddress, addressesArr);
621
+ const instructions = await kaminoManager.insertIntoLutIxs(txSigner, lutAddress, addressesArr);
598
622
 
599
623
  await processTx(
600
624
  env.c,
601
- signer,
625
+ txSigner,
602
626
  [
603
627
  ...instructions,
604
628
  ...getPriorityFeeAndCuIxs({
@@ -640,7 +664,8 @@ async function main() {
640
664
  'simulate|multisig|execute - simulate - to print txn simulation and to get tx simulation link in explorer, execute - execute tx, multisig - to get bs58 tx for multisig usage'
641
665
  )
642
666
  .option(`--staging`, 'If true, will use the staging programs')
643
- .action(async ({ vault, mode, staging }) => {
667
+ .option(`--signer <string>`, 'If set, it will use the provided signer instead of the default one')
668
+ .action(async ({ vault, mode, staging, signer }) => {
644
669
  const env = await initEnv(staging);
645
670
  const vaultAddress = address(vault);
646
671
 
@@ -653,14 +678,18 @@ async function main() {
653
678
 
654
679
  const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
655
680
  const vaultState = await kaminoVault.getState();
656
- const signer = await env.getSigner({ vaultState });
657
- const syncLUTIxs = await kaminoManager.syncVaultLUTIxs(signer, kaminoVault);
681
+ let txSigner = await env.getSigner({ vaultState });
682
+ // if the signer is provided (path to a keypair) we use it, otherwise we use the default one
683
+ if (signer) {
684
+ txSigner = await parseKeypairFile(signer as string);
685
+ }
686
+ const syncLUTIxs = await kaminoManager.syncVaultLUTIxs(txSigner, kaminoVault);
658
687
 
659
688
  // if we need to create the LUT we have to do that in a separate tx and wait a little bit after
660
689
  if (syncLUTIxs.setupLUTIfNeededIxs.length > 0) {
661
690
  await processTx(
662
691
  env.c,
663
- signer,
692
+ txSigner,
664
693
  [
665
694
  ...syncLUTIxs.setupLUTIfNeededIxs,
666
695
  ...getPriorityFeeAndCuIxs({
@@ -677,7 +706,7 @@ async function main() {
677
706
  for (const ix of syncLUTIxs.syncLUTIxs) {
678
707
  await processTx(
679
708
  env.c,
680
- signer,
709
+ txSigner,
681
710
  [
682
711
  ix,
683
712
  ...getPriorityFeeAndCuIxs({
@@ -1353,6 +1382,7 @@ async function main() {
1353
1382
  console.log('reserve ', reserveAddress);
1354
1383
  console.log('reserve incentive', incentive);
1355
1384
  });
1385
+ console.log('totalIncentivesAPY', vaultOverview.reservesFarmsIncentives.totalIncentivesAPY.toString());
1356
1386
  });
1357
1387
 
1358
1388
  commands
@@ -110,11 +110,16 @@ export function closeLookupTableIx(authority: TransactionSigner, lookupTable: Ad
110
110
  * Returns the accounts in a lookup table
111
111
  * @param rpc
112
112
  * @param lookupTable - lookup table to get the accounts from
113
- * @returns - an array of accounts in the lookup table
113
+ * @returns - an array of accounts in the lookup table or an empty array if the lookup table does not exist
114
114
  */
115
115
  export async function getAccountsInLut(rpc: Rpc<GetAccountInfoApi>, lookupTable: Address): Promise<Address[]> {
116
- const lutState = await fetchAddressLookupTable(rpc, lookupTable);
117
- return lutState.data.addresses;
116
+ try {
117
+ const lutState = await fetchAddressLookupTable(rpc, lookupTable);
118
+ return lutState.data.addresses;
119
+ } catch (error) {
120
+ console.error(`Error fetching accounts in lookup table ${lookupTable.toString()}`, error);
121
+ return [];
122
+ }
118
123
  }
119
124
  /**
120
125
  * This method inserts the missing keys from the provided keys into an existent lookup table