@defisaver/positions-sdk 0.0.32 → 0.0.34-dev
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/cjs/compoundV3/index.js +32 -35
- package/cjs/config/contracts.d.ts +908 -41
- package/cjs/config/contracts.js +171 -44
- package/cjs/contracts.js +4 -10
- package/cjs/curveUsd/index.js +1 -1
- package/cjs/helpers/curveUsdHelpers/index.d.ts +2 -1
- package/cjs/helpers/curveUsdHelpers/index.js +25 -17
- package/cjs/markets/curveUsd/index.js +15 -15
- package/cjs/markets/morphoBlue/index.d.ts +2 -0
- package/cjs/markets/morphoBlue/index.js +17 -1
- package/cjs/moneymarket/moneymarketCommonService.js +1 -1
- package/cjs/morphoBlue/index.js +6 -3
- package/cjs/services/utils.d.ts +4 -0
- package/cjs/services/utils.js +13 -1
- package/cjs/types/contracts/generated/CrvUSDView.d.ts +30 -4
- package/cjs/types/curveUsd.d.ts +11 -5
- package/cjs/types/curveUsd.js +5 -5
- package/cjs/types/morphoBlue.d.ts +2 -1
- package/cjs/types/morphoBlue.js +1 -0
- package/esm/compoundV3/index.js +27 -30
- package/esm/config/contracts.d.ts +908 -41
- package/esm/config/contracts.js +171 -44
- package/esm/contracts.js +4 -10
- package/esm/curveUsd/index.js +1 -1
- package/esm/helpers/curveUsdHelpers/index.d.ts +2 -1
- package/esm/helpers/curveUsdHelpers/index.js +26 -18
- package/esm/markets/curveUsd/index.js +15 -15
- package/esm/markets/morphoBlue/index.d.ts +2 -0
- package/esm/markets/morphoBlue/index.js +15 -0
- package/esm/moneymarket/moneymarketCommonService.js +1 -1
- package/esm/morphoBlue/index.js +6 -3
- package/esm/services/utils.d.ts +4 -0
- package/esm/services/utils.js +11 -0
- package/esm/types/contracts/generated/CrvUSDView.d.ts +30 -4
- package/esm/types/curveUsd.d.ts +11 -5
- package/esm/types/curveUsd.js +5 -5
- package/esm/types/morphoBlue.d.ts +2 -1
- package/esm/types/morphoBlue.js +1 -0
- package/package.json +1 -1
- package/src/compoundV3/index.ts +27 -29
- package/src/config/contracts.js +171 -44
- package/src/contracts.ts +5 -11
- package/src/curveUsd/index.ts +1 -1
- package/src/helpers/curveUsdHelpers/index.ts +28 -20
- package/src/markets/curveUsd/index.ts +15 -15
- package/src/markets/morphoBlue/index.ts +16 -0
- package/src/moneymarket/moneymarketCommonService.ts +1 -1
- package/src/morphoBlue/index.ts +8 -3
- package/src/services/utils.ts +14 -1
- package/src/types/contracts/generated/CrvUSDView.ts +43 -8
- package/src/types/curveUsd.ts +11 -5
- package/src/types/morphoBlue.ts +1 -0
- package/yarn-error.log +64 -0
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();
|