@defisaver/positions-sdk 2.1.149 → 2.1.150-cirbtc-dev

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.
@@ -12,7 +12,7 @@ import {
12
12
  SparkMarkets,
13
13
  } from '../markets';
14
14
  import { _getMorphoBlueAccountData, _getMorphoBluePortfolioMarketData, getMorphoEarn } from '../morphoBlue';
15
- import { _getMorphoMidnightAccountData, _getMorphoMidnightMarketData } from '../morphoMidnight';
15
+ import { _getMorphoMidnightAccountData, _getMorphoMidnightMarketData, getMorphoMidnightEarn } from '../morphoMidnight';
16
16
  import {
17
17
  AaveV2MarketData,
18
18
  AaveV3MarketData,
@@ -137,6 +137,7 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
137
137
  stakingPositions[address.toLowerCase() as EthAddress] = {
138
138
  aaveV3: {},
139
139
  morphoBlue: {},
140
+ morphoMidnight: {},
140
141
  compoundV3: {},
141
142
  spark: {},
142
143
  aaveV2: {},
@@ -486,8 +487,31 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
486
487
  })).flat(),
487
488
  ...morphoMidnightMarkets.map((market) => addresses.map(async (address) => {
488
489
  try {
489
- const accData = await _getMorphoMidnightAccountData(client, network, address, market, morphoMidnightMarketsData[market.value]);
490
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: '', data: accData };
490
+ const [accDataPromise, earnDataPromise] = await Promise.allSettled([
491
+ _getMorphoMidnightAccountData(client, network, address, market, morphoMidnightMarketsData[market.value]),
492
+ getMorphoMidnightEarn(client, network, address, market, morphoMidnightMarketsData[market.value]),
493
+ ]);
494
+ if (accDataPromise.status === 'rejected') {
495
+ console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, accDataPromise.reason);
496
+ positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
497
+ }
498
+ if (earnDataPromise.status === 'rejected') {
499
+ console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, earnDataPromise.reason);
500
+ positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
501
+ }
502
+ if (accDataPromise.status !== 'rejected') {
503
+ const accData = accDataPromise.value;
504
+ if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: '', data: accData };
505
+ }
506
+ if (earnDataPromise.status !== 'rejected') {
507
+ const earnData = earnDataPromise.value;
508
+ if (earnData && new Dec(earnData.amount).gt(0)) {
509
+ stakingPositions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = {
510
+ error: '',
511
+ data: earnData,
512
+ };
513
+ }
514
+ }
491
515
  } catch (error) {
492
516
  console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, error);
493
517
  positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
@@ -16,6 +16,7 @@ export enum CompoundVersions {
16
16
  'CompoundV3USDT' = 'v3-USDT',
17
17
  'CompoundV3USDS' = 'v3-USDS',
18
18
  'CompoundV3wstETH' = 'v3-wstETH',
19
+ 'CompoundV3InstitutionalUSDC' = 'v3-institutional-USDC',
19
20
  }
20
21
 
21
22
  export enum CompoundVersionType {
@@ -32,6 +33,7 @@ export interface CompoundMarketData {
32
33
  chainIds: NetworkNumber[],
33
34
  label: string,
34
35
  shortLabel: string,
36
+ url: string,
35
37
  value: CompoundVersions,
36
38
  baseAsset: string,
37
39
  collAssets: readonly string[],