@kamino-finance/klend-sdk 6.0.5-beta.2 → 6.0.5-beta.20

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 (62) hide show
  1. package/dist/classes/action.d.ts +1 -1
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +32 -16
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/manager.d.ts +29 -18
  6. package/dist/classes/manager.d.ts.map +1 -1
  7. package/dist/classes/manager.js +66 -49
  8. package/dist/classes/manager.js.map +1 -1
  9. package/dist/classes/market.d.ts +12 -11
  10. package/dist/classes/market.d.ts.map +1 -1
  11. package/dist/classes/market.js +77 -37
  12. package/dist/classes/market.js.map +1 -1
  13. package/dist/classes/vault.d.ts +5 -3
  14. package/dist/classes/vault.d.ts.map +1 -1
  15. package/dist/classes/vault.js +8 -6
  16. package/dist/classes/vault.js.map +1 -1
  17. package/dist/client_kamino_manager.d.ts.map +1 -1
  18. package/dist/client_kamino_manager.js +30 -22
  19. package/dist/client_kamino_manager.js.map +1 -1
  20. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  21. package/dist/lending_operations/repay_with_collateral_operations.js +36 -32
  22. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  23. package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
  24. package/dist/lending_operations/swap_collateral_operations.js +4 -4
  25. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  26. package/dist/leverage/operations.d.ts +4 -3
  27. package/dist/leverage/operations.d.ts.map +1 -1
  28. package/dist/leverage/operations.js +186 -154
  29. package/dist/leverage/operations.js.map +1 -1
  30. package/dist/leverage/types.d.ts +1 -0
  31. package/dist/leverage/types.d.ts.map +1 -1
  32. package/dist/utils/managerTypes.d.ts +1 -2
  33. package/dist/utils/managerTypes.d.ts.map +1 -1
  34. package/dist/utils/managerTypes.js +9 -9
  35. package/dist/utils/managerTypes.js.map +1 -1
  36. package/dist/utils/obligations.d.ts +5 -0
  37. package/dist/utils/obligations.d.ts.map +1 -0
  38. package/dist/utils/obligations.js +53 -0
  39. package/dist/utils/obligations.js.map +1 -0
  40. package/dist/utils/oracle.d.ts +3 -3
  41. package/dist/utils/oracle.d.ts.map +1 -1
  42. package/dist/utils/oracle.js +2 -2
  43. package/dist/utils/oracle.js.map +1 -1
  44. package/dist/utils/pubkey.d.ts +1 -0
  45. package/dist/utils/pubkey.d.ts.map +1 -1
  46. package/dist/utils/pubkey.js +10 -0
  47. package/dist/utils/pubkey.js.map +1 -1
  48. package/package.json +3 -3
  49. package/src/classes/action.ts +32 -20
  50. package/src/classes/manager.ts +87 -53
  51. package/src/classes/market.ts +132 -52
  52. package/src/classes/vault.ts +17 -6
  53. package/src/client.ts +4 -4
  54. package/src/client_kamino_manager.ts +40 -35
  55. package/src/lending_operations/repay_with_collateral_operations.ts +76 -72
  56. package/src/lending_operations/swap_collateral_operations.ts +13 -11
  57. package/src/leverage/operations.ts +362 -328
  58. package/src/leverage/types.ts +1 -0
  59. package/src/utils/managerTypes.ts +1 -2
  60. package/src/utils/obligations.ts +69 -0
  61. package/src/utils/oracle.ts +5 -4
  62. package/src/utils/pubkey.ts +9 -0
@@ -1 +1 @@
1
- {"version":3,"file":"pubkey.js","sourceRoot":"","sources":["../../src/utils/pubkey.ts"],"names":[],"mappings":";;;;;;AAWA,0CAEC;AAbD,6CAA4C;AAC5C,kDAAuB;AAEV,QAAA,WAAW,GAAG,IAAI,mBAAS,CAAC,6CAA6C,CAAC,CAAC;AAC3E,QAAA,yBAAyB,GAAG,IAAI,mBAAS,CAAC,6CAA6C,CAAC,CAAC;AAEtG;;;;GAIG;AACH,SAAgB,eAAe,CAAC,MAAiB;IAC/C,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAW,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAS,CAAC,OAAO,CAAC,CAAC;AACpF,CAAC;AAED;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AQ,mBAAS;IAC9C,6DAA6D;IAC7D,MAAM,CAAC,IAAI,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEzC,YAAY,KAA+D;QACzE,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,KAAK;QACX,YAAY;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;;AAjBH,8CAkBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamino-finance/klend-sdk",
3
- "version": "6.0.5-beta.2",
3
+ "version": "6.0.5-beta.20",
4
4
  "description": "Typescript SDK for interacting with the Kamino Lending (klend) protocol",
5
5
  "repository": {
6
6
  "type": "git",
@@ -59,8 +59,8 @@
59
59
  "@coral-xyz/anchor": "^0.28.0",
60
60
  "@coral-xyz/borsh": "^0.28.0",
61
61
  "@kamino-finance/farms-sdk": "3.0.2",
62
- "@kamino-finance/kliquidity-sdk": "8.2.1",
63
- "@kamino-finance/scope-sdk": "^8.0.5",
62
+ "@kamino-finance/kliquidity-sdk": "8.5.2-beta.0",
63
+ "@kamino-finance/scope-sdk": "8.1.0-beta.4",
64
64
  "@solana/buffer-layout": "^4.0.0",
65
65
  "@solana/spl-token": "^0.4.8",
66
66
  "@solana/web3.js": "^1.95.8",
@@ -75,7 +75,7 @@ import { KaminoReserve } from './reserve';
75
75
  import { ReserveFarmKind } from '../idl_codegen/types';
76
76
  import { farmsId } from '@kamino-finance/farms-sdk';
77
77
  import { Reserve } from '../idl_codegen/accounts';
78
- import { VanillaObligation } from '../utils/ObligationType';
78
+ import { VanillaObligation } from '../utils';
79
79
  import { PROGRAM_ID } from '../lib';
80
80
  import { Scope } from '@kamino-finance/scope-sdk';
81
81
  import { ObligationOrderAtIndex } from './obligationOrder';
@@ -430,16 +430,12 @@ export class KaminoAction {
430
430
  return axn;
431
431
  }
432
432
 
433
- async addScopeRefreshIxs(scope: Scope, tokens: number[], feed: string = 'hubble') {
434
- this.setupIxsLabels.unshift(`refreshScopePrices`);
435
- this.setupIxs.unshift(
436
- await scope.refreshPriceListIx(
437
- {
438
- feed: feed,
439
- },
440
- tokens
441
- )
442
- );
433
+ async addScopeRefreshIxs(scope: Scope, tokens: number[], scopeConfig: PublicKey) {
434
+ const refreshIx = await scope.refreshPriceListIx({ config: scopeConfig }, tokens);
435
+ if (refreshIx) {
436
+ this.setupIxsLabels.unshift(`refreshScopePrices`);
437
+ this.setupIxs.unshift(refreshIx);
438
+ }
443
439
  }
444
440
 
445
441
  static async buildBorrowTxns(
@@ -732,10 +728,16 @@ export class KaminoAction {
732
728
  ...(axn.outflowReserve ? [axn.outflowReserve.address] : []),
733
729
  ...(axn.preLoadedDepositReservesSameTx ? axn.preLoadedDepositReservesSameTx : []),
734
730
  ]).toArray();
735
- const tokenIds = getTokenIdsForScopeRefresh(axn.kaminoMarket, allReserves);
736
731
 
737
- if (tokenIds.length > 0 && scopeRefreshConfig) {
738
- await axn.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
732
+ const scopeTokensMap = getTokenIdsForScopeRefresh(axn.kaminoMarket, allReserves);
733
+
734
+ if (scopeTokensMap.size > 0 && scopeRefreshConfig) {
735
+ for (const [configPubkey, config] of scopeRefreshConfig.scopeConfigurations) {
736
+ const tokenIds = scopeTokensMap.get(config.oraclePrices);
737
+ if (tokenIds && tokenIds.length > 0) {
738
+ await axn.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, configPubkey);
739
+ }
740
+ }
739
741
  }
740
742
  return axn;
741
743
  }
@@ -922,10 +924,15 @@ export class KaminoAction {
922
924
  ...(axn.outflowReserve ? [axn.outflowReserve.address] : []),
923
925
  ...(axn.preLoadedDepositReservesSameTx ? axn.preLoadedDepositReservesSameTx : []),
924
926
  ]).toArray();
925
- const tokenIds = getTokenIdsForScopeRefresh(axn.kaminoMarket, allReserves);
927
+ const scopeTokensMap = getTokenIdsForScopeRefresh(axn.kaminoMarket, allReserves);
926
928
 
927
- if (tokenIds.length > 0 && scopeRefreshConfig) {
928
- await axn.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
929
+ if (scopeTokensMap.size > 0 && scopeRefreshConfig) {
930
+ for (const [configPubkey, config] of scopeRefreshConfig.scopeConfigurations) {
931
+ const tokenIds = scopeTokensMap.get(config.oraclePrices);
932
+ if (tokenIds && tokenIds.length > 0) {
933
+ await axn.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, configPubkey);
934
+ }
935
+ }
929
936
  }
930
937
  return axn;
931
938
  }
@@ -2748,10 +2755,15 @@ export class KaminoAction {
2748
2755
  ...(this.outflowReserve ? [this.outflowReserve.address] : []),
2749
2756
  ...(this.preLoadedDepositReservesSameTx ? this.preLoadedDepositReservesSameTx : []),
2750
2757
  ]).toArray();
2751
- const tokenIds = getTokenIdsForScopeRefresh(this.kaminoMarket, allReserves);
2758
+ const scopeTokensMap = getTokenIdsForScopeRefresh(this.kaminoMarket, allReserves);
2752
2759
 
2753
- if (tokenIds.length > 0 && scopeRefreshConfig) {
2754
- await this.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
2760
+ if (scopeTokensMap.size > 0 && scopeRefreshConfig) {
2761
+ for (const [configPubkey, config] of scopeRefreshConfig.scopeConfigurations) {
2762
+ const tokenIds = scopeTokensMap.get(config.oraclePrices);
2763
+ if (tokenIds && tokenIds.length > 0) {
2764
+ await this.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, configPubkey);
2765
+ }
2766
+ }
2755
2767
  }
2756
2768
  }
2757
2769
 
@@ -52,6 +52,7 @@ import {
52
52
  Reserve,
53
53
  ReserveWithAddress,
54
54
  ScopeOracleConfig,
55
+ setOrAppend,
55
56
  updateEntireReserveConfigIx,
56
57
  updateLendingMarket,
57
58
  UpdateLendingMarketAccounts,
@@ -60,7 +61,7 @@ import {
60
61
  UpdateLendingMarketOwnerAccounts,
61
62
  } from '../lib';
62
63
  import { PROGRAM_ID } from '../idl_codegen/programId';
63
- import { Scope, TokenMetadatas, U16_MAX } from '@kamino-finance/scope-sdk';
64
+ import { OracleMappings, Scope, TokenMetadatas, U16_MAX } from '@kamino-finance/scope-sdk';
64
65
  import BN from 'bn.js';
65
66
  import { ReserveConfig, UpdateLendingMarketMode, UpdateLendingMarketModeKind } from '../idl_codegen/types';
66
67
  import Decimal from 'decimal.js';
@@ -69,7 +70,7 @@ import { VaultState } from '../idl_codegen_kamino_vault/accounts';
69
70
  import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
70
71
  import { Data } from '@kamino-finance/kliquidity-sdk';
71
72
  import bs58 from 'bs58';
72
- import { getProgramAccounts } from '../utils/rpc';
73
+ import { getProgramAccounts } from '../utils';
73
74
  import { VaultConfigField, VaultConfigFieldKind } from '../idl_codegen_kamino_vault/types';
74
75
  import {
75
76
  AcceptVaultOwnershipIxs,
@@ -317,6 +318,7 @@ export class KaminoManager {
317
318
  * This function enables the update of the scope oracle configuration. In order to get a list of scope prices, getScopeOracleConfigs can be used
318
319
  * @param market - lending market which owns the reserve
319
320
  * @param reserve - reserve which to be updated
321
+ * @param oraclePrices - scope OraclePrices account pubkey
320
322
  * @param scopeOracleConfig - new scope oracle config
321
323
  * @param scopeTwapConfig - new scope twap config
322
324
  * @param maxAgeBufferSeconds - buffer to be added to onchain max_age - if oracle price is older than that, txns interacting with the reserve will fail
@@ -325,6 +327,7 @@ export class KaminoManager {
325
327
  async updateReserveScopeOracleConfigurationIxs(
326
328
  market: MarketWithAddress,
327
329
  reserve: ReserveWithAddress,
330
+ oraclePrices: PublicKey,
328
331
  scopeOracleConfig: ScopeOracleConfig,
329
332
  scopeTwapConfig?: ScopeOracleConfig,
330
333
  maxAgeBufferSeconds: number = 20
@@ -341,7 +344,7 @@ export class KaminoManager {
341
344
  }
342
345
 
343
346
  const { scopeConfiguration } = getReserveOracleConfigs({
344
- scopePriceConfigAddress: scopeOracleConfig.scopePriceConfigAddress,
347
+ scopePriceConfigAddress: oraclePrices,
345
348
  scopeChain: [scopeOracleConfig.oracleId],
346
349
  scopeTwapChain: [scopeTwapId],
347
350
  });
@@ -523,7 +526,6 @@ export class KaminoManager {
523
526
  * This method withdraws all the pending fees from the vault to the owner's token ATA
524
527
  * @param vault - vault for which the admin withdraws the pending fees
525
528
  * @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
526
- * @param [vaultReservesMap] - a hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
527
529
  * @returns - list of instructions to withdraw all pending fees, including the ATA creation instructions if needed
528
530
  */
529
531
  async withdrawPendingFeesIxs(vault: KaminoVault, slot: number): Promise<TransactionInstruction[]> {
@@ -533,7 +535,7 @@ export class KaminoManager {
533
535
  /**
534
536
  * This method inserts the missing keys from the provided keys into an existent lookup table
535
537
  * @param payer - payer wallet pubkey
536
- * @param lookupTable - lookup table to insert the keys into
538
+ * @param lut
537
539
  * @param keys - keys to insert into the lookup table
538
540
  * @param [accountsInLUT] - the existent accounts in the lookup table. Optional. If provided, the function will not fetch the accounts in the lookup table
539
541
  * @returns - an array of instructions to insert the missing keys into the lookup table
@@ -551,7 +553,6 @@ export class KaminoManager {
551
553
  * Sync a vault for lookup table; create and set the LUT for the vault if needed and fill it with all the needed accounts
552
554
  * @param vault the vault to sync and set the LUT for if needed
553
555
  * @param vaultReserves optional; the state of the reserves in the vault allocation
554
- * @param [vaultReservesMap] - optional parameter; a hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
555
556
  * @returns a struct that contains a list of ix to create the LUT and assign it to the vault if needed + a list of ixs to insert all the accounts in the LUT
556
557
  */
557
558
  async syncVaultLUTIxs(
@@ -632,8 +633,8 @@ export class KaminoManager {
632
633
 
633
634
  /**
634
635
  * This method returns the vault name
635
- * @param vault - vault to retrieve the onchain name for
636
636
  * @returns - the vault name as string
637
+ * @param vaultState
637
638
  */
638
639
  getDecodedVaultName(vaultState: VaultState): string {
639
640
  return this._vaultClient.decodeVaultName(vaultState.name);
@@ -661,7 +662,6 @@ export class KaminoManager {
661
662
  async getAllMarkets(programId: PublicKey = PROGRAM_ID): Promise<KaminoMarket[]> {
662
663
  // Get all lending markets
663
664
  const marketGenerator = getAllLendingMarketAccounts(this.getConnection(), programId);
664
- const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
665
665
 
666
666
  const lendingMarketPairs: [PublicKey, LendingMarket][] = [];
667
667
  for await (const pair of marketGenerator) {
@@ -691,7 +691,7 @@ export class KaminoManager {
691
691
  }
692
692
  }
693
693
 
694
- const combinedMarkets = lendingMarketPairs.map(([pubkey, market]) => {
694
+ return lendingMarketPairs.map(([pubkey, market]) => {
695
695
  const reserves = marketToReserve.get(pubkey);
696
696
  const reservesByAddress = new PubkeyHashMap<PublicKey, KaminoReserve>();
697
697
  if (!reserves) {
@@ -718,10 +718,14 @@ export class KaminoManager {
718
718
  });
719
719
  }
720
720
 
721
- return KaminoMarket.loadWithReserves(this.getConnection(), market, reservesByAddress, pubkey, slotDuration);
721
+ return KaminoMarket.loadWithReserves(
722
+ this.getConnection(),
723
+ market,
724
+ reservesByAddress,
725
+ pubkey,
726
+ this.recentSlotDurationMs
727
+ );
722
728
  });
723
-
724
- return combinedMarkets;
725
729
  }
726
730
 
727
731
  /**
@@ -859,7 +863,7 @@ export class KaminoManager {
859
863
  * @param vault - the kamino vault to get available liquidity to withdraw for
860
864
  * @param price - the price of the token in the vault (e.g. USDC)
861
865
  * @param [slot] - the slot for which to calculate the holdings. Optional. If not provided the function will fetch the current slot
862
- * @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
866
+ * @param vaultReserves
863
867
  * @param [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
864
868
  * @returns an VaultHoldingsWithUSDValue object with details about the tokens available and invested in the vault, denominated in tokens and USD
865
869
  */
@@ -878,7 +882,7 @@ export class KaminoManager {
878
882
  * @param vault - the kamino vault to get available liquidity to withdraw for
879
883
  * @param price - the price of the token in the vault (e.g. USDC)
880
884
  * @param [slot] - the slot for which to retrieve the vault overview for. Optional. If not provided the function will fetch the current slot
881
- * @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
885
+ * @param vaultReserves
882
886
  * @param [kaminoMarkets] - a list of all kamino markets. Optional. If provided the function will be significantly faster as it will not have to fetch the markets
883
887
  * @param [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
884
888
  * @returns an VaultOverview object with details about the tokens available and invested in the vault, denominated in tokens and USD
@@ -938,7 +942,7 @@ export class KaminoManager {
938
942
  * This will return the APY of the vault under the assumption that all the available tokens in the vault are all the time invested in the reserves as ratio; for percentage it needs multiplication by 100
939
943
  * @param vault - the kamino vault to get APY for
940
944
  * @param slot - current slot
941
- * @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
945
+ * @param vaultReserves
942
946
  * @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault
943
947
  */
944
948
  async getVaultTheoreticalAPY(
@@ -953,7 +957,7 @@ export class KaminoManager {
953
957
  * This will return the APY of the vault based on the current invested amounts; for percentage it needs multiplication by 100
954
958
  * @param vault - the kamino vault to get APY for
955
959
  * @param slot - current slot
956
- * @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
960
+ * @param vaultReserves
957
961
  * @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault
958
962
  */
959
963
  async getVaultActualAPY(
@@ -976,8 +980,10 @@ export class KaminoManager {
976
980
  /**
977
981
  * Simulate the current holdings of the vault and the earned interest
978
982
  * @param vaultState the kamino vault state to get simulated holdings and earnings for
979
- * @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
980
- * @param [currentSlot] - the current slot. Optional. If not provided it will fetch the current slot
983
+ * @param vaultReserves
984
+ * @param vaultReserves
985
+ * @param slot
986
+ * @param slot
981
987
  * @param [previousTotalAUM] - the previous AUM of the vault to compute the earned interest relative to this value. Optional. If not provided the function will estimate the total AUM at the slot of the last state update on chain
982
988
  * @param [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
983
989
  * @returns a struct of simulated vault holdings and earned interest
@@ -1056,8 +1062,8 @@ export class KaminoManager {
1056
1062
 
1057
1063
  /**
1058
1064
  * This will load the onchain state for all the reserves that the vault has allocations for
1059
- * @param vaultState - the vault state to load reserves for
1060
1065
  * @returns a hashmap from each reserve pubkey to the reserve state
1066
+ * @param vault
1061
1067
  */
1062
1068
  getVaultReserves(vault: VaultState): PublicKey[] {
1063
1069
  return this._vaultClient.getVaultReserves(vault);
@@ -1067,6 +1073,15 @@ export class KaminoManager {
1067
1073
  * This will retrieve all the tokens that can be use as collateral by the users who borrow the token in the vault alongside details about the min and max loan to value ratio
1068
1074
  * @param vaultState - the vault state to load reserves for
1069
1075
  *
1076
+ * @param slot
1077
+ * @param vaultReservesMap
1078
+ * @param kaminoMarkets
1079
+ * @param slot
1080
+ * @param vaultReservesMap
1081
+ * @param kaminoMarkets
1082
+ * @param slot
1083
+ * @param vaultReservesMap
1084
+ * @param kaminoMarkets
1070
1085
  * @returns a hashmap from each reserve pubkey to the market overview of the collaterals that can be used and the min and max loan to value ratio in that market
1071
1086
  */
1072
1087
  async getVaultCollaterals(
@@ -1080,6 +1095,7 @@ export class KaminoManager {
1080
1095
 
1081
1096
  /**
1082
1097
  * 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
1098
+ * @param payer
1083
1099
  * @param kaminoVault - vault to invest from
1084
1100
  * @returns - an array of invest instructions for each invest action required for the vault reserves
1085
1101
  */
@@ -1090,8 +1106,8 @@ export class KaminoManager {
1090
1106
  /**
1091
1107
  * This will trigger invest by balancing, based on weights, the reserve allocation of the vault. It can either withdraw or deposit into the given reserve to balance it
1092
1108
  * @param payer wallet pubkey
1093
- * @param vault - vault to invest from
1094
- * @param reserve - reserve to invest into or disinvest from
1109
+ * @param kaminoVault
1110
+ * @param reserveWithAddress
1095
1111
  * @param [vaultReservesMap] - optional parameter; a hashmap from each reserve pubkey to the reserve state. If provided the function will be significantly faster as it will not have to fetch the reserves
1096
1112
  * @returns - an array of invest instructions for each invest action required for the vault reserves
1097
1113
  */
@@ -1124,7 +1140,7 @@ export class KaminoManager {
1124
1140
 
1125
1141
  /**
1126
1142
  * This will return the amount of token invested from the vault into the given reserve
1127
- * @param vault - the kamino vault to get invested amount in reserve for
1143
+ * @param vaultState
1128
1144
  * @param slot - current slot
1129
1145
  * @param reserve - the reserve state to get vault invested amount in
1130
1146
  * @returns vault amount supplied in reserve in decimal
@@ -1135,43 +1151,63 @@ export class KaminoManager {
1135
1151
 
1136
1152
  /**
1137
1153
  * This returns an array of scope oracle configs to be used to set the scope price and twap oracles for a reserve
1138
- * @param feed - scope feed to fetch prices from
1154
+ * @param market - kamino market
1139
1155
  * @param cluster - cluster to fetch from, this should be left unchanged unless working on devnet or locally
1140
- * @returns - an array of scope oracle configs
1156
+ * @returns - a map with keys as scope OraclePrices pubkeys and values of scope oracle configs
1141
1157
  */
1142
1158
  async getScopeOracleConfigs(
1143
- feed: string = 'hubble',
1159
+ market: KaminoMarket,
1144
1160
  cluster: ENV = 'mainnet-beta'
1145
- ): Promise<Array<ScopeOracleConfig>> {
1146
- const scopeOracleConfigs: Array<ScopeOracleConfig> = [];
1161
+ ): Promise<PubkeyHashMap<PublicKey, ScopeOracleConfig[]>> {
1162
+ const scopeOracleConfigs = new PubkeyHashMap<PublicKey, ScopeOracleConfig[]>();
1147
1163
 
1148
1164
  const scope = new Scope(cluster, this._connection);
1149
- const oracleMappings = await scope.getOracleMappings({ feed: feed });
1150
- const [, feedConfig] = await scope.getFeedConfiguration({ feed: feed });
1151
- const tokenMetadatas = await TokenMetadatas.fetch(this._connection, feedConfig.tokensMetadata);
1152
- const decoder = new TextDecoder('utf-8');
1153
-
1154
- console.log('feedConfig.tokensMetadata', feedConfig.tokensMetadata);
1155
1165
 
1156
- if (tokenMetadatas === null) {
1157
- throw new Error('TokenMetadatas not found');
1166
+ const configs = (await scope.getAllConfigurations()).filter(([_, config]) =>
1167
+ market.scopeFeeds.contains(config.oraclePrices)
1168
+ );
1169
+ if (!configs || configs.length === 0) {
1170
+ return scopeOracleConfigs;
1158
1171
  }
1159
1172
 
1160
- for (let index = 0; index < oracleMappings.priceInfoAccounts.length; index++) {
1161
- if (!oracleMappings.priceInfoAccounts[index].equals(PublicKey.default)) {
1162
- const name = decoder.decode(Uint8Array.from(tokenMetadatas.metadatasArray[index].name)).replace(/\0/g, '');
1163
- const oracleType = parseOracleType(oracleMappings.priceTypes[index]);
1164
-
1165
- scopeOracleConfigs.push({
1166
- scopePriceConfigAddress: feedConfig.oraclePrices,
1167
- name: name,
1168
- oracleType: oracleType,
1169
- oracleId: index,
1170
- oracleAccount: oracleMappings.priceInfoAccounts[index],
1171
- twapEnabled: oracleMappings.twapEnabled[index] === 1,
1172
- twapSourceId: oracleMappings.twapSource[index],
1173
- max_age: tokenMetadatas.metadatasArray[index].maxAgePriceSlots.toNumber(),
1174
- });
1173
+ const configOracleMappings = await OracleMappings.fetchMultiple(
1174
+ this._connection,
1175
+ configs.map(([_, config]) => config.oracleMappings),
1176
+ scope.config.programId
1177
+ );
1178
+
1179
+ const configTokenMetadatas = await TokenMetadatas.fetchMultiple(
1180
+ this._connection,
1181
+ configs.map(([_, config]) => config.tokensMetadata),
1182
+ scope.config.programId
1183
+ );
1184
+ const decoder = new TextDecoder('utf-8');
1185
+
1186
+ for (let i = 0; i < configs.length; i++) {
1187
+ const [configPubkey, config] = configs[i];
1188
+ const oracleMappings = configOracleMappings[i];
1189
+ const tokenMetadatas = configTokenMetadatas[i];
1190
+ if (!oracleMappings) {
1191
+ throw new Error(`OracleMappings account not found for config ${configPubkey}`);
1192
+ }
1193
+ if (!tokenMetadatas) {
1194
+ throw new Error(`TokenMetadatas account not found for config ${configPubkey}`);
1195
+ }
1196
+
1197
+ for (let j = 0; j < oracleMappings.priceInfoAccounts.length; j++) {
1198
+ if (!oracleMappings.priceInfoAccounts[j].equals(PublicKey.default)) {
1199
+ const name = decoder.decode(Uint8Array.from(tokenMetadatas.metadatasArray[j].name)).replace(/\0/g, '');
1200
+ const oracleType = parseOracleType(oracleMappings.priceTypes[j]);
1201
+ setOrAppend(scopeOracleConfigs, config.oraclePrices, {
1202
+ name: name,
1203
+ oracleType: oracleType,
1204
+ oracleId: j,
1205
+ oracleAccount: oracleMappings.priceInfoAccounts[j],
1206
+ twapEnabled: oracleMappings.twapEnabled[j] === 1,
1207
+ twapSourceId: oracleMappings.twapSource[j],
1208
+ max_age: tokenMetadatas.metadatasArray[j].maxAgePriceSlots.toNumber(),
1209
+ });
1210
+ }
1175
1211
  }
1176
1212
  }
1177
1213
 
@@ -1329,7 +1365,5 @@ function updateMarketConfigIx(
1329
1365
  value: [...value, ...Array(72 - value.length).fill(0)],
1330
1366
  };
1331
1367
 
1332
- const ix = updateLendingMarket(args, accounts, programId);
1333
-
1334
- return ix;
1368
+ return updateLendingMarket(args, accounts, programId);
1335
1369
  }