@defisaver/positions-sdk 0.0.87 → 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.
- package/README.md +63 -63
- package/cjs/compoundV3/index.js +3 -11
- package/cjs/markets/spark/marketAssets.js +1 -1
- package/cjs/morphoAaveV3/index.js +3 -11
- package/cjs/spark/index.js +3 -11
- package/esm/compoundV3/index.js +4 -12
- package/esm/markets/spark/marketAssets.js +1 -1
- package/esm/morphoAaveV3/index.js +5 -13
- package/esm/spark/index.js +5 -13
- package/package.json +40 -40
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +558 -558
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +219 -219
- package/src/compoundV3/index.ts +266 -274
- package/src/config/contracts.js +848 -848
- package/src/constants/index.ts +5 -5
- package/src/contracts.ts +128 -128
- package/src/curveUsd/index.ts +229 -229
- package/src/exchange/index.ts +17 -17
- package/src/helpers/aaveHelpers/index.ts +134 -134
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +181 -181
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/index.ts +7 -7
- package/src/helpers/llamaLendHelpers/index.ts +45 -45
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +56 -56
- package/src/helpers/sparkHelpers/index.ts +106 -106
- package/src/index.ts +46 -46
- package/src/liquity/index.ts +116 -116
- package/src/llamaLend/index.ts +268 -268
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +80 -80
- package/src/markets/aave/marketAssets.ts +25 -25
- package/src/markets/compound/index.ts +142 -142
- package/src/markets/compound/marketsAssets.ts +50 -50
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/index.ts +5 -5
- package/src/markets/llamaLend/contractAddresses.ts +95 -95
- package/src/markets/llamaLend/index.ts +150 -150
- package/src/markets/morphoBlue/index.ts +561 -561
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +76 -76
- package/src/morphoAaveV2/index.ts +256 -256
- package/src/morphoAaveV3/index.ts +612 -620
- package/src/morphoBlue/index.ts +162 -162
- package/src/multicall/index.ts +22 -22
- package/src/services/dsrService.ts +15 -15
- package/src/services/priceService.ts +21 -21
- package/src/services/utils.ts +51 -51
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +424 -434
- package/src/staking/staking.ts +186 -186
- package/src/types/aave.ts +256 -256
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +128 -128
- package/src/types/curveUsd.ts +118 -118
- package/src/types/index.ts +8 -8
- package/src/types/liquity.ts +30 -30
- package/src/types/llamaLend.ts +143 -143
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +136 -136
- package/src/types/spark.ts +106 -106
package/README.md
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# DeFi Saver Positions SDK
|
|
2
|
-
|
|
3
|
-
Supported protocols:
|
|
4
|
-
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
-
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
-
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
-
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
-
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
-
- [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
|
|
10
|
-
- [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
|
|
11
|
-
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
12
|
-
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
13
|
-
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
14
|
-
- [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
|
|
15
|
-
|
|
16
|
-
## Setup
|
|
17
|
-
Supported Node version is v10.
|
|
18
|
-
|
|
19
|
-
- run `npm install` (first time)
|
|
20
|
-
- run `npm run build`
|
|
21
|
-
|
|
22
|
-
`build` command will generate contracts and build ejs and esm folders
|
|
23
|
-
|
|
24
|
-
## How to use
|
|
25
|
-
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
26
|
-
|
|
27
|
-
This is a Compound V3 example, and every other protocol is similar
|
|
28
|
-
```js
|
|
29
|
-
import Web3 from 'web3';
|
|
30
|
-
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// every protocol has market data and user data getters
|
|
34
|
-
const {
|
|
35
|
-
getCompoundV3MarketsData,
|
|
36
|
-
getCompoundV3AccountData,
|
|
37
|
-
} = compoundV3;
|
|
38
|
-
|
|
39
|
-
const provider = 'Your RPC provider';
|
|
40
|
-
const web3 = new Web3(provider);
|
|
41
|
-
|
|
42
|
-
const user = '0x123...';
|
|
43
|
-
|
|
44
|
-
const { assetsData } = await getCompoundV3MarketsData(
|
|
45
|
-
web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
46
|
-
1, // network
|
|
47
|
-
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
48
|
-
web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const userData = await getCompoundV3AccountData(
|
|
52
|
-
web3,
|
|
53
|
-
1, // network
|
|
54
|
-
userAddress, // EOA or DSProxy
|
|
55
|
-
'', // proxy address of the user, or just empty string if checking for EOA
|
|
56
|
-
{
|
|
57
|
-
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
58
|
-
assetsData,
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
1
|
+
# DeFi Saver Positions SDK
|
|
2
|
+
|
|
3
|
+
Supported protocols:
|
|
4
|
+
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
+
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
+
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
+
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
+
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
+
- [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
|
|
10
|
+
- [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
|
|
11
|
+
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
12
|
+
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
13
|
+
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
14
|
+
- [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
Supported Node version is v10.
|
|
18
|
+
|
|
19
|
+
- run `npm install` (first time)
|
|
20
|
+
- run `npm run build`
|
|
21
|
+
|
|
22
|
+
`build` command will generate contracts and build ejs and esm folders
|
|
23
|
+
|
|
24
|
+
## How to use
|
|
25
|
+
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
26
|
+
|
|
27
|
+
This is a Compound V3 example, and every other protocol is similar
|
|
28
|
+
```js
|
|
29
|
+
import Web3 from 'web3';
|
|
30
|
+
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// every protocol has market data and user data getters
|
|
34
|
+
const {
|
|
35
|
+
getCompoundV3MarketsData,
|
|
36
|
+
getCompoundV3AccountData,
|
|
37
|
+
} = compoundV3;
|
|
38
|
+
|
|
39
|
+
const provider = 'Your RPC provider';
|
|
40
|
+
const web3 = new Web3(provider);
|
|
41
|
+
|
|
42
|
+
const user = '0x123...';
|
|
43
|
+
|
|
44
|
+
const { assetsData } = await getCompoundV3MarketsData(
|
|
45
|
+
web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
46
|
+
1, // network
|
|
47
|
+
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
48
|
+
web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const userData = await getCompoundV3AccountData(
|
|
52
|
+
web3,
|
|
53
|
+
1, // network
|
|
54
|
+
userAddress, // EOA or DSProxy
|
|
55
|
+
'', // proxy address of the user, or just empty string if checking for EOA
|
|
56
|
+
{
|
|
57
|
+
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
58
|
+
assetsData,
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
package/cjs/compoundV3/index.js
CHANGED
|
@@ -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
|
|
65
|
-
|
|
66
|
-
coll.
|
|
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);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sparkAssetsDefaultMarket = exports.sparkAssetsDefaultMarketEth = void 0;
|
|
4
4
|
const common_1 = require("../../types/common");
|
|
5
|
-
exports.sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT'];
|
|
5
|
+
exports.sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH'];
|
|
6
6
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
7
7
|
exports.sparkAssetsDefaultMarket = {
|
|
8
8
|
[common_1.NetworkNumber.Eth]: exports.sparkAssetsDefaultMarketEth,
|
|
@@ -216,17 +216,9 @@ const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainnetWeb3)
|
|
|
216
216
|
isolationModeBorrowingEnabled: false,
|
|
217
217
|
isFlashLoanEnabled: false,
|
|
218
218
|
};
|
|
219
|
-
if (symbol
|
|
220
|
-
data.incentiveSupplyApy = yield (0, staking_1.
|
|
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);
|
package/cjs/spark/index.js
CHANGED
|
@@ -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
|
|
130
|
-
market.incentiveSupplyApy = yield (0, staking_1.
|
|
131
|
-
market.incentiveSupplyToken =
|
|
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);
|
package/esm/compoundV3/index.js
CHANGED
|
@@ -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 {
|
|
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
|
|
59
|
-
|
|
60
|
-
coll.
|
|
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);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NetworkNumber } from '../../types/common';
|
|
2
|
-
export const sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT'];
|
|
2
|
+
export const sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH'];
|
|
3
3
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
4
4
|
export const sparkAssetsDefaultMarket = {
|
|
5
5
|
[NetworkNumber.Eth]: sparkAssetsDefaultMarketEth,
|
|
@@ -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,
|
|
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 {
|
|
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
|
|
214
|
-
data.incentiveSupplyApy = yield
|
|
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);
|
package/esm/spark/index.js
CHANGED
|
@@ -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,
|
|
13
|
-
import { calculateNetApy,
|
|
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
|
|
123
|
-
market.incentiveSupplyApy = yield
|
|
124
|
-
market.incentiveSupplyToken =
|
|
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,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./cjs/index.js",
|
|
6
|
-
"module": "./esm/index.js",
|
|
7
|
-
"types": "./esm/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build:esm": "rm -rf esm && tsc -p tsconfig.json",
|
|
10
|
-
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
|
|
11
|
-
"build": "npm run generate-contracts && npm run build:cjs && npm run build:esm",
|
|
12
|
-
"dev": "npm run generate-contracts && tsc -p tsconfig.cjs.json --watch",
|
|
13
|
-
"lint": "eslint src/ --fix",
|
|
14
|
-
"generate-contracts": "node scripts/generateContracts.js",
|
|
15
|
-
"test": "mocha tests/*",
|
|
16
|
-
"build-test": "npm run build && mocha tests/*"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [],
|
|
19
|
-
"author": "",
|
|
20
|
-
"license": "ISC",
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@defisaver/tokens": "^1.5.23",
|
|
23
|
-
"@ethersproject/bignumber": "^5.7.0",
|
|
24
|
-
"@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
|
|
25
|
-
"decimal.js": "^10.4.3"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@defisaver/eslint-config": "^1.0.1",
|
|
29
|
-
"chai": "^4.3.8",
|
|
30
|
-
"dotenv": "^16.3.1",
|
|
31
|
-
"eslint": "^8.49.0",
|
|
32
|
-
"mocha": "^10.2.0",
|
|
33
|
-
"typechain": "^8.3.1",
|
|
34
|
-
"typechain-target-web3-v1-3mihai3": "^6.0.2",
|
|
35
|
-
"typescript": "^5.2.2"
|
|
36
|
-
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"web3": "^1.10.2"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@defisaver/positions-sdk",
|
|
3
|
+
"version": "0.0.89",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./cjs/index.js",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"types": "./esm/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build:esm": "rm -rf esm && tsc -p tsconfig.json",
|
|
10
|
+
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
|
|
11
|
+
"build": "npm run generate-contracts && npm run build:cjs && npm run build:esm",
|
|
12
|
+
"dev": "npm run generate-contracts && tsc -p tsconfig.cjs.json --watch",
|
|
13
|
+
"lint": "eslint src/ --fix",
|
|
14
|
+
"generate-contracts": "node scripts/generateContracts.js",
|
|
15
|
+
"test": "mocha tests/*",
|
|
16
|
+
"build-test": "npm run build && mocha tests/*"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [],
|
|
19
|
+
"author": "",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@defisaver/tokens": "^1.5.23",
|
|
23
|
+
"@ethersproject/bignumber": "^5.7.0",
|
|
24
|
+
"@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
|
|
25
|
+
"decimal.js": "^10.4.3"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@defisaver/eslint-config": "^1.0.1",
|
|
29
|
+
"chai": "^4.3.8",
|
|
30
|
+
"dotenv": "^16.3.1",
|
|
31
|
+
"eslint": "^8.49.0",
|
|
32
|
+
"mocha": "^10.2.0",
|
|
33
|
+
"typechain": "^8.3.1",
|
|
34
|
+
"typechain-target-web3-v1-3mihai3": "^6.0.2",
|
|
35
|
+
"typescript": "^5.2.2"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"web3": "^1.10.2"
|
|
39
|
+
}
|
|
40
|
+
}
|