@kamino-finance/klend-sdk 5.12.6 → 5.12.7-beta.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.
Files changed (47) hide show
  1. package/dist/classes/manager.d.ts.map +1 -1
  2. package/dist/classes/manager.js +50 -13
  3. package/dist/classes/manager.js.map +1 -1
  4. package/dist/classes/market.d.ts +1 -0
  5. package/dist/classes/market.d.ts.map +1 -1
  6. package/dist/classes/market.js +3 -0
  7. package/dist/classes/market.js.map +1 -1
  8. package/dist/classes/vault.d.ts +0 -1
  9. package/dist/classes/vault.d.ts.map +1 -1
  10. package/dist/classes/vault.js +0 -16
  11. package/dist/classes/vault.js.map +1 -1
  12. package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +0 -2
  13. package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts.map +1 -1
  14. package/dist/idl_codegen_kamino_vault/instructions/deposit.js +0 -2
  15. package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -1
  16. package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +0 -4
  17. package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts.map +1 -1
  18. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js +0 -12
  19. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -1
  20. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.d.ts +0 -2
  21. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.d.ts.map +1 -1
  22. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.js +0 -2
  23. package/dist/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.js.map +1 -1
  24. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +11 -26
  25. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts.map +1 -1
  26. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +10 -15
  27. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -1
  28. package/dist/utils/accountListing.d.ts +2 -2
  29. package/dist/utils/accountListing.d.ts.map +1 -1
  30. package/dist/utils/accountListing.js +1 -1
  31. package/dist/utils/accountListing.js.map +1 -1
  32. package/dist/utils/oracle.d.ts +1 -0
  33. package/dist/utils/oracle.d.ts.map +1 -1
  34. package/dist/utils/oracle.js +8 -7
  35. package/dist/utils/oracle.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/classes/manager.ts +71 -21
  38. package/src/classes/market.ts +11 -0
  39. package/src/classes/vault.ts +1 -16
  40. package/src/client.ts +26 -1
  41. package/src/idl_codegen_kamino_vault/instructions/deposit.ts +0 -4
  42. package/src/idl_codegen_kamino_vault/instructions/withdraw.ts +0 -16
  43. package/src/idl_codegen_kamino_vault/instructions/withdrawFromAvailable.ts +0 -4
  44. package/src/idl_codegen_kamino_vault/types/ReserveConfig.ts +16 -31
  45. package/src/idl_kamino_vault.json +10 -120
  46. package/src/utils/accountListing.ts +3 -3
  47. package/src/utils/oracle.ts +14 -9
package/src/client.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  getAllObligationAccounts,
13
13
  getAllReserveAccounts,
14
14
  getAllLendingMarketAccounts,
15
+ KaminoManager,
15
16
  } from './lib';
16
17
  import * as fs from 'fs';
17
18
  import { Connection, GetProgramAccountsFilter, Keypair, PublicKey } from '@solana/web3.js';
@@ -19,7 +20,7 @@ import { BN } from '@coral-xyz/anchor';
19
20
  import { Reserve } from './idl_codegen/accounts';
20
21
  import { buildAndSendTxnWithLogs, buildVersionedTransaction } from './utils/instruction';
21
22
  import { VanillaObligation } from './utils/ObligationType';
22
- import { parseTokenSymbol } from './classes/utils';
23
+ import { getMedianSlotDurationInMsFromLastEpochs, parseTokenSymbol } from './classes/utils';
23
24
  import { Env, initEnv } from '../tests/runner/setup_utils';
24
25
  import { initializeFarmsForReserve } from '../tests/runner/farms/farms_operations';
25
26
  import { Scope } from '@kamino-finance/scope-sdk';
@@ -75,6 +76,30 @@ async function main() {
75
76
  console.log(`Total lending markets: ${count}`);
76
77
  });
77
78
 
79
+ commands
80
+ .command('print-all-markets-lite')
81
+ .option(`--rpc <string>`, 'The RPC URL')
82
+ .action(async ({ rpc }) => {
83
+ const startTime = Date.now();
84
+
85
+ const connection = new Connection(rpc, {});
86
+ const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
87
+ const kaminoManager = new KaminoManager(connection, slotDuration);
88
+ const allMarkets = await kaminoManager.getAllMarkets();
89
+ for (const market of allMarkets) {
90
+ console.log(
91
+ `Market: ${market.getName()} Address: ${
92
+ market.address
93
+ } Deposit TVL: ${market.getTotalDepositTVL()} Borrow TVL: ${market.getTotalBorrowTVL()} TVL: ${market
94
+ .getTotalDepositTVL()
95
+ .minus(market.getTotalBorrowTVL())}`
96
+ );
97
+ }
98
+
99
+ const duration = Date.now() - startTime;
100
+ console.log(`Execution duration: ${duration}ms`);
101
+ });
102
+
78
103
  commands
79
104
  .command('print-obligation')
80
105
  .option(`--rpc <string>`, 'The rpc url')
@@ -20,8 +20,6 @@ export interface DepositAccounts {
20
20
  klendProgram: PublicKey
21
21
  tokenProgram: PublicKey
22
22
  sharesTokenProgram: PublicKey
23
- eventAuthority: PublicKey
24
- program: PublicKey
25
23
  }
26
24
 
27
25
  export const layout = borsh.struct([borsh.u64("maxAmount")])
@@ -43,8 +41,6 @@ export function deposit(
43
41
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
44
42
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
45
43
  { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
46
- { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
47
- { pubkey: accounts.program, isSigner: false, isWritable: false },
48
44
  ]
49
45
  const identifier = Buffer.from([242, 35, 198, 137, 82, 225, 242, 182])
50
46
  const buffer = Buffer.alloc(1000)
@@ -21,8 +21,6 @@ export interface WithdrawAccounts {
21
21
  tokenProgram: PublicKey
22
22
  sharesTokenProgram: PublicKey
23
23
  klendProgram: PublicKey
24
- eventAuthority: PublicKey
25
- program: PublicKey
26
24
  }
27
25
  withdrawFromReserveAccounts: {
28
26
  vaultState: PublicKey
@@ -35,8 +33,6 @@ export interface WithdrawAccounts {
35
33
  reserveCollateralTokenProgram: PublicKey
36
34
  instructionSysvarAccount: PublicKey
37
35
  }
38
- eventAuthority: PublicKey
39
- program: PublicKey
40
36
  }
41
37
 
42
38
  export const layout = borsh.struct([borsh.u64("sharesAmount")])
@@ -102,16 +98,6 @@ export function withdraw(
102
98
  isSigner: false,
103
99
  isWritable: false,
104
100
  },
105
- {
106
- pubkey: accounts.withdrawFromAvailable.eventAuthority,
107
- isSigner: false,
108
- isWritable: false,
109
- },
110
- {
111
- pubkey: accounts.withdrawFromAvailable.program,
112
- isSigner: false,
113
- isWritable: false,
114
- },
115
101
  {
116
102
  pubkey: accounts.withdrawFromReserveAccounts.vaultState,
117
103
  isSigner: false,
@@ -158,8 +144,6 @@ export function withdraw(
158
144
  isSigner: false,
159
145
  isWritable: false,
160
146
  },
161
- { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
162
- { pubkey: accounts.program, isSigner: false, isWritable: false },
163
147
  ]
164
148
  const identifier = Buffer.from([183, 18, 70, 156, 148, 109, 161, 34])
165
149
  const buffer = Buffer.alloc(1000)
@@ -20,8 +20,6 @@ export interface WithdrawFromAvailableAccounts {
20
20
  tokenProgram: PublicKey
21
21
  sharesTokenProgram: PublicKey
22
22
  klendProgram: PublicKey
23
- eventAuthority: PublicKey
24
- program: PublicKey
25
23
  }
26
24
 
27
25
  export const layout = borsh.struct([borsh.u64("sharesAmount")])
@@ -43,8 +41,6 @@ export function withdrawFromAvailable(
43
41
  { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
44
42
  { pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
45
43
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
46
- { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
47
- { pubkey: accounts.program, isSigner: false, isWritable: false },
48
44
  ]
49
45
  const identifier = Buffer.from([19, 131, 112, 155, 170, 220, 34, 57])
50
46
  const buffer = Buffer.alloc(1000)
@@ -10,15 +10,10 @@ export interface ReserveConfigFields {
10
10
  assetTier: number
11
11
  /** Flat rate that goes to the host */
12
12
  hostFixedInterestRateBps: number
13
- /**
14
- * [DEPRECATED] Space that used to hold 2 fields:
15
- * - Boost for side (debt or collateral)
16
- * - Reward points multiplier per obligation type
17
- * Can be re-used after making sure all underlying production account data is zeroed.
18
- */
13
+ /** [DEPRECATED] Boost for side (debt or collateral) */
19
14
  reserved2: Array<number>
20
- /** Cut of the order execution bonus that the protocol receives, as a percentage */
21
- protocolOrderExecutionFeePct: number
15
+ /** [DEPRECATED] Reward points multiplier per obligation type */
16
+ reserved3: Array<number>
22
17
  /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
23
18
  protocolTakeRatePct: number
24
19
  /** Cut of the liquidation bonus that the protocol receives, as a percentage */
@@ -103,15 +98,10 @@ export interface ReserveConfigJSON {
103
98
  assetTier: number
104
99
  /** Flat rate that goes to the host */
105
100
  hostFixedInterestRateBps: number
106
- /**
107
- * [DEPRECATED] Space that used to hold 2 fields:
108
- * - Boost for side (debt or collateral)
109
- * - Reward points multiplier per obligation type
110
- * Can be re-used after making sure all underlying production account data is zeroed.
111
- */
101
+ /** [DEPRECATED] Boost for side (debt or collateral) */
112
102
  reserved2: Array<number>
113
- /** Cut of the order execution bonus that the protocol receives, as a percentage */
114
- protocolOrderExecutionFeePct: number
103
+ /** [DEPRECATED] Reward points multiplier per obligation type */
104
+ reserved3: Array<number>
115
105
  /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
116
106
  protocolTakeRatePct: number
117
107
  /** Cut of the liquidation bonus that the protocol receives, as a percentage */
@@ -197,15 +187,10 @@ export class ReserveConfig {
197
187
  readonly assetTier: number
198
188
  /** Flat rate that goes to the host */
199
189
  readonly hostFixedInterestRateBps: number
200
- /**
201
- * [DEPRECATED] Space that used to hold 2 fields:
202
- * - Boost for side (debt or collateral)
203
- * - Reward points multiplier per obligation type
204
- * Can be re-used after making sure all underlying production account data is zeroed.
205
- */
190
+ /** [DEPRECATED] Boost for side (debt or collateral) */
206
191
  readonly reserved2: Array<number>
207
- /** Cut of the order execution bonus that the protocol receives, as a percentage */
208
- readonly protocolOrderExecutionFeePct: number
192
+ /** [DEPRECATED] Reward points multiplier per obligation type */
193
+ readonly reserved3: Array<number>
209
194
  /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
210
195
  readonly protocolTakeRatePct: number
211
196
  /** Cut of the liquidation bonus that the protocol receives, as a percentage */
@@ -287,7 +272,7 @@ export class ReserveConfig {
287
272
  this.assetTier = fields.assetTier
288
273
  this.hostFixedInterestRateBps = fields.hostFixedInterestRateBps
289
274
  this.reserved2 = fields.reserved2
290
- this.protocolOrderExecutionFeePct = fields.protocolOrderExecutionFeePct
275
+ this.reserved3 = fields.reserved3
291
276
  this.protocolTakeRatePct = fields.protocolTakeRatePct
292
277
  this.protocolLiquidationFeePct = fields.protocolLiquidationFeePct
293
278
  this.loanToValuePct = fields.loanToValuePct
@@ -333,8 +318,8 @@ export class ReserveConfig {
333
318
  borsh.u8("status"),
334
319
  borsh.u8("assetTier"),
335
320
  borsh.u16("hostFixedInterestRateBps"),
336
- borsh.array(borsh.u8(), 9, "reserved2"),
337
- borsh.u8("protocolOrderExecutionFeePct"),
321
+ borsh.array(borsh.u8(), 2, "reserved2"),
322
+ borsh.array(borsh.u8(), 8, "reserved3"),
338
323
  borsh.u8("protocolTakeRatePct"),
339
324
  borsh.u8("protocolLiquidationFeePct"),
340
325
  borsh.u8("loanToValuePct"),
@@ -376,7 +361,7 @@ export class ReserveConfig {
376
361
  assetTier: obj.assetTier,
377
362
  hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
378
363
  reserved2: obj.reserved2,
379
- protocolOrderExecutionFeePct: obj.protocolOrderExecutionFeePct,
364
+ reserved3: obj.reserved3,
380
365
  protocolTakeRatePct: obj.protocolTakeRatePct,
381
366
  protocolLiquidationFeePct: obj.protocolLiquidationFeePct,
382
367
  loanToValuePct: obj.loanToValuePct,
@@ -419,7 +404,7 @@ export class ReserveConfig {
419
404
  assetTier: fields.assetTier,
420
405
  hostFixedInterestRateBps: fields.hostFixedInterestRateBps,
421
406
  reserved2: fields.reserved2,
422
- protocolOrderExecutionFeePct: fields.protocolOrderExecutionFeePct,
407
+ reserved3: fields.reserved3,
423
408
  protocolTakeRatePct: fields.protocolTakeRatePct,
424
409
  protocolLiquidationFeePct: fields.protocolLiquidationFeePct,
425
410
  loanToValuePct: fields.loanToValuePct,
@@ -464,7 +449,7 @@ export class ReserveConfig {
464
449
  assetTier: this.assetTier,
465
450
  hostFixedInterestRateBps: this.hostFixedInterestRateBps,
466
451
  reserved2: this.reserved2,
467
- protocolOrderExecutionFeePct: this.protocolOrderExecutionFeePct,
452
+ reserved3: this.reserved3,
468
453
  protocolTakeRatePct: this.protocolTakeRatePct,
469
454
  protocolLiquidationFeePct: this.protocolLiquidationFeePct,
470
455
  loanToValuePct: this.loanToValuePct,
@@ -507,7 +492,7 @@ export class ReserveConfig {
507
492
  assetTier: obj.assetTier,
508
493
  hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
509
494
  reserved2: obj.reserved2,
510
- protocolOrderExecutionFeePct: obj.protocolOrderExecutionFeePct,
495
+ reserved3: obj.reserved3,
511
496
  protocolTakeRatePct: obj.protocolTakeRatePct,
512
497
  protocolLiquidationFeePct: obj.protocolLiquidationFeePct,
513
498
  loanToValuePct: obj.loanToValuePct,
@@ -180,16 +180,6 @@
180
180
  "name": "sharesTokenProgram",
181
181
  "isMut": false,
182
182
  "isSigner": false
183
- },
184
- {
185
- "name": "eventAuthority",
186
- "isMut": false,
187
- "isSigner": false
188
- },
189
- {
190
- "name": "program",
191
- "isMut": false,
192
- "isSigner": false
193
183
  }
194
184
  ],
195
185
  "args": [
@@ -259,16 +249,6 @@
259
249
  "name": "klendProgram",
260
250
  "isMut": false,
261
251
  "isSigner": false
262
- },
263
- {
264
- "name": "eventAuthority",
265
- "isMut": false,
266
- "isSigner": false
267
- },
268
- {
269
- "name": "program",
270
- "isMut": false,
271
- "isSigner": false
272
252
  }
273
253
  ]
274
254
  },
@@ -321,16 +301,6 @@
321
301
  "isSigner": false
322
302
  }
323
303
  ]
324
- },
325
- {
326
- "name": "eventAuthority",
327
- "isMut": false,
328
- "isSigner": false
329
- },
330
- {
331
- "name": "program",
332
- "isMut": false,
333
- "isSigner": false
334
304
  }
335
305
  ],
336
306
  "args": [
@@ -752,16 +722,6 @@
752
722
  "name": "klendProgram",
753
723
  "isMut": false,
754
724
  "isSigner": false
755
- },
756
- {
757
- "name": "eventAuthority",
758
- "isMut": false,
759
- "isSigner": false
760
- },
761
- {
762
- "name": "program",
763
- "isMut": false,
764
- "isSigner": false
765
725
  }
766
726
  ],
767
727
  "args": [
@@ -1238,24 +1198,26 @@
1238
1198
  {
1239
1199
  "name": "reserved2",
1240
1200
  "docs": [
1241
- "[DEPRECATED] Space that used to hold 2 fields:",
1242
- "- Boost for side (debt or collateral)",
1243
- "- Reward points multiplier per obligation type",
1244
- "Can be re-used after making sure all underlying production account data is zeroed."
1201
+ "[DEPRECATED] Boost for side (debt or collateral)"
1245
1202
  ],
1246
1203
  "type": {
1247
1204
  "array": [
1248
1205
  "u8",
1249
- 9
1206
+ 2
1250
1207
  ]
1251
1208
  }
1252
1209
  },
1253
1210
  {
1254
- "name": "protocolOrderExecutionFeePct",
1211
+ "name": "reserved3",
1255
1212
  "docs": [
1256
- "Cut of the order execution bonus that the protocol receives, as a percentage"
1213
+ "[DEPRECATED] Reward points multiplier per obligation type"
1257
1214
  ],
1258
- "type": "u8"
1215
+ "type": {
1216
+ "array": [
1217
+ "u8",
1218
+ 8
1219
+ ]
1220
+ }
1259
1221
  },
1260
1222
  {
1261
1223
  "name": "protocolTakeRatePct",
@@ -2020,78 +1982,6 @@
2020
1982
  }
2021
1983
  }
2022
1984
  ],
2023
- "events": [
2024
- {
2025
- "name": "DepositResultEvent",
2026
- "fields": [
2027
- {
2028
- "name": "sharesToMint",
2029
- "type": "u64",
2030
- "index": false
2031
- },
2032
- {
2033
- "name": "tokenToDeposit",
2034
- "type": "u64",
2035
- "index": false
2036
- },
2037
- {
2038
- "name": "crankFundsToDeposit",
2039
- "type": "u64",
2040
- "index": false
2041
- }
2042
- ]
2043
- },
2044
- {
2045
- "name": "DepositUserAtaBalanceEvent",
2046
- "fields": [
2047
- {
2048
- "name": "userAtaBalance",
2049
- "type": "u64",
2050
- "index": false
2051
- }
2052
- ]
2053
- },
2054
- {
2055
- "name": "SharesToWithdrawEvent",
2056
- "fields": [
2057
- {
2058
- "name": "sharesAmount",
2059
- "type": "u64",
2060
- "index": false
2061
- },
2062
- {
2063
- "name": "userSharesBefore",
2064
- "type": "u64",
2065
- "index": false
2066
- }
2067
- ]
2068
- },
2069
- {
2070
- "name": "WithdrawResultEvent",
2071
- "fields": [
2072
- {
2073
- "name": "sharesToBurn",
2074
- "type": "u64",
2075
- "index": false
2076
- },
2077
- {
2078
- "name": "availableToSendToUser",
2079
- "type": "u64",
2080
- "index": false
2081
- },
2082
- {
2083
- "name": "investedToDisinvestCtokens",
2084
- "type": "u64",
2085
- "index": false
2086
- },
2087
- {
2088
- "name": "investedLiquidityToSendToUser",
2089
- "type": "u64",
2090
- "index": false
2091
- }
2092
- ]
2093
- }
2094
- ],
2095
1985
  "errors": [
2096
1986
  {
2097
1987
  "code": 7000,
@@ -1,4 +1,4 @@
1
- import { Connection, PublicKey } from '@solana/web3.js';
1
+ import { AccountInfo, Connection, PublicKey } from '@solana/web3.js';
2
2
  import { LendingMarket, Obligation, Reserve } from '../idl_codegen/accounts';
3
3
  import { PROGRAM_ID } from '../idl_codegen/programId';
4
4
  import bs58 from 'bs58';
@@ -35,7 +35,7 @@ export async function* getAllObligationAccounts(
35
35
 
36
36
  export async function* getAllReserveAccounts(
37
37
  connection: Connection
38
- ): AsyncGenerator<[PublicKey, Reserve], void, unknown> {
38
+ ): AsyncGenerator<[PublicKey, Reserve, AccountInfo<Buffer>], void, unknown> {
39
39
  // due to relatively low count of reserves, we technically don't really need a generator, but let's keep it consistent within this file
40
40
  const reserves = await connection.getProgramAccounts(PROGRAM_ID, {
41
41
  filters: [
@@ -51,7 +51,7 @@ export async function* getAllReserveAccounts(
51
51
  ],
52
52
  });
53
53
  for (const reserve of reserves) {
54
- yield [reserve.pubkey, Reserve.decode(reserve.account.data)];
54
+ yield [reserve.pubkey, Reserve.decode(reserve.account.data), reserve.account];
55
55
  }
56
56
  }
57
57
 
@@ -40,17 +40,15 @@ export type ScopePriceRefreshConfig = {
40
40
  scopeFeed: string;
41
41
  };
42
42
 
43
- // TODO: Add freshness of the latest price to match sc logic
44
- export async function getTokenOracleData(
45
- connection: Connection,
43
+ export function getTokenOracleDataSync(
44
+ allOracleAccounts: AllOracleAccounts,
45
+ switchboardV2: SwitchboardProgram,
46
46
  reserves: Reserve[]
47
- ): Promise<Array<[Reserve, TokenOracleData | undefined]>> {
48
- const allOracleAccounts = await getAllOracleAccounts(connection, reserves);
47
+ ) {
49
48
  const tokenOracleDataForReserves: Array<[Reserve, TokenOracleData | undefined]> = [];
50
49
  const pythCache = new PubkeyHashMap<PublicKey, PythPrices>();
51
50
  const switchboardCache = new PubkeyHashMap<PublicKey, CandidatePrice>();
52
51
  const scopeCache = new PubkeyHashMap<PublicKey, OraclePrices>();
53
- let switchboardV2: SwitchboardProgram | undefined;
54
52
  for (const reserve of reserves) {
55
53
  let currentBest: CandidatePrice | undefined = undefined;
56
54
  const oracle = {
@@ -66,9 +64,6 @@ export async function getTokenOracleData(
66
64
  }
67
65
  }
68
66
  if (isNotNullPubkey(oracle.switchboardFeedAddress)) {
69
- if (!switchboardV2) {
70
- switchboardV2 = await SwitchboardProgram.loadMainnet(connection);
71
- }
72
67
  const switchboardPrice = cacheOrGetSwitchboardPrice(
73
68
  oracle.switchboardFeedAddress,
74
69
  switchboardCache,
@@ -109,6 +104,16 @@ export async function getTokenOracleData(
109
104
  return tokenOracleDataForReserves;
110
105
  }
111
106
 
107
+ // TODO: Add freshness of the latest price to match sc logic
108
+ export async function getTokenOracleData(
109
+ connection: Connection,
110
+ reserves: Reserve[]
111
+ ): Promise<Array<[Reserve, TokenOracleData | undefined]>> {
112
+ const allOracleAccounts = await getAllOracleAccounts(connection, reserves);
113
+ const switchboardV2 = await SwitchboardProgram.loadMainnet(connection);
114
+ return getTokenOracleDataSync(allOracleAccounts, switchboardV2, reserves);
115
+ }
116
+
112
117
  export type AllOracleAccounts = PubkeyHashMap<PublicKey, AccountInfo<Buffer>>;
113
118
 
114
119
  export async function getAllOracleAccounts(connection: Connection, reserves: Reserve[]): Promise<AllOracleAccounts> {