@defisaver/positions-sdk 2.1.159-shifter-v2-dev → 2.1.160-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.
Files changed (108) hide show
  1. package/cjs/aaveV2/index.js +0 -2
  2. package/cjs/constants/index.d.ts +1 -0
  3. package/cjs/constants/index.js +4 -1
  4. package/cjs/fluid/index.d.ts +0 -5
  5. package/cjs/fluid/index.js +1 -36
  6. package/cjs/helpers/aaveHelpers/index.js +0 -3
  7. package/cjs/helpers/aaveV4Helpers/index.js +0 -1
  8. package/cjs/helpers/compoundHelpers/index.js +0 -2
  9. package/cjs/helpers/curveUsdHelpers/index.js +0 -2
  10. package/cjs/helpers/fluidHelpers/index.js +0 -1
  11. package/cjs/helpers/liquityV2Helpers/index.js +0 -1
  12. package/cjs/helpers/llamaLendHelpers/index.js +0 -2
  13. package/cjs/helpers/makerHelpers/index.d.ts +1 -1
  14. package/cjs/helpers/makerHelpers/index.js +2 -2
  15. package/cjs/helpers/morphoBlueHelpers/index.js +3 -6
  16. package/cjs/helpers/morphoMidnightHelpers/index.js +0 -2
  17. package/cjs/helpers/sparkHelpers/index.js +0 -1
  18. package/cjs/liquity/index.js +1 -8
  19. package/cjs/maker/index.d.ts +2 -7
  20. package/cjs/maker/index.js +12 -32
  21. package/cjs/markets/index.d.ts +0 -1
  22. package/cjs/markets/index.js +1 -3
  23. package/cjs/portfolio/index.d.ts +1 -5
  24. package/cjs/portfolio/index.js +0 -272
  25. package/cjs/savings/morphoVaults/index.js +2 -2
  26. package/cjs/types/aave.d.ts +0 -2
  27. package/cjs/types/aaveV4.d.ts +0 -1
  28. package/cjs/types/compound.d.ts +0 -2
  29. package/cjs/types/fluid.d.ts +0 -1
  30. package/cjs/types/liquity.d.ts +0 -1
  31. package/cjs/types/liquityV2.d.ts +0 -2
  32. package/cjs/types/maker.d.ts +0 -1
  33. package/cjs/types/morphoBlue.d.ts +0 -2
  34. package/cjs/types/morphoMidnight.d.ts +0 -1
  35. package/cjs/types/portfolio.d.ts +10 -26
  36. package/cjs/types/spark.d.ts +0 -2
  37. package/esm/aaveV2/index.js +0 -2
  38. package/esm/constants/index.d.ts +1 -0
  39. package/esm/constants/index.js +3 -0
  40. package/esm/fluid/index.d.ts +0 -5
  41. package/esm/fluid/index.js +0 -33
  42. package/esm/helpers/aaveHelpers/index.js +0 -3
  43. package/esm/helpers/aaveV4Helpers/index.js +0 -1
  44. package/esm/helpers/compoundHelpers/index.js +0 -2
  45. package/esm/helpers/curveUsdHelpers/index.js +0 -2
  46. package/esm/helpers/fluidHelpers/index.js +0 -1
  47. package/esm/helpers/liquityV2Helpers/index.js +0 -1
  48. package/esm/helpers/llamaLendHelpers/index.js +0 -2
  49. package/esm/helpers/makerHelpers/index.d.ts +1 -1
  50. package/esm/helpers/makerHelpers/index.js +2 -2
  51. package/esm/helpers/morphoBlueHelpers/index.js +4 -7
  52. package/esm/helpers/morphoMidnightHelpers/index.js +0 -2
  53. package/esm/helpers/sparkHelpers/index.js +0 -1
  54. package/esm/liquity/index.js +1 -8
  55. package/esm/maker/index.d.ts +2 -7
  56. package/esm/maker/index.js +13 -31
  57. package/esm/markets/index.d.ts +0 -1
  58. package/esm/markets/index.js +0 -1
  59. package/esm/portfolio/index.d.ts +1 -5
  60. package/esm/portfolio/index.js +3 -274
  61. package/esm/savings/morphoVaults/index.js +2 -2
  62. package/esm/types/aave.d.ts +0 -2
  63. package/esm/types/aaveV4.d.ts +0 -1
  64. package/esm/types/compound.d.ts +0 -2
  65. package/esm/types/fluid.d.ts +0 -1
  66. package/esm/types/liquity.d.ts +0 -1
  67. package/esm/types/liquityV2.d.ts +0 -2
  68. package/esm/types/maker.d.ts +0 -1
  69. package/esm/types/morphoBlue.d.ts +0 -2
  70. package/esm/types/morphoMidnight.d.ts +0 -1
  71. package/esm/types/portfolio.d.ts +10 -26
  72. package/esm/types/spark.d.ts +0 -2
  73. package/package.json +1 -1
  74. package/src/aaveV2/index.ts +0 -2
  75. package/src/constants/index.ts +5 -1
  76. package/src/fluid/index.ts +0 -40
  77. package/src/helpers/aaveHelpers/index.ts +0 -3
  78. package/src/helpers/aaveV4Helpers/index.ts +0 -1
  79. package/src/helpers/compoundHelpers/index.ts +0 -2
  80. package/src/helpers/curveUsdHelpers/index.ts +0 -2
  81. package/src/helpers/fluidHelpers/index.ts +0 -1
  82. package/src/helpers/liquityV2Helpers/index.ts +0 -1
  83. package/src/helpers/llamaLendHelpers/index.ts +0 -2
  84. package/src/helpers/makerHelpers/index.ts +1 -2
  85. package/src/helpers/morphoBlueHelpers/index.ts +6 -7
  86. package/src/helpers/morphoMidnightHelpers/index.ts +0 -2
  87. package/src/helpers/sparkHelpers/index.ts +0 -1
  88. package/src/liquity/index.ts +1 -8
  89. package/src/maker/index.ts +29 -62
  90. package/src/markets/index.ts +1 -2
  91. package/src/portfolio/index.ts +2 -257
  92. package/src/savings/morphoVaults/index.ts +2 -3
  93. package/src/types/aave.ts +0 -3
  94. package/src/types/aaveV4.ts +0 -1
  95. package/src/types/compound.ts +0 -2
  96. package/src/types/fluid.ts +0 -1
  97. package/src/types/liquity.ts +0 -2
  98. package/src/types/liquityV2.ts +0 -2
  99. package/src/types/maker.ts +0 -2
  100. package/src/types/morphoBlue.ts +0 -2
  101. package/src/types/morphoMidnight.ts +0 -1
  102. package/src/types/portfolio.ts +12 -31
  103. package/src/types/spark.ts +0 -2
  104. package/cjs/markets/maker/index.d.ts +0 -1
  105. package/cjs/markets/maker/index.js +0 -13
  106. package/esm/markets/maker/index.d.ts +0 -1
  107. package/esm/markets/maker/index.js +0 -10
  108. package/src/markets/maker/index.ts +0 -10
@@ -7,7 +7,6 @@ import {
7
7
  CrvUsdMarkets,
8
8
  LiquityV2Markets,
9
9
  LlamaLendMarkets,
10
- MakerActiveIlks,
11
10
  MorphoBlueMarkets,
12
11
  MorphoMidnightMarkets,
13
12
  SparkMarkets,
@@ -28,7 +27,6 @@ import {
28
27
  LlamaLendGlobalMarketData,
29
28
  MorphoBlueMarketInfo,
30
29
  MorphoMidnightMarketInfo,
31
- PortfolioMarketsData,
32
30
  PortfolioPositionsData,
33
31
  SparkMarketsData,
34
32
  } from '../types';
@@ -38,13 +36,13 @@ import { _getCurveUsdGlobalData, _getCurveUsdUserData } from '../curveUsd';
38
36
  import { _getLlamaLendGlobalData, _getLlamaLendUserData } from '../llamaLend';
39
37
  import { _getAaveV3AccountData, _getAaveV3MarketData, getStakeAaveData } from '../aaveV3';
40
38
  import { ZERO_ADDRESS } from '../constants';
41
- import { _getMakerCdpData, _getMakerIlksData, _getUserCdps } from '../maker';
39
+ import { _getMakerCdpData, _getUserCdps } from '../maker';
42
40
  import { _getAaveV2AccountData, _getAaveV2MarketsData } from '../aaveV2';
43
41
  import { _getCompoundV2AccountData, _getCompoundV2MarketsData } from '../compoundV2';
44
42
  import { getViemProvider } from '../services/viem';
45
43
  import { _getLiquityTroveInfo, getLiquityStakingData } from '../liquity';
46
44
  import { _getLiquityV2MarketData, getLiquitySAndYBold, getLiquityV2Staking } from '../liquityV2';
47
- import { _getAllFluidMarketDataPortfolio, _getAllUserEarnPositionsWithFTokens, _getUserPositionsPortfolio } from '../fluid';
45
+ import { _getAllUserEarnPositionsWithFTokens, _getUserPositionsPortfolio } from '../fluid';
48
46
  import { getUmbrellaData } from '../umbrella';
49
47
  import { getMerklUnclaimedRewards, getUnclaimedRewardsForAllMarkets } from '../claiming/aaveV3';
50
48
  import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
@@ -593,257 +591,4 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
593
591
  };
594
592
  }
595
593
 
596
-
597
- export async function getShifterPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim = false): Promise<{
598
- positions: PortfolioPositionsData;
599
- markets: PortfolioMarketsData;
600
- }> {
601
- const isMainnet = network === NetworkNumber.Eth;
602
- const isFluidSupported = [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Plasma].includes(network);
603
-
604
- const morphoMarkets = Object.values(MorphoBlueMarkets(network)).filter((market) => market.chainIds.includes(network));
605
- const compoundV3Markets = Object.values(CompoundMarkets(network)).filter((market) => market.chainIds.includes(network) && market.value !== CompoundVersions.CompoundV2);
606
- const sparkMarkets = Object.values(SparkMarkets(network)).filter((market) => market.chainIds.includes(network));
607
- const aaveV3Markets = [AaveVersions.AaveV3, AaveVersions.AaveV3Lido, AaveVersions.AaveV3Etherfi].map((version) => AaveMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
608
- const aaveV2Markets = [AaveVersions.AaveV2].map((version) => AaveMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
609
- const compoundV2Markets = [CompoundVersions.CompoundV2].map((version) => CompoundMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
610
- const crvUsdMarkets = Object.values(CrvUsdMarkets(network)).filter((market) => market.chainIds.includes(network));
611
- const llamaLendMarkets = [NetworkNumber.Eth, NetworkNumber.Arb].includes(network) ? Object.values(LlamaLendMarkets(network)).filter((market) => market.chainIds.includes(network)) : [];
612
- const liquityV2Markets = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)) : [];
613
- const aaveV4Spokes = Object.values(AaveV4Spokes(network)).filter((market) => market.chainIds.includes(network));
614
-
615
- const args: [NetworkNumber, any?] = [network, { batch: { multicall: { batchSize: isSim ? 2_000 : 2_500_000 } } }];
616
- const client = getViemProvider(provider, ...args);
617
- const defaultClient = getViemProvider(defaultProvider, ...args);
618
-
619
- const markets: PortfolioMarketsData = {
620
- morphoMarketsData: {},
621
- morphoMidnightMarketsData: {}, // Morpho Midnight is not fetched for the shifter; key kept so the payload shape is stable
622
- compoundV3MarketsData: {},
623
- sparkMarketsData: {},
624
- aaveV3MarketsData: {},
625
- aaveV2MarketsData: {},
626
- compoundV2MarketsData: {},
627
- crvUsdMarketsData: {},
628
- llamaLendMarketsData: {},
629
- liquityV2MarketsData: {},
630
- aaveV4SpokesData: {},
631
- fluidMarketsData: {},
632
- makerMarketsData: {},
633
- };
634
- const makerCdps: Record<string, CdpInfo[]> = {};
635
-
636
- const positions: PortfolioPositionsData = {};
637
-
638
- for (const address of addresses) {
639
- positions[address.toLowerCase() as EthAddress] = {
640
- aaveV3: {},
641
- aaveV4: {},
642
- morphoBlue: {},
643
- morphoMidnight: {}, // not fetched for the shifter (see markets above)
644
- compoundV3: {},
645
- spark: {},
646
- maker: {},
647
- aaveV2: {},
648
- compoundV2: {},
649
- liquity: {},
650
- crvUsd: {},
651
- llamaLend: {},
652
- fluid: {
653
- error: '',
654
- data: {},
655
- },
656
- };
657
- }
658
-
659
- await Promise.allSettled([
660
- // === MARKET DATA (needs to be fetched first) ===
661
- ...morphoMarkets.map(async (market) => {
662
- markets.morphoMarketsData[market.value] = await _getMorphoBluePortfolioMarketData(client, network, market);
663
- }),
664
- ...compoundV3Markets.map(async (market) => {
665
- markets.compoundV3MarketsData[market.value] = await _getCompoundV3MarketsData(client, network, market, defaultClient);
666
- }),
667
- ...sparkMarkets.map(async (market) => {
668
- markets.sparkMarketsData[market.value] = await _getSparkMarketsData(client, network, market);
669
- }),
670
- ...aaveV3Markets.map(async (market) => {
671
- markets.aaveV3MarketsData[market.value] = await _getAaveV3MarketData(client, network, market);
672
- }),
673
- ...aaveV4Spokes.map(async (spoke) => {
674
- markets.aaveV4SpokesData[spoke.value] = await _getAaveV4SpokeData(client, network, spoke);
675
- }),
676
- ...aaveV2Markets.map(async (market) => {
677
- markets.aaveV2MarketsData[market.value] = await _getAaveV2MarketsData(client, network, market);
678
- }),
679
- ...compoundV2Markets.map(async (market) => {
680
- markets.compoundV2MarketsData[market.value] = await _getCompoundV2MarketsData(client, network);
681
- }),
682
- ...crvUsdMarkets.map(async (market) => {
683
- markets.crvUsdMarketsData[market.value] = await _getCurveUsdGlobalData(client, network, market);
684
- }),
685
- ...llamaLendMarkets.map(async (market) => {
686
- markets.llamaLendMarketsData[market.value] = await _getLlamaLendGlobalData(client, network, market);
687
- }),
688
- ...liquityV2Markets.map(async (market) => {
689
- markets.liquityV2MarketsData[market.value] = await _getLiquityV2MarketData(client, network, market);
690
- }),
691
- (async () => {
692
- if (!isFluidSupported) return;
693
- try {
694
- markets.fluidMarketsData = await _getAllFluidMarketDataPortfolio(client, network);
695
- } catch (error) {
696
- console.error('Error fetching Fluid markets data:', error);
697
- }
698
- })(),
699
- (async () => {
700
- if (!isMainnet) return; // Maker CDPs are only available on mainnet
701
- try {
702
- markets.makerMarketsData = await _getMakerIlksData(client, network, MakerActiveIlks);
703
- } catch (error) {
704
- console.error('Error fetching Maker ilks data:', error);
705
- }
706
- })(),
707
-
708
- // === INDEPENDENT USER DATA (doesn't depend on market data) ===
709
- ...addresses.map(async (address) => {
710
- if (!isMainnet) return; // Maker CDPs are only available on mainnet
711
- const makerCdp = await _getUserCdps(client, network, address);
712
- makerCdps[address.toLowerCase() as EthAddress] = makerCdp;
713
- }),
714
- ...addresses.map(async (address) => {
715
- try {
716
- if (!isFluidSupported) return; // Fluid is not available on Optimism
717
- const userPositions = (await _getUserPositionsPortfolio(client, network, address));
718
- for (const position of userPositions) {
719
- if (position.userData && new Dec(position.userData.suppliedUsd).gt(0)) {
720
- positions[address.toLowerCase() as EthAddress].fluid.data[position.userData.nftId] = position.userData;
721
- }
722
- }
723
- } catch (error) {
724
- console.error(`Error fetching Fluid positions for address ${address}:`, error);
725
- positions[address.toLowerCase() as EthAddress].fluid = {
726
- error: `Error fetching Fluid positions for address ${address}`,
727
- data: {},
728
- };
729
- }
730
- }),
731
- ]);
732
-
733
- await Promise.all([
734
- ...aaveV3Markets.map((market) => addresses.map(async (address) => {
735
- try {
736
- const accData = await _getAaveV3AccountData(client, network, address, { selectedMarket: market, ...markets.aaveV3MarketsData[market.value] });
737
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].aaveV3[market.value] = { error: '', data: accData };
738
- } catch (error) {
739
- console.error(`Error fetching AaveV3 account data for address ${address} on market ${market.value}:`, error);
740
- positions[address.toLowerCase() as EthAddress].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
741
- }
742
- })).flat(),
743
- ...aaveV4Spokes.map((spoke) => addresses.map(async (address) => {
744
- try {
745
- const accData = await _getAaveV4AccountData(client, network, markets.aaveV4SpokesData[spoke.value], address);
746
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].aaveV4[spoke.value] = { error: '', data: accData };
747
- } catch (error) {
748
- console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
749
- positions[address.toLowerCase() as EthAddress].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
750
- }
751
- })).flat(),
752
- ...morphoMarkets.map((market) => addresses.map(async (address) => {
753
- try {
754
- const accData = await _getMorphoBlueAccountData(client, network, address, market, markets.morphoMarketsData[market.value]);
755
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].morphoBlue[market.value] = { error: '', data: accData };
756
- } catch (error) {
757
- console.error(`Error fetching MorphoBlue account data for address ${address} on market ${market.value}:`, error);
758
- positions[address.toLowerCase() as EthAddress].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
759
- }
760
- })).flat(),
761
- ...compoundV3Markets.map((market) => addresses.map(async (address) => {
762
- try {
763
- const accData = await _getCompoundV3AccountData(client, network, address, ZERO_ADDRESS, { selectedMarket: market, assetsData: markets.compoundV3MarketsData[market.value].assetsData });
764
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].compoundV3[market.value] = { error: '', data: accData };
765
- } catch (error) {
766
- console.error(`Error fetching CompoundV3 account data for address ${address} on market ${market.value}:`, error);
767
- positions[address.toLowerCase() as EthAddress].compoundV3[market.value] = { error: `Error fetching CompoundV3 account data for address ${address} on market ${market.value}`, data: null };
768
- }
769
- })).flat(),
770
- ...sparkMarkets.map((market) => addresses.map(async (address) => {
771
- try {
772
- const accData = await _getSparkAccountData(client, network, address, { selectedMarket: market, assetsData: markets.sparkMarketsData[market.value].assetsData, eModeCategoriesData: markets.sparkMarketsData[market.value].eModeCategoriesData });
773
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].spark[market.value] = { error: '', data: accData };
774
- } catch (error) {
775
- console.error(`Error fetching Spark account data for address ${address} on market ${market.value}:`, error);
776
- positions[address.toLowerCase() as EthAddress].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
777
- }
778
- })).flat(),
779
- ...addresses.map(async (address) => makerCdps[address.toLowerCase() as EthAddress]?.map(async (cdpInfo) => {
780
- try {
781
- // reuse ilk data fetched for the markets payload; ilks outside the active set are fetched on demand
782
- const cdpData = await _getMakerCdpData(client, network, cdpInfo, markets.makerMarketsData[cdpInfo.ilkLabel]);
783
- if (cdpData) {
784
- positions[address.toLowerCase() as EthAddress].maker[cdpInfo.id] = { error: '', data: cdpData };
785
- }
786
- } catch (error) {
787
- console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
788
- positions[address.toLowerCase() as EthAddress].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
789
- }
790
- })).flat(),
791
- ...aaveV2Markets.map((market) => addresses.map(async (address) => {
792
- try {
793
- const accData = await _getAaveV2AccountData(client, network, address, markets.aaveV2MarketsData[market.value].assetsData, market);
794
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].aaveV2[market.value] = { error: '', data: accData };
795
- } catch (error) {
796
- console.error(`Error fetching AaveV2 account data for address ${address}:`, error);
797
- positions[address.toLowerCase() as EthAddress].aaveV2[market.value] = { error: `Error fetching AaveV2 account data for address ${address}`, data: null };
798
- }
799
- })).flat(),
800
- ...compoundV2Markets.map((market) => addresses.map(async (address) => {
801
- try {
802
- const accData = await _getCompoundV2AccountData(client, network, address, markets.compoundV2MarketsData[market.value].assetsData);
803
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].compoundV2[market.value] = { error: '', data: accData };
804
- } catch (error) {
805
- console.error(`Error fetching CompoundV2 account data for address ${address}:`, error);
806
- positions[address.toLowerCase() as EthAddress].compoundV2[market.value] = { error: `Error fetching CompoundV2 account data for address ${address}`, data: null };
807
- }
808
- })).flat(),
809
- ...addresses.map(async (address) => {
810
- try {
811
- if (!isMainnet) return; // Liquity trove info is only available on mainnet
812
- const troveInfo = await _getLiquityTroveInfo(client, network, address);
813
- if (new Dec(troveInfo.collateral).gt(0)) positions[address.toLowerCase() as EthAddress].liquity = { error: '', data: troveInfo };
814
- } catch (error) {
815
- console.error(`Error fetching Liquity trove info for address ${address}:`, error);
816
- positions[address.toLowerCase() as EthAddress].liquity = { error: `Error fetching Liquity trove info for address ${address}`, data: null };
817
- }
818
- }),
819
- ...crvUsdMarkets.map((market) => addresses.map(async (address) => {
820
- try {
821
- const accData = await _getCurveUsdUserData(client, network, address, market, markets.crvUsdMarketsData[market.value].activeBand);
822
- if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
823
- positions[address.toLowerCase() as EthAddress].crvUsd[market.value] = { error: '', data: { ...accData, borrowRate: markets.crvUsdMarketsData[market.value].borrowRate } };
824
- }
825
- } catch (error) {
826
- console.error(`Error fetching Curve USD account data for address ${address} on market ${market.value}:`, error);
827
- positions[address.toLowerCase() as EthAddress].crvUsd[market.value] = { error: `Error fetching Curve USD account data for address ${address} on market ${market.value}`, data: null };
828
- }
829
- })).flat(),
830
- ...llamaLendMarkets.map((market) => addresses.map(async (address) => {
831
- try {
832
- const accData = await _getLlamaLendUserData(client, network, address, market, markets.llamaLendMarketsData[market.value]);
833
- if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
834
- positions[address.toLowerCase() as EthAddress].llamaLend[market.value] = { error: '', data: { ...accData, borrowRate: markets.llamaLendMarketsData[market.value].borrowRate } };
835
- }
836
- } catch (error) {
837
- console.error(`Error fetching LlamaLend account data for address ${address} on market ${market.value}:`, error);
838
- positions[address.toLowerCase() as EthAddress].llamaLend[market.value] = { error: `Error fetching LlamaLend account data for address ${address} on market ${market.value}`, data: null };
839
- }
840
- })).flat(),
841
- ]);
842
-
843
- return {
844
- positions,
845
- markets,
846
- };
847
- }
848
-
849
594
  export * from './discovery';
@@ -8,13 +8,12 @@ import {
8
8
  } from '../../types';
9
9
  import { getViemProvider } from '../../services/viem';
10
10
  import { getMorphoVaultContractViem } from '../../contracts';
11
+ import { MORPHO_API_URL } from '../../constants';
11
12
 
12
13
  export {
13
14
  morphoVaultsOptions,
14
15
  };
15
16
 
16
- const MORPHO_BLUE_API = 'https://api.morpho.org/graphql';
17
-
18
17
  // Morpho API caps list page size at 100 items
19
18
  const MORPHO_API_PAGE_SIZE = 100;
20
19
 
@@ -41,7 +40,7 @@ export const fetchMorphoVaultsLiquidity = async (network: NetworkNumber, vaults:
41
40
 
42
41
  const liquidityByAddress: Record<string, string> = {};
43
42
  await Promise.all(chunks.map(async (chunk) => {
44
- const data = await graphqlRequest(MORPHO_BLUE_API, vaultsLiquidityQuery, {
43
+ const data = await graphqlRequest(MORPHO_API_URL, vaultsLiquidityQuery, {
45
44
  addresses: chunk.map((vault) => vault.address),
46
45
  chainIds: [network],
47
46
  // the BigInt scalar serializes as a JSON number when it fits in Number.MAX_SAFE_INTEGER, a string otherwise
package/src/types/aave.ts CHANGED
@@ -143,8 +143,6 @@ export interface AavePositionData extends MMPositionData {
143
143
  collRatio: string,
144
144
  // Safety ratio as evaluated by automation bots (LTV-0 collateral credited at LLTV - 5%). Aave v3 only.
145
145
  safetyRatioWithLtvZeroFallback?: string,
146
- // Normalised safety ratio (100 = liquidation on every protocol). Aave v3: the LTV-0 fallback ratio, Aave v2: `ratio`.
147
- safetyRatio?: string,
148
146
  suppliedUsd: string,
149
147
  borrowedUsd: string,
150
148
  borrowLimitUsd: string,
@@ -179,7 +177,6 @@ export interface AaveV3AggregatedPositionData {
179
177
  collRatio: string,
180
178
  borrowLimitWithLtvZeroFallbackUsd: string,
181
179
  safetyRatioWithLtvZeroFallback: string,
182
- safetyRatio: string,
183
180
  netApy: string,
184
181
  incentiveUsd: string,
185
182
  totalInterestUsd: string,
@@ -183,7 +183,6 @@ export interface AaveV4AggregatedPositionData {
183
183
  leftToBorrowUsd: string,
184
184
  ratio: string,
185
185
  collRatio: string,
186
- safetyRatio: string,
187
186
  liqRatio: string,
188
187
  liqPercent: string,
189
188
  leveragedType: LeverageType,
@@ -112,7 +112,6 @@ export interface CompoundAggregatedPositionData {
112
112
  leftToBorrowUsd: string,
113
113
  ratio: string,
114
114
  collRatio: string,
115
- safetyRatio: string,
116
115
  netApy: string,
117
116
  incentiveUsd: string,
118
117
  totalInterestUsd: string,
@@ -133,7 +132,6 @@ export interface CompoundAggregatedPositionData {
133
132
  export interface CompoundPositionData extends MMPositionData {
134
133
  ratio: string,
135
134
  minRatio: string,
136
- safetyRatio?: string,
137
135
  suppliedUsd: string,
138
136
  borrowedUsd: string,
139
137
  borrowLimitUsd: string,
@@ -344,7 +344,6 @@ export interface FluidAggregatedVaultData {
344
344
  merklBorrowIncentives: IncentiveData[],
345
345
  ratio: string,
346
346
  collRatio: string,
347
- safetyRatio: string,
348
347
  minRatio: string,
349
348
  totalInterestUsd: string,
350
349
  leveragedType?: LeverageType,
@@ -26,8 +26,6 @@ export interface LiquityTroveInfo {
26
26
  totalETH: string,
27
27
  totalLUSD: string,
28
28
  minCollateralRatio: number,
29
- // Collateral ratio rebased so 100 sits on `minCollateralRatio` (normalised safety ratio).
30
- safetyRatio: string,
31
29
  priceForRecovery: string,
32
30
  debtInFront: string,
33
31
  exposure: string,
@@ -104,7 +104,6 @@ export interface LiquityV2AggregatedTroveData {
104
104
  liquidationPrice: string,
105
105
  ratio: string,
106
106
  collRatio: string,
107
- safetyRatio: string,
108
107
  exposure: string,
109
108
  }
110
109
 
@@ -113,7 +112,6 @@ export interface LiquityV2TroveData {
113
112
  troveId: string,
114
113
  ratio: string,
115
114
  collRatio: string,
116
- safetyRatio?: string,
117
115
  liqRatio: string,
118
116
  borrowLimitRatio: string,
119
117
  interestRate: string,
@@ -47,8 +47,6 @@ export interface CdpData {
47
47
  debtAssetMarketPrice: string,
48
48
  liquidationPrice: string,
49
49
  ratio: string,
50
- // Collateral ratio rebased so 100 sits on `liqPercent` (normalised safety ratio).
51
- safetyRatio: string,
52
50
  liqRatio: string,
53
51
  liqPercent: number,
54
52
  assetPrice: string,
@@ -206,7 +206,6 @@ export interface MorphoBlueAggregatedPositionData {
206
206
  totalInterestUsd: string,
207
207
  ltv: string,
208
208
  ratio: string,
209
- safetyRatio: string, // borrowLimitUsd / borrowedUsd as a percentage (100 = liquidation)
210
209
  leveragedType: LeverageType,
211
210
  leveragedAsset?: string,
212
211
  currentVolatilePairRatio?: string,
@@ -230,7 +229,6 @@ export interface MorphoBluePositionData {
230
229
  totalInterestUsd: string,
231
230
  ltv: string,
232
231
  ratio: string,
233
- safetyRatio?: string,
234
232
  leveragedType: LeverageType,
235
233
  leveragedAsset?: string,
236
234
  currentVolatilePairRatio?: string,
@@ -191,7 +191,6 @@ export interface MorphoMidnightAggregatedPositionData {
191
191
  ltv: string,
192
192
  ratio: string, // health ratio as a percentage (from MidnightView.ratio, 1e18-scaled)
193
193
  healthRatio: string, // liquidationLimitUsd / borrowedUsd
194
- safetyRatio: string, // borrowLimitUsd / borrowedUsd as a percentage (100 = liquidation)
195
194
  leveragedType: LeverageType,
196
195
  leveragedAsset?: string,
197
196
  currentVolatilePairRatio?: string,
@@ -1,20 +1,16 @@
1
- import {
2
- AaveV2MarketData, AaveV2PositionData, AaveV3MarketData, AaveV3PositionData, AaveVersions,
3
- } from './aave';
4
- import { AaveV4AccountData, AaveV4SpokeData, AaveV4SpokesType } from './aaveV4';
1
+ import { AaveV2PositionData, AaveV3PositionData, AaveVersions } from './aave';
2
+ import { AaveV4AccountData, AaveV4SpokesType } from './aaveV4';
5
3
  import { EthAddress } from './common';
6
- import {
7
- CompoundV2MarketsData, CompoundV2PositionData, CompoundV3MarketsData, CompoundV3PositionData, CompoundVersions,
8
- } from './compound';
9
- import { CrvUSDGlobalMarketData, CrvUSDUserData, CrvUSDVersions } from './curveUsd';
10
- import { FluidMarketData, FluidVaultData } from './fluid';
4
+ import { CompoundV2PositionData, CompoundV3PositionData, CompoundVersions } from './compound';
5
+ import { CrvUSDUserData, CrvUSDVersions } from './curveUsd';
6
+ import { FluidVaultData } from './fluid';
11
7
  import { LiquityTroveInfo } from './liquity';
12
- import { LiquityV2MarketData, LiquityV2TroveData, LiquityV2Versions } from './liquityV2';
13
- import { LlamaLendGlobalMarketData, LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
14
- import { CdpData, IlkInfo } from './maker';
15
- import { MorphoBlueMarketInfo, MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
16
- import { MorphoMidnightMarketInfo, MorphoMidnightPositionData, MorphoMidnightVersions } from './morphoMidnight';
17
- import { SparkMarketsData, SparkPositionData, SparkVersions } from './spark';
8
+ import { LiquityV2TroveData, LiquityV2Versions } from './liquityV2';
9
+ import { LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
10
+ import { CdpData } from './maker';
11
+ import { MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
12
+ import { MorphoMidnightPositionData, MorphoMidnightVersions } from './morphoMidnight';
13
+ import { SparkPositionData, SparkVersions } from './spark';
18
14
 
19
15
  export interface PortfolioProtocolData<T> {
20
16
  error: string,
@@ -66,19 +62,4 @@ export interface PortfolioPositionsDataForAddress {
66
62
 
67
63
  export interface PortfolioPositionsData {
68
64
  [key: EthAddress]: PortfolioPositionsDataForAddress;
69
- }
70
- export interface PortfolioMarketsData {
71
- morphoMarketsData: Record<string, MorphoBlueMarketInfo>;
72
- morphoMidnightMarketsData: Record<string, MorphoMidnightMarketInfo>;
73
- compoundV3MarketsData: Record<string, CompoundV3MarketsData>;
74
- sparkMarketsData: Record<string, SparkMarketsData>;
75
- aaveV3MarketsData: Record<string, AaveV3MarketData>;
76
- aaveV2MarketsData: Record<string, AaveV2MarketData>;
77
- compoundV2MarketsData: Record<string, CompoundV2MarketsData>;
78
- crvUsdMarketsData: Record<string, CrvUSDGlobalMarketData>;
79
- llamaLendMarketsData: Record<string, LlamaLendGlobalMarketData>;
80
- liquityV2MarketsData: Record<string, LiquityV2MarketData>;
81
- aaveV4SpokesData: Record<string, AaveV4SpokeData>;
82
- fluidMarketsData: Record<string, FluidMarketData>;
83
- makerMarketsData: Record<string, IlkInfo>;
84
- }
65
+ }
@@ -99,7 +99,6 @@ export interface SparkAggregatedPositionData {
99
99
  leftToBorrowUsd: string,
100
100
  ratio: string,
101
101
  collRatio: string,
102
- safetyRatio: string,
103
102
  netApy: string,
104
103
  incentiveUsd: string,
105
104
  totalInterestUsd: string,
@@ -120,7 +119,6 @@ export interface SparkPositionData extends MMPositionData {
120
119
  ratio: string,
121
120
  minRatio: string,
122
121
  collRatio: string,
123
- safetyRatio?: string,
124
122
  suppliedUsd: string,
125
123
  borrowedUsd: string,
126
124
  borrowLimitUsd: string,
@@ -1 +0,0 @@
1
- export declare const MakerActiveIlks: string[];
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MakerActiveIlks = void 0;
4
- exports.MakerActiveIlks = [
5
- 'ETH-A',
6
- 'ETH-B',
7
- 'ETH-C',
8
- 'WSTETH-A',
9
- 'WSTETH-B',
10
- 'WBTC-A',
11
- 'WBTC-B',
12
- 'WBTC-C',
13
- ];
@@ -1 +0,0 @@
1
- export declare const MakerActiveIlks: string[];
@@ -1,10 +0,0 @@
1
- export const MakerActiveIlks = [
2
- 'ETH-A',
3
- 'ETH-B',
4
- 'ETH-C',
5
- 'WSTETH-A',
6
- 'WSTETH-B',
7
- 'WBTC-A',
8
- 'WBTC-B',
9
- 'WBTC-C',
10
- ];
@@ -1,10 +0,0 @@
1
- export const MakerActiveIlks: string[] = [
2
- 'ETH-A',
3
- 'ETH-B',
4
- 'ETH-C',
5
- 'WSTETH-A',
6
- 'WSTETH-B',
7
- 'WBTC-A',
8
- 'WBTC-B',
9
- 'WBTC-C',
10
- ];