@defisaver/positions-sdk 0.0.34 → 0.0.35
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 +32 -35
- package/cjs/markets/curveUsd/index.js +15 -15
- package/cjs/types/curveUsd.d.ts +5 -5
- package/cjs/types/curveUsd.js +5 -5
- package/esm/compoundV3/index.js +27 -30
- package/esm/markets/curveUsd/index.js +15 -15
- package/esm/types/curveUsd.d.ts +5 -5
- package/esm/types/curveUsd.js +5 -5
- package/package.json +40 -40
- package/src/aaveV2/index.ts +226 -226
- package/src/aaveV3/index.ts +561 -561
- 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 +273 -275
- package/src/config/contracts.js +817 -817
- package/src/constants/index.ts +5 -5
- package/src/contracts.ts +124 -124
- package/src/curveUsd/index.ts +228 -228
- 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 +6 -6
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +46 -46
- package/src/helpers/sparkHelpers/index.ts +106 -106
- package/src/index.ts +42 -42
- package/src/liquity/index.ts +116 -116
- package/src/maker/index.ts +101 -101
- package/src/markets/aave/index.ts +80 -80
- package/src/markets/aave/marketAssets.ts +24 -24
- package/src/markets/compound/index.ts +141 -141
- package/src/markets/compound/marketsAssets.ts +48 -48
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/index.ts +4 -4
- package/src/markets/morphoBlue/index.ts +36 -36
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +75 -75
- package/src/morphoAaveV2/index.ts +255 -255
- package/src/morphoAaveV3/index.ts +619 -619
- package/src/morphoBlue/index.ts +170 -170
- 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 +47 -47
- package/src/spark/index.ts +422 -422
- package/src/staking/staking.ts +167 -167
- package/src/types/aave.ts +256 -256
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +83 -83
- package/src/types/compound.ts +128 -128
- package/src/types/curveUsd.ts +118 -118
- package/src/types/index.ts +7 -7
- package/src/types/liquity.ts +30 -30
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +80 -80
- package/src/types/spark.ts +106 -106
- package/yarn-error.log +64 -0
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
|
@@ -17,13 +17,12 @@ const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const contracts_1 = require("../contracts");
|
|
19
19
|
const multicall_1 = require("../multicall");
|
|
20
|
-
const compound_1 = require("../types/compound");
|
|
21
20
|
const staking_1 = require("../staking");
|
|
22
21
|
const utils_1 = require("../services/utils");
|
|
23
22
|
const constants_1 = require("../constants");
|
|
24
23
|
const moneymarket_1 = require("../moneymarket");
|
|
25
24
|
const compoundHelpers_1 = require("../helpers/compoundHelpers");
|
|
26
|
-
const
|
|
25
|
+
const compound_1 = require("../markets/compound");
|
|
27
26
|
const priceService_1 = require("../services/priceService");
|
|
28
27
|
const getCompoundV3MarketsData = (web3, network, selectedMarket, defaultWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
28
|
const baseAssetPrice = selectedMarket.baseAsset === 'ETH' ? yield (0, priceService_1.getEthPrice)(defaultWeb3) : yield (0, priceService_1.getUSDCPrice)(defaultWeb3);
|
|
@@ -44,35 +43,33 @@ const getCompoundV3MarketsData = (web3, network, selectedMarket, defaultWeb3) =>
|
|
|
44
43
|
];
|
|
45
44
|
const data = yield (0, multicall_1.multicall)(calls, web3, network);
|
|
46
45
|
const colls = data[1].colls.map((coll) => (0, compoundHelpers_1.formatMarketData)(coll, network, baseAssetPrice));
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
(0,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
coll.incentiveSupplyToken = 'rETH';
|
|
75
|
-
}
|
|
46
|
+
for (const coll of colls) {
|
|
47
|
+
if (coll.symbol === 'wstETH') {
|
|
48
|
+
// eslint-disable-next-line no-await-in-loop
|
|
49
|
+
const [[totalSupplyAlternative, supplyCapAlternative], priceAlternative] = yield Promise.all([
|
|
50
|
+
(0, staking_1.getStETHByWstETHMultiple)([
|
|
51
|
+
(0, tokens_1.assetAmountInWei)(coll.totalSupply, 'wstETH'),
|
|
52
|
+
(0, tokens_1.assetAmountInWei)(coll.supplyCap, 'wstETH'),
|
|
53
|
+
], defaultWeb3),
|
|
54
|
+
(0, staking_1.getWstETHByStETH)((0, tokens_1.assetAmountInWei)(1, 'stETH'), defaultWeb3),
|
|
55
|
+
]);
|
|
56
|
+
coll.totalSupplyAlternative = (0, tokens_1.assetAmountInEth)(totalSupplyAlternative, 'stETH');
|
|
57
|
+
coll.supplyCapAlternative = (0, tokens_1.assetAmountInEth)(supplyCapAlternative, 'stETH');
|
|
58
|
+
coll.priceAlternative = (0, tokens_1.assetAmountInEth)(priceAlternative, 'wstETH');
|
|
59
|
+
// const stEthMarket = markets.find(({ symbol }) => symbol === 'stETH');
|
|
60
|
+
// eslint-disable-next-line no-await-in-loop
|
|
61
|
+
coll.incentiveSupplyApy = yield (0, staking_1.getStETHApr)(defaultWeb3);
|
|
62
|
+
coll.incentiveSupplyToken = 'wstETH';
|
|
63
|
+
}
|
|
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';
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
const base = (0, compoundHelpers_1.formatBaseData)(data[0].baseToken, network, baseAssetPrice);
|
|
@@ -127,9 +124,9 @@ const getCompoundV3AccountBalances = (web3, network, block, addressMapping, addr
|
|
|
127
124
|
return balances;
|
|
128
125
|
}
|
|
129
126
|
const market = ({
|
|
130
|
-
[(0,
|
|
131
|
-
[(0,
|
|
132
|
-
[(0,
|
|
127
|
+
[(0, compound_1.COMPOUND_V3_ETH)(network).baseMarketAddress.toLowerCase()]: (0, compound_1.COMPOUND_V3_ETH)(network),
|
|
128
|
+
[(0, compound_1.COMPOUND_V3_USDC)(network).baseMarketAddress.toLowerCase()]: (0, compound_1.COMPOUND_V3_USDC)(network),
|
|
129
|
+
[(0, compound_1.COMPOUND_V3_USDBC)(network).baseMarketAddress.toLowerCase()]: (0, compound_1.COMPOUND_V3_USDBC)(network),
|
|
133
130
|
})[marketAddress.toLowerCase()];
|
|
134
131
|
const loanInfoContract = (0, contracts_1.CompV3ViewContract)(web3, network, block);
|
|
135
132
|
const loanInfo = yield loanInfoContract.methods.getLoanData(market.baseMarketAddress, address).call({}, block);
|
|
@@ -182,7 +179,7 @@ const getCompoundV3AccountData = (web3, network, address, proxyAddress, extracte
|
|
|
182
179
|
if (loanData.borrowAmount.toString() !== '0') {
|
|
183
180
|
usedAssets[baseAssetSymbol].isBorrowed = true;
|
|
184
181
|
usedAssets[baseAssetSymbol].borrowed = (0, tokens_1.assetAmountInEth)(loanData.borrowAmount, baseAssetInfo.symbol);
|
|
185
|
-
if (selectedMarket.value === (0,
|
|
182
|
+
if (selectedMarket.value === (0, compound_1.COMPOUND_V3_ETH)(network).value) {
|
|
186
183
|
usedAssets[baseAssetSymbol].borrowedUsd = new decimal_js_1.default((0, tokens_1.assetAmountInEth)(loanData.borrowValue, baseAssetInfo.symbol))
|
|
187
184
|
.mul(assetsData[baseAssetSymbol].price)
|
|
188
185
|
.toString();
|
|
@@ -5,9 +5,9 @@ const contracts_1 = require("../../contracts");
|
|
|
5
5
|
const types_1 = require("../../types");
|
|
6
6
|
const CRVUSD_WSTETH_MARKET = (networkId) => ({
|
|
7
7
|
chainIds: [1],
|
|
8
|
-
label: 'wstETH',
|
|
8
|
+
label: 'CurveUSD - wstETH',
|
|
9
9
|
shortLabel: 'wstETH',
|
|
10
|
-
value: types_1.CrvUSDVersions.
|
|
10
|
+
value: types_1.CrvUSDVersions.crvUSDwstETH,
|
|
11
11
|
collAsset: 'wstETH',
|
|
12
12
|
baseAsset: 'crvUSD',
|
|
13
13
|
controllerAddress: (0, contracts_1.getConfigContractAddress)('crvUSDwstETHController', networkId),
|
|
@@ -17,9 +17,9 @@ const CRVUSD_WSTETH_MARKET = (networkId) => ({
|
|
|
17
17
|
exports.CRVUSD_WSTETH_MARKET = CRVUSD_WSTETH_MARKET;
|
|
18
18
|
const CRVUSD_ETH_MARKET = (networkId) => ({
|
|
19
19
|
chainIds: [1],
|
|
20
|
-
label: 'ETH',
|
|
20
|
+
label: 'CurveUSD - ETH',
|
|
21
21
|
shortLabel: 'ETH',
|
|
22
|
-
value: types_1.CrvUSDVersions.
|
|
22
|
+
value: types_1.CrvUSDVersions.crvUSDETH,
|
|
23
23
|
collAsset: 'ETH',
|
|
24
24
|
baseAsset: 'crvUSD',
|
|
25
25
|
controllerAddress: (0, contracts_1.getConfigContractAddress)('crvUSDETHController', networkId),
|
|
@@ -29,9 +29,9 @@ const CRVUSD_ETH_MARKET = (networkId) => ({
|
|
|
29
29
|
exports.CRVUSD_ETH_MARKET = CRVUSD_ETH_MARKET;
|
|
30
30
|
const CRVUSD_WBTC_MARKET = (networkId) => ({
|
|
31
31
|
chainIds: [1],
|
|
32
|
-
label: 'WBTC',
|
|
32
|
+
label: 'CurveUSD - WBTC',
|
|
33
33
|
shortLabel: 'WBTC',
|
|
34
|
-
value: types_1.CrvUSDVersions.
|
|
34
|
+
value: types_1.CrvUSDVersions.crvUSDWBTC,
|
|
35
35
|
collAsset: 'WBTC',
|
|
36
36
|
baseAsset: 'crvUSD',
|
|
37
37
|
controllerAddress: (0, contracts_1.getConfigContractAddress)('crvUSDWBTCController', networkId),
|
|
@@ -41,9 +41,9 @@ const CRVUSD_WBTC_MARKET = (networkId) => ({
|
|
|
41
41
|
exports.CRVUSD_WBTC_MARKET = CRVUSD_WBTC_MARKET;
|
|
42
42
|
const CRVUSD_TBTC_MARKET = (networkId) => ({
|
|
43
43
|
chainIds: [1],
|
|
44
|
-
label: 'tBTC',
|
|
44
|
+
label: 'CurveUSD - tBTC',
|
|
45
45
|
shortLabel: 'tBTC',
|
|
46
|
-
value: types_1.CrvUSDVersions.
|
|
46
|
+
value: types_1.CrvUSDVersions.crvUSDtBTC,
|
|
47
47
|
collAsset: 'tBTC',
|
|
48
48
|
baseAsset: 'crvUSD',
|
|
49
49
|
controllerAddress: (0, contracts_1.getConfigContractAddress)('crvUSDtBTCController', networkId),
|
|
@@ -53,9 +53,9 @@ const CRVUSD_TBTC_MARKET = (networkId) => ({
|
|
|
53
53
|
exports.CRVUSD_TBTC_MARKET = CRVUSD_TBTC_MARKET;
|
|
54
54
|
const CRVUSD_SFRXETH_MARKET = (networkId) => ({
|
|
55
55
|
chainIds: [1],
|
|
56
|
-
label: 'sfrxETH',
|
|
56
|
+
label: 'CurveUSD - sfrxETH',
|
|
57
57
|
shortLabel: 'sfrxETH',
|
|
58
|
-
value: types_1.CrvUSDVersions.
|
|
58
|
+
value: types_1.CrvUSDVersions.crvUSDsfrxETH,
|
|
59
59
|
collAsset: 'sfrxETH',
|
|
60
60
|
baseAsset: 'crvUSD',
|
|
61
61
|
controllerAddress: (0, contracts_1.getConfigContractAddress)('crvUSDsfrxETHController', networkId),
|
|
@@ -64,10 +64,10 @@ const CRVUSD_SFRXETH_MARKET = (networkId) => ({
|
|
|
64
64
|
});
|
|
65
65
|
exports.CRVUSD_SFRXETH_MARKET = CRVUSD_SFRXETH_MARKET;
|
|
66
66
|
const CrvUsdMarkets = (networkId) => ({
|
|
67
|
-
[types_1.CrvUSDVersions.
|
|
68
|
-
[types_1.CrvUSDVersions.
|
|
69
|
-
[types_1.CrvUSDVersions.
|
|
70
|
-
[types_1.CrvUSDVersions.
|
|
71
|
-
[types_1.CrvUSDVersions.
|
|
67
|
+
[types_1.CrvUSDVersions.crvUSDwstETH]: (0, exports.CRVUSD_WSTETH_MARKET)(networkId),
|
|
68
|
+
[types_1.CrvUSDVersions.crvUSDETH]: (0, exports.CRVUSD_ETH_MARKET)(networkId),
|
|
69
|
+
[types_1.CrvUSDVersions.crvUSDWBTC]: (0, exports.CRVUSD_WBTC_MARKET)(networkId),
|
|
70
|
+
[types_1.CrvUSDVersions.crvUSDtBTC]: (0, exports.CRVUSD_TBTC_MARKET)(networkId),
|
|
71
|
+
[types_1.CrvUSDVersions.crvUSDsfrxETH]: (0, exports.CRVUSD_SFRXETH_MARKET)(networkId),
|
|
72
72
|
});
|
|
73
73
|
exports.CrvUsdMarkets = CrvUsdMarkets;
|
package/cjs/types/curveUsd.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NetworkNumber } from './common';
|
|
2
2
|
export declare enum CrvUSDVersions {
|
|
3
|
-
'
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
3
|
+
'crvUSDwstETH' = "wstETH",
|
|
4
|
+
'crvUSDWBTC' = "WBTC",
|
|
5
|
+
'crvUSDETH' = "ETH",
|
|
6
|
+
'crvUSDtBTC' = "tBTC",
|
|
7
|
+
'crvUSDsfrxETH' = "sfrxETH"
|
|
8
8
|
}
|
|
9
9
|
export declare enum CrvUSDStatus {
|
|
10
10
|
Nonexistant = "Nonexistant",
|
package/cjs/types/curveUsd.js
CHANGED
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CrvUSDStatus = exports.CrvUSDVersions = void 0;
|
|
4
4
|
var CrvUSDVersions;
|
|
5
5
|
(function (CrvUSDVersions) {
|
|
6
|
-
CrvUSDVersions["
|
|
7
|
-
CrvUSDVersions["
|
|
8
|
-
CrvUSDVersions["
|
|
9
|
-
CrvUSDVersions["
|
|
10
|
-
CrvUSDVersions["
|
|
6
|
+
CrvUSDVersions["crvUSDwstETH"] = "wstETH";
|
|
7
|
+
CrvUSDVersions["crvUSDWBTC"] = "WBTC";
|
|
8
|
+
CrvUSDVersions["crvUSDETH"] = "ETH";
|
|
9
|
+
CrvUSDVersions["crvUSDtBTC"] = "tBTC";
|
|
10
|
+
CrvUSDVersions["crvUSDsfrxETH"] = "sfrxETH";
|
|
11
11
|
})(CrvUSDVersions || (exports.CrvUSDVersions = CrvUSDVersions = {}));
|
|
12
12
|
var CrvUSDStatus;
|
|
13
13
|
(function (CrvUSDStatus) {
|
package/esm/compoundV3/index.js
CHANGED
|
@@ -11,7 +11,6 @@ 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 { CompoundVersions, } from '../types/compound';
|
|
15
14
|
import { getCbETHApr, getREthApr, getStETHApr, getStETHByWstETHMultiple, getWstETHByStETH, } from '../staking';
|
|
16
15
|
import { wethToEth } from '../services/utils';
|
|
17
16
|
import { ZERO_ADDRESS } from '../constants';
|
|
@@ -38,35 +37,33 @@ export const getCompoundV3MarketsData = (web3, network, selectedMarket, defaultW
|
|
|
38
37
|
];
|
|
39
38
|
const data = yield multicall(calls, web3, network);
|
|
40
39
|
const colls = data[1].colls.map((coll) => formatMarketData(coll, network, baseAssetPrice));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
coll.incentiveSupplyToken = 'rETH';
|
|
69
|
-
}
|
|
40
|
+
for (const coll of colls) {
|
|
41
|
+
if (coll.symbol === 'wstETH') {
|
|
42
|
+
// eslint-disable-next-line no-await-in-loop
|
|
43
|
+
const [[totalSupplyAlternative, supplyCapAlternative], priceAlternative] = yield Promise.all([
|
|
44
|
+
getStETHByWstETHMultiple([
|
|
45
|
+
assetAmountInWei(coll.totalSupply, 'wstETH'),
|
|
46
|
+
assetAmountInWei(coll.supplyCap, 'wstETH'),
|
|
47
|
+
], defaultWeb3),
|
|
48
|
+
getWstETHByStETH(assetAmountInWei(1, 'stETH'), defaultWeb3),
|
|
49
|
+
]);
|
|
50
|
+
coll.totalSupplyAlternative = assetAmountInEth(totalSupplyAlternative, 'stETH');
|
|
51
|
+
coll.supplyCapAlternative = assetAmountInEth(supplyCapAlternative, 'stETH');
|
|
52
|
+
coll.priceAlternative = assetAmountInEth(priceAlternative, 'wstETH');
|
|
53
|
+
// const stEthMarket = markets.find(({ symbol }) => symbol === 'stETH');
|
|
54
|
+
// eslint-disable-next-line no-await-in-loop
|
|
55
|
+
coll.incentiveSupplyApy = yield getStETHApr(defaultWeb3);
|
|
56
|
+
coll.incentiveSupplyToken = 'wstETH';
|
|
57
|
+
}
|
|
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';
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
const base = formatBaseData(data[0].baseToken, network, baseAssetPrice);
|
|
@@ -2,9 +2,9 @@ import { getConfigContractAddress } from '../../contracts';
|
|
|
2
2
|
import { CrvUSDVersions } from '../../types';
|
|
3
3
|
export const CRVUSD_WSTETH_MARKET = (networkId) => ({
|
|
4
4
|
chainIds: [1],
|
|
5
|
-
label: 'wstETH',
|
|
5
|
+
label: 'CurveUSD - wstETH',
|
|
6
6
|
shortLabel: 'wstETH',
|
|
7
|
-
value: CrvUSDVersions.
|
|
7
|
+
value: CrvUSDVersions.crvUSDwstETH,
|
|
8
8
|
collAsset: 'wstETH',
|
|
9
9
|
baseAsset: 'crvUSD',
|
|
10
10
|
controllerAddress: getConfigContractAddress('crvUSDwstETHController', networkId),
|
|
@@ -13,9 +13,9 @@ export const CRVUSD_WSTETH_MARKET = (networkId) => ({
|
|
|
13
13
|
});
|
|
14
14
|
export const CRVUSD_ETH_MARKET = (networkId) => ({
|
|
15
15
|
chainIds: [1],
|
|
16
|
-
label: 'ETH',
|
|
16
|
+
label: 'CurveUSD - ETH',
|
|
17
17
|
shortLabel: 'ETH',
|
|
18
|
-
value: CrvUSDVersions.
|
|
18
|
+
value: CrvUSDVersions.crvUSDETH,
|
|
19
19
|
collAsset: 'ETH',
|
|
20
20
|
baseAsset: 'crvUSD',
|
|
21
21
|
controllerAddress: getConfigContractAddress('crvUSDETHController', networkId),
|
|
@@ -24,9 +24,9 @@ export const CRVUSD_ETH_MARKET = (networkId) => ({
|
|
|
24
24
|
});
|
|
25
25
|
export const CRVUSD_WBTC_MARKET = (networkId) => ({
|
|
26
26
|
chainIds: [1],
|
|
27
|
-
label: 'WBTC',
|
|
27
|
+
label: 'CurveUSD - WBTC',
|
|
28
28
|
shortLabel: 'WBTC',
|
|
29
|
-
value: CrvUSDVersions.
|
|
29
|
+
value: CrvUSDVersions.crvUSDWBTC,
|
|
30
30
|
collAsset: 'WBTC',
|
|
31
31
|
baseAsset: 'crvUSD',
|
|
32
32
|
controllerAddress: getConfigContractAddress('crvUSDWBTCController', networkId),
|
|
@@ -35,9 +35,9 @@ export const CRVUSD_WBTC_MARKET = (networkId) => ({
|
|
|
35
35
|
});
|
|
36
36
|
export const CRVUSD_TBTC_MARKET = (networkId) => ({
|
|
37
37
|
chainIds: [1],
|
|
38
|
-
label: 'tBTC',
|
|
38
|
+
label: 'CurveUSD - tBTC',
|
|
39
39
|
shortLabel: 'tBTC',
|
|
40
|
-
value: CrvUSDVersions.
|
|
40
|
+
value: CrvUSDVersions.crvUSDtBTC,
|
|
41
41
|
collAsset: 'tBTC',
|
|
42
42
|
baseAsset: 'crvUSD',
|
|
43
43
|
controllerAddress: getConfigContractAddress('crvUSDtBTCController', networkId),
|
|
@@ -46,9 +46,9 @@ export const CRVUSD_TBTC_MARKET = (networkId) => ({
|
|
|
46
46
|
});
|
|
47
47
|
export const CRVUSD_SFRXETH_MARKET = (networkId) => ({
|
|
48
48
|
chainIds: [1],
|
|
49
|
-
label: 'sfrxETH',
|
|
49
|
+
label: 'CurveUSD - sfrxETH',
|
|
50
50
|
shortLabel: 'sfrxETH',
|
|
51
|
-
value: CrvUSDVersions.
|
|
51
|
+
value: CrvUSDVersions.crvUSDsfrxETH,
|
|
52
52
|
collAsset: 'sfrxETH',
|
|
53
53
|
baseAsset: 'crvUSD',
|
|
54
54
|
controllerAddress: getConfigContractAddress('crvUSDsfrxETHController', networkId),
|
|
@@ -56,9 +56,9 @@ export const CRVUSD_SFRXETH_MARKET = (networkId) => ({
|
|
|
56
56
|
createCollAssets: ['sfrxETH'],
|
|
57
57
|
});
|
|
58
58
|
export const CrvUsdMarkets = (networkId) => ({
|
|
59
|
-
[CrvUSDVersions.
|
|
60
|
-
[CrvUSDVersions.
|
|
61
|
-
[CrvUSDVersions.
|
|
62
|
-
[CrvUSDVersions.
|
|
63
|
-
[CrvUSDVersions.
|
|
59
|
+
[CrvUSDVersions.crvUSDwstETH]: CRVUSD_WSTETH_MARKET(networkId),
|
|
60
|
+
[CrvUSDVersions.crvUSDETH]: CRVUSD_ETH_MARKET(networkId),
|
|
61
|
+
[CrvUSDVersions.crvUSDWBTC]: CRVUSD_WBTC_MARKET(networkId),
|
|
62
|
+
[CrvUSDVersions.crvUSDtBTC]: CRVUSD_TBTC_MARKET(networkId),
|
|
63
|
+
[CrvUSDVersions.crvUSDsfrxETH]: CRVUSD_SFRXETH_MARKET(networkId),
|
|
64
64
|
});
|
package/esm/types/curveUsd.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NetworkNumber } from './common';
|
|
2
2
|
export declare enum CrvUSDVersions {
|
|
3
|
-
'
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
3
|
+
'crvUSDwstETH' = "wstETH",
|
|
4
|
+
'crvUSDWBTC' = "WBTC",
|
|
5
|
+
'crvUSDETH' = "ETH",
|
|
6
|
+
'crvUSDtBTC' = "tBTC",
|
|
7
|
+
'crvUSDsfrxETH' = "sfrxETH"
|
|
8
8
|
}
|
|
9
9
|
export declare enum CrvUSDStatus {
|
|
10
10
|
Nonexistant = "Nonexistant",
|
package/esm/types/curveUsd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export var CrvUSDVersions;
|
|
2
2
|
(function (CrvUSDVersions) {
|
|
3
|
-
CrvUSDVersions["
|
|
4
|
-
CrvUSDVersions["
|
|
5
|
-
CrvUSDVersions["
|
|
6
|
-
CrvUSDVersions["
|
|
7
|
-
CrvUSDVersions["
|
|
3
|
+
CrvUSDVersions["crvUSDwstETH"] = "wstETH";
|
|
4
|
+
CrvUSDVersions["crvUSDWBTC"] = "WBTC";
|
|
5
|
+
CrvUSDVersions["crvUSDETH"] = "ETH";
|
|
6
|
+
CrvUSDVersions["crvUSDtBTC"] = "tBTC";
|
|
7
|
+
CrvUSDVersions["crvUSDsfrxETH"] = "sfrxETH";
|
|
8
8
|
})(CrvUSDVersions || (CrvUSDVersions = {}));
|
|
9
9
|
export var CrvUSDStatus;
|
|
10
10
|
(function (CrvUSDStatus) {
|
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.5",
|
|
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.35",
|
|
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.5",
|
|
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
|
+
}
|