@defisaver/positions-sdk 0.0.88 → 0.0.89

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.
@@ -58,18 +58,10 @@ const getCompoundV3MarketsData = (web3, network, selectedMarket, defaultWeb3) =>
58
58
  coll.priceAlternative = (0, tokens_1.assetAmountInEth)(priceAlternative, 'wstETH');
59
59
  // const stEthMarket = markets.find(({ symbol }) => symbol === 'stETH');
60
60
  // eslint-disable-next-line no-await-in-loop
61
- coll.incentiveSupplyApy = yield (0, staking_1.getStETHApr)(defaultWeb3);
62
- coll.incentiveSupplyToken = 'wstETH';
63
61
  }
64
- if (coll.symbol === 'cbETH') {
65
- // eslint-disable-next-line no-await-in-loop
66
- coll.incentiveSupplyApy = yield (0, staking_1.getCbETHApr)(defaultWeb3);
67
- coll.incentiveSupplyToken = 'cbETH';
68
- }
69
- if (coll.symbol === 'rETH') {
70
- // eslint-disable-next-line no-await-in-loop
71
- coll.incentiveSupplyApy = yield (0, staking_1.getREthApr)(defaultWeb3);
72
- coll.incentiveSupplyToken = 'rETH';
62
+ if (staking_1.STAKING_ASSETS.includes(coll.symbol)) {
63
+ coll.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(coll.symbol, defaultWeb3);
64
+ coll.incentiveSupplyToken = coll.symbol;
73
65
  }
74
66
  }
75
67
  const base = (0, compoundHelpers_1.formatBaseData)(data[0].baseToken, network, baseAssetPrice);
@@ -216,17 +216,9 @@ const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainnetWeb3)
216
216
  isolationModeBorrowingEnabled: false,
217
217
  isFlashLoanEnabled: false,
218
218
  };
219
- if (symbol === 'wstETH') {
220
- data.incentiveSupplyApy = yield (0, staking_1.getStETHApr)(mainnetWeb3);
221
- data.incentiveSupplyToken = symbol;
222
- }
223
- if (symbol === 'cbETH' && !(0, utils_1.isLayer2Network)(network)) {
224
- data.incentiveSupplyApy = yield (0, staking_1.getCbETHApr)(mainnetWeb3);
225
- data.incentiveSupplyToken = symbol;
226
- }
227
- if (symbol === 'rETH') {
228
- data.incentiveSupplyApy = yield (0, staking_1.getREthApr)(mainnetWeb3);
229
- data.incentiveSupplyToken = symbol;
219
+ if (staking_1.STAKING_ASSETS.includes(data.symbol)) {
220
+ data.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(data.symbol, mainnetWeb3);
221
+ data.incentiveSupplyToken = data.symbol;
230
222
  }
231
223
  if (data.symbol === 'sDAI') {
232
224
  data.incentiveSupplyApy = yield (0, dsrService_1.getDsrApy)(web3, network);
@@ -126,17 +126,9 @@ const getSparkMarketsData = (web3, network, selectedMarket, mainnetWeb3) => __aw
126
126
  yield Promise.all(assetsData.map((market) => __awaiter(void 0, void 0, void 0, function* () {
127
127
  /* eslint-disable no-param-reassign */
128
128
  const rewardForMarket = rewardInfo[market.underlyingTokenAddress];
129
- if (market.symbol === 'wstETH') {
130
- market.incentiveSupplyApy = yield (0, staking_1.getStETHApr)(mainnetWeb3);
131
- market.incentiveSupplyToken = 'wstETH';
132
- }
133
- if (market.symbol === 'cbETH' && !(0, utils_1.isLayer2Network)(network)) {
134
- market.incentiveSupplyApy = yield (0, staking_1.getCbETHApr)(mainnetWeb3);
135
- market.incentiveSupplyToken = 'cbETH';
136
- }
137
- if (market.symbol === 'rETH') {
138
- market.incentiveSupplyApy = yield (0, staking_1.getREthApr)(mainnetWeb3);
139
- market.incentiveSupplyToken = 'rETH';
129
+ if (staking_1.STAKING_ASSETS.includes(market.symbol)) {
130
+ market.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(market.symbol, mainnetWeb3);
131
+ market.incentiveSupplyToken = market.symbol;
140
132
  }
141
133
  if (market.symbol === 'sDAI') {
142
134
  market.incentiveSupplyApy = yield (0, dsrService_1.getDsrApy)(web3, network);
@@ -11,7 +11,7 @@ import Dec from 'decimal.js';
11
11
  import { assetAmountInEth, assetAmountInWei, getAssetInfo, getAssetInfoByAddress, } from '@defisaver/tokens';
12
12
  import { CompV3ViewContract } from '../contracts';
13
13
  import { multicall } from '../multicall';
14
- import { getCbETHApr, getREthApr, getStETHApr, getStETHByWstETHMultiple, getWstETHByStETH, } from '../staking';
14
+ import { getStakingApy, getStETHByWstETHMultiple, getWstETHByStETH, STAKING_ASSETS, } from '../staking';
15
15
  import { wethToEth } from '../services/utils';
16
16
  import { ZERO_ADDRESS } from '../constants';
17
17
  import { calculateBorrowingAssetLimit } from '../moneymarket';
@@ -52,18 +52,10 @@ export const getCompoundV3MarketsData = (web3, network, selectedMarket, defaultW
52
52
  coll.priceAlternative = assetAmountInEth(priceAlternative, 'wstETH');
53
53
  // const stEthMarket = markets.find(({ symbol }) => symbol === 'stETH');
54
54
  // eslint-disable-next-line no-await-in-loop
55
- coll.incentiveSupplyApy = yield getStETHApr(defaultWeb3);
56
- coll.incentiveSupplyToken = 'wstETH';
57
55
  }
58
- if (coll.symbol === 'cbETH') {
59
- // eslint-disable-next-line no-await-in-loop
60
- coll.incentiveSupplyApy = yield getCbETHApr(defaultWeb3);
61
- coll.incentiveSupplyToken = 'cbETH';
62
- }
63
- if (coll.symbol === 'rETH') {
64
- // eslint-disable-next-line no-await-in-loop
65
- coll.incentiveSupplyApy = yield getREthApr(defaultWeb3);
66
- coll.incentiveSupplyToken = 'rETH';
56
+ if (STAKING_ASSETS.includes(coll.symbol)) {
57
+ coll.incentiveSupplyApy = yield getStakingApy(coll.symbol, defaultWeb3);
58
+ coll.incentiveSupplyToken = coll.symbol;
67
59
  }
68
60
  }
69
61
  const base = formatBaseData(data[0].baseToken, network, baseAssetPrice);
@@ -13,10 +13,10 @@ import PoolInterestRates from '@morpho-org/morpho-aave-v3-sdk/lib/maths/PoolInte
13
13
  import P2PInterestRates from '@morpho-org/morpho-aave-v3-sdk/lib/maths/P2PInterestRates';
14
14
  import { BigNumber } from '@ethersproject/bignumber';
15
15
  import Dec from 'decimal.js';
16
- import { ethToWeth, ethToWethByAddress, getAbiItem, isLayer2Network, wethToEthByAddress, } from '../services/utils';
16
+ import { ethToWeth, ethToWethByAddress, getAbiItem, wethToEthByAddress, } from '../services/utils';
17
17
  import { createContractWrapper, getConfigContractAbi, getConfigContractAddress, } from '../contracts';
18
18
  import { multicall } from '../multicall';
19
- import { getCbETHApr, getREthApr, getStETHApr } from '../staking';
19
+ import { getStakingApy, STAKING_ASSETS } from '../staking';
20
20
  import { getDsrApy } from '../services/dsrService';
21
21
  import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
22
22
  import { EMPTY_AAVE_DATA } from '../aaveV3';
@@ -210,17 +210,9 @@ export const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainne
210
210
  isolationModeBorrowingEnabled: false,
211
211
  isFlashLoanEnabled: false,
212
212
  };
213
- if (symbol === 'wstETH') {
214
- data.incentiveSupplyApy = yield getStETHApr(mainnetWeb3);
215
- data.incentiveSupplyToken = symbol;
216
- }
217
- if (symbol === 'cbETH' && !isLayer2Network(network)) {
218
- data.incentiveSupplyApy = yield getCbETHApr(mainnetWeb3);
219
- data.incentiveSupplyToken = symbol;
220
- }
221
- if (symbol === 'rETH') {
222
- data.incentiveSupplyApy = yield getREthApr(mainnetWeb3);
223
- data.incentiveSupplyToken = symbol;
213
+ if (STAKING_ASSETS.includes(data.symbol)) {
214
+ data.incentiveSupplyApy = yield getStakingApy(data.symbol, mainnetWeb3);
215
+ data.incentiveSupplyToken = data.symbol;
224
216
  }
225
217
  if (data.symbol === 'sDAI') {
226
218
  data.incentiveSupplyApy = yield getDsrApy(web3, network);
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import Dec from 'decimal.js';
11
11
  import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tokens';
12
- import { ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress, } from '../services/utils';
13
- import { calculateNetApy, getCbETHApr, getREthApr, getStETHApr, } from '../staking';
12
+ import { ethToWeth, getAbiItem, wethToEth, wethToEthByAddress, } from '../services/utils';
13
+ import { calculateNetApy, getStakingApy, STAKING_ASSETS, } from '../staking';
14
14
  import { getDsrApy } from '../services/dsrService';
15
15
  import { SparkIncentiveDataProviderContract, SparkViewContract, getConfigContractAbi, createContractWrapper, } from '../contracts';
16
16
  import { multicall } from '../multicall';
@@ -119,17 +119,9 @@ export const getSparkMarketsData = (web3, network, selectedMarket, mainnetWeb3)
119
119
  yield Promise.all(assetsData.map((market) => __awaiter(void 0, void 0, void 0, function* () {
120
120
  /* eslint-disable no-param-reassign */
121
121
  const rewardForMarket = rewardInfo[market.underlyingTokenAddress];
122
- if (market.symbol === 'wstETH') {
123
- market.incentiveSupplyApy = yield getStETHApr(mainnetWeb3);
124
- market.incentiveSupplyToken = 'wstETH';
125
- }
126
- if (market.symbol === 'cbETH' && !isLayer2Network(network)) {
127
- market.incentiveSupplyApy = yield getCbETHApr(mainnetWeb3);
128
- market.incentiveSupplyToken = 'cbETH';
129
- }
130
- if (market.symbol === 'rETH') {
131
- market.incentiveSupplyApy = yield getREthApr(mainnetWeb3);
132
- market.incentiveSupplyToken = 'rETH';
122
+ if (STAKING_ASSETS.includes(market.symbol)) {
123
+ market.incentiveSupplyApy = yield getStakingApy(market.symbol, mainnetWeb3);
124
+ market.incentiveSupplyToken = market.symbol;
133
125
  }
134
126
  if (market.symbol === 'sDAI') {
135
127
  market.incentiveSupplyApy = yield getDsrApy(web3, network);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "0.0.88",
3
+ "version": "0.0.89",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -12,7 +12,7 @@ import {
12
12
  Blockish, EthAddress, NetworkNumber, PositionBalances,
13
13
  } from '../types/common';
14
14
  import {
15
- getCbETHApr, getREthApr, getStETHApr, getStETHByWstETHMultiple, getWstETHByStETH,
15
+ getStakingApy, getStETHByWstETHMultiple, getWstETHByStETH, STAKING_ASSETS,
16
16
  } from '../staking';
17
17
  import { wethToEth } from '../services/utils';
18
18
  import { ZERO_ADDRESS } from '../constants';
@@ -57,18 +57,10 @@ export const getCompoundV3MarketsData = async (web3: Web3, network: NetworkNumbe
57
57
  coll.priceAlternative = assetAmountInEth(priceAlternative, 'wstETH');
58
58
  // const stEthMarket = markets.find(({ symbol }) => symbol === 'stETH');
59
59
  // eslint-disable-next-line no-await-in-loop
60
- coll.incentiveSupplyApy = await getStETHApr(defaultWeb3);
61
- coll.incentiveSupplyToken = 'wstETH';
62
60
  }
63
- if (coll.symbol === 'cbETH') {
64
- // eslint-disable-next-line no-await-in-loop
65
- coll.incentiveSupplyApy = await getCbETHApr(defaultWeb3);
66
- coll.incentiveSupplyToken = 'cbETH';
67
- }
68
- if (coll.symbol === 'rETH') {
69
- // eslint-disable-next-line no-await-in-loop
70
- coll.incentiveSupplyApy = await getREthApr(defaultWeb3);
71
- coll.incentiveSupplyToken = 'rETH';
61
+ if (STAKING_ASSETS.includes(coll.symbol)) {
62
+ coll.incentiveSupplyApy = await getStakingApy(coll.symbol, defaultWeb3);
63
+ coll.incentiveSupplyToken = coll.symbol;
72
64
  }
73
65
  }
74
66
  const base = formatBaseData(data[0].baseToken, network, baseAssetPrice);
@@ -271,4 +263,4 @@ export const getCompoundV3FullPositionData = async (web3: Web3, network: Network
271
263
  const marketData = await getCompoundV3MarketsData(web3, network, selectedMarket, mainnetWeb3);
272
264
  const positionData = await getCompoundV3AccountData(web3, network, address, proxyAddress, { selectedMarket, assetsData: marketData.assetsData });
273
265
  return positionData;
274
- };
266
+ };
@@ -19,7 +19,7 @@ import {
19
19
  getConfigContractAddress,
20
20
  } from '../contracts';
21
21
  import { multicall } from '../multicall';
22
- import { getCbETHApr, getREthApr, getStETHApr } from '../staking';
22
+ import { getStakingApy, STAKING_ASSETS} from '../staking';
23
23
  import {
24
24
  MorphoAaveV3AssetData, MorphoAaveV3AssetsData, MorphoAaveV3MarketData, MorphoAaveV3MarketInfo, MorphoAaveV3PositionData,
25
25
  } from '../types';
@@ -304,17 +304,9 @@ export const getMorphoAaveV3MarketsData = async (web3: Web3, network: NetworkNum
304
304
  isFlashLoanEnabled: false,
305
305
  };
306
306
 
307
- if (symbol === 'wstETH') {
308
- data.incentiveSupplyApy = await getStETHApr(mainnetWeb3);
309
- data.incentiveSupplyToken = symbol;
310
- }
311
- if (symbol === 'cbETH' && !isLayer2Network(network)) {
312
- data.incentiveSupplyApy = await getCbETHApr(mainnetWeb3);
313
- data.incentiveSupplyToken = symbol;
314
- }
315
- if (symbol === 'rETH') {
316
- data.incentiveSupplyApy = await getREthApr(mainnetWeb3);
317
- data.incentiveSupplyToken = symbol;
307
+ if (STAKING_ASSETS.includes(data.symbol)) {
308
+ data.incentiveSupplyApy = await getStakingApy(data.symbol, mainnetWeb3);
309
+ data.incentiveSupplyToken = data.symbol;
318
310
  }
319
311
  if (data.symbol === 'sDAI') {
320
312
  data.incentiveSupplyApy = await getDsrApy(web3, network);
@@ -8,7 +8,7 @@ import {
8
8
  ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress,
9
9
  } from '../services/utils';
10
10
  import {
11
- calculateNetApy, getCbETHApr, getREthApr, getStETHApr,
11
+ calculateNetApy, getStakingApy, STAKING_ASSETS,
12
12
  } from '../staking';
13
13
  import { getDsrApy } from '../services/dsrService';
14
14
  import {
@@ -148,19 +148,9 @@ export const getSparkMarketsData = async (web3: Web3, network: NetworkNumber, se
148
148
  await Promise.all(assetsData.map(async (market) => {
149
149
  /* eslint-disable no-param-reassign */
150
150
  const rewardForMarket = (rewardInfo as any)[market.underlyingTokenAddress];
151
- if (market.symbol === 'wstETH') {
152
- market.incentiveSupplyApy = await getStETHApr(mainnetWeb3);
153
- market.incentiveSupplyToken = 'wstETH';
154
- }
155
-
156
- if (market.symbol === 'cbETH' && !isLayer2Network(network)) {
157
- market.incentiveSupplyApy = await getCbETHApr(mainnetWeb3);
158
- market.incentiveSupplyToken = 'cbETH';
159
- }
160
-
161
- if (market.symbol === 'rETH') {
162
- market.incentiveSupplyApy = await getREthApr(mainnetWeb3);
163
- market.incentiveSupplyToken = 'rETH';
151
+ if (STAKING_ASSETS.includes(market.symbol)) {
152
+ market.incentiveSupplyApy = await getStakingApy(market.symbol, mainnetWeb3);
153
+ market.incentiveSupplyToken = market.symbol;
164
154
  }
165
155
 
166
156
  if (market.symbol === 'sDAI') {