@defisaver/positions-sdk 2.1.46-aave-dev → 2.1.46-aave-v3-6-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.
@@ -67,13 +67,17 @@ exports.aaveAnyGetSuppliableAsCollAssets = aaveAnyGetSuppliableAsCollAssets;
67
67
  const aaveAnyGetEmodeMutableProps = ({ eModeCategory, eModeCategoriesData, assetsData, }, _asset) => {
68
68
  const asset = (0, utils_1.getNativeAssetFromWrapped)(_asset);
69
69
  const assetData = assetsData[asset];
70
- const eModeCategoryData = (eModeCategoriesData === null || eModeCategoriesData === void 0 ? void 0 : eModeCategoriesData[eModeCategory]) || { collateralAssets: [], collateralFactor: '0', liquidationRatio: '0' };
70
+ const eModeCategoryData = (eModeCategoriesData === null || eModeCategoriesData === void 0 ? void 0 : eModeCategoriesData[eModeCategory]) || {
71
+ collateralAssets: [], ltvZeroAssets: [], collateralFactor: '0', liquidationRatio: '0',
72
+ };
71
73
  if (eModeCategory === 0
72
74
  || !eModeCategoryData.collateralAssets.includes(asset)
73
75
  || new decimal_js_1.default(eModeCategoryData.collateralFactor || 0).eq(0)) {
74
76
  const { liquidationRatio, collateralFactor } = assetData;
75
77
  return ({ liquidationRatio, collateralFactor });
76
78
  }
79
+ if (eModeCategoryData.ltvZeroAssets.includes(asset))
80
+ return ({ liquidationRatio: '0', collateralFactor: '0' });
77
81
  const { liquidationRatio, collateralFactor } = eModeCategoryData;
78
82
  return ({ liquidationRatio, collateralFactor });
79
83
  };
@@ -87,6 +87,7 @@ const _getSparkMarketsData = (provider, network, selectedMarket) => __awaiter(vo
87
87
  collateralFactor: new decimal_js_1.default(market.ltv).div(10000).toString(),
88
88
  collateralAssets: eModeCategoriesData[emodeCategoryId] ? [...eModeCategoriesData[emodeCategoryId].collateralAssets, selectedMarket.assets[i]] : [selectedMarket.assets[i]],
89
89
  borrowAssets: eModeCategoriesData[emodeCategoryId] ? [...eModeCategoriesData[emodeCategoryId].borrowAssets, selectedMarket.assets[i]] : [selectedMarket.assets[i]],
90
+ ltvZeroAssets: [],
90
91
  };
91
92
  return ({
92
93
  symbol: selectedMarket.assets[i],
@@ -38,6 +38,8 @@ export interface EModeCategoryData {
38
38
  collateralBitmap?: string;
39
39
  collateralAssets: string[];
40
40
  borrowAssets: string[];
41
+ ltvzeroBitmap?: string;
42
+ ltvZeroAssets: string[];
41
43
  }
42
44
  export interface EModeCategoryDataMapping {
43
45
  enteringTerms: boolean[];
@@ -63,21 +63,31 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
63
63
  getMeritCampaigns(network, market.value),
64
64
  ]);
65
65
  isBorrowAllowed = isLayer2Network(network) ? isBorrowAllowed : true;
66
+ // same break logic as view contract
67
+ let missCounter = 0;
66
68
  const eModeCategoriesData = {};
67
69
  for (let i = 0; i < eModesInfo.length; i++) {
68
- if (!eModesInfo[i].label)
69
- break;
70
- eModeCategoriesData[i + 1] = {
71
- label: eModesInfo[i].label,
72
- id: i + 1,
73
- liquidationBonus: new Dec(eModesInfo[i].liquidationBonus).div(10000).toString(),
74
- liquidationRatio: new Dec(eModesInfo[i].liquidationThreshold).div(10000).toString(),
75
- collateralFactor: new Dec(eModesInfo[i].ltv).div(10000).toString(),
76
- borrowableBitmap: eModesInfo[i].borrowableBitmap.toString(),
77
- collateralBitmap: eModesInfo[i].collateralBitmap.toString(),
78
- borrowAssets: [],
79
- collateralAssets: [],
80
- };
70
+ if (eModesInfo[i].liquidationThreshold !== 0) {
71
+ eModeCategoriesData[i + 1] = {
72
+ label: eModesInfo[i].label,
73
+ id: i + 1,
74
+ liquidationBonus: new Dec(eModesInfo[i].liquidationBonus).div(10000).toString(),
75
+ liquidationRatio: new Dec(eModesInfo[i].liquidationThreshold).div(10000).toString(),
76
+ collateralFactor: new Dec(eModesInfo[i].ltv).div(10000).toString(),
77
+ borrowableBitmap: eModesInfo[i].borrowableBitmap.toString(),
78
+ collateralBitmap: eModesInfo[i].collateralBitmap.toString(),
79
+ ltvzeroBitmap: eModesInfo[i].ltvzeroBitmap.toString(),
80
+ borrowAssets: [],
81
+ collateralAssets: [],
82
+ ltvZeroAssets: [],
83
+ };
84
+ missCounter = 0;
85
+ }
86
+ else {
87
+ ++missCounter;
88
+ if (missCounter > 2)
89
+ break;
90
+ }
81
91
  }
82
92
  if (networksWithIncentives.includes(network) && rewardInfo) {
83
93
  rewardInfo = rewardInfo.reduce((all, _market) => {
@@ -95,6 +105,8 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
95
105
  eModeCategoriesData[eModeIndex].collateralAssets.push(symbol);
96
106
  if (isEnabledOnBitmap(Number(eModeCategoriesData[eModeIndex].borrowableBitmap), Number(tokenMarket.assetId)))
97
107
  eModeCategoriesData[eModeIndex].borrowAssets.push(symbol);
108
+ if (isEnabledOnBitmap(Number(eModeCategoriesData[eModeIndex].ltvzeroBitmap), Number(tokenMarket.assetId)))
109
+ eModeCategoriesData[eModeIndex].ltvZeroAssets.push(symbol);
98
110
  }
99
111
  const borrowCap = tokenMarket.borrowCap.toString();
100
112
  const borrowCapInWei = new Dec(assetAmountInWei(borrowCap, symbol));
@@ -279,6 +291,7 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
279
291
  collateralFactor: '0',
280
292
  collateralAssets: assetsData.map((a) => a.symbol),
281
293
  borrowAssets: assetsData.map((a) => a.symbol),
294
+ ltvZeroAssets: [],
282
295
  };
283
296
  return { assetsData: payload, eModeCategoriesData };
284
297
  });