@kamino-finance/klend-sdk 5.13.1 → 5.13.4

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 (116) hide show
  1. package/dist/classes/action.d.ts +32 -31
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +126 -95
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/index.d.ts +3 -2
  6. package/dist/classes/index.d.ts.map +1 -1
  7. package/dist/classes/index.js +3 -2
  8. package/dist/classes/index.js.map +1 -1
  9. package/dist/classes/manager.d.ts +15 -7
  10. package/dist/classes/manager.d.ts.map +1 -1
  11. package/dist/classes/manager.js +57 -46
  12. package/dist/classes/manager.js.map +1 -1
  13. package/dist/classes/obligationOrder.d.ts +1 -1
  14. package/dist/classes/obligationOrder.d.ts.map +1 -1
  15. package/dist/classes/reserve.d.ts +2 -2
  16. package/dist/classes/reserve.d.ts.map +1 -1
  17. package/dist/classes/reserve.js +70 -70
  18. package/dist/classes/reserve.js.map +1 -1
  19. package/dist/classes/shared.d.ts +13 -0
  20. package/dist/classes/shared.d.ts.map +1 -1
  21. package/dist/classes/utils.d.ts +1 -9
  22. package/dist/classes/utils.d.ts.map +1 -1
  23. package/dist/classes/utils.js +4 -51
  24. package/dist/classes/utils.js.map +1 -1
  25. package/dist/classes/vault.d.ts +22 -4
  26. package/dist/classes/vault.d.ts.map +1 -1
  27. package/dist/classes/vault.js +78 -43
  28. package/dist/classes/vault.js.map +1 -1
  29. package/dist/classes/{types.d.ts → vault_types.d.ts} +3 -15
  30. package/dist/classes/vault_types.d.ts.map +1 -0
  31. package/dist/classes/{types.js → vault_types.js} +1 -1
  32. package/dist/classes/vault_types.js.map +1 -0
  33. package/dist/client_kamino_manager.d.ts.map +1 -1
  34. package/dist/client_kamino_manager.js +44 -28
  35. package/dist/client_kamino_manager.js.map +1 -1
  36. package/dist/lending_operations/repay_with_collateral_operations.js +6 -6
  37. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  38. package/dist/lending_operations/swap_collateral_operations.d.ts +6 -6
  39. package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
  40. package/dist/lending_operations/swap_collateral_operations.js +61 -61
  41. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  42. package/dist/leverage/calcs.d.ts +0 -1
  43. package/dist/leverage/calcs.d.ts.map +1 -1
  44. package/dist/leverage/calcs.js +5 -8
  45. package/dist/leverage/calcs.js.map +1 -1
  46. package/dist/leverage/operations.d.ts +5 -5
  47. package/dist/leverage/operations.d.ts.map +1 -1
  48. package/dist/leverage/operations.js +73 -73
  49. package/dist/leverage/operations.js.map +1 -1
  50. package/dist/leverage/types.d.ts +1 -1
  51. package/dist/leverage/types.d.ts.map +1 -1
  52. package/dist/leverage/utils.d.ts +2 -2
  53. package/dist/leverage/utils.d.ts.map +1 -1
  54. package/dist/leverage/utils.js +5 -5
  55. package/dist/leverage/utils.js.map +1 -1
  56. package/dist/referrals/instructions.d.ts +3 -3
  57. package/dist/referrals/instructions.d.ts.map +1 -1
  58. package/dist/referrals/instructions.js +10 -10
  59. package/dist/referrals/instructions.js.map +1 -1
  60. package/dist/referrals/operations.js +6 -6
  61. package/dist/referrals/operations.js.map +1 -1
  62. package/dist/utils/ata.d.ts +3 -3
  63. package/dist/utils/ata.d.ts.map +1 -1
  64. package/dist/utils/ata.js +22 -22
  65. package/dist/utils/ata.js.map +1 -1
  66. package/dist/utils/instruction.d.ts +2 -2
  67. package/dist/utils/instruction.d.ts.map +1 -1
  68. package/dist/utils/instruction.js +12 -12
  69. package/dist/utils/instruction.js.map +1 -1
  70. package/dist/utils/lookupTable.js +6 -6
  71. package/dist/utils/lookupTable.js.map +1 -1
  72. package/dist/utils/metadata.d.ts +14 -0
  73. package/dist/utils/metadata.d.ts.map +1 -0
  74. package/dist/utils/metadata.js +78 -0
  75. package/dist/utils/metadata.js.map +1 -0
  76. package/dist/utils/seeds.d.ts +6 -0
  77. package/dist/utils/seeds.d.ts.map +1 -1
  78. package/dist/utils/seeds.js +10 -0
  79. package/dist/utils/seeds.js.map +1 -1
  80. package/dist/utils/userMetadata.d.ts +1 -1
  81. package/dist/utils/userMetadata.d.ts.map +1 -1
  82. package/dist/utils/userMetadata.js +3 -3
  83. package/dist/utils/userMetadata.js.map +1 -1
  84. package/package.json +1 -1
  85. package/src/classes/action.ts +143 -102
  86. package/src/classes/index.ts +5 -2
  87. package/src/classes/manager.ts +74 -51
  88. package/src/classes/obligationOrder.ts +1 -1
  89. package/src/classes/reserve.ts +126 -132
  90. package/src/classes/shared.ts +15 -0
  91. package/src/classes/utils.ts +3 -52
  92. package/src/classes/vault.ts +125 -44
  93. package/src/classes/{types.ts → vault_types.ts} +2 -16
  94. package/src/client.ts +16 -16
  95. package/src/client_kamino_manager.ts +59 -27
  96. package/src/lending_operations/repay_with_collateral_operations.ts +13 -13
  97. package/src/lending_operations/swap_collateral_operations.ts +85 -85
  98. package/src/leverage/calcs.ts +2 -6
  99. package/src/leverage/operations.ts +84 -84
  100. package/src/leverage/types.ts +1 -1
  101. package/src/leverage/utils.ts +5 -5
  102. package/src/referrals/instructions.ts +6 -6
  103. package/src/referrals/operations.ts +9 -9
  104. package/src/utils/ata.ts +18 -18
  105. package/src/utils/instruction.ts +10 -10
  106. package/src/utils/lookupTable.ts +6 -6
  107. package/src/utils/metadata.ts +115 -0
  108. package/src/utils/seeds.ts +13 -0
  109. package/src/utils/userMetadata.ts +1 -1
  110. package/dist/classes/types.d.ts.map +0 -1
  111. package/dist/classes/types.js.map +0 -1
  112. package/dist/classes/types_utils.d.ts +0 -14
  113. package/dist/classes/types_utils.d.ts.map +0 -1
  114. package/dist/classes/types_utils.js +0 -50
  115. package/dist/classes/types_utils.js.map +0 -1
  116. package/src/classes/types_utils.ts +0 -49
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ReserveAllocationConfig = exports.KaminoVaultConfig = exports.KaminoVault = exports.KaminoVaultClient = exports.INITIAL_DEPOSIT_LAMPORTS = exports.kaminoVaultStagingId = exports.kaminoVaultId = void 0;
6
+ exports.ReserveAllocationConfig = exports.KaminoVaultConfig = exports.KaminoVault = exports.KaminoVaultClient = exports.INITIAL_DEPOSIT_LAMPORTS = exports.METADATA_PROGRAM_ID = exports.METADATA_SEED = exports.kaminoVaultStagingId = exports.kaminoVaultId = void 0;
7
7
  exports.getCTokenVaultPda = getCTokenVaultPda;
8
8
  exports.getEventAuthorityPda = getEventAuthorityPda;
9
+ exports.printHoldings = printHoldings;
9
10
  const anchor_1 = require("@coral-xyz/anchor");
10
11
  const web3_js_1 = require("@solana/web3.js");
11
12
  const spl_token_1 = require("@solana/spl-token");
@@ -27,7 +28,7 @@ const CreationParameters_1 = require("@kamino-finance/kliquidity-sdk/dist/utils/
27
28
  const dist_1 = require("@kamino-finance/farms-sdk/dist");
28
29
  const lookupTable_1 = require("../utils/lookupTable");
29
30
  const farm_utils_1 = require("./farm_utils");
30
- const types_utils_1 = require("./types_utils");
31
+ const metadata_1 = require("../utils/metadata");
31
32
  exports.kaminoVaultId = new web3_js_1.PublicKey('KvauGMspG5k6rtzrqqn7WNn3oZdyKqLKwK2XWQ8FLjd');
32
33
  exports.kaminoVaultStagingId = new web3_js_1.PublicKey('stKvQfwRsQiKnLtMNVLHKS3exFJmZFsgfzBPWHECUYK');
33
34
  const TOKEN_VAULT_SEED = 'token_vault';
@@ -35,6 +36,8 @@ const CTOKEN_VAULT_SEED = 'ctoken_vault';
35
36
  const BASE_VAULT_AUTHORITY_SEED = 'authority';
36
37
  const SHARES_SEED = 'shares';
37
38
  const EVENT_AUTHORITY_SEED = '__event_authority';
39
+ exports.METADATA_SEED = 'metadata';
40
+ exports.METADATA_PROGRAM_ID = new web3_js_1.PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s');
38
41
  exports.INITIAL_DEPOSIT_LAMPORTS = 1000;
39
42
  /**
40
43
  * KaminoVaultClient is a class that provides a high-level interface to interact with the Kamino Vault program.
@@ -79,7 +82,7 @@ class KaminoVaultClient {
79
82
  const sharesIssued = new decimal_js_1.default(vault.sharesIssued.toString()).div(new decimal_js_1.default(vault.sharesMintDecimals.toString()));
80
83
  console.log('Name: ', vaultName);
81
84
  console.log('Shares issued: ', sharesIssued);
82
- (0, types_utils_1.printHoldings)(holdings);
85
+ printHoldings(holdings);
83
86
  console.log('Tokens per share: ', tokensPerShare);
84
87
  }
85
88
  /**
@@ -144,30 +147,47 @@ class KaminoVaultClient {
144
147
  ];
145
148
  const insertIntoLUTIxs = await this.insertIntoLookupTableIxs(vaultConfig.admin, lut, accountsToBeInserted, []);
146
149
  const setLUTIx = this.updateUninitialisedVaultConfigIx(vaultConfig.admin, vaultState.publicKey, new types_1.VaultConfigField.LookupTable(), lut.toString());
147
- const ixns = [createVaultIx, initVaultIx, setLUTIx];
150
+ const ixs = [createVaultIx, initVaultIx, setLUTIx];
148
151
  if (vaultConfig.getPerformanceFeeBps() > 0) {
149
152
  const setPerformanceFeeIx = this.updateUninitialisedVaultConfigIx(vaultConfig.admin, vaultState.publicKey, new types_1.VaultConfigField.PerformanceFeeBps(), vaultConfig.getPerformanceFeeBps().toString());
150
- ixns.push(setPerformanceFeeIx);
153
+ ixs.push(setPerformanceFeeIx);
151
154
  }
152
155
  if (vaultConfig.getManagementFeeBps() > 0) {
153
156
  const setManagementFeeIx = this.updateUninitialisedVaultConfigIx(vaultConfig.admin, vaultState.publicKey, new types_1.VaultConfigField.ManagementFeeBps(), vaultConfig.getManagementFeeBps().toString());
154
- ixns.push(setManagementFeeIx);
157
+ ixs.push(setManagementFeeIx);
155
158
  }
156
159
  if (vaultConfig.name && vaultConfig.name.length > 0) {
157
160
  const setNameIx = this.updateUninitialisedVaultConfigIx(vaultConfig.admin, vaultState.publicKey, new types_1.VaultConfigField.Name(), vaultConfig.name);
158
- ixns.push(setNameIx);
161
+ ixs.push(setNameIx);
159
162
  }
163
+ const metadataIx = await this.getSetSharesMetadataIx(this.getConnection(), vaultConfig.admin, vaultState.publicKey, sharesMint, baseVaultAuthority, vaultConfig.vaultTokenSymbol, vaultConfig.vaultTokenName);
160
164
  return {
161
165
  vault: vaultState,
162
166
  initVaultIxs: {
163
167
  createAtaIfNeededIxs: prerequisiteIxs,
164
- initVaultIxs: ixns,
168
+ initVaultIxs: ixs,
165
169
  createLUTIx,
166
170
  populateLUTIxs: insertIntoLUTIxs,
167
171
  cleanupIxs,
172
+ initSharesMetadataIx: metadataIx,
168
173
  },
169
174
  };
170
175
  }
176
+ /**
177
+ * This method creates an instruction to set the shares metadata for a vault
178
+ * @param vault - the vault to set the shares metadata for
179
+ * @param tokenName - the name of the token in the vault (symbol; e.g. "USDC" which becomes "kVUSDC")
180
+ * @param extraName - the extra string appended to the prefix("Kamino Vault USDC <extraName>")
181
+ * @returns - an instruction to set the shares metadata for the vault
182
+ */
183
+ async getSetSharesMetadataIx(connection, vaultAdmin, vault, sharesMint, baseVaultAuthority, tokenName, extraName) {
184
+ const [sharesMintMetadata] = (0, utils_2.getKVaultSharesMetadataPda)(sharesMint);
185
+ const { name, symbol, uri } = (0, metadata_1.resolveMetadata)(sharesMint, extraName, tokenName);
186
+ const ix = (await connection.getAccountInfo(sharesMintMetadata)) === null
187
+ ? await (0, metadata_1.getInitializeKVaultSharesMetadataIx)(connection, vaultAdmin, vault, sharesMint, baseVaultAuthority, name, symbol, uri)
188
+ : await (0, metadata_1.getUpdateSharesMetadataIx)(connection, vaultAdmin, vault, sharesMint, baseVaultAuthority, name, symbol, uri);
189
+ return ix;
190
+ }
171
191
  /**
172
192
  * This method updates the vault reserve allocation cofnig for an exiting vault reserve, or adds a new reserve to the vault if it does not exist.
173
193
  * @param vault - vault to be updated
@@ -441,7 +461,7 @@ class KaminoVaultClient {
441
461
  });
442
462
  }
443
463
  const reserveStates = await lib_1.Reserve.fetchMultiple(this.getConnection(), reservesToWithdraw, this._kaminoLendProgramId);
444
- const withdrawIxns = await Promise.all(reservesToWithdraw.map(async (reserve, index) => {
464
+ const withdrawIxs = await Promise.all(reservesToWithdraw.map(async (reserve, index) => {
445
465
  if (reserveStates[index] === null) {
446
466
  throw new Error(`Reserve ${reserve.toBase58()} not found`);
447
467
  }
@@ -449,7 +469,7 @@ class KaminoVaultClient {
449
469
  const marketAddress = reserveState.lendingMarket;
450
470
  return this.withdrawPendingFeesIx(vault, vaultState, marketAddress, { address: reserve, state: reserveState }, adminTokenAta);
451
471
  }));
452
- return [createAtaIx, ...withdrawIxns];
472
+ return [createAtaIx, ...withdrawIxs];
453
473
  }
454
474
  // async closeVaultIx(vault: KaminoVault): Promise<TransactionInstruction> {
455
475
  // const vaultState: VaultState = await vault.getState(this.getConnection());
@@ -472,8 +492,8 @@ class KaminoVaultClient {
472
492
  const vaultState = await vault.getState(this.getConnection());
473
493
  const tokenProgramID = vaultState.tokenProgram;
474
494
  const userTokenAta = (0, lib_1.getAssociatedTokenAddress)(vaultState.tokenMint, user, true, tokenProgramID);
475
- const createAtasIxns = [];
476
- const closeAtasIxns = [];
495
+ const createAtasIxs = [];
496
+ const closeAtasIxs = [];
477
497
  if (vaultState.tokenMint.equals(spl_token_1.NATIVE_MINT)) {
478
498
  const [{ ata: wsolAta, createAtaIx: createWsolAtaIxn }] = (0, utils_2.createAtasIdempotent)(user, [
479
499
  {
@@ -481,17 +501,17 @@ class KaminoVaultClient {
481
501
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
482
502
  },
483
503
  ]);
484
- createAtasIxns.push(createWsolAtaIxn);
485
- const transferWsolIxns = (0, lib_1.getTransferWsolIxns)(user, wsolAta, (0, utils_1.numberToLamportsDecimal)(tokenAmount, vaultState.tokenMintDecimals.toNumber()).ceil());
486
- createAtasIxns.push(...transferWsolIxns);
504
+ createAtasIxs.push(createWsolAtaIxn);
505
+ const transferWsolIxs = (0, lib_1.getTransferWsolIxs)(user, wsolAta, (0, utils_1.numberToLamportsDecimal)(tokenAmount, vaultState.tokenMintDecimals.toNumber()).ceil());
506
+ createAtasIxs.push(...transferWsolIxs);
487
507
  }
488
- const [{ ata: userSharesAta, createAtaIx: createSharesAtaIxns }] = (0, utils_2.createAtasIdempotent)(user, [
508
+ const [{ ata: userSharesAta, createAtaIx: createSharesAtaIxs }] = (0, utils_2.createAtasIdempotent)(user, [
489
509
  {
490
510
  mint: vaultState.sharesMint,
491
511
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
492
512
  },
493
513
  ]);
494
- createAtasIxns.push(createSharesAtaIxns);
514
+ createAtasIxs.push(createSharesAtaIxs);
495
515
  const eventAuthority = getEventAuthorityPda(this._kaminoVaultProgramId);
496
516
  const depoistAccounts = {
497
517
  user: user,
@@ -531,7 +551,7 @@ class KaminoVaultClient {
531
551
  depositIx.keys = depositIx.keys.concat(vaultReservesAccountMetas);
532
552
  depositIx.keys = depositIx.keys.concat(vaultReservesLendingMarkets);
533
553
  const depositIxs = {
534
- depositIxs: [...createAtasIxns, depositIx, ...closeAtasIxns],
554
+ depositIxs: [...createAtasIxs, depositIx, ...closeAtasIxs],
535
555
  stakeInFarmIfNeededIxs: [],
536
556
  };
537
557
  // if there is no farm, we can return the deposit instructions, otherwise include the stake ix in the response
@@ -591,16 +611,16 @@ class KaminoVaultClient {
591
611
  // if the vault has allocations withdraw otherwise wtihdraw from available ix
592
612
  const vaultAllocation = vaultState.vaultAllocationStrategy.find((allocation) => !allocation.reserve.equals(web3_js_1.PublicKey.default));
593
613
  if (vaultAllocation) {
594
- const withdrawFromVaultIxs = await this.wihdrdrawWithReserveIxns(user, kaminoVault, shareAmount, slot, vaultReservesMap);
614
+ const withdrawFromVaultIxs = await this.wihdrdrawWithReserveIxs(user, kaminoVault, shareAmount, slot, vaultReservesMap);
595
615
  withdrawIxs.withdrawIxs = withdrawFromVaultIxs;
596
616
  }
597
617
  else {
598
- const withdrawFromVaultIxs = await this.withdrawFromAvailableIxns(user, kaminoVault, shareAmount);
618
+ const withdrawFromVaultIxs = await this.withdrawFromAvailableIxs(user, kaminoVault, shareAmount);
599
619
  withdrawIxs.withdrawIxs = withdrawFromVaultIxs;
600
620
  }
601
621
  return withdrawIxs;
602
622
  }
603
- async withdrawFromAvailableIxns(user, vault, shareAmount) {
623
+ async withdrawFromAvailableIxs(user, vault, shareAmount) {
604
624
  const vaultState = await vault.getState(this.getConnection());
605
625
  const kaminoVault = new KaminoVault(vault.address, vaultState, vault.programId);
606
626
  const userSharesAta = (0, lib_1.getAssociatedTokenAddress)(vaultState.sharesMint, user);
@@ -614,7 +634,7 @@ class KaminoVaultClient {
614
634
  const withdrawFromAvailableIxn = await this.withdrawFromAvailableIx(user, kaminoVault, vaultState, userSharesAta, userTokenAta, shareLamportsToWithdraw);
615
635
  return [createAtaIx, withdrawFromAvailableIxn];
616
636
  }
617
- async wihdrdrawWithReserveIxns(user, vault, shareAmount, slot, vaultReservesMap) {
637
+ async wihdrdrawWithReserveIxs(user, vault, shareAmount, slot, vaultReservesMap) {
618
638
  const vaultState = await vault.getState(this.getConnection());
619
639
  const vaultReservesState = vaultReservesMap ? vaultReservesMap : await this.loadVaultReserves(vaultState);
620
640
  const userSharesAta = (0, lib_1.getAssociatedTokenAddress)(vaultState.sharesMint, user);
@@ -661,8 +681,8 @@ class KaminoVaultClient {
661
681
  }
662
682
  });
663
683
  }
664
- const withdrawIxns = [];
665
- withdrawIxns.push(createAtaIx);
684
+ const withdrawIxs = [];
685
+ withdrawIxs.push(createAtaIx);
666
686
  for (let reserveIndex = 0; reserveIndex < reserveWithSharesAmountToWithdraw.length; reserveIndex++) {
667
687
  const reserveWithTokens = reserveWithSharesAmountToWithdraw[reserveIndex];
668
688
  const reserveState = vaultReservesState.get(reserveWithTokens.reserve);
@@ -677,9 +697,9 @@ class KaminoVaultClient {
677
697
  sharesToWithdraw = reserveWithTokens.shares;
678
698
  }
679
699
  const withdrawFromReserveIx = this.withdrawIx(user, vault, vaultState, marketAddress, { address: reserveWithTokens.reserve, state: reserveState.state }, userSharesAta, userTokenAta, sharesToWithdraw, vaultReservesState);
680
- withdrawIxns.push(withdrawFromReserveIx);
700
+ withdrawIxs.push(withdrawFromReserveIx);
681
701
  }
682
- return withdrawIxns;
702
+ return withdrawIxs;
683
703
  }
684
704
  /**
685
705
  * This will trigger invest by balancing, based on weights, the reserve allocations of the vault. It can either withdraw or deposit into reserves to balance them. This is a function that should be cranked
@@ -731,7 +751,7 @@ class KaminoVaultClient {
731
751
  }
732
752
  }
733
753
  }
734
- const investIxnsPromises = [];
754
+ const investIxsPromises = [];
735
755
  // invest first the reserves from which we disinvest, then the other ones
736
756
  for (const reserve of reservesToDisinvestFrom) {
737
757
  const reserveState = allReservesStateMap.get(reserve);
@@ -742,7 +762,7 @@ class KaminoVaultClient {
742
762
  address: reserve,
743
763
  state: reserveState.state,
744
764
  }, allReservesStateMap, false);
745
- investIxnsPromises.push(investIxsPromise);
765
+ investIxsPromises.push(investIxsPromise);
746
766
  }
747
767
  for (const reserve of reservesToInvestInto) {
748
768
  const reserveState = allReservesStateMap.get(reserve);
@@ -753,12 +773,12 @@ class KaminoVaultClient {
753
773
  address: reserve,
754
774
  state: reserveState.state,
755
775
  }, allReservesStateMap, false);
756
- investIxnsPromises.push(investIxsPromise);
776
+ investIxsPromises.push(investIxsPromise);
757
777
  }
758
- let investIxns = [];
759
- investIxns.push(createAtaIx);
760
- investIxns = await Promise.all(investIxnsPromises).then((ixns) => ixns.flat());
761
- return investIxns;
778
+ let investIxs = [];
779
+ investIxs.push(createAtaIx);
780
+ investIxs = await Promise.all(investIxsPromises).then((ixs) => ixs.flat());
781
+ return investIxs;
762
782
  }
763
783
  // todo: make sure we also check the ata of the investor for the vault token exists
764
784
  /**
@@ -1006,22 +1026,22 @@ class KaminoVaultClient {
1006
1026
  let lut = vaultState.vaultLookupTable;
1007
1027
  if (lut.equals(web3_js_1.PublicKey.default)) {
1008
1028
  const recentSlot = await this.getConnection().getSlot();
1009
- const [ixn, address] = (0, lookupTable_1.initLookupTableIx)(vaultState.vaultAdminAuthority, recentSlot);
1010
- setupLUTIfNeededIxs.push(ixn);
1029
+ const [ix, address] = (0, lookupTable_1.initLookupTableIx)(vaultState.vaultAdminAuthority, recentSlot);
1030
+ setupLUTIfNeededIxs.push(ix);
1011
1031
  lut = address;
1012
1032
  // set the new LUT for the vault
1013
1033
  const updateVaultConfigIxs = await this.updateVaultConfigIxs(vault, new types_1.VaultConfigField.LookupTable(), lut.toString());
1014
1034
  setupLUTIfNeededIxs.push(updateVaultConfigIxs.updateVaultConfigIx);
1015
1035
  }
1016
- const ixns = [];
1036
+ const ixs = [];
1017
1037
  let overridenExistentAccounts = undefined;
1018
1038
  if (vaultState.vaultLookupTable.equals(web3_js_1.PublicKey.default)) {
1019
1039
  overridenExistentAccounts = [];
1020
1040
  }
1021
- ixns.push(...(await this.insertIntoLookupTableIxs(vaultState.vaultAdminAuthority, lut, allAccountsToBeInserted, overridenExistentAccounts)));
1041
+ ixs.push(...(await this.insertIntoLookupTableIxs(vaultState.vaultAdminAuthority, lut, allAccountsToBeInserted, overridenExistentAccounts)));
1022
1042
  return {
1023
1043
  setupLUTIfNeededIxs,
1024
- syncLUTIxs: ixns,
1044
+ syncLUTIxs: ixs,
1025
1045
  };
1026
1046
  }
1027
1047
  getReserveAccountsToInsertInLut(reserveState) {
@@ -1057,18 +1077,18 @@ class KaminoVaultClient {
1057
1077
  // deduplicate missing accounts and remove default accounts and convert it back to an array
1058
1078
  const missingAccountsList = new utils_2.PublicKeySet(missingAccounts).toArray();
1059
1079
  const chunkSize = 20;
1060
- const ixns = [];
1080
+ const ixs = [];
1061
1081
  for (let i = 0; i < missingAccountsList.length; i += chunkSize) {
1062
1082
  const chunk = missingAccountsList.slice(i, i + chunkSize);
1063
- const ixn = web3_js_1.AddressLookupTableProgram.extendLookupTable({
1083
+ const ix = web3_js_1.AddressLookupTableProgram.extendLookupTable({
1064
1084
  lookupTable,
1065
1085
  authority: payer,
1066
1086
  payer,
1067
1087
  addresses: chunk,
1068
1088
  });
1069
- ixns.push(ixn);
1089
+ ixs.push(ix);
1070
1090
  }
1071
- return ixns;
1091
+ return ixs;
1072
1092
  }
1073
1093
  /** Read the total holdings of a vault and the reserve weights and returns a map from each reserve to how many tokens should be deposited.
1074
1094
  * @param vaultState - the vault state to calculate the allocation for
@@ -1499,6 +1519,7 @@ class KaminoVaultClient {
1499
1519
  .map((filteredReserve) => {
1500
1520
  const reserveAsCollateral = {
1501
1521
  mint: filteredReserve.getLiquidityMint(),
1522
+ address: filteredReserve.address,
1502
1523
  liquidationLTVPct: new decimal_js_1.default(filteredReserve.state.config.liquidationThresholdPct),
1503
1524
  };
1504
1525
  marketOverview.reservesAsCollateral.push(reserveAsCollateral);
@@ -1873,8 +1894,12 @@ class KaminoVaultConfig {
1873
1894
  performanceFeeRatePercentage;
1874
1895
  /** The management fee rate of the vault, as percents, expressed as a decimal */
1875
1896
  managementFeeRatePercentage;
1876
- /** The name to be stored on cain for the vault (max 40 characters). */
1897
+ /** The name to be stored on chain for the vault (max 40 characters). */
1877
1898
  name;
1899
+ /** The symbol of the vault token to be stored (max 5 characters). E.g. USDC for a vault using USDC as token. */
1900
+ vaultTokenSymbol;
1901
+ /** The name of the vault token to be stored (max 10 characters), after the prefix `Kamino Vault <vaultTokenSymbol>`. E.g. USDC Vault for a vault using USDC as token. */
1902
+ vaultTokenName;
1878
1903
  constructor(args) {
1879
1904
  this.admin = args.admin;
1880
1905
  this.tokenMint = args.tokenMint;
@@ -1882,6 +1907,8 @@ class KaminoVaultConfig {
1882
1907
  this.managementFeeRatePercentage = args.managementFeeRatePercentage;
1883
1908
  this.tokenMintProgramId = args.tokenMintProgramId;
1884
1909
  this.name = args.name;
1910
+ this.vaultTokenSymbol = args.vaultTokenSymbol;
1911
+ this.vaultTokenName = args.vaultTokenName;
1885
1912
  }
1886
1913
  getPerformanceFeeBps() {
1887
1914
  return this.performanceFeeRatePercentage.mul(100).toNumber();
@@ -1917,4 +1944,12 @@ function getCTokenVaultPda(vaultAddress, reserveAddress, kaminoVaultProgramId) {
1917
1944
  function getEventAuthorityPda(kaminoVaultProgramId) {
1918
1945
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(EVENT_AUTHORITY_SEED)], kaminoVaultProgramId)[0];
1919
1946
  }
1947
+ function printHoldings(holdings) {
1948
+ console.log('Holdings:');
1949
+ console.log(' Available:', holdings.available.toString());
1950
+ console.log(' Invested:', holdings.invested.toString());
1951
+ console.log(' Total AUM including fees:', holdings.totalAUMIncludingFees.toString());
1952
+ console.log(' Pending fees:', holdings.pendingFees.toString());
1953
+ console.log(' Invested in reserves:', (0, utils_1.pubkeyHashMapToJson)(holdings.investedInReserves));
1954
+ }
1920
1955
  //# sourceMappingURL=vault.js.map