@defisaver/positions-sdk 2.1.47 → 2.1.48

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.
@@ -54,13 +54,17 @@ export const aaveAnyGetSuppliableAsCollAssets = (_a) => {
54
54
  export const aaveAnyGetEmodeMutableProps = ({ eModeCategory, eModeCategoriesData, assetsData, }, _asset) => {
55
55
  const asset = getNativeAssetFromWrapped(_asset);
56
56
  const assetData = assetsData[asset];
57
- const eModeCategoryData = (eModeCategoriesData === null || eModeCategoriesData === void 0 ? void 0 : eModeCategoriesData[eModeCategory]) || { collateralAssets: [], collateralFactor: '0', liquidationRatio: '0' };
57
+ const eModeCategoryData = (eModeCategoriesData === null || eModeCategoriesData === void 0 ? void 0 : eModeCategoriesData[eModeCategory]) || {
58
+ collateralAssets: [], ltvZeroAssets: [], collateralFactor: '0', liquidationRatio: '0',
59
+ };
58
60
  if (eModeCategory === 0
59
61
  || !eModeCategoryData.collateralAssets.includes(asset)
60
62
  || new Dec(eModeCategoryData.collateralFactor || 0).eq(0)) {
61
63
  const { liquidationRatio, collateralFactor } = assetData;
62
64
  return ({ liquidationRatio, collateralFactor });
63
65
  }
66
+ if (eModeCategoryData.ltvZeroAssets.includes(asset))
67
+ return ({ liquidationRatio: '0', collateralFactor: '0' });
64
68
  const { liquidationRatio, collateralFactor } = eModeCategoryData;
65
69
  return ({ liquidationRatio, collateralFactor });
66
70
  };
@@ -80,6 +80,7 @@ export const _getSparkMarketsData = (provider, network, selectedMarket) => __awa
80
80
  collateralFactor: new Dec(market.ltv).div(10000).toString(),
81
81
  collateralAssets: eModeCategoriesData[emodeCategoryId] ? [...eModeCategoriesData[emodeCategoryId].collateralAssets, selectedMarket.assets[i]] : [selectedMarket.assets[i]],
82
82
  borrowAssets: eModeCategoriesData[emodeCategoryId] ? [...eModeCategoriesData[emodeCategoryId].borrowAssets, selectedMarket.assets[i]] : [selectedMarket.assets[i]],
83
+ ltvZeroAssets: [],
83
84
  };
84
85
  return ({
85
86
  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[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.1.47",
3
+ "version": "2.1.48",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -84,7 +84,6 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
84
84
  const aaveIncentivesContract = AaveIncentiveDataProviderV3ContractViem(provider, network);
85
85
  const marketAddress = market.providerAddress;
86
86
  const networksWithIncentives = [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Opt, NetworkNumber.Linea, NetworkNumber.Plasma];
87
-
88
87
  // eslint-disable-next-line prefer-const
89
88
  let [loanInfo, eModesInfo, isBorrowAllowed, rewardInfo, merkleRewardsMap, meritRewardsMap] = await Promise.all([
90
89
  loanInfoContract.read.getFullTokensInfo([marketAddress, _addresses as EthAddress[]], setViemBlockNumber(blockNumber)),
@@ -96,20 +95,29 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
96
95
  ]);
97
96
  isBorrowAllowed = isLayer2Network(network) ? isBorrowAllowed : true;
98
97
 
98
+ // same break logic as view contract
99
+ let missCounter = 0;
99
100
  const eModeCategoriesData: EModeCategoriesData = {};
100
101
  for (let i = 0; i < eModesInfo.length; i++) {
101
- if (!eModesInfo[i].label) break;
102
- eModeCategoriesData[i + 1] = {
103
- label: eModesInfo[i].label,
104
- id: i + 1,
105
- liquidationBonus: new Dec(eModesInfo[i].liquidationBonus).div(10000).toString(),
106
- liquidationRatio: new Dec(eModesInfo[i].liquidationThreshold).div(10000).toString(),
107
- collateralFactor: new Dec(eModesInfo[i].ltv).div(10000).toString(),
108
- borrowableBitmap: eModesInfo[i].borrowableBitmap.toString(),
109
- collateralBitmap: eModesInfo[i].collateralBitmap.toString(),
110
- borrowAssets: [],
111
- collateralAssets: [],
112
- };
102
+ if (eModesInfo[i].liquidationThreshold !== 0) {
103
+ eModeCategoriesData[i + 1] = {
104
+ label: eModesInfo[i].label,
105
+ id: i + 1,
106
+ liquidationBonus: new Dec(eModesInfo[i].liquidationBonus).div(10000).toString(),
107
+ liquidationRatio: new Dec(eModesInfo[i].liquidationThreshold).div(10000).toString(),
108
+ collateralFactor: new Dec(eModesInfo[i].ltv).div(10000).toString(),
109
+ borrowableBitmap: eModesInfo[i].borrowableBitmap.toString(),
110
+ collateralBitmap: eModesInfo[i].collateralBitmap.toString(),
111
+ ltvzeroBitmap: eModesInfo[i].ltvzeroBitmap.toString(),
112
+ borrowAssets: [],
113
+ collateralAssets: [],
114
+ ltvZeroAssets: [],
115
+ };
116
+ missCounter = 0;
117
+ } else {
118
+ ++missCounter;
119
+ if (missCounter > 2) break;
120
+ }
113
121
  }
114
122
 
115
123
  if (networksWithIncentives.includes(network) && rewardInfo) {
@@ -128,6 +136,7 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
128
136
  for (const eModeIndex in eModeCategoriesData) {
129
137
  if (isEnabledOnBitmap(Number(eModeCategoriesData[eModeIndex].collateralBitmap), Number(tokenMarket.assetId))) eModeCategoriesData[eModeIndex].collateralAssets.push(symbol);
130
138
  if (isEnabledOnBitmap(Number(eModeCategoriesData[eModeIndex].borrowableBitmap), Number(tokenMarket.assetId))) eModeCategoriesData[eModeIndex].borrowAssets.push(symbol);
139
+ if (isEnabledOnBitmap(Number(eModeCategoriesData[eModeIndex].ltvzeroBitmap), Number(tokenMarket.assetId))) eModeCategoriesData[eModeIndex].ltvZeroAssets.push(symbol);
131
140
  }
132
141
 
133
142
  const borrowCap = tokenMarket.borrowCap.toString();
@@ -326,6 +335,7 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
326
335
  collateralFactor: '0',
327
336
  collateralAssets: assetsData.map((a) => a.symbol),
328
337
  borrowAssets: assetsData.map((a) => a.symbol),
338
+ ltvZeroAssets: [],
329
339
  };
330
340
 
331
341
  return { assetsData: payload, eModeCategoriesData };