@defisaver/positions-sdk 2.1.59 → 2.1.61-aave-v4-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/aaveV3/index.d.ts +1 -0
- package/cjs/aaveV3/index.js +1 -0
- package/cjs/aaveV4/index.d.ts +7 -0
- package/cjs/aaveV4/index.js +174 -0
- package/cjs/compoundV2/index.d.ts +1 -0
- package/cjs/compoundV2/index.js +1 -0
- package/cjs/compoundV3/index.d.ts +1 -0
- package/cjs/compoundV3/index.js +1 -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/eulerV2/index.d.ts +1 -0
- package/cjs/eulerV2/index.js +1 -0
- package/cjs/fluid/index.d.ts +3 -0
- package/cjs/helpers/aaveHelpers/index.js +1 -0
- package/cjs/helpers/aaveV4Helpers/index.d.ts +13 -0
- package/cjs/helpers/aaveV4Helpers/index.js +117 -0
- package/cjs/helpers/compoundHelpers/index.js +2 -0
- package/cjs/helpers/curveUsdHelpers/index.js +1 -0
- package/cjs/helpers/eulerHelpers/index.js +1 -0
- package/cjs/helpers/fluidHelpers/index.js +1 -0
- package/cjs/helpers/index.d.ts +1 -0
- package/cjs/helpers/index.js +2 -1
- package/cjs/helpers/liquityV2Helpers/index.js +1 -0
- package/cjs/helpers/llamaLendHelpers/index.js +1 -0
- package/cjs/helpers/morphoBlueHelpers/index.js +3 -2
- package/cjs/helpers/sparkHelpers/index.js +1 -0
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/liquity/index.js +2 -0
- package/cjs/maker/index.js +2 -0
- package/cjs/markets/aaveV4/index.d.ts +16 -0
- package/cjs/markets/aaveV4/index.js +59 -0
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/moneymarket/moneymarketCommonService.d.ts +1 -0
- package/cjs/moneymarket/moneymarketCommonService.js +8 -1
- package/cjs/portfolio/index.js +20 -0
- package/cjs/services/utils.d.ts +1 -0
- package/cjs/services/utils.js +2 -1
- package/cjs/spark/index.d.ts +1 -0
- package/cjs/spark/index.js +1 -0
- package/cjs/types/aave.d.ts +1 -0
- package/cjs/types/aaveV4.d.ts +139 -0
- package/cjs/types/aaveV4.js +13 -0
- package/cjs/types/common.d.ts +1 -0
- package/cjs/types/compound.d.ts +1 -0
- package/cjs/types/curveUsd.d.ts +2 -0
- package/cjs/types/euler.d.ts +1 -0
- package/cjs/types/fluid.d.ts +1 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/liquity.d.ts +1 -0
- package/cjs/types/liquityV2.d.ts +2 -0
- package/cjs/types/llamaLend.d.ts +2 -0
- package/cjs/types/maker.d.ts +1 -0
- package/cjs/types/morphoBlue.d.ts +2 -0
- package/cjs/types/portfolio.d.ts +4 -0
- package/cjs/types/spark.d.ts +1 -0
- package/esm/aaveV3/index.d.ts +1 -0
- package/esm/aaveV3/index.js +1 -0
- package/esm/aaveV4/index.d.ts +7 -0
- package/esm/aaveV4/index.js +165 -0
- package/esm/compoundV2/index.d.ts +1 -0
- package/esm/compoundV2/index.js +1 -0
- package/esm/compoundV3/index.d.ts +1 -0
- package/esm/compoundV3/index.js +1 -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/eulerV2/index.d.ts +1 -0
- package/esm/eulerV2/index.js +1 -0
- package/esm/fluid/index.d.ts +3 -0
- package/esm/helpers/aaveHelpers/index.js +2 -1
- package/esm/helpers/aaveV4Helpers/index.d.ts +13 -0
- package/esm/helpers/aaveV4Helpers/index.js +108 -0
- package/esm/helpers/compoundHelpers/index.js +3 -1
- package/esm/helpers/curveUsdHelpers/index.js +2 -1
- package/esm/helpers/eulerHelpers/index.js +2 -1
- package/esm/helpers/fluidHelpers/index.js +2 -1
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/liquityV2Helpers/index.js +2 -1
- package/esm/helpers/llamaLendHelpers/index.js +2 -1
- package/esm/helpers/morphoBlueHelpers/index.js +5 -4
- package/esm/helpers/sparkHelpers/index.js +2 -1
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/liquity/index.js +2 -0
- package/esm/maker/index.js +2 -0
- package/esm/markets/aaveV4/index.d.ts +16 -0
- package/esm/markets/aaveV4/index.js +47 -0
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/moneymarket/moneymarketCommonService.d.ts +1 -0
- package/esm/moneymarket/moneymarketCommonService.js +6 -0
- package/esm/portfolio/index.js +21 -1
- package/esm/services/utils.d.ts +1 -0
- package/esm/services/utils.js +1 -0
- package/esm/spark/index.d.ts +1 -0
- package/esm/spark/index.js +1 -0
- package/esm/types/aave.d.ts +1 -0
- package/esm/types/aaveV4.d.ts +139 -0
- package/esm/types/aaveV4.js +10 -0
- package/esm/types/common.d.ts +1 -0
- package/esm/types/compound.d.ts +1 -0
- package/esm/types/curveUsd.d.ts +2 -0
- package/esm/types/euler.d.ts +1 -0
- package/esm/types/fluid.d.ts +1 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/liquity.d.ts +1 -0
- package/esm/types/liquityV2.d.ts +2 -0
- package/esm/types/llamaLend.d.ts +2 -0
- package/esm/types/maker.d.ts +1 -0
- package/esm/types/morphoBlue.d.ts +2 -0
- package/esm/types/portfolio.d.ts +4 -0
- package/esm/types/spark.d.ts +1 -0
- package/package.json +1 -1
- package/src/aaveV3/index.ts +1 -0
- package/src/aaveV4/index.ts +176 -0
- package/src/compoundV2/index.ts +1 -0
- package/src/compoundV3/index.ts +1 -0
- package/src/config/contracts.ts +8 -0
- package/src/contracts.ts +3 -1
- package/src/eulerV2/index.ts +1 -0
- package/src/helpers/aaveHelpers/index.ts +2 -1
- package/src/helpers/aaveV4Helpers/index.ts +128 -0
- package/src/helpers/compoundHelpers/index.ts +3 -1
- package/src/helpers/curveUsdHelpers/index.ts +5 -1
- package/src/helpers/eulerHelpers/index.ts +2 -1
- package/src/helpers/fluidHelpers/index.ts +4 -1
- package/src/helpers/index.ts +1 -0
- package/src/helpers/liquityV2Helpers/index.ts +4 -1
- package/src/helpers/llamaLendHelpers/index.ts +4 -1
- package/src/helpers/morphoBlueHelpers/index.ts +5 -4
- package/src/helpers/sparkHelpers/index.ts +2 -1
- package/src/index.ts +2 -0
- package/src/liquity/index.ts +2 -0
- package/src/maker/index.ts +2 -0
- package/src/markets/aaveV4/index.ts +68 -0
- package/src/markets/index.ts +6 -1
- package/src/moneymarket/moneymarketCommonService.ts +6 -0
- package/src/portfolio/index.ts +20 -0
- package/src/services/utils.ts +1 -0
- package/src/spark/index.ts +1 -0
- package/src/types/aave.ts +1 -0
- package/src/types/aaveV4.ts +155 -0
- package/src/types/common.ts +1 -0
- package/src/types/compound.ts +1 -0
- package/src/types/curveUsd.ts +2 -0
- package/src/types/euler.ts +1 -0
- package/src/types/fluid.ts +2 -1
- package/src/types/index.ts +2 -1
- package/src/types/liquity.ts +1 -0
- package/src/types/liquityV2.ts +2 -0
- package/src/types/llamaLend.ts +2 -0
- package/src/types/maker.ts +1 -0
- package/src/types/morphoBlue.ts +2 -0
- package/src/types/portfolio.ts +4 -0
- package/src/types/spark.ts +1 -0
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/eulerV2/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare const EMPTY_EULER_V2_DATA: {
|
|
|
34
34
|
lastUpdated: number;
|
|
35
35
|
hasBorrowInDifferentVault: boolean;
|
|
36
36
|
addressSpaceTakenByAnotherAccount: boolean;
|
|
37
|
+
exposure: string;
|
|
37
38
|
};
|
|
38
39
|
export declare const _getEulerV2AccountData: (provider: Client, network: NetworkNumber, addressForPosition: EthAddress, ownerAddress: EthAddress, extractedState: ({
|
|
39
40
|
selectedMarket: EulerV2Market;
|
package/cjs/eulerV2/index.js
CHANGED
|
@@ -179,6 +179,7 @@ exports.EMPTY_EULER_V2_DATA = {
|
|
|
179
179
|
lastUpdated: Date.now(),
|
|
180
180
|
hasBorrowInDifferentVault: false,
|
|
181
181
|
addressSpaceTakenByAnotherAccount: false,
|
|
182
|
+
exposure: 'N/A',
|
|
182
183
|
};
|
|
183
184
|
const _getEulerV2AccountData = (provider, network, addressForPosition, ownerAddress, extractedState) => __awaiter(void 0, void 0, void 0, function* () {
|
|
184
185
|
if (!addressForPosition)
|
package/cjs/fluid/index.d.ts
CHANGED
|
@@ -136,6 +136,7 @@ export declare const _getUserPositions: (provider: PublicClient, network: Networ
|
|
|
136
136
|
currentVolatilePairRatio?: string;
|
|
137
137
|
minCollRatio?: string;
|
|
138
138
|
collLiquidationRatio?: string;
|
|
139
|
+
exposure: string;
|
|
139
140
|
owner: string;
|
|
140
141
|
vaultId: number;
|
|
141
142
|
usedAssets: FluidUsedAssets;
|
|
@@ -167,6 +168,7 @@ export declare const getUserPositions: (provider: EthereumProvider, network: Net
|
|
|
167
168
|
currentVolatilePairRatio?: string;
|
|
168
169
|
minCollRatio?: string;
|
|
169
170
|
collLiquidationRatio?: string;
|
|
171
|
+
exposure: string;
|
|
170
172
|
owner: string;
|
|
171
173
|
vaultId: number;
|
|
172
174
|
usedAssets: FluidUsedAssets;
|
|
@@ -198,6 +200,7 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
|
|
|
198
200
|
currentVolatilePairRatio?: string;
|
|
199
201
|
minCollRatio?: string;
|
|
200
202
|
collLiquidationRatio?: string;
|
|
203
|
+
exposure: string;
|
|
201
204
|
owner: string;
|
|
202
205
|
vaultId: number;
|
|
203
206
|
usedAssets: FluidUsedAssets;
|
|
@@ -133,6 +133,7 @@ const aaveAnyGetAggregatedPositionData = (_a) => {
|
|
|
133
133
|
payload.netApy = netApy;
|
|
134
134
|
payload.incentiveUsd = incentiveUsd;
|
|
135
135
|
payload.totalInterestUsd = totalInterestUsd;
|
|
136
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
136
137
|
return payload;
|
|
137
138
|
};
|
|
138
139
|
exports.aaveAnyGetAggregatedPositionData = aaveAnyGetAggregatedPositionData;
|
|
@@ -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;
|
|
@@ -120,6 +120,7 @@ const getCompoundV2AggregatedData = (_a) => {
|
|
|
120
120
|
const assetPrice = assetsData[(0, utils_1.handleWbtcLegacy)(leveragedAsset)].price;
|
|
121
121
|
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
122
122
|
}
|
|
123
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
123
124
|
return payload;
|
|
124
125
|
};
|
|
125
126
|
exports.getCompoundV2AggregatedData = getCompoundV2AggregatedData;
|
|
@@ -169,6 +170,7 @@ const getCompoundV3AggregatedData = (_a) => {
|
|
|
169
170
|
}
|
|
170
171
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
171
172
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
173
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
172
174
|
return payload;
|
|
173
175
|
};
|
|
174
176
|
exports.getCompoundV3AggregatedData = getCompoundV3AggregatedData;
|
|
@@ -45,6 +45,7 @@ const getCrvUsdAggregatedData = (_a) => {
|
|
|
45
45
|
payload.leveragedAsset = leveragedAsset;
|
|
46
46
|
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, usedAssets[selectedMarket.collAsset].price, payload.borrowedUsd, payload.borrowLimitUsd);
|
|
47
47
|
}
|
|
48
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
48
49
|
return payload;
|
|
49
50
|
};
|
|
50
51
|
exports.getCrvUsdAggregatedData = getCrvUsdAggregatedData;
|
|
@@ -132,6 +132,7 @@ const getEulerV2AggregatedData = (_a) => {
|
|
|
132
132
|
}
|
|
133
133
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
134
134
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
135
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
135
136
|
return payload;
|
|
136
137
|
};
|
|
137
138
|
exports.getEulerV2AggregatedData = getEulerV2AggregatedData;
|
|
@@ -75,6 +75,7 @@ const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, }, supplyS
|
|
|
75
75
|
}
|
|
76
76
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
77
77
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
78
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
78
79
|
return payload;
|
|
79
80
|
};
|
|
80
81
|
exports.getFluidAggregatedData = getFluidAggregatedData;
|
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"));
|
|
@@ -59,6 +59,7 @@ const getLiquityV2AggregatedPositionData = ({ usedAssets, assetsData, minCollRat
|
|
|
59
59
|
const assetPrice = assetsData[leveragedAsset].price;
|
|
60
60
|
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.borrowLimitUsd);
|
|
61
61
|
}
|
|
62
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
62
63
|
return payload;
|
|
63
64
|
};
|
|
64
65
|
exports.getLiquityV2AggregatedPositionData = getLiquityV2AggregatedPositionData;
|
|
@@ -53,6 +53,7 @@ const getLlamaLendAggregatedData = (_a) => {
|
|
|
53
53
|
payload.leveragedAsset = leveragedAsset;
|
|
54
54
|
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, usedAssets[collAsset].price, payload.borrowedUsd, payload.borrowLimitUsd);
|
|
55
55
|
}
|
|
56
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
56
57
|
return payload;
|
|
57
58
|
};
|
|
58
59
|
exports.getLlamaLendAggregatedData = getLlamaLendAggregatedData;
|
|
@@ -70,6 +70,7 @@ const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, marketInf
|
|
|
70
70
|
}
|
|
71
71
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
72
72
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
73
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
73
74
|
return payload;
|
|
74
75
|
};
|
|
75
76
|
exports.getMorphoBlueAggregatedPositionData = getMorphoBlueAggregatedPositionData;
|
|
@@ -222,7 +223,7 @@ const getReallocatableLiquidity = (marketId_1, ...args_1) => __awaiter(void 0, [
|
|
|
222
223
|
query: MARKET_QUERY,
|
|
223
224
|
variables: { uniqueKey: marketId, chainId: network },
|
|
224
225
|
}),
|
|
225
|
-
signal: AbortSignal.timeout(utils_1.
|
|
226
|
+
signal: AbortSignal.timeout(utils_1.LONGER_TIMEOUT),
|
|
226
227
|
});
|
|
227
228
|
const data = yield response.json();
|
|
228
229
|
const marketData = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.marketByUniqueKey;
|
|
@@ -286,7 +287,7 @@ const getReallocation = (market_1, assetsData_1, amountToBorrow_1, ...args_1) =>
|
|
|
286
287
|
query: MARKET_QUERY,
|
|
287
288
|
variables: { uniqueKey: marketId, chainId: network },
|
|
288
289
|
}),
|
|
289
|
-
signal: AbortSignal.timeout(utils_1.
|
|
290
|
+
signal: AbortSignal.timeout(utils_1.LONGER_TIMEOUT),
|
|
290
291
|
});
|
|
291
292
|
const data = yield response.json();
|
|
292
293
|
const marketData = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.marketByUniqueKey;
|
|
@@ -113,6 +113,7 @@ const sparkGetAggregatedPositionData = (_a) => {
|
|
|
113
113
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
114
114
|
payload.healthRatio = new decimal_js_1.default(payload.liquidationLimitUsd).div(payload.borrowedUsd).toDP(4).toString();
|
|
115
115
|
payload.minHealthRatio = new decimal_js_1.default(payload.liquidationLimitUsd).div(payload.borrowLimitUsd).toDP(4).toString();
|
|
116
|
+
payload.exposure = (0, moneymarket_1.getExposure)(payload.borrowedUsd, payload.suppliedUsd);
|
|
116
117
|
return payload;
|
|
117
118
|
};
|
|
118
119
|
exports.sparkGetAggregatedPositionData = sparkGetAggregatedPositionData;
|
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"));
|
package/cjs/liquity/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const types_1 = require("../types");
|
|
|
21
21
|
const constants_1 = require("../constants");
|
|
22
22
|
const viem_1 = require("../services/viem");
|
|
23
23
|
const utils_1 = require("../services/utils");
|
|
24
|
+
const moneymarket_1 = require("../moneymarket");
|
|
24
25
|
exports.LIQUITY_NORMAL_MODE_RATIO = 110; // MCR
|
|
25
26
|
exports.LIQUITY_RECOVERY_MODE_RATIO = 150; // CCR
|
|
26
27
|
const _getLiquityAccountBalances = (provider, network, block, addressMapping, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -91,6 +92,7 @@ const _getLiquityTroveInfo = (provider, network, address) => __awaiter(void 0, v
|
|
|
91
92
|
minCollateralRatio: recoveryMode ? exports.LIQUITY_RECOVERY_MODE_RATIO : exports.LIQUITY_NORMAL_MODE_RATIO,
|
|
92
93
|
priceForRecovery: new decimal_js_1.default(recoveryMode ? exports.LIQUITY_RECOVERY_MODE_RATIO : exports.LIQUITY_NORMAL_MODE_RATIO).mul(totalLUSD).div(totalETH).div(100)
|
|
93
94
|
.toString(),
|
|
95
|
+
exposure: (0, moneymarket_1.getExposure)((0, tokens_1.assetAmountInEth)(troveInfo[2].toString()), new decimal_js_1.default((0, tokens_1.assetAmountInEth)(troveInfo[1].toString())).mul(assetPrice).toString()),
|
|
94
96
|
};
|
|
95
97
|
return payload;
|
|
96
98
|
});
|
package/cjs/maker/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const types_1 = require("../types");
|
|
|
20
20
|
const utils_1 = require("../services/utils");
|
|
21
21
|
const makerHelpers_1 = require("../helpers/makerHelpers");
|
|
22
22
|
const viem_1 = require("../services/viem");
|
|
23
|
+
const moneymarket_1 = require("../moneymarket");
|
|
23
24
|
const _getMakerAccountBalances = (provider, network, block, addressMapping, cdpId, _managerAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
25
|
let balances = {
|
|
25
26
|
collateral: {},
|
|
@@ -149,6 +150,7 @@ const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, void 0, v
|
|
|
149
150
|
globalDebtCurrent: collInfo.globalDebtCurrent,
|
|
150
151
|
liquidationFee: collInfo.liquidationFee,
|
|
151
152
|
lastUpdated: Date.now(),
|
|
153
|
+
exposure: (0, moneymarket_1.getExposure)((0, tokens_1.assetAmountInEth)(debt, 'DAI'), collateralUsd),
|
|
152
154
|
};
|
|
153
155
|
});
|
|
154
156
|
exports._getMakerCdpData = _getMakerCdpData;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AaveV4HubInfo, AaveV4HubsType, AaveV4SpokeInfo, AaveV4SpokesType, NetworkNumber } from '../../types';
|
|
2
|
+
export declare const AAVE_V4_CORE_HUB: (networkId: NetworkNumber) => AaveV4HubInfo;
|
|
3
|
+
export declare const AAVE_V4_YIELD_SEEKING_HUB: (networkId: NetworkNumber) => AaveV4HubInfo;
|
|
4
|
+
export declare const AaveV4Hubs: (networkId: NetworkNumber) => {
|
|
5
|
+
readonly aave_v4_core_hub: AaveV4HubInfo;
|
|
6
|
+
readonly aave_v4_yield_seeking_hub: AaveV4HubInfo;
|
|
7
|
+
};
|
|
8
|
+
export declare const getAaveV4HubTypeInfo: (type: AaveV4HubsType, network?: NetworkNumber) => AaveV4HubInfo;
|
|
9
|
+
export declare const getAaveV4HubByAddress: (networkId: NetworkNumber, address: string) => AaveV4HubInfo | undefined;
|
|
10
|
+
export declare const AAVE_V4_CORE_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
11
|
+
export declare const AAVE_V4_YIELD_SEEKING_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
12
|
+
export declare const AaveV4Spokes: (networkId: NetworkNumber) => {
|
|
13
|
+
readonly aave_v4_core_spoke: AaveV4SpokeInfo;
|
|
14
|
+
readonly aave_v4_yield_seeking_spoke: AaveV4SpokeInfo;
|
|
15
|
+
};
|
|
16
|
+
export declare const getAaveV4SpokeTypeInfo: (type: AaveV4SpokesType, network?: NetworkNumber) => AaveV4SpokeInfo;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAaveV4SpokeTypeInfo = exports.AaveV4Spokes = exports.AAVE_V4_YIELD_SEEKING_SPOKE = exports.AAVE_V4_CORE_SPOKE = exports.getAaveV4HubByAddress = exports.getAaveV4HubTypeInfo = exports.AaveV4Hubs = exports.AAVE_V4_YIELD_SEEKING_HUB = exports.AAVE_V4_CORE_HUB = void 0;
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
// HUBS
|
|
6
|
+
const AAVE_V4_CORE_HUB = (networkId) => ({
|
|
7
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
8
|
+
label: 'Core Hub',
|
|
9
|
+
value: types_1.AaveV4HubsType.AaveV4CoreHub,
|
|
10
|
+
address: '0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
|
|
11
|
+
});
|
|
12
|
+
exports.AAVE_V4_CORE_HUB = AAVE_V4_CORE_HUB;
|
|
13
|
+
const AAVE_V4_YIELD_SEEKING_HUB = (networkId) => ({
|
|
14
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
15
|
+
label: 'Yield Seeking Hub',
|
|
16
|
+
value: types_1.AaveV4HubsType.AaveV4YieldSeekingHub,
|
|
17
|
+
address: '0x86F37ba3b480c5fE22A7eb1ba2B2D49c94089FBB',
|
|
18
|
+
});
|
|
19
|
+
exports.AAVE_V4_YIELD_SEEKING_HUB = AAVE_V4_YIELD_SEEKING_HUB;
|
|
20
|
+
const AaveV4Hubs = (networkId) => ({
|
|
21
|
+
[types_1.AaveV4HubsType.AaveV4CoreHub]: (0, exports.AAVE_V4_CORE_HUB)(networkId),
|
|
22
|
+
[types_1.AaveV4HubsType.AaveV4YieldSeekingHub]: (0, exports.AAVE_V4_YIELD_SEEKING_HUB)(networkId),
|
|
23
|
+
});
|
|
24
|
+
exports.AaveV4Hubs = AaveV4Hubs;
|
|
25
|
+
const getAaveV4HubTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Hubs)(network !== null && network !== void 0 ? network : types_1.NetworkNumber.Eth))[type]);
|
|
26
|
+
exports.getAaveV4HubTypeInfo = getAaveV4HubTypeInfo;
|
|
27
|
+
const getAaveV4HubByAddress = (networkId, address) => Object.values((0, exports.AaveV4Hubs)(networkId)).find(hub => hub.address.toLowerCase() === address.toLowerCase());
|
|
28
|
+
exports.getAaveV4HubByAddress = getAaveV4HubByAddress;
|
|
29
|
+
// SPOKES
|
|
30
|
+
const AAVE_V4_CORE_SPOKE = (networkId) => ({
|
|
31
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
32
|
+
label: 'Core Spoke',
|
|
33
|
+
value: types_1.AaveV4SpokesType.AaveV4CoreSpoke,
|
|
34
|
+
url: 'core',
|
|
35
|
+
address: '0xBa97c5E52cd5BC3D7950Ae70779F8FfE92d40CdC',
|
|
36
|
+
hubs: [
|
|
37
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
exports.AAVE_V4_CORE_SPOKE = AAVE_V4_CORE_SPOKE;
|
|
41
|
+
const AAVE_V4_YIELD_SEEKING_SPOKE = (networkId) => ({
|
|
42
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
43
|
+
label: 'Yield Seeking Spoke',
|
|
44
|
+
value: types_1.AaveV4SpokesType.AaveV4YieldSeekingSpoke,
|
|
45
|
+
url: 'yield-seeking',
|
|
46
|
+
address: '0x2559e4e04f2ca7180e5f20c2872d22ec89601b56',
|
|
47
|
+
hubs: [
|
|
48
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
49
|
+
(0, exports.AAVE_V4_YIELD_SEEKING_HUB)(types_1.NetworkNumber.Eth).address,
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
exports.AAVE_V4_YIELD_SEEKING_SPOKE = AAVE_V4_YIELD_SEEKING_SPOKE;
|
|
53
|
+
const AaveV4Spokes = (networkId) => ({
|
|
54
|
+
[types_1.AaveV4SpokesType.AaveV4CoreSpoke]: (0, exports.AAVE_V4_CORE_SPOKE)(networkId),
|
|
55
|
+
[types_1.AaveV4SpokesType.AaveV4YieldSeekingSpoke]: (0, exports.AAVE_V4_YIELD_SEEKING_SPOKE)(networkId),
|
|
56
|
+
});
|
|
57
|
+
exports.AaveV4Spokes = AaveV4Spokes;
|
|
58
|
+
const getAaveV4SpokeTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Spokes)(network !== null && network !== void 0 ? network : types_1.NetworkNumber.Eth))[type]);
|
|
59
|
+
exports.getAaveV4SpokeTypeInfo = getAaveV4SpokeTypeInfo;
|
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; } });
|
|
@@ -10,3 +10,4 @@ export declare const isLeveragedPos: (usedAssets: MMUsedAssets, dustLimit?: numb
|
|
|
10
10
|
leveragedAsset: string;
|
|
11
11
|
};
|
|
12
12
|
export declare const aprToApy: (interest: string | number, frequency?: number) => string;
|
|
13
|
+
export declare const getExposure: (borrowedUsd: string, suppliedUsd: string) => string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.aprToApy = exports.isLeveragedPos = exports.STABLE_ASSETS = exports.calculateBorrowingAssetLimit = exports.calcLeverageLiqPrice = exports.calcShortLiqPrice = exports.calcLongLiqPrice = exports.getAssetsTotal = void 0;
|
|
6
|
+
exports.getExposure = exports.aprToApy = exports.isLeveragedPos = exports.STABLE_ASSETS = exports.calculateBorrowingAssetLimit = exports.calcLeverageLiqPrice = exports.calcShortLiqPrice = exports.calcLongLiqPrice = exports.getAssetsTotal = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const common_1 = require("../types/common");
|
|
@@ -90,3 +90,10 @@ const aprToApy = (interest, frequency = constants_1.BLOCKS_IN_A_YEAR) => new dec
|
|
|
90
90
|
.times(100)
|
|
91
91
|
.toString();
|
|
92
92
|
exports.aprToApy = aprToApy;
|
|
93
|
+
const getExposure = (borrowedUsd, suppliedUsd) => {
|
|
94
|
+
if (borrowedUsd === '0' || suppliedUsd === '0')
|
|
95
|
+
return 'N/A';
|
|
96
|
+
const balanceUsd = new decimal_js_1.default(suppliedUsd).sub(borrowedUsd).toString();
|
|
97
|
+
return new decimal_js_1.default(suppliedUsd).div(balanceUsd).toDecimalPlaces(2).toString();
|
|
98
|
+
};
|
|
99
|
+
exports.getExposure = getExposure;
|
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([
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const MAXUINT: string;
|
|
|
21
21
|
export declare const isMaxuint: (amount: string) => boolean;
|
|
22
22
|
export declare const isMainnetNetwork: (network: NetworkNumber) => network is NetworkNumber.Eth;
|
|
23
23
|
export declare const DEFAULT_TIMEOUT = 2000;
|
|
24
|
+
export declare const LONGER_TIMEOUT = 5000;
|
|
24
25
|
/**
|
|
25
26
|
* Converts web3 hybrid response (that can be used as objects and arrays, so has duplicated values) to objects.
|
|
26
27
|
* @param value
|
package/cjs/services/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getNativeAssetFromWrapped = exports.getWrappedNativeAssetFromUnwrapped = exports.wxplToXpl = exports.xplToWxpl = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.convertHybridArraysToObjects = exports.DEFAULT_TIMEOUT = exports.isMainnetNetwork = exports.isMaxuint = exports.MAXUINT = exports.isEnabledOnBitmap = exports.mapRange = exports.bytesToString = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.getWeiAmountForDecimals = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.addToArrayIf = exports.addToObjectIf = exports.isLayer2Network = void 0;
|
|
6
|
+
exports.getNativeAssetFromWrapped = exports.getWrappedNativeAssetFromUnwrapped = exports.wxplToXpl = exports.xplToWxpl = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.convertHybridArraysToObjects = exports.LONGER_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.isMainnetNetwork = exports.isMaxuint = exports.MAXUINT = exports.isEnabledOnBitmap = exports.mapRange = exports.bytesToString = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.getWeiAmountForDecimals = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.addToArrayIf = exports.addToObjectIf = exports.isLayer2Network = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const tokens_1 = require("@defisaver/tokens");
|
|
9
9
|
const common_1 = require("../types/common");
|
|
@@ -56,6 +56,7 @@ exports.isMaxuint = isMaxuint;
|
|
|
56
56
|
const isMainnetNetwork = (network) => network === common_1.NetworkNumber.Eth;
|
|
57
57
|
exports.isMainnetNetwork = isMainnetNetwork;
|
|
58
58
|
exports.DEFAULT_TIMEOUT = 2000; // 2 seconds
|
|
59
|
+
exports.LONGER_TIMEOUT = 5000; // 5 seconds
|
|
59
60
|
/**
|
|
60
61
|
* Converts web3 hybrid response (that can be used as objects and arrays, so has duplicated values) to objects.
|
|
61
62
|
* @param value
|
package/cjs/spark/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare const EMPTY_SPARK_DATA: {
|
|
|
26
26
|
suppliedCollateralUsd: string;
|
|
27
27
|
totalSupplied: string;
|
|
28
28
|
eModeCategories: never[];
|
|
29
|
+
exposure: string;
|
|
29
30
|
};
|
|
30
31
|
export declare const _getSparkAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
|
|
31
32
|
export declare const getSparkAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
|