@defisaver/positions-sdk 2.1.52-dev-3 → 2.1.53-aave-v4
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 +64 -64
- package/cjs/aaveV4/index.d.ts +7 -0
- package/cjs/aaveV4/index.js +174 -0
- package/cjs/config/contracts.d.ts +1277 -0
- package/cjs/config/contracts.js +9 -0
- package/cjs/contracts.d.ts +23120 -0
- package/cjs/contracts.js +2 -1
- package/cjs/fluid/index.d.ts +3 -3
- package/cjs/helpers/aaveV4Helpers/index.d.ts +13 -0
- package/cjs/helpers/aaveV4Helpers/index.js +117 -0
- package/cjs/helpers/index.d.ts +1 -0
- package/cjs/helpers/index.js +2 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/markets/aaveV4/index.d.ts +13 -0
- package/cjs/markets/aaveV4/index.js +39 -0
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/portfolio/index.js +20 -0
- package/cjs/savings/morphoVaults/index.js +17 -17
- package/cjs/types/aaveV4.d.ts +137 -0
- package/cjs/types/aaveV4.js +11 -0
- package/cjs/types/index.d.ts +2 -0
- package/cjs/types/index.js +2 -0
- package/cjs/types/portfolio.d.ts +4 -0
- package/esm/aaveV4/index.d.ts +7 -0
- package/esm/aaveV4/index.js +165 -0
- package/esm/config/contracts.d.ts +1277 -0
- package/esm/config/contracts.js +8 -0
- package/esm/contracts.d.ts +23120 -0
- package/esm/contracts.js +1 -0
- package/esm/fluid/index.d.ts +3 -3
- package/esm/helpers/aaveV4Helpers/index.d.ts +13 -0
- package/esm/helpers/aaveV4Helpers/index.js +108 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/markets/aaveV4/index.d.ts +13 -0
- package/esm/markets/aaveV4/index.js +29 -0
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/portfolio/index.js +21 -1
- package/esm/savings/morphoVaults/index.js +17 -17
- package/esm/types/aaveV4.d.ts +137 -0
- package/esm/types/aaveV4.js +8 -0
- package/esm/types/index.d.ts +2 -0
- package/esm/types/index.js +2 -0
- package/esm/types/portfolio.d.ts +4 -0
- package/package.json +48 -48
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +635 -635
- package/src/aaveV3/merit.ts +97 -97
- package/src/aaveV3/merkl.ts +74 -74
- package/src/aaveV4/index.ts +176 -0
- package/src/claiming/aaveV3.ts +154 -154
- package/src/claiming/compV3.ts +22 -22
- package/src/claiming/ethena.ts +61 -61
- package/src/claiming/index.ts +12 -12
- package/src/claiming/king.ts +66 -66
- package/src/claiming/morphoBlue.ts +118 -118
- package/src/claiming/spark.ts +225 -225
- package/src/compoundV2/index.ts +244 -244
- package/src/compoundV3/index.ts +274 -274
- package/src/config/contracts.ts +1328 -1320
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +174 -172
- package/src/curveUsd/index.ts +254 -254
- package/src/eulerV2/index.ts +324 -324
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1800 -1800
- package/src/helpers/aaveHelpers/index.ts +202 -202
- package/src/helpers/aaveV4Helpers/index.ts +128 -0
- package/src/helpers/compoundHelpers/index.ts +276 -276
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +229 -229
- package/src/helpers/fluidHelpers/index.ts +335 -335
- package/src/helpers/index.ts +11 -10
- package/src/helpers/liquityV2Helpers/index.ts +82 -82
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +405 -405
- package/src/helpers/sparkHelpers/index.ts +169 -169
- package/src/index.ts +51 -49
- package/src/liquity/index.ts +159 -159
- package/src/liquityV2/index.ts +703 -703
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +118 -118
- package/src/markets/aave/marketAssets.ts +54 -54
- package/src/markets/aaveV4/index.ts +42 -0
- package/src/markets/compound/index.ts +243 -243
- package/src/markets/compound/marketsAssets.ts +97 -97
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2900 -2900
- package/src/markets/index.ts +26 -25
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +988 -988
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -12
- package/src/moneymarket/moneymarketCommonService.ts +84 -84
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +606 -586
- package/src/savings/index.ts +95 -95
- package/src/savings/makerDsr/index.ts +53 -53
- package/src/savings/makerDsr/options.ts +9 -9
- package/src/savings/morphoVaults/index.ts +80 -80
- package/src/savings/morphoVaults/options.ts +193 -193
- package/src/savings/skyOptions/index.ts +95 -95
- package/src/savings/skyOptions/options.ts +10 -10
- package/src/savings/sparkSavingsVaults/index.ts +60 -60
- package/src/savings/sparkSavingsVaults/options.ts +35 -35
- package/src/savings/yearnV3Vaults/index.ts +61 -61
- package/src/savings/yearnV3Vaults/options.ts +55 -55
- package/src/savings/yearnVaults/index.ts +73 -73
- package/src/savings/yearnVaults/options.ts +32 -32
- package/src/services/priceService.ts +278 -278
- package/src/services/utils.ts +115 -115
- package/src/services/viem.ts +57 -57
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +459 -459
- package/src/staking/eligibility.ts +53 -53
- package/src/staking/index.ts +1 -1
- package/src/staking/staking.ts +192 -192
- package/src/types/aave.ts +199 -199
- package/src/types/aaveV4.ts +153 -0
- package/src/types/claiming.ts +114 -114
- package/src/types/common.ts +115 -115
- package/src/types/compound.ts +145 -145
- package/src/types/curveUsd.ts +123 -123
- package/src/types/euler.ts +176 -176
- package/src/types/fluid.ts +485 -485
- package/src/types/index.ts +17 -15
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +128 -128
- package/src/types/llamaLend.ts +161 -161
- package/src/types/maker.ts +63 -63
- package/src/types/merit.ts +1 -1
- package/src/types/merkl.ts +70 -70
- package/src/types/morphoBlue.ts +202 -202
- package/src/types/portfolio.ts +64 -60
- package/src/types/savings/index.ts +23 -23
- package/src/types/savings/makerDsr.ts +13 -13
- package/src/types/savings/morphoVaults.ts +32 -32
- package/src/types/savings/sky.ts +14 -14
- package/src/types/savings/sparkSavingsVaults.ts +15 -15
- package/src/types/savings/yearnV3Vaults.ts +17 -17
- package/src/types/savings/yearnVaults.ts +14 -14
- package/src/types/spark.ts +135 -135
- package/src/umbrella/index.ts +69 -69
- package/src/umbrella/umbrellaUtils.ts +29 -29
package/cjs/contracts.js
CHANGED
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.AaveRewardsControllerViem = exports.SparkRewardsControllerViem = exports.UUPSViem = exports.LiquityStabilityPoolViem = exports.LiquityLQTYStakingViem = exports.AaveUmbrellaViewViem = exports.AaveIncentivesControllerViem = exports.FluidViewContractViem = exports.LiquityV2LegacyViewContractViem = exports.LiquityV2ViewContractViem = exports.LiquityActivePoolContractViem = exports.LiquityPriceFeedContractViem = exports.LiquityTroveManagerContractViem = exports.LiquityCollSurplusPoolContractViem = exports.LiquityViewContractViem = exports.BTCPriceFeedContractViem = exports.WeETHPriceFeedContractViem = exports.ComptrollerContractViem = exports.CompoundLoanInfoContractViem = exports.McdJugContractViem = exports.McdDogContractViem = exports.McdSpotterContractViem = exports.McdVatContractViem = exports.McdViewContractViem = exports.McdGetCdpsContractViem = exports.LlamaLendViewContractViem = exports.CrvUSDFactoryContractViem = exports.CrvUSDViewContractViem = exports.EulerV2ViewContractViem = exports.SparkIncentiveDataProviderContractViem = exports.SparkViewContractViem = exports.CompV3ViewContractViem = exports.WstETHPriceFeedContractViem = exports.USDCPriceFeedContractViem = exports.ETHPriceFeedContractViem = exports.COMPPriceFeedContractViem = exports.DFSFeedRegistryContractViem = exports.FeedRegistryContractViem = exports.AaveIncentiveDataProviderV3ContractViem = exports.AaveV3ViewContractViem = exports.AaveLoanInfoV2ContractViem = exports.MorphoBlueViewContractViem = exports.getYearnV3VaultContractViem = exports.getErc20ContractViem = exports.getSparkSavingsVaultContractViem = exports.getYearnVaultContractViem = exports.getMorphoVaultContractViem = exports.createViemContractFromConfigFunc = exports.getConfigContractAbi = exports.getConfigContractAddress = void 0;
|
|
37
|
-
exports.SkySavingsContractView = exports.MakerDsrContractViem = exports.YearnViewContractViem = exports.StkAAVEViem = exports.LiquityV2sBoldVaultViem = void 0;
|
|
37
|
+
exports.AaveV4ViewContractViem = exports.SkySavingsContractView = exports.MakerDsrContractViem = exports.YearnViewContractViem = exports.StkAAVEViem = exports.LiquityV2sBoldVaultViem = void 0;
|
|
38
38
|
const viem_1 = require("viem");
|
|
39
39
|
const configRaw = __importStar(require("./config/contracts"));
|
|
40
40
|
// @ts-ignore
|
|
@@ -177,3 +177,4 @@ exports.StkAAVEViem = (0, exports.createViemContractFromConfigFunc)('StkAAVE');
|
|
|
177
177
|
exports.YearnViewContractViem = (0, exports.createViemContractFromConfigFunc)('YearnView');
|
|
178
178
|
exports.MakerDsrContractViem = (0, exports.createViemContractFromConfigFunc)('MakerDsr');
|
|
179
179
|
exports.SkySavingsContractView = (0, exports.createViemContractFromConfigFunc)('SkySavings');
|
|
180
|
+
exports.AaveV4ViewContractViem = (0, exports.createViemContractFromConfigFunc)('AaveV4View');
|
package/cjs/fluid/index.d.ts
CHANGED
|
@@ -130,7 +130,7 @@ export declare const _getUserPositions: (provider: PublicClient, network: Networ
|
|
|
130
130
|
collRatio: string;
|
|
131
131
|
minRatio: string;
|
|
132
132
|
totalInterestUsd: string;
|
|
133
|
-
leveragedType?: import("../types
|
|
133
|
+
leveragedType?: import("../types").LeverageType;
|
|
134
134
|
leveragedAsset?: string;
|
|
135
135
|
liquidationPrice?: string;
|
|
136
136
|
currentVolatilePairRatio?: string;
|
|
@@ -161,7 +161,7 @@ export declare const getUserPositions: (provider: EthereumProvider, network: Net
|
|
|
161
161
|
collRatio: string;
|
|
162
162
|
minRatio: string;
|
|
163
163
|
totalInterestUsd: string;
|
|
164
|
-
leveragedType?: import("../types
|
|
164
|
+
leveragedType?: import("../types").LeverageType;
|
|
165
165
|
leveragedAsset?: string;
|
|
166
166
|
liquidationPrice?: string;
|
|
167
167
|
currentVolatilePairRatio?: string;
|
|
@@ -192,7 +192,7 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
|
|
|
192
192
|
collRatio: string;
|
|
193
193
|
minRatio: string;
|
|
194
194
|
totalInterestUsd: string;
|
|
195
|
-
leveragedType?: import("../types
|
|
195
|
+
leveragedType?: import("../types").LeverageType;
|
|
196
196
|
leveragedAsset?: string;
|
|
197
197
|
liquidationPrice?: string;
|
|
198
198
|
currentVolatilePairRatio?: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets } from '../../types';
|
|
2
|
+
import { LeverageType, NetworkNumber } from '../../types/common';
|
|
3
|
+
export declare const aaveV4GetCollateralFactor: (assetData: AaveV4ReserveAssetData, usedAssetData: AaveV4UsedReserveAsset, useUserCollateralFactor?: boolean) => number;
|
|
4
|
+
export declare const isLeveragedPosAaveV4: (usedAssets: AaveV4UsedReserveAssets, dustLimit?: number) => {
|
|
5
|
+
leveragedType: LeverageType;
|
|
6
|
+
leveragedAsset: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const aaveV4GetAggregatedPositionData: ({ usedAssets, assetsData, network, useUserCollateralFactor, }: {
|
|
9
|
+
usedAssets: AaveV4UsedReserveAssets;
|
|
10
|
+
assetsData: AaveV4AssetsData;
|
|
11
|
+
network: NetworkNumber;
|
|
12
|
+
useUserCollateralFactor?: boolean;
|
|
13
|
+
}) => AaveV4AggregatedPositionData;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.aaveV4GetAggregatedPositionData = exports.isLeveragedPosAaveV4 = exports.aaveV4GetCollateralFactor = void 0;
|
|
7
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
+
const moneymarket_1 = require("../../moneymarket");
|
|
9
|
+
const common_1 = require("../../types/common");
|
|
10
|
+
const aaveV4GetCollateralFactor = (assetData, usedAssetData, useUserCollateralFactor = false) => (useUserCollateralFactor ? usedAssetData.collateralFactor : assetData.collateralFactor);
|
|
11
|
+
exports.aaveV4GetCollateralFactor = aaveV4GetCollateralFactor;
|
|
12
|
+
const isLeveragedPosAaveV4 = (usedAssets, dustLimit = 5) => {
|
|
13
|
+
let borrowUnstable = 0;
|
|
14
|
+
let supplyStable = 0;
|
|
15
|
+
let borrowStable = 0;
|
|
16
|
+
let supplyUnstable = 0;
|
|
17
|
+
let longAsset = '';
|
|
18
|
+
let shortAsset = '';
|
|
19
|
+
Object.values(usedAssets).forEach(({ symbol, suppliedUsd, borrowedUsd, collateral, reserveId, }) => {
|
|
20
|
+
const spokeAsset = `${symbol}-${reserveId}`;
|
|
21
|
+
const isSupplied = (+suppliedUsd) > dustLimit; // ignore dust like <limit leftover supply
|
|
22
|
+
const isBorrowed = (+borrowedUsd) > dustLimit; // ignore dust like <limit leftover supply
|
|
23
|
+
if (isSupplied && moneymarket_1.STABLE_ASSETS.includes(symbol) && collateral)
|
|
24
|
+
supplyStable += 1;
|
|
25
|
+
if (isBorrowed && moneymarket_1.STABLE_ASSETS.includes(symbol))
|
|
26
|
+
borrowStable += 1;
|
|
27
|
+
if (isBorrowed && !moneymarket_1.STABLE_ASSETS.includes(symbol)) {
|
|
28
|
+
borrowUnstable += 1;
|
|
29
|
+
shortAsset = spokeAsset;
|
|
30
|
+
}
|
|
31
|
+
if (isSupplied && !moneymarket_1.STABLE_ASSETS.includes(symbol) && collateral) {
|
|
32
|
+
supplyUnstable += 1;
|
|
33
|
+
longAsset = spokeAsset;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const isLong = borrowStable > 0 && borrowUnstable === 0 && supplyUnstable === 1 && supplyStable === 0;
|
|
37
|
+
const isShort = supplyStable > 0 && supplyUnstable === 0 && borrowUnstable === 1 && borrowStable === 0;
|
|
38
|
+
const isVolatilePair = supplyUnstable === 1 && borrowUnstable === 1 && supplyStable === 0 && borrowStable === 0;
|
|
39
|
+
if (isLong) {
|
|
40
|
+
return {
|
|
41
|
+
leveragedType: common_1.LeverageType.Long,
|
|
42
|
+
leveragedAsset: longAsset,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (isShort) {
|
|
46
|
+
return {
|
|
47
|
+
leveragedType: common_1.LeverageType.Short,
|
|
48
|
+
leveragedAsset: shortAsset,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (isVolatilePair) {
|
|
52
|
+
return {
|
|
53
|
+
leveragedType: common_1.LeverageType.VolatilePair,
|
|
54
|
+
leveragedAsset: longAsset,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
leveragedType: common_1.LeverageType.None,
|
|
59
|
+
leveragedAsset: '',
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.isLeveragedPosAaveV4 = isLeveragedPosAaveV4;
|
|
63
|
+
const aaveV4GetAggregatedPositionData = ({ usedAssets, assetsData, network, useUserCollateralFactor = false, }) => {
|
|
64
|
+
const payload = {};
|
|
65
|
+
payload.suppliedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedUsd }) => suppliedUsd);
|
|
66
|
+
payload.suppliedCollateralUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ suppliedUsd }) => suppliedUsd);
|
|
67
|
+
payload.borrowLimitUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ symbol, suppliedUsd, reserveId }) => new decimal_js_1.default(suppliedUsd).mul((0, exports.aaveV4GetCollateralFactor)(assetsData[`${symbol}-${reserveId}`], usedAssets[`${symbol}-${reserveId}`], useUserCollateralFactor)));
|
|
68
|
+
payload.liquidationLimitUsd = payload.borrowLimitUsd;
|
|
69
|
+
payload.borrowedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd);
|
|
70
|
+
payload.drawnUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ drawnUsd }) => drawnUsd);
|
|
71
|
+
payload.premiumUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ premiumUsd }) => premiumUsd);
|
|
72
|
+
const leftToBorrowUsd = new decimal_js_1.default(payload.borrowLimitUsd).sub(payload.borrowedUsd);
|
|
73
|
+
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
74
|
+
payload.ratio = +payload.suppliedUsd ? new decimal_js_1.default(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
75
|
+
payload.collRatio = +payload.suppliedUsd ? new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
76
|
+
payload.liqRatio = new decimal_js_1.default(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
|
|
77
|
+
payload.liqPercent = new decimal_js_1.default(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
78
|
+
const { leveragedType, leveragedAsset } = (0, exports.isLeveragedPosAaveV4)(usedAssets);
|
|
79
|
+
payload.leveragedType = leveragedType;
|
|
80
|
+
payload.leveragedAsset = leveragedAsset;
|
|
81
|
+
payload.liquidationPrice = '';
|
|
82
|
+
if (leveragedType !== '') {
|
|
83
|
+
const leveragedAssetData = assetsData[leveragedAsset];
|
|
84
|
+
let assetPrice = (leveragedAssetData === null || leveragedAssetData === void 0 ? void 0 : leveragedAssetData.price) || '0';
|
|
85
|
+
if (leveragedType === common_1.LeverageType.VolatilePair) {
|
|
86
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
87
|
+
const borrowedAssetPrice = assetsData[`${borrowedAsset.symbol}-${borrowedAsset.reserveId}`].price;
|
|
88
|
+
const leveragedAssetPrice = assetsData[leveragedAsset].price;
|
|
89
|
+
const isReverse = new decimal_js_1.default(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
90
|
+
if (isReverse) {
|
|
91
|
+
payload.leveragedType = common_1.LeverageType.VolatilePairReverse;
|
|
92
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
93
|
+
assetPrice = new decimal_js_1.default(borrowedAssetPrice).div(assetPrice).toString();
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(borrowedAssetPrice).toString();
|
|
97
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
101
|
+
}
|
|
102
|
+
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
103
|
+
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
104
|
+
// payload.healthRatio = new Dec(payload.liquidationLimitUsd).div(payload.borrowedUsd).toDP(4).toString();
|
|
105
|
+
payload.minHealthRatio = new decimal_js_1.default(payload.liquidationLimitUsd).div(payload.borrowLimitUsd).toDP(4).toString();
|
|
106
|
+
// TODO: Re-implement netApy calculation
|
|
107
|
+
// const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy({
|
|
108
|
+
// usedAssets,
|
|
109
|
+
// assetsData,
|
|
110
|
+
// optionalData: { healthRatio: payload.healthRatio },
|
|
111
|
+
// });
|
|
112
|
+
payload.netApy = '0';
|
|
113
|
+
payload.incentiveUsd = '0';
|
|
114
|
+
payload.totalInterestUsd = '0';
|
|
115
|
+
return payload;
|
|
116
|
+
};
|
|
117
|
+
exports.aaveV4GetAggregatedPositionData = aaveV4GetAggregatedPositionData;
|
package/cjs/helpers/index.d.ts
CHANGED
package/cjs/helpers/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.fluidHelpers = exports.eulerV2Helpers = exports.liquityV2Helpers = exports.llamaLendHelpers = exports.morphoBlueHelpers = exports.makerHelpers = exports.curveUsdHelpers = exports.sparkHelpers = exports.compoundHelpers = exports.aaveHelpers = void 0;
|
|
36
|
+
exports.aaveV4Helpers = exports.fluidHelpers = exports.eulerV2Helpers = exports.liquityV2Helpers = exports.llamaLendHelpers = exports.morphoBlueHelpers = exports.makerHelpers = exports.curveUsdHelpers = exports.sparkHelpers = exports.compoundHelpers = exports.aaveHelpers = void 0;
|
|
37
37
|
exports.aaveHelpers = __importStar(require("./aaveHelpers"));
|
|
38
38
|
exports.compoundHelpers = __importStar(require("./compoundHelpers"));
|
|
39
39
|
exports.sparkHelpers = __importStar(require("./sparkHelpers"));
|
|
@@ -44,3 +44,4 @@ exports.llamaLendHelpers = __importStar(require("./llamaLendHelpers"));
|
|
|
44
44
|
exports.liquityV2Helpers = __importStar(require("./liquityV2Helpers"));
|
|
45
45
|
exports.eulerV2Helpers = __importStar(require("./eulerHelpers"));
|
|
46
46
|
exports.fluidHelpers = __importStar(require("./fluidHelpers"));
|
|
47
|
+
exports.aaveV4Helpers = __importStar(require("./aaveV4Helpers"));
|
|
@@ -138,73 +138,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, provider, network)
|
|
|
138
138
|
});
|
|
139
139
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
140
140
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
141
|
-
const MARKET_QUERY = `
|
|
142
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
143
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
144
|
-
reallocatableLiquidityAssets
|
|
145
|
-
targetBorrowUtilization
|
|
146
|
-
loanAsset {
|
|
147
|
-
address
|
|
148
|
-
decimals
|
|
149
|
-
priceUsd
|
|
150
|
-
}
|
|
151
|
-
state {
|
|
152
|
-
liquidityAssets
|
|
153
|
-
borrowAssets
|
|
154
|
-
supplyAssets
|
|
155
|
-
}
|
|
156
|
-
publicAllocatorSharedLiquidity {
|
|
157
|
-
assets
|
|
158
|
-
vault {
|
|
159
|
-
address
|
|
160
|
-
name
|
|
161
|
-
}
|
|
162
|
-
allocationMarket {
|
|
163
|
-
uniqueKey
|
|
164
|
-
loanAsset {
|
|
165
|
-
address
|
|
166
|
-
}
|
|
167
|
-
collateralAsset {
|
|
168
|
-
address
|
|
169
|
-
}
|
|
170
|
-
irmAddress
|
|
171
|
-
oracle {
|
|
172
|
-
address
|
|
173
|
-
}
|
|
174
|
-
lltv
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
loanAsset {
|
|
178
|
-
address
|
|
179
|
-
}
|
|
180
|
-
collateralAsset {
|
|
181
|
-
address
|
|
182
|
-
}
|
|
183
|
-
oracle {
|
|
184
|
-
address
|
|
185
|
-
}
|
|
186
|
-
irmAddress
|
|
187
|
-
lltv
|
|
188
|
-
}
|
|
189
|
-
}
|
|
141
|
+
const MARKET_QUERY = `
|
|
142
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
143
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
144
|
+
reallocatableLiquidityAssets
|
|
145
|
+
targetBorrowUtilization
|
|
146
|
+
loanAsset {
|
|
147
|
+
address
|
|
148
|
+
decimals
|
|
149
|
+
priceUsd
|
|
150
|
+
}
|
|
151
|
+
state {
|
|
152
|
+
liquidityAssets
|
|
153
|
+
borrowAssets
|
|
154
|
+
supplyAssets
|
|
155
|
+
}
|
|
156
|
+
publicAllocatorSharedLiquidity {
|
|
157
|
+
assets
|
|
158
|
+
vault {
|
|
159
|
+
address
|
|
160
|
+
name
|
|
161
|
+
}
|
|
162
|
+
allocationMarket {
|
|
163
|
+
uniqueKey
|
|
164
|
+
loanAsset {
|
|
165
|
+
address
|
|
166
|
+
}
|
|
167
|
+
collateralAsset {
|
|
168
|
+
address
|
|
169
|
+
}
|
|
170
|
+
irmAddress
|
|
171
|
+
oracle {
|
|
172
|
+
address
|
|
173
|
+
}
|
|
174
|
+
lltv
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
loanAsset {
|
|
178
|
+
address
|
|
179
|
+
}
|
|
180
|
+
collateralAsset {
|
|
181
|
+
address
|
|
182
|
+
}
|
|
183
|
+
oracle {
|
|
184
|
+
address
|
|
185
|
+
}
|
|
186
|
+
irmAddress
|
|
187
|
+
lltv
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
190
|
`;
|
|
191
|
-
const REWARDS_QUERY = `
|
|
192
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
193
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
194
|
-
uniqueKey
|
|
195
|
-
state {
|
|
196
|
-
rewards {
|
|
197
|
-
amountPerSuppliedToken
|
|
198
|
-
supplyApr
|
|
199
|
-
amountPerBorrowedToken
|
|
200
|
-
borrowApr
|
|
201
|
-
asset {
|
|
202
|
-
address
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
191
|
+
const REWARDS_QUERY = `
|
|
192
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
193
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
194
|
+
uniqueKey
|
|
195
|
+
state {
|
|
196
|
+
rewards {
|
|
197
|
+
amountPerSuppliedToken
|
|
198
|
+
supplyApr
|
|
199
|
+
amountPerBorrowedToken
|
|
200
|
+
borrowApr
|
|
201
|
+
asset {
|
|
202
|
+
address
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
208
|
`;
|
|
209
209
|
/**
|
|
210
210
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './setup';
|
|
2
2
|
import * as fluid from './fluid';
|
|
3
|
+
import * as aaveV4 from './aaveV4';
|
|
3
4
|
import * as aaveV3 from './aaveV3';
|
|
4
5
|
import * as aaveV2 from './aaveV2';
|
|
5
6
|
import * as compoundV3 from './compoundV3';
|
|
@@ -21,4 +22,4 @@ import * as portfolio from './portfolio';
|
|
|
21
22
|
import * as claiming from './claiming';
|
|
22
23
|
import * as savings from './savings';
|
|
23
24
|
export * from './types';
|
|
24
|
-
export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
|
|
25
|
+
export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
|
package/cjs/index.js
CHANGED
|
@@ -36,10 +36,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.savings = exports.claiming = exports.portfolio = exports.fluid = exports.eulerV2 = exports.llamaLend = exports.morphoBlue = exports.helpers = exports.markets = exports.moneymarket = exports.staking = exports.exchange = exports.maker = exports.liquityV2 = exports.liquity = exports.curveUsd = exports.spark = exports.compoundV3 = exports.compoundV2 = exports.aaveV3 = exports.aaveV2 = void 0;
|
|
39
|
+
exports.savings = exports.claiming = exports.portfolio = exports.fluid = exports.eulerV2 = exports.llamaLend = exports.morphoBlue = exports.helpers = exports.markets = exports.moneymarket = exports.staking = exports.exchange = exports.maker = exports.liquityV2 = exports.liquity = exports.curveUsd = exports.spark = exports.compoundV3 = exports.compoundV2 = exports.aaveV4 = exports.aaveV3 = exports.aaveV2 = void 0;
|
|
40
40
|
require("./setup");
|
|
41
41
|
const fluid = __importStar(require("./fluid"));
|
|
42
42
|
exports.fluid = fluid;
|
|
43
|
+
const aaveV4 = __importStar(require("./aaveV4"));
|
|
44
|
+
exports.aaveV4 = aaveV4;
|
|
43
45
|
const aaveV3 = __importStar(require("./aaveV3"));
|
|
44
46
|
exports.aaveV3 = aaveV3;
|
|
45
47
|
const aaveV2 = __importStar(require("./aaveV2"));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AaveV4HubInfo, AaveV4HubsType, AaveV4SpokeInfo, AaveV4SpokesType } from '../../types';
|
|
2
|
+
import { NetworkNumber } from '../../types/common';
|
|
3
|
+
export declare const AAVE_V4_CORE_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
4
|
+
export declare const AaveV4Spokes: (networkId: NetworkNumber) => {
|
|
5
|
+
readonly aave_v4_core_spoke: AaveV4SpokeInfo;
|
|
6
|
+
};
|
|
7
|
+
export declare const getAaveV4SpokeTypeInfo: (type: AaveV4SpokesType, network?: NetworkNumber) => AaveV4SpokeInfo;
|
|
8
|
+
export declare const AAVE_V4_CORE_HUB: (networkId: NetworkNumber) => AaveV4HubInfo;
|
|
9
|
+
export declare const AaveV4Hubs: (networkId: NetworkNumber) => {
|
|
10
|
+
readonly aave_v4_core_hub: AaveV4HubInfo;
|
|
11
|
+
};
|
|
12
|
+
export declare const getAaveV4HubTypeInfo: (type: AaveV4HubsType, network?: NetworkNumber) => AaveV4HubInfo;
|
|
13
|
+
export declare const getAaveV4HubByAddress: (networkId: NetworkNumber, address: string) => AaveV4HubInfo | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAaveV4HubByAddress = exports.getAaveV4HubTypeInfo = exports.AaveV4Hubs = exports.AAVE_V4_CORE_HUB = exports.getAaveV4SpokeTypeInfo = exports.AaveV4Spokes = exports.AAVE_V4_CORE_SPOKE = void 0;
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
const common_1 = require("../../types/common");
|
|
6
|
+
// SPOKES
|
|
7
|
+
const AAVE_V4_CORE_SPOKE = (networkId) => ({
|
|
8
|
+
chainIds: [common_1.NetworkNumber.Eth],
|
|
9
|
+
label: 'Core Spoke',
|
|
10
|
+
value: types_1.AaveV4SpokesType.AaveV4CoreSpoke,
|
|
11
|
+
url: 'core',
|
|
12
|
+
address: '0xBa97c5E52cd5BC3D7950Ae70779F8FfE92d40CdC',
|
|
13
|
+
hubs: [
|
|
14
|
+
'0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
exports.AAVE_V4_CORE_SPOKE = AAVE_V4_CORE_SPOKE;
|
|
18
|
+
const AaveV4Spokes = (networkId) => ({
|
|
19
|
+
[types_1.AaveV4SpokesType.AaveV4CoreSpoke]: (0, exports.AAVE_V4_CORE_SPOKE)(networkId),
|
|
20
|
+
});
|
|
21
|
+
exports.AaveV4Spokes = AaveV4Spokes;
|
|
22
|
+
const getAaveV4SpokeTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Spokes)(network !== null && network !== void 0 ? network : common_1.NetworkNumber.Eth))[type]);
|
|
23
|
+
exports.getAaveV4SpokeTypeInfo = getAaveV4SpokeTypeInfo;
|
|
24
|
+
// HUBS
|
|
25
|
+
const AAVE_V4_CORE_HUB = (networkId) => ({
|
|
26
|
+
chainIds: [common_1.NetworkNumber.Eth],
|
|
27
|
+
label: 'Core Hub',
|
|
28
|
+
value: types_1.AaveV4HubsType.AaveV4CoreHub,
|
|
29
|
+
address: '0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
|
|
30
|
+
});
|
|
31
|
+
exports.AAVE_V4_CORE_HUB = AAVE_V4_CORE_HUB;
|
|
32
|
+
const AaveV4Hubs = (networkId) => ({
|
|
33
|
+
[types_1.AaveV4HubsType.AaveV4CoreHub]: (0, exports.AAVE_V4_CORE_HUB)(networkId),
|
|
34
|
+
});
|
|
35
|
+
exports.AaveV4Hubs = AaveV4Hubs;
|
|
36
|
+
const getAaveV4HubTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Hubs)(network !== null && network !== void 0 ? network : common_1.NetworkNumber.Eth))[type]);
|
|
37
|
+
exports.getAaveV4HubTypeInfo = getAaveV4HubTypeInfo;
|
|
38
|
+
const getAaveV4HubByAddress = (networkId, address) => Object.values((0, exports.AaveV4Hubs)(networkId)).find(hub => hub.address.toLowerCase() === address.toLowerCase());
|
|
39
|
+
exports.getAaveV4HubByAddress = getAaveV4HubByAddress;
|
package/cjs/markets/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { LlamaLendMarkets } from './llamaLend';
|
|
|
7
7
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
8
8
|
export { EulerV2Markets } from './euler';
|
|
9
9
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
10
|
+
export { AaveV4Spokes } from './aaveV4';
|
package/cjs/markets/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFluidMarketInfoByAddress = exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.EulerV2Markets = exports.findLiquityV2MarketByAddress = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
|
|
3
|
+
exports.AaveV4Spokes = exports.getFluidMarketInfoByAddress = exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.EulerV2Markets = exports.findLiquityV2MarketByAddress = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
|
|
4
4
|
var aave_1 = require("./aave");
|
|
5
5
|
Object.defineProperty(exports, "AaveMarkets", { enumerable: true, get: function () { return aave_1.AaveMarkets; } });
|
|
6
6
|
Object.defineProperty(exports, "aaveV1AssetsDefaultMarket", { enumerable: true, get: function () { return aave_1.aaveV1AssetsDefaultMarket; } });
|
|
@@ -35,3 +35,5 @@ Object.defineProperty(exports, "getFluidVersionsDataForNetwork", { enumerable: t
|
|
|
35
35
|
Object.defineProperty(exports, "getFluidMarketInfoById", { enumerable: true, get: function () { return fluid_1.getFluidMarketInfoById; } });
|
|
36
36
|
Object.defineProperty(exports, "getFTokenAddress", { enumerable: true, get: function () { return fluid_1.getFTokenAddress; } });
|
|
37
37
|
Object.defineProperty(exports, "getFluidMarketInfoByAddress", { enumerable: true, get: function () { return fluid_1.getFluidMarketInfoByAddress; } });
|
|
38
|
+
var aaveV4_1 = require("./aaveV4");
|
|
39
|
+
Object.defineProperty(exports, "AaveV4Spokes", { enumerable: true, get: function () { return aaveV4_1.AaveV4Spokes; } });
|
package/cjs/portfolio/index.js
CHANGED
|
@@ -40,6 +40,7 @@ const spark_2 = require("../claiming/spark");
|
|
|
40
40
|
const morphoBlue_2 = require("../claiming/morphoBlue");
|
|
41
41
|
const king_1 = require("../claiming/king");
|
|
42
42
|
const ethena_1 = require("../claiming/ethena");
|
|
43
|
+
const aaveV4_1 = require("../aaveV4");
|
|
43
44
|
function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1) {
|
|
44
45
|
return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
|
|
45
46
|
const isMainnet = network === common_1.NetworkNumber.Eth;
|
|
@@ -56,6 +57,7 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
56
57
|
const llamaLendMarkets = [common_1.NetworkNumber.Eth, common_1.NetworkNumber.Arb].includes(network) ? Object.values((0, markets_1.LlamaLendMarkets)(network)).filter((market) => market.chainIds.includes(network)) : [];
|
|
57
58
|
const liquityV2Markets = [common_1.NetworkNumber.Eth].includes(network) ? Object.values((0, markets_1.LiquityV2Markets)(network)) : [];
|
|
58
59
|
const liquityV2MarketsStaking = [common_1.NetworkNumber.Eth].includes(network) ? Object.values((0, markets_1.LiquityV2Markets)(network)).filter(market => !market.isLegacy) : [];
|
|
60
|
+
const aaveV4Spokes = Object.values((0, markets_1.AaveV4Spokes)(network)).filter((market) => market.chainIds.includes(network));
|
|
59
61
|
const args = [network, { batch: { multicall: { batchSize: isSim ? 500000 : 2500000 } } }];
|
|
60
62
|
const client = (0, viem_1.getViemProvider)(provider, ...args);
|
|
61
63
|
const defaultClient = (0, viem_1.getViemProvider)(defaultProvider, ...args);
|
|
@@ -70,6 +72,7 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
70
72
|
const crvUsdMarketsData = {};
|
|
71
73
|
const llamaLendMarketsData = {};
|
|
72
74
|
const liquityV2MarketsData = {};
|
|
75
|
+
const aaveV4SpokesData = {};
|
|
73
76
|
const markets = {
|
|
74
77
|
morphoMarketsData,
|
|
75
78
|
compoundV3MarketsData,
|
|
@@ -81,6 +84,7 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
81
84
|
crvUsdMarketsData,
|
|
82
85
|
llamaLendMarketsData,
|
|
83
86
|
liquityV2MarketsData,
|
|
87
|
+
aaveV4SpokesData,
|
|
84
88
|
};
|
|
85
89
|
const positions = {};
|
|
86
90
|
const stakingPositions = {};
|
|
@@ -89,6 +93,7 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
89
93
|
for (const address of allAddresses) {
|
|
90
94
|
positions[address.toLowerCase()] = {
|
|
91
95
|
aaveV3: {},
|
|
96
|
+
aaveV4: {},
|
|
92
97
|
morphoBlue: {},
|
|
93
98
|
compoundV3: {},
|
|
94
99
|
spark: {},
|
|
@@ -154,6 +159,10 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
154
159
|
const marketData = yield (0, aaveV3_1._getAaveV3MarketData)(client, network, market);
|
|
155
160
|
aaveV3MarketsData[market.value] = marketData;
|
|
156
161
|
})),
|
|
162
|
+
...aaveV4Spokes.map((spoke) => __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
const spokeData = yield (0, aaveV4_1._getAaveV4SpokeData)(client, network, spoke);
|
|
164
|
+
aaveV4SpokesData[spoke.value] = spokeData;
|
|
165
|
+
})),
|
|
157
166
|
...aaveV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
158
167
|
const marketData = yield (0, aaveV2_1._getAaveV2MarketsData)(client, network, market);
|
|
159
168
|
aaveV2MarketsData[market.value] = marketData;
|
|
@@ -423,6 +432,17 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
423
432
|
positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
424
433
|
}
|
|
425
434
|
}))).flat(),
|
|
435
|
+
...aaveV4Spokes.map((spoke) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
436
|
+
try {
|
|
437
|
+
const accData = yield (0, aaveV4_1._getAaveV4AccountData)(client, network, aaveV4SpokesData[spoke.value], address);
|
|
438
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
439
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: '', data: accData };
|
|
440
|
+
}
|
|
441
|
+
catch (error) {
|
|
442
|
+
console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
|
|
443
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
|
|
444
|
+
}
|
|
445
|
+
}))).flat(),
|
|
426
446
|
...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
427
447
|
try {
|
|
428
448
|
const [accDataPromise, earnDataPromise] = yield Promise.allSettled([
|
|
@@ -54,23 +54,23 @@ const morphoVaultsOptions = __importStar(require("./options"));
|
|
|
54
54
|
exports.morphoVaultsOptions = morphoVaultsOptions;
|
|
55
55
|
const viem_1 = require("../../services/viem");
|
|
56
56
|
const contracts_1 = require("../../contracts");
|
|
57
|
-
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
58
|
-
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
59
|
-
id,
|
|
60
|
-
dailyApy,
|
|
61
|
-
dailyApys {
|
|
62
|
-
apy, netApy
|
|
63
|
-
},
|
|
64
|
-
monthlyApys {
|
|
65
|
-
apy, netApy
|
|
66
|
-
},
|
|
67
|
-
liquidity {
|
|
68
|
-
underlying, usd,
|
|
69
|
-
},
|
|
70
|
-
asset {
|
|
71
|
-
priceUsd
|
|
72
|
-
}
|
|
73
|
-
}
|
|
57
|
+
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
58
|
+
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
59
|
+
id,
|
|
60
|
+
dailyApy,
|
|
61
|
+
dailyApys {
|
|
62
|
+
apy, netApy
|
|
63
|
+
},
|
|
64
|
+
monthlyApys {
|
|
65
|
+
apy, netApy
|
|
66
|
+
},
|
|
67
|
+
liquidity {
|
|
68
|
+
underlying, usd,
|
|
69
|
+
},
|
|
70
|
+
asset {
|
|
71
|
+
priceUsd
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
74
|
}`;
|
|
75
75
|
const MORPHO_BLUE_API = 'https://blue-api.morpho.org/graphql';
|
|
76
76
|
const _getMorphoVaultData = (provider, network, morphoVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|