@defisaver/positions-sdk 2.1.47 → 2.1.49-pt-apr-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.
@@ -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
  };
@@ -15,7 +15,7 @@ export const aaveV3AssetsDefaultMarketOpt = [
15
15
  export const aaveV3AssetsDefaultMarketArb = ['DAI', 'LINK', 'USDC.e', 'WBTC', 'ETH', 'USDT', 'AAVE', 'EURS', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC', 'FRAX', 'ARB', 'weETH', 'GHO', 'ezETH', 'rsETH', 'tBTC'];
16
16
  export const aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH', 'USDC', 'weETH', 'cbBTC', 'ezETH', 'GHO', 'wrsETH', 'LBTC', 'EURC', 'AAVE', 'tBTC'];
17
17
  export const aaveV3AssetsDefaultMarketLinea = ['ETH', 'USDC', 'weETH', 'ezETH', 'USDT', 'wstETH', 'wrsETH', 'WBTC', 'mUSD'];
18
- export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL'];
18
+ export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr'];
19
19
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
20
20
  export const aaveV3AssetsDefaultMarket = {
21
21
  [NetworkNumber.Eth]: aaveV3AssetsDefaultMarketEth,
@@ -20,7 +20,7 @@ export const STABLE_ASSETS = [
20
20
  'DAI', 'USDC', 'USDT', 'TUSD', 'USDP', 'GUSD', 'BUSD', 'SUSD', 'FRAX', 'LUSD', 'USDC.e', 'GHO', 'sDAI', 'USDA',
21
21
  'USDe', 'sUSDe', 'USDS', 'sUSDS', 'USR', 'EURC', 'BOLD', 'BOLD Legacy', 'RLUSD', 'PT sUSDe July', 'PT eUSDe May',
22
22
  'USDtb', 'eUSDe', 'PT USDe July', 'PT eUSDe Aug', 'PT sUSDe Sep', 'PT USDe Sep', 'PT sUSDe Nov', 'PT USDe Nov', 'PT sUSDe Jan', 'PT USDe Jan',
23
- 'PT sUSDe Feb', 'PT USDe Feb',
23
+ 'PT sUSDe Feb', 'PT USDe Feb', 'PT USDe Apr', 'PT sUSDe Apr',
24
24
  ];
25
25
  export const isLeveragedPos = (usedAssets, dustLimit = 5) => {
26
26
  let borrowUnstable = 0;
@@ -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],
@@ -66,7 +66,7 @@ export const STAKING_ASSETS = [
66
66
  'cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH',
67
67
  'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS', 'tETH', 'PT sUSDe Sep', 'PT USDe Sep',
68
68
  'PT sUSDe Nov', 'PT USDe Nov', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'syrupUSDC', 'wstUSR',
69
- 'PT sUSDe Feb', 'PT USDe Feb',
69
+ 'PT sUSDe Feb', 'PT USDe Feb', 'PT USDe Apr', 'PT sUSDe Apr',
70
70
  ];
71
71
  export const getStakingApy = memoize((asset_1, ...args_1) => __awaiter(void 0, [asset_1, ...args_1], void 0, function* (asset, network = NetworkNumber.Eth) {
72
72
  try {
@@ -130,6 +130,10 @@ export const getStakingApy = memoize((asset_1, ...args_1) => __awaiter(void 0, [
130
130
  return yield getApyFromDfsApi('PT sUSDe Feb', network);
131
131
  if (asset === 'PT USDe Feb')
132
132
  return yield getApyFromDfsApi('PT USDe Feb', network);
133
+ if (asset === 'PT sUSDe Apr')
134
+ return yield getApyFromDfsApi('PT sUSDe Apr', network);
135
+ if (asset === 'PT USDe Apr')
136
+ return yield getApyFromDfsApi('PT USDe Apr', network);
133
137
  }
134
138
  catch (e) {
135
139
  console.error(`Failed to fetch APY for ${asset}`);
@@ -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.49-pt-apr-dev",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -21,7 +21,7 @@
21
21
  "author": "",
22
22
  "license": "ISC",
23
23
  "dependencies": {
24
- "@defisaver/tokens": "^1.7.18",
24
+ "@defisaver/tokens": "1.7.19-pt-apr-1-dev",
25
25
  "@types/lodash": "^4.17.15",
26
26
  "@types/memoizee": "^0.4.12",
27
27
  "decimal.js": "^10.6.0",
@@ -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 };