@defisaver/positions-sdk 0.0.190 → 0.0.192
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/aaveV3/index.js +1 -1
- package/cjs/compoundV3/index.js +14 -9
- package/cjs/config/contracts.d.ts +756 -232
- package/cjs/config/contracts.js +52 -8
- package/cjs/contracts.d.ts +2 -0
- package/cjs/contracts.js +3 -1
- 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/morphoBlue/index.d.ts +8 -0
- package/cjs/markets/morphoBlue/index.js +71 -2
- package/cjs/morphoBlue/index.js +27 -10
- package/cjs/services/priceService.d.ts +3 -0
- package/cjs/services/priceService.js +34 -1
- 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/WstETHPriceFeed.d.ts +39 -0
- package/cjs/types/contracts/generated/WstETHPriceFeed.js +5 -0
- package/cjs/types/contracts/generated/index.d.ts +4 -0
- package/cjs/types/morphoBlue.d.ts +5 -1
- package/cjs/types/morphoBlue.js +4 -0
- package/esm/aaveV3/index.js +1 -1
- package/esm/compoundV3/index.js +15 -10
- package/esm/config/contracts.d.ts +756 -232
- package/esm/config/contracts.js +52 -8
- package/esm/contracts.d.ts +2 -0
- package/esm/contracts.js +2 -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/morphoBlue/index.d.ts +8 -0
- package/esm/markets/morphoBlue/index.js +65 -1
- package/esm/morphoBlue/index.js +30 -13
- package/esm/services/priceService.d.ts +3 -0
- package/esm/services/priceService.js +32 -1
- 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/WstETHPriceFeed.d.ts +39 -0
- package/esm/types/contracts/generated/WstETHPriceFeed.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +4 -0
- package/esm/types/morphoBlue.d.ts +5 -1
- package/esm/types/morphoBlue.js +4 -0
- package/package.json +2 -2
- package/src/aaveV3/index.ts +1 -0
- package/src/compoundV3/index.ts +20 -11
- package/src/config/contracts.js +52 -8
- package/src/contracts.ts +2 -0
- package/src/markets/compound/index.ts +42 -2
- package/src/markets/compound/marketsAssets.ts +20 -2
- package/src/markets/morphoBlue/index.ts +70 -1
- package/src/morphoBlue/index.ts +33 -16
- package/src/services/priceService.ts +42 -2
- package/src/types/compound.ts +2 -0
- 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/WstETHPriceFeed.ts +59 -0
- package/src/types/contracts/generated/index.ts +4 -0
- package/src/types/morphoBlue.ts +4 -0
package/cjs/aaveV3/index.js
CHANGED
|
@@ -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) => {
|