@defisaver/positions-sdk 0.0.196 → 0.0.198-dev-liquity-v2-2
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +69 -69
- package/cjs/aaveV3/index.js +2 -2
- package/cjs/compoundV3/index.js +14 -9
- package/cjs/config/contracts.d.ts +1041 -301
- package/cjs/config/contracts.js +71 -13
- package/cjs/contracts.d.ts +3 -0
- package/cjs/contracts.js +4 -1
- package/cjs/helpers/index.d.ts +1 -0
- package/cjs/helpers/index.js +2 -1
- package/cjs/helpers/liquityV2Helpers/index.d.ts +12 -0
- package/cjs/helpers/liquityV2Helpers/index.js +63 -0
- package/cjs/helpers/morphoBlueHelpers/index.d.ts +46 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +242 -20
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/liquityV2/index.d.ts +16 -0
- package/cjs/liquityV2/index.js +139 -0
- package/cjs/markets/compound/index.d.ts +4 -0
- package/cjs/markets/compound/index.js +41 -1
- package/cjs/markets/compound/marketsAssets.d.ts +14 -0
- package/cjs/markets/compound/marketsAssets.js +17 -3
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/markets/liquityV2/index.d.ts +10 -0
- package/cjs/markets/liquityV2/index.js +47 -0
- package/cjs/markets/morphoBlue/index.d.ts +10 -0
- package/cjs/markets/morphoBlue/index.js +89 -3
- package/cjs/moneymarket/moneymarketCommonService.js +1 -1
- package/cjs/morphoAaveV3/index.js +1 -0
- package/cjs/morphoBlue/index.js +41 -10
- package/cjs/services/priceService.d.ts +3 -0
- package/cjs/services/priceService.js +34 -1
- package/cjs/types/aave.d.ts +1 -0
- package/cjs/types/compound.d.ts +3 -1
- package/cjs/types/compound.js +2 -0
- package/cjs/types/contracts/generated/CUSDSv3.d.ts +441 -0
- package/cjs/types/contracts/generated/CUSDSv3.js +5 -0
- package/cjs/types/contracts/generated/CWstETHv3.d.ts +441 -0
- package/cjs/types/contracts/generated/CWstETHv3.js +5 -0
- package/cjs/types/contracts/generated/DFSFeedRegistry.d.ts +40 -0
- package/cjs/types/contracts/generated/DFSFeedRegistry.js +5 -0
- package/cjs/types/contracts/generated/LiquityV2View.d.ts +240 -0
- package/cjs/types/contracts/generated/LiquityV2View.js +5 -0
- package/cjs/types/contracts/generated/MorphoBlueView.d.ts +5 -5
- package/cjs/types/contracts/generated/WstETHPriceFeed.d.ts +39 -0
- package/cjs/types/contracts/generated/WstETHPriceFeed.js +5 -0
- package/cjs/types/contracts/generated/index.d.ts +5 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/liquityV2.d.ts +105 -0
- package/cjs/types/liquityV2.js +24 -0
- package/cjs/types/morphoBlue.d.ts +40 -1
- package/cjs/types/morphoBlue.js +5 -0
- package/esm/aaveV3/index.js +2 -2
- package/esm/compoundV3/index.js +15 -10
- package/esm/config/contracts.d.ts +1041 -301
- package/esm/config/contracts.js +71 -13
- package/esm/contracts.d.ts +3 -0
- package/esm/contracts.js +3 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/liquityV2Helpers/index.d.ts +12 -0
- package/esm/helpers/liquityV2Helpers/index.js +55 -0
- package/esm/helpers/morphoBlueHelpers/index.d.ts +46 -1
- package/esm/helpers/morphoBlueHelpers/index.js +239 -21
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/liquityV2/index.d.ts +16 -0
- package/esm/liquityV2/index.js +129 -0
- package/esm/markets/compound/index.d.ts +4 -0
- package/esm/markets/compound/index.js +39 -1
- package/esm/markets/compound/marketsAssets.d.ts +14 -0
- package/esm/markets/compound/marketsAssets.js +16 -2
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/markets/liquityV2/index.d.ts +10 -0
- package/esm/markets/liquityV2/index.js +40 -0
- package/esm/markets/morphoBlue/index.d.ts +10 -0
- package/esm/markets/morphoBlue/index.js +82 -2
- package/esm/moneymarket/moneymarketCommonService.js +1 -1
- package/esm/morphoAaveV3/index.js +1 -0
- package/esm/morphoBlue/index.js +45 -14
- package/esm/services/priceService.d.ts +3 -0
- package/esm/services/priceService.js +32 -1
- package/esm/types/aave.d.ts +1 -0
- package/esm/types/compound.d.ts +3 -1
- package/esm/types/compound.js +2 -0
- package/esm/types/contracts/generated/CUSDSv3.d.ts +441 -0
- package/esm/types/contracts/generated/CUSDSv3.js +4 -0
- package/esm/types/contracts/generated/CWstETHv3.d.ts +441 -0
- package/esm/types/contracts/generated/CWstETHv3.js +4 -0
- package/esm/types/contracts/generated/DFSFeedRegistry.d.ts +40 -0
- package/esm/types/contracts/generated/DFSFeedRegistry.js +4 -0
- package/esm/types/contracts/generated/LiquityV2View.d.ts +240 -0
- package/esm/types/contracts/generated/LiquityV2View.js +4 -0
- package/esm/types/contracts/generated/MorphoBlueView.d.ts +5 -5
- package/esm/types/contracts/generated/WstETHPriceFeed.d.ts +39 -0
- package/esm/types/contracts/generated/WstETHPriceFeed.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +5 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/liquityV2.d.ts +105 -0
- package/esm/types/liquityV2.js +21 -0
- package/esm/types/morphoBlue.d.ts +40 -1
- package/esm/types/morphoBlue.js +5 -0
- package/package.json +49 -49
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +625 -625
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +220 -220
- package/src/compoundV3/index.ts +291 -291
- package/src/config/contracts.js +1101 -1095
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +133 -132
- package/src/curveUsd/index.ts +229 -229
- package/src/eulerV2/index.ts +303 -303
- package/src/exchange/index.ts +17 -17
- package/src/helpers/aaveHelpers/index.ts +198 -198
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +246 -246
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +232 -232
- package/src/helpers/index.ts +10 -9
- package/src/helpers/liquityV2Helpers/index.ts +80 -0
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +365 -365
- package/src/helpers/sparkHelpers/index.ts +150 -150
- package/src/index.ts +50 -48
- package/src/liquity/index.ts +116 -116
- package/src/liquityV2/index.ts +159 -0
- package/src/llamaLend/index.ts +275 -275
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +152 -152
- package/src/markets/aave/marketAssets.ts +46 -46
- package/src/markets/compound/index.ts +213 -213
- package/src/markets/compound/marketsAssets.ts +82 -82
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/index.ts +24 -24
- package/src/markets/liquityV2/index.ts +44 -0
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +895 -878
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoAaveV2/index.ts +256 -256
- package/src/morphoAaveV3/index.ts +631 -631
- package/src/morphoBlue/index.ts +204 -204
- package/src/multicall/index.ts +22 -22
- package/src/services/dsrService.ts +15 -15
- package/src/services/priceService.ts +62 -62
- package/src/services/utils.ts +56 -56
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +461 -461
- package/src/staking/staking.ts +220 -220
- package/src/types/aave.ts +271 -271
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +131 -131
- package/src/types/contracts/generated/CUSDSv3.ts +685 -0
- package/src/types/contracts/generated/CWstETHv3.ts +685 -0
- package/src/types/contracts/generated/DFSFeedRegistry.ts +77 -0
- package/src/types/contracts/generated/LiquityV2View.ts +311 -0
- package/src/types/contracts/generated/MorphoBlueView.ts +9 -5
- package/src/types/contracts/generated/WstETHPriceFeed.ts +59 -0
- package/src/types/contracts/generated/index.ts +5 -0
- package/src/types/curveUsd.ts +118 -118
- package/src/types/euler.ts +171 -171
- package/src/types/index.ts +10 -9
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +113 -0
- package/src/types/llamaLend.ts +155 -155
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +192 -191
- package/src/types/spark.ts +131 -131
- package/.vscode/launch.json +0 -17
- package/.vscode/settings.json +0 -37
package/.mocharc.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"require": "ts-node/register",
|
|
3
|
-
"extension": ["ts"]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"require": "ts-node/register",
|
|
3
|
+
"extension": ["ts"]
|
|
4
|
+
}
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v20.17.0
|
|
1
|
+
v20.17.0
|
package/README.md
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
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)
|
|
64
|
-
|
|
65
|
-
## Testing
|
|
66
|
-
|
|
67
|
-
`npm run test` - Run all tests
|
|
68
|
-
|
|
69
|
-
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
|
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)
|
|
64
|
+
|
|
65
|
+
## Testing
|
|
66
|
+
|
|
67
|
+
`npm run test` - Run all tests
|
|
68
|
+
|
|
69
|
+
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
package/cjs/aaveV3/index.js
CHANGED
|
@@ -148,7 +148,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
148
148
|
const assetsData = yield Promise.all(loanInfo
|
|
149
149
|
.map((tokenMarket, i) => __awaiter(this, void 0, void 0, function* () {
|
|
150
150
|
const symbol = market.assets[i];
|
|
151
|
-
const nativeAsset = symbol === 'GHO' && network === common_1.NetworkNumber.Eth && market.
|
|
151
|
+
const nativeAsset = symbol === 'GHO' && network === common_1.NetworkNumber.Eth && market.value === 'v3default';
|
|
152
152
|
// eslint-disable-next-line guard-for-in
|
|
153
153
|
for (const eModeIndex in eModeCategoriesData) {
|
|
154
154
|
if ((0, utils_1.isEnabledOnBitmap)(Number(eModeCategoriesData[eModeIndex].collateralBitmap), Number(tokenMarket.assetId)))
|
|
@@ -182,7 +182,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
182
182
|
minDiscountTokenBalance,
|
|
183
183
|
minGhoBalanceForDiscount,
|
|
184
184
|
},
|
|
185
|
-
})), { symbol, isIsolated: new decimal_js_1.default(tokenMarket.debtCeilingForIsolationMode).gt(0), debtCeilingForIsolationMode: new decimal_js_1.default(tokenMarket.debtCeilingForIsolationMode).div(100).toString(), isSiloed: tokenMarket.isSiloedForBorrowing, isolationModeTotalDebt: new decimal_js_1.default(tokenMarket.isolationModeTotalDebt).div(100).toString(), assetId: Number(tokenMarket.assetId), underlyingTokenAddress: tokenMarket.underlyingTokenAddress, supplyRate: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(tokenMarket.supplyRate.toString()).div(1e25).toString()), borrowRate: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(tokenMarket.borrowRateVariable.toString()).div(1e25).toString()), borrowRateDiscounted: (0, moneymarket_1.aprToApy)(nativeAsset ? new decimal_js_1.default(tokenMarket.borrowRateVariable.toString()).div(1e25).mul(1 - parseFloat(discountRateOnBorrow)).toString() : '0'), borrowRateStable: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(tokenMarket.borrowRateStable.toString()).div(1e25).toString()), collateralFactor: new decimal_js_1.default(tokenMarket.collateralFactor.toString()).div(10000).toString(), liquidationRatio: new decimal_js_1.default(tokenMarket.liquidationRatio.toString()).div(10000).toString(), marketLiquidity, utilization: new decimal_js_1.default(tokenMarket.totalBorrow.toString()).times(100).div(new decimal_js_1.default(tokenMarket.totalSupply.toString())).toString(), usageAsCollateralEnabled: tokenMarket.usageAsCollateralEnabled, supplyCap: tokenMarket.supplyCap, borrowCap, totalSupply: (0, tokens_1.assetAmountInEth)(tokenMarket.totalSupply.toString(), symbol), isInactive: !tokenMarket.isActive, isFrozen: tokenMarket.isFrozen, isPaused: tokenMarket.isPaused, canBeBorrowed: tokenMarket.isActive && !tokenMarket.isPaused && !tokenMarket.isFrozen && tokenMarket.borrowingEnabled && isBorrowAllowed, canBeSupplied: !nativeAsset && tokenMarket.isActive && !tokenMarket.isPaused && !tokenMarket.isFrozen, canBeWithdrawn: tokenMarket.isActive && !tokenMarket.isPaused, canBePayBacked: tokenMarket.isActive && !tokenMarket.isPaused, disabledStableBorrowing: !tokenMarket.stableBorrowRateEnabled, totalBorrow: (0, tokens_1.assetAmountInEth)(tokenMarket.totalBorrow.toString(), symbol), totalBorrowVar: (0, tokens_1.assetAmountInEth)(tokenMarket.totalBorrowVar.toString(), symbol), price: new decimal_js_1.default(tokenMarket.price.toString()).div(1e8).toString(), isolationModeBorrowingEnabled: tokenMarket.isolationModeBorrowingEnabled, isFlashLoanEnabled: tokenMarket.isFlashLoanEnabled, aTokenAddress: tokenMarket.aTokenAddress }));
|
|
185
|
+
})), { symbol, isIsolated: new decimal_js_1.default(tokenMarket.debtCeilingForIsolationMode).gt(0), debtCeilingForIsolationMode: new decimal_js_1.default(tokenMarket.debtCeilingForIsolationMode).div(100).toString(), isSiloed: tokenMarket.isSiloedForBorrowing, isolationModeTotalDebt: new decimal_js_1.default(tokenMarket.isolationModeTotalDebt).div(100).toString(), assetId: Number(tokenMarket.assetId), underlyingTokenAddress: tokenMarket.underlyingTokenAddress, supplyRate: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(tokenMarket.supplyRate.toString()).div(1e25).toString()), borrowRate: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(tokenMarket.borrowRateVariable.toString()).div(1e25).toString()), borrowRateDiscounted: (0, moneymarket_1.aprToApy)(nativeAsset ? new decimal_js_1.default(tokenMarket.borrowRateVariable.toString()).div(1e25).mul(1 - parseFloat(discountRateOnBorrow)).toString() : '0'), borrowRateStable: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(tokenMarket.borrowRateStable.toString()).div(1e25).toString()), collateralFactor: new decimal_js_1.default(tokenMarket.collateralFactor.toString()).div(10000).toString(), liquidationBonus: new decimal_js_1.default(tokenMarket.liquidationBonus.toString()).div(10000).toString(), liquidationRatio: new decimal_js_1.default(tokenMarket.liquidationRatio.toString()).div(10000).toString(), marketLiquidity, utilization: new decimal_js_1.default(tokenMarket.totalBorrow.toString()).times(100).div(new decimal_js_1.default(tokenMarket.totalSupply.toString())).toString(), usageAsCollateralEnabled: tokenMarket.usageAsCollateralEnabled, supplyCap: tokenMarket.supplyCap, borrowCap, totalSupply: (0, tokens_1.assetAmountInEth)(tokenMarket.totalSupply.toString(), symbol), isInactive: !tokenMarket.isActive, isFrozen: tokenMarket.isFrozen, isPaused: tokenMarket.isPaused, canBeBorrowed: tokenMarket.isActive && !tokenMarket.isPaused && !tokenMarket.isFrozen && tokenMarket.borrowingEnabled && isBorrowAllowed, canBeSupplied: !nativeAsset && tokenMarket.isActive && !tokenMarket.isPaused && !tokenMarket.isFrozen, canBeWithdrawn: tokenMarket.isActive && !tokenMarket.isPaused, canBePayBacked: tokenMarket.isActive && !tokenMarket.isPaused, disabledStableBorrowing: !tokenMarket.stableBorrowRateEnabled, totalBorrow: (0, tokens_1.assetAmountInEth)(tokenMarket.totalBorrow.toString(), symbol), totalBorrowVar: (0, tokens_1.assetAmountInEth)(tokenMarket.totalBorrowVar.toString(), symbol), price: new decimal_js_1.default(tokenMarket.price.toString()).div(1e8).toString(), isolationModeBorrowingEnabled: tokenMarket.isolationModeBorrowingEnabled, isFlashLoanEnabled: tokenMarket.isFlashLoanEnabled, aTokenAddress: tokenMarket.aTokenAddress }));
|
|
186
186
|
})));
|
|
187
187
|
// Get incentives data
|
|
188
188
|
yield Promise.all(assetsData.map((_market) => __awaiter(this, void 0, void 0, function* () {
|
package/cjs/compoundV3/index.js
CHANGED
|
@@ -25,8 +25,18 @@ const compoundHelpers_1 = require("../helpers/compoundHelpers");
|
|
|
25
25
|
const compound_1 = require("../markets/compound");
|
|
26
26
|
const priceService_1 = require("../services/priceService");
|
|
27
27
|
const getSupportedAssetsAddressesForMarket = (selectedMarket, network) => selectedMarket.collAssets.map(asset => (0, tokens_1.getAssetInfo)((0, utils_1.ethToWeth)(asset), network)).map(addr => addr.address.toLowerCase());
|
|
28
|
+
const getBaseAssetPriceFunction = (asset) => {
|
|
29
|
+
switch (asset) {
|
|
30
|
+
case 'wstETH':
|
|
31
|
+
return priceService_1.getWstETHPrice;
|
|
32
|
+
case 'ETH':
|
|
33
|
+
return priceService_1.getEthPrice;
|
|
34
|
+
default:
|
|
35
|
+
return priceService_1.getUSDCPrice;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
28
38
|
const getCompoundV3MarketsData = (web3, network, selectedMarket, defaultWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
const baseAssetPrice =
|
|
39
|
+
const baseAssetPrice = yield getBaseAssetPriceFunction(selectedMarket.baseAsset)(defaultWeb3);
|
|
30
40
|
const compPrice = yield (0, priceService_1.getCompPrice)(defaultWeb3);
|
|
31
41
|
const contract = (0, contracts_1.CompV3ViewContract)(web3, network);
|
|
32
42
|
const CompV3ViewAddress = contract.options.address;
|
|
@@ -178,14 +188,9 @@ const getCompoundV3AccountData = (web3, network, address, proxyAddress, extracte
|
|
|
178
188
|
if (loanData.borrowAmount.toString() !== '0') {
|
|
179
189
|
usedAssets[baseAssetSymbol].isBorrowed = true;
|
|
180
190
|
usedAssets[baseAssetSymbol].borrowed = (0, tokens_1.assetAmountInEth)(loanData.borrowAmount, baseAssetInfo.symbol);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
.toString();
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
usedAssets[baseAssetSymbol].borrowedUsd = (0, tokens_1.assetAmountInEth)(loanData.borrowValue, baseAssetInfo.symbol);
|
|
188
|
-
}
|
|
191
|
+
usedAssets[baseAssetSymbol].borrowedUsd = new decimal_js_1.default((0, tokens_1.assetAmountInEth)(loanData.borrowValue, baseAssetInfo.symbol))
|
|
192
|
+
.mul(assetsData[baseAssetSymbol].price)
|
|
193
|
+
.toString();
|
|
189
194
|
}
|
|
190
195
|
const supportedAssetsAddresses = getSupportedAssetsAddressesForMarket(selectedMarket, network);
|
|
191
196
|
loanData.collAddr.forEach((coll, i) => {
|