@kamino-finance/klend-sdk 7.1.9 → 7.2.0

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.
@@ -13,6 +13,7 @@ import {
13
13
  GetProgramAccountsApi,
14
14
  GetAccountInfoApi,
15
15
  GetMultipleAccountsApi,
16
+ SolanaRpcApiMainnet,
16
17
  } from '@solana/kit';
17
18
  import Decimal from 'decimal.js';
18
19
  import {
@@ -55,10 +56,11 @@ import { getCreateAccountInstruction, SYSTEM_PROGRAM_ADDRESS } from '@solana-pro
55
56
  import { SYSVAR_RENT_ADDRESS } from '@solana/sysvars';
56
57
  import { noopSigner } from '../utils/signer';
57
58
  import { getRewardPerTimeUnitSecond } from './farm_utils';
59
+ import { Scope, ScopeEntryMetadata } from '@kamino-finance/scope-sdk';
58
60
 
59
61
  export type KaminoReserveRpcApi = GetProgramAccountsApi & GetAccountInfoApi & GetMultipleAccountsApi;
60
62
 
61
- export const DEFAULT_RECENT_SLOT_DURATION_MS = 450;
63
+ export const DEFAULT_RECENT_SLOT_DURATION_MS = 400;
62
64
 
63
65
  export class KaminoReserve {
64
66
  state: Reserve;
@@ -72,6 +74,8 @@ export class KaminoReserve {
72
74
  private rpc: Rpc<KaminoReserveRpcApi>;
73
75
  private readonly recentSlotDurationMs: number;
74
76
 
77
+ private metadata?: ScopeEntryMetadata[];
78
+
75
79
  constructor(
76
80
  state: Reserve,
77
81
  address: Address,
@@ -133,6 +137,19 @@ export class KaminoReserve {
133
137
  return parseTokenSymbol(this.state.config.tokenInfo.name);
134
138
  }
135
139
 
140
+ /**
141
+ * @returns list of logo names and human readable oracle descriptions
142
+ */
143
+ async getOracleMetadata(): Promise<[string, string][]> {
144
+ if (!this.metadata) {
145
+ const scope = new Scope('mainnet-beta', this.rpc as Rpc<SolanaRpcApiMainnet>);
146
+ const { priceFeed, priceChain } = this.state.config.tokenInfo.scopeConfiguration;
147
+ this.metadata = await scope.getChainMetadata({ prices: priceFeed }, priceChain);
148
+ }
149
+
150
+ return this.metadata.map((m) => [m.provider, m.name]);
151
+ }
152
+
136
153
  /**
137
154
  * @returns the total borrowed amount of the reserve in lamports
138
155
  */