@defisaver/positions-sdk 0.0.21 → 0.0.23
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/aaveV2/index.js +1 -3
- package/cjs/aaveV3/index.js +12 -14
- package/cjs/helpers/curveUsdHelpers/index.js +1 -0
- package/cjs/markets/curveUsd/index.js +15 -15
- package/cjs/morphoAaveV3/index.js +1 -3
- package/cjs/spark/index.js +1 -3
- package/cjs/types/curveUsd.d.ts +6 -5
- package/cjs/types/curveUsd.js +5 -5
- package/esm/aaveV2/index.js +2 -4
- package/esm/aaveV3/index.js +2 -4
- package/esm/helpers/curveUsdHelpers/index.js +1 -0
- package/esm/markets/curveUsd/index.js +15 -15
- package/esm/morphoAaveV3/index.js +1 -3
- package/esm/spark/index.js +2 -4
- package/esm/types/curveUsd.d.ts +6 -5
- package/esm/types/curveUsd.js +5 -5
- package/package.json +40 -40
- package/src/aaveV2/index.ts +226 -231
- package/src/aaveV3/index.ts +561 -565
- 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 +275 -275
- package/src/config/contracts.js +673 -673
- package/src/constants/index.ts +3 -3
- package/src/contracts.ts +100 -100
- 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 +33 -32
- package/src/helpers/index.ts +5 -5
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/sparkHelpers/index.ts +106 -106
- package/src/index.ts +40 -40
- 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 +32 -32
- package/src/markets/compound/index.ts +141 -141
- package/src/markets/compound/marketsAssets.ts +46 -46
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/index.ts +3 -3
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +9 -9
- package/src/moneymarket/moneymarketCommonService.ts +75 -75
- package/src/morpho/markets.ts +39 -39
- package/src/morphoAaveV2/index.ts +255 -255
- package/src/morphoAaveV3/index.ts +619 -624
- 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 +34 -34
- package/src/spark/index.ts +421 -425
- 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 +113 -112
- package/src/types/index.ts +6 -6
- package/src/types/liquity.ts +30 -30
- package/src/types/maker.ts +50 -50
- 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/aaveV2/index.js
CHANGED
|
@@ -23,7 +23,6 @@ const aaveV3_1 = require("../aaveV3");
|
|
|
23
23
|
const aave_1 = require("../markets/aave");
|
|
24
24
|
const aaveHelpers_1 = require("../helpers/aaveHelpers");
|
|
25
25
|
const priceService_1 = require("../services/priceService");
|
|
26
|
-
const contracts_2 = __importDefault(require("../config/contracts"));
|
|
27
26
|
const getAaveV2MarketsData = (web3, network, selectedMarket, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
27
|
const ethPrice = yield (0, priceService_1.getEthPrice)(mainnetWeb3);
|
|
29
28
|
const _addresses = selectedMarket.assets.map(a => (0, tokens_1.getAssetInfo)((0, utils_1.ethToWeth)(a)).address);
|
|
@@ -95,9 +94,8 @@ const getAaveV2AccountBalances = (web3, network, block, addressMapping, address)
|
|
|
95
94
|
const market = aave_1.AAVE_V2;
|
|
96
95
|
const loanInfoContract = (0, contracts_1.AaveLoanInfoV2Contract)(web3, network, block);
|
|
97
96
|
const marketAddress = market.providerAddress;
|
|
98
|
-
const protocolDataProviderContract = new web3.eth.Contract(
|
|
99
97
|
// @ts-ignore
|
|
100
|
-
|
|
98
|
+
const protocolDataProviderContract = (0, contracts_1.createContractWrapper)(web3, network, market.protocolData, market.protocolDataAddress);
|
|
101
99
|
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
102
100
|
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
103
101
|
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
package/cjs/aaveV3/index.js
CHANGED
|
@@ -15,8 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getAaveV3FullPositionData = exports.getAaveV3AccountData = exports.getAaveV3AccountBalances = exports.EMPTY_AAVE_DATA = exports.getAaveV3MarketData = exports.aaveV3EmodeCategoriesMapping = exports.aaveV3CalculateDiscountRate = exports.test = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
|
-
const contracts_1 =
|
|
19
|
-
const contracts_2 = require("../contracts");
|
|
18
|
+
const contracts_1 = require("../contracts");
|
|
20
19
|
const utils_1 = require("../services/utils");
|
|
21
20
|
const common_1 = require("../types/common");
|
|
22
21
|
const staking_1 = require("../staking");
|
|
@@ -26,7 +25,7 @@ const moneymarket_1 = require("../moneymarket");
|
|
|
26
25
|
const aaveHelpers_1 = require("../helpers/aaveHelpers");
|
|
27
26
|
const aave_1 = require("../markets/aave");
|
|
28
27
|
const test = (web3, network) => {
|
|
29
|
-
const contract = (0,
|
|
28
|
+
const contract = (0, contracts_1.AaveV3ViewContract)(web3, 1);
|
|
30
29
|
return contract.methods.AAVE_REFERRAL_CODE().call();
|
|
31
30
|
};
|
|
32
31
|
exports.test = test;
|
|
@@ -80,12 +79,12 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
80
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
80
|
const _addresses = market.assets.map(a => (0, tokens_1.getAssetInfo)((0, utils_1.ethToWeth)(a), network).address);
|
|
82
81
|
const isL2 = (0, utils_1.isLayer2Network)(network);
|
|
83
|
-
const loanInfoContract = (0,
|
|
84
|
-
const aaveIncentivesContract = (0,
|
|
82
|
+
const loanInfoContract = (0, contracts_1.AaveV3ViewContract)(web3, network);
|
|
83
|
+
const aaveIncentivesContract = (0, contracts_1.AaveIncentiveDataProviderV3Contract)(web3, network);
|
|
85
84
|
const marketAddress = market.providerAddress;
|
|
86
|
-
const GhoDiscountRateStrategyAddress = (0,
|
|
87
|
-
const GhoDiscountRateStrategyAbi = (0,
|
|
88
|
-
const GhoTokenAbi = (0,
|
|
85
|
+
const GhoDiscountRateStrategyAddress = (0, contracts_1.getConfigContractAddress)('GhoDiscountRateStrategy', common_1.NetworkNumber.Eth);
|
|
86
|
+
const GhoDiscountRateStrategyAbi = (0, contracts_1.getConfigContractAbi)('GhoDiscountRateStrategy');
|
|
87
|
+
const GhoTokenAbi = (0, contracts_1.getConfigContractAbi)('GHO');
|
|
89
88
|
const multicallCallsObject = [
|
|
90
89
|
{
|
|
91
90
|
target: GhoDiscountRateStrategyAddress,
|
|
@@ -113,7 +112,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
113
112
|
params: [],
|
|
114
113
|
},
|
|
115
114
|
];
|
|
116
|
-
const ghoContract = (0,
|
|
115
|
+
const ghoContract = (0, contracts_1.GhoTokenContract)(web3, network);
|
|
117
116
|
// eslint-disable-next-line prefer-const
|
|
118
117
|
let [loanInfo, isBorrowAllowed, multiRes] = yield Promise.all([
|
|
119
118
|
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(),
|
|
@@ -259,12 +258,11 @@ const getAaveV3AccountBalances = (web3, network, block, addressMapping, address)
|
|
|
259
258
|
if (!address) {
|
|
260
259
|
return balances;
|
|
261
260
|
}
|
|
262
|
-
const loanInfoContract = (0,
|
|
261
|
+
const loanInfoContract = (0, contracts_1.AaveV3ViewContract)(web3, network, block);
|
|
263
262
|
const market = (0, aave_1.AAVE_V3)(network);
|
|
264
263
|
const marketAddress = market.providerAddress;
|
|
265
|
-
const protocolDataProviderContract = new web3.eth.Contract(
|
|
266
264
|
// @ts-ignore
|
|
267
|
-
contracts_1.
|
|
265
|
+
const protocolDataProviderContract = (0, contracts_1.createContractWrapper)(web3, network, market.protocolData, market.protocolDataAddress);
|
|
268
266
|
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
269
267
|
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
270
268
|
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
|
@@ -306,11 +304,11 @@ const getAaveV3AccountData = (web3, network, address, extractedState) => __await
|
|
|
306
304
|
return payload;
|
|
307
305
|
}
|
|
308
306
|
const isL2 = (0, utils_1.isLayer2Network)(network);
|
|
309
|
-
const loanInfoContract = (0,
|
|
307
|
+
const loanInfoContract = (0, contracts_1.AaveV3ViewContract)(web3, network);
|
|
310
308
|
const marketAddress = market.providerAddress;
|
|
311
309
|
const _addresses = market.assets.map((a) => (0, tokens_1.getAssetInfo)((0, utils_1.ethToWeth)(a), network).address);
|
|
312
310
|
const middleAddressIndex = Math.floor(_addresses.length / 2); // split addresses in half to avoid gas limit by multicall
|
|
313
|
-
const LendingPoolAbi = (0,
|
|
311
|
+
const LendingPoolAbi = (0, contracts_1.getConfigContractAbi)(market.lendingPool);
|
|
314
312
|
const multicallData = [
|
|
315
313
|
{
|
|
316
314
|
target: market.lendingPoolAddress,
|
|
@@ -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;
|
|
@@ -28,7 +28,6 @@ const moneymarket_1 = require("../moneymarket");
|
|
|
28
28
|
const aaveV3_1 = require("../aaveV3");
|
|
29
29
|
const aaveHelpers_1 = require("../helpers/aaveHelpers");
|
|
30
30
|
const aave_1 = require("../markets/aave");
|
|
31
|
-
const contracts_2 = __importDefault(require("../config/contracts"));
|
|
32
31
|
const morphoAaveMath = new AaveV3_maths_1.MorphoAaveMath();
|
|
33
32
|
const poolInterestRates = new PoolInterestRates_1.default();
|
|
34
33
|
const p2pInterestRates = new P2PInterestRates_1.default();
|
|
@@ -260,9 +259,8 @@ const getMorphoAaveV3AccountBalances = (web3, network, block, addressMapping, ad
|
|
|
260
259
|
const selectedMarket = (0, aave_1.MORPHO_AAVE_V3_ETH)(network);
|
|
261
260
|
// @ts-ignore
|
|
262
261
|
const lendingPoolContract = (0, contracts_1.createContractWrapper)(web3, network, selectedMarket.lendingPool, selectedMarket.lendingPoolAddress);
|
|
263
|
-
const protocolDataProviderContract = new web3.eth.Contract(
|
|
264
262
|
// @ts-ignore
|
|
265
|
-
|
|
263
|
+
const protocolDataProviderContract = (0, contracts_1.createContractWrapper)(web3, network, selectedMarket.protocolData, selectedMarket.protocolDataAddress);
|
|
266
264
|
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
267
265
|
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
268
266
|
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
package/cjs/spark/index.js
CHANGED
|
@@ -23,7 +23,6 @@ const multicall_1 = require("../multicall");
|
|
|
23
23
|
const sparkHelpers_1 = require("../helpers/sparkHelpers");
|
|
24
24
|
const moneymarket_1 = require("../moneymarket");
|
|
25
25
|
const spark_1 = require("../markets/spark");
|
|
26
|
-
const contracts_2 = __importDefault(require("../config/contracts"));
|
|
27
26
|
const sparkEmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
28
27
|
const { assetsData } = extractedState;
|
|
29
28
|
const usedAssetsValues = Object.values(usedAssets);
|
|
@@ -213,9 +212,8 @@ const getSparkAccountBalances = (web3, network, block, addressMapping, address)
|
|
|
213
212
|
const loanInfoContract = (0, contracts_1.SparkViewContract)(web3, network, block);
|
|
214
213
|
const market = (0, spark_1.SPARK_V1)(network);
|
|
215
214
|
const marketAddress = market.providerAddress;
|
|
216
|
-
const protocolDataProviderContract = new web3.eth.Contract(
|
|
217
215
|
// @ts-ignore
|
|
218
|
-
|
|
216
|
+
const protocolDataProviderContract = (0, contracts_1.createContractWrapper)(web3, network, market.protocolData, market.protocolDataAddress);
|
|
219
217
|
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
220
218
|
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
221
219
|
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
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",
|
|
@@ -67,6 +67,7 @@ export interface CrvUSDAggregatedPositionData {
|
|
|
67
67
|
borrowedUsd: string;
|
|
68
68
|
borrowed: string;
|
|
69
69
|
safetyRatio: string;
|
|
70
|
+
borrowLimitUsd: string;
|
|
70
71
|
}
|
|
71
72
|
export interface CrvUSDUsedAsset {
|
|
72
73
|
isSupplied: boolean;
|
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/aaveV2/index.js
CHANGED
|
@@ -11,13 +11,12 @@ import Dec from 'decimal.js';
|
|
|
11
11
|
import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
12
12
|
import { calculateNetApy, getStETHApr } from '../staking';
|
|
13
13
|
import { ethToWeth, wethToEth, wethToEthByAddress } from '../services/utils';
|
|
14
|
-
import { AaveLoanInfoV2Contract } from '../contracts';
|
|
14
|
+
import { AaveLoanInfoV2Contract, createContractWrapper } from '../contracts';
|
|
15
15
|
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
16
16
|
import { EMPTY_AAVE_DATA } from '../aaveV3';
|
|
17
17
|
import { AAVE_V2 } from '../markets/aave';
|
|
18
18
|
import { aaveAnyGetAggregatedPositionData } from '../helpers/aaveHelpers';
|
|
19
19
|
import { getEthPrice } from '../services/priceService';
|
|
20
|
-
import configRaw from '../config/contracts';
|
|
21
20
|
export const getAaveV2MarketsData = (web3, network, selectedMarket, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
21
|
const ethPrice = yield getEthPrice(mainnetWeb3);
|
|
23
22
|
const _addresses = selectedMarket.assets.map(a => getAssetInfo(ethToWeth(a)).address);
|
|
@@ -88,9 +87,8 @@ export const getAaveV2AccountBalances = (web3, network, block, addressMapping, a
|
|
|
88
87
|
const market = AAVE_V2;
|
|
89
88
|
const loanInfoContract = AaveLoanInfoV2Contract(web3, network, block);
|
|
90
89
|
const marketAddress = market.providerAddress;
|
|
91
|
-
const protocolDataProviderContract = new web3.eth.Contract(
|
|
92
90
|
// @ts-ignore
|
|
93
|
-
|
|
91
|
+
const protocolDataProviderContract = createContractWrapper(web3, network, market.protocolData, market.protocolDataAddress);
|
|
94
92
|
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
95
93
|
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
96
94
|
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -9,8 +9,7 @@ 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
|
|
13
|
-
import { AaveIncentiveDataProviderV3Contract, AaveV3ViewContract, getConfigContractAbi, getConfigContractAddress, GhoTokenContract, } from '../contracts';
|
|
12
|
+
import { AaveIncentiveDataProviderV3Contract, AaveV3ViewContract, createContractWrapper, getConfigContractAbi, getConfigContractAddress, GhoTokenContract, } from '../contracts';
|
|
14
13
|
import { addToObjectIf, ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress, } from '../services/utils';
|
|
15
14
|
import { NetworkNumber, } from '../types/common';
|
|
16
15
|
import { getStakingApy } from '../staking';
|
|
@@ -252,9 +251,8 @@ export const getAaveV3AccountBalances = (web3, network, block, addressMapping, a
|
|
|
252
251
|
const loanInfoContract = AaveV3ViewContract(web3, network, block);
|
|
253
252
|
const market = AAVE_V3(network);
|
|
254
253
|
const marketAddress = market.providerAddress;
|
|
255
|
-
const protocolDataProviderContract = new web3.eth.Contract(
|
|
256
254
|
// @ts-ignore
|
|
257
|
-
|
|
255
|
+
const protocolDataProviderContract = createContractWrapper(web3, network, market.protocolData, market.protocolDataAddress);
|
|
258
256
|
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
259
257
|
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
260
258
|
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
|
@@ -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
|
});
|
|
@@ -22,7 +22,6 @@ import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
|
22
22
|
import { EMPTY_AAVE_DATA } from '../aaveV3';
|
|
23
23
|
import { aaveAnyGetAggregatedPositionData } from '../helpers/aaveHelpers';
|
|
24
24
|
import { MORPHO_AAVE_V3_ETH } from '../markets/aave';
|
|
25
|
-
import configRaw from '../config/contracts';
|
|
26
25
|
const morphoAaveMath = new MorphoAaveMath();
|
|
27
26
|
const poolInterestRates = new PoolInterestRates();
|
|
28
27
|
const p2pInterestRates = new P2PInterestRates();
|
|
@@ -253,9 +252,8 @@ export const getMorphoAaveV3AccountBalances = (web3, network, block, addressMapp
|
|
|
253
252
|
const selectedMarket = MORPHO_AAVE_V3_ETH(network);
|
|
254
253
|
// @ts-ignore
|
|
255
254
|
const lendingPoolContract = createContractWrapper(web3, network, selectedMarket.lendingPool, selectedMarket.lendingPoolAddress);
|
|
256
|
-
const protocolDataProviderContract = new web3.eth.Contract(
|
|
257
255
|
// @ts-ignore
|
|
258
|
-
|
|
256
|
+
const protocolDataProviderContract = createContractWrapper(web3, network, selectedMarket.protocolData, selectedMarket.protocolDataAddress);
|
|
259
257
|
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
260
258
|
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
261
259
|
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
package/esm/spark/index.js
CHANGED
|
@@ -12,12 +12,11 @@ import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
|
12
12
|
import { ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress, } from '../services/utils';
|
|
13
13
|
import { calculateNetApy, getCbETHApr, getREthApr, getStETHApr, } from '../staking';
|
|
14
14
|
import { getDsrApy } from '../services/dsrService';
|
|
15
|
-
import { SparkIncentiveDataProviderContract, SparkViewContract, getConfigContractAbi, } from '../contracts';
|
|
15
|
+
import { SparkIncentiveDataProviderContract, SparkViewContract, getConfigContractAbi, createContractWrapper, } from '../contracts';
|
|
16
16
|
import { multicall } from '../multicall';
|
|
17
17
|
import { sparkGetAggregatedPositionData, sparkIsInIsolationMode } from '../helpers/sparkHelpers';
|
|
18
18
|
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
19
19
|
import { SPARK_V1 } from '../markets/spark';
|
|
20
|
-
import configRaw from '../config/contracts';
|
|
21
20
|
export const sparkEmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
22
21
|
const { assetsData } = extractedState;
|
|
23
22
|
const usedAssetsValues = Object.values(usedAssets);
|
|
@@ -205,9 +204,8 @@ export const getSparkAccountBalances = (web3, network, block, addressMapping, ad
|
|
|
205
204
|
const loanInfoContract = SparkViewContract(web3, network, block);
|
|
206
205
|
const market = SPARK_V1(network);
|
|
207
206
|
const marketAddress = market.providerAddress;
|
|
208
|
-
const protocolDataProviderContract = new web3.eth.Contract(
|
|
209
207
|
// @ts-ignore
|
|
210
|
-
|
|
208
|
+
const protocolDataProviderContract = createContractWrapper(web3, network, market.protocolData, market.protocolDataAddress);
|
|
211
209
|
const reserveTokens = yield protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
212
210
|
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
213
211
|
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
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",
|
|
@@ -67,6 +67,7 @@ export interface CrvUSDAggregatedPositionData {
|
|
|
67
67
|
borrowedUsd: string;
|
|
68
68
|
borrowed: string;
|
|
69
69
|
safetyRatio: string;
|
|
70
|
+
borrowLimitUsd: string;
|
|
70
71
|
}
|
|
71
72
|
export interface CrvUSDUsedAsset {
|
|
72
73
|
isSupplied: boolean;
|
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) {
|