@defisaver/positions-sdk 2.1.71 → 2.1.72-aave-v4-3-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/aaveV4/index.d.ts +7 -0
- package/cjs/aaveV4/index.js +293 -0
- package/cjs/aaveV4/lend.d.ts +45 -0
- package/cjs/aaveV4/lend.js +141 -0
- package/cjs/config/contracts.d.ts +1551 -0
- package/cjs/config/contracts.js +9 -0
- package/cjs/contracts.d.ts +32741 -0
- package/cjs/contracts.js +2 -1
- package/cjs/helpers/aaveV4Helpers/index.d.ts +12 -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/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/markets/aave/marketAssets.js +1 -1
- package/cjs/markets/aaveV4/index.d.ts +28 -0
- package/cjs/markets/aaveV4/index.js +140 -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/staking/eligibility.d.ts +6 -0
- package/cjs/staking/eligibility.js +37 -19
- package/cjs/staking/staking.js +4 -2
- package/cjs/types/aaveV4.d.ts +153 -0
- package/cjs/types/aaveV4.js +19 -0
- package/cjs/types/common.d.ts +2 -1
- package/cjs/types/common.js +1 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/portfolio.d.ts +4 -0
- package/esm/aaveV4/index.d.ts +7 -0
- package/esm/aaveV4/index.js +250 -0
- package/esm/aaveV4/lend.d.ts +45 -0
- package/esm/aaveV4/lend.js +134 -0
- package/esm/config/contracts.d.ts +1551 -0
- package/esm/config/contracts.js +8 -0
- package/esm/contracts.d.ts +32741 -0
- package/esm/contracts.js +1 -0
- package/esm/helpers/aaveV4Helpers/index.d.ts +12 -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/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/markets/aave/marketAssets.js +1 -1
- package/esm/markets/aaveV4/index.d.ts +28 -0
- package/esm/markets/aaveV4/index.js +122 -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/staking/eligibility.d.ts +6 -0
- package/esm/staking/eligibility.js +35 -18
- package/esm/staking/staking.js +4 -2
- package/esm/types/aaveV4.d.ts +153 -0
- package/esm/types/aaveV4.js +16 -0
- package/esm/types/common.d.ts +2 -1
- package/esm/types/common.js +1 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/portfolio.d.ts +4 -0
- package/package.json +2 -2
- package/src/aaveV4/index.ts +286 -0
- package/src/aaveV4/lend.ts +180 -0
- package/src/config/contracts.ts +9 -1
- package/src/contracts.ts +3 -1
- package/src/helpers/aaveV4Helpers/index.ts +133 -0
- package/src/helpers/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/markets/aave/marketAssets.ts +1 -1
- package/src/markets/aaveV4/index.ts +149 -0
- package/src/markets/index.ts +6 -1
- package/src/portfolio/index.ts +20 -0
- package/src/staking/eligibility.ts +67 -15
- package/src/staking/staking.ts +3 -2
- package/src/types/aaveV4.ts +169 -0
- package/src/types/common.ts +1 -0
- package/src/types/index.ts +2 -1
- package/src/types/portfolio.ts +4 -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');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets, LeverageType, NetworkNumber } from '../../types';
|
|
2
|
+
export declare const aaveV4GetCollateralFactor: (assetData: AaveV4ReserveAssetData, usedAssetData: AaveV4UsedReserveAsset, useUserCollateralFactor?: boolean) => number;
|
|
3
|
+
export declare const isLeveragedPosAaveV4: (usedAssets: AaveV4UsedReserveAssets, dustLimit?: number) => {
|
|
4
|
+
leveragedType: LeverageType;
|
|
5
|
+
leveragedAsset: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const aaveV4GetAggregatedPositionData: ({ usedAssets, assetsData, network, useUserCollateralFactor, }: {
|
|
8
|
+
usedAssets: AaveV4UsedReserveAssets;
|
|
9
|
+
assetsData: AaveV4AssetsData;
|
|
10
|
+
network: NetworkNumber;
|
|
11
|
+
useUserCollateralFactor?: boolean;
|
|
12
|
+
}) => 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 types_1 = require("../../types");
|
|
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: types_1.LeverageType.Long,
|
|
42
|
+
leveragedAsset: longAsset,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (isShort) {
|
|
46
|
+
return {
|
|
47
|
+
leveragedType: types_1.LeverageType.Short,
|
|
48
|
+
leveragedAsset: shortAsset,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (isVolatilePair) {
|
|
52
|
+
return {
|
|
53
|
+
leveragedType: types_1.LeverageType.VolatilePair,
|
|
54
|
+
leveragedAsset: longAsset,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
leveragedType: types_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 === types_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 = types_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"));
|
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"));
|
|
@@ -18,7 +18,7 @@ exports.aaveV3AssetsDefaultMarketOpt = [
|
|
|
18
18
|
exports.aaveV3AssetsDefaultMarketArb = ['DAI', 'LINK', 'USDC.e', 'WBTC', 'ETH', 'USDT', 'AAVE', 'EURS', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC', 'FRAX', 'ARB', 'weETH', 'GHO', 'ezETH', 'rsETH', 'tBTC'];
|
|
19
19
|
exports.aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH', 'USDC', 'weETH', 'cbBTC', 'ezETH', 'GHO', 'wrsETH', 'LBTC', 'EURC', 'AAVE', 'tBTC', 'syrupUSDC'];
|
|
20
20
|
exports.aaveV3AssetsDefaultMarketLinea = ['ETH', 'USDC', 'weETH', 'ezETH', 'USDT', 'wstETH', 'wrsETH', 'WBTC', 'mUSD'];
|
|
21
|
-
exports.aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr'];
|
|
21
|
+
exports.aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr', 'GHO'];
|
|
22
22
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
23
23
|
exports.aaveV3AssetsDefaultMarket = {
|
|
24
24
|
[common_1.NetworkNumber.Eth]: exports.aaveV3AssetsDefaultMarketEth,
|
|
@@ -0,0 +1,28 @@
|
|
|
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_PLUS_HUB: (networkId: NetworkNumber) => AaveV4HubInfo;
|
|
4
|
+
export declare const AAVE_V4_PRIME_HUB: (networkId: NetworkNumber) => AaveV4HubInfo;
|
|
5
|
+
export declare const AaveV4Hubs: (networkId: NetworkNumber) => {
|
|
6
|
+
readonly aave_v4_core_hub: AaveV4HubInfo;
|
|
7
|
+
readonly aave_v4_plus_hub: AaveV4HubInfo;
|
|
8
|
+
readonly aave_v4_prime_hub: AaveV4HubInfo;
|
|
9
|
+
};
|
|
10
|
+
export declare const getAaveV4HubTypeInfo: (type: AaveV4HubsType, network?: NetworkNumber) => AaveV4HubInfo;
|
|
11
|
+
export declare const getAaveV4HubByAddress: (networkId: NetworkNumber, address: string) => AaveV4HubInfo | undefined;
|
|
12
|
+
export declare const AAVE_V4_BLUECHIP_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
13
|
+
export declare const AAVE_V4_ETHENA_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
14
|
+
export declare const AAVE_V4_ETHERFI_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
15
|
+
export declare const AAVE_V4_GOLD_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
16
|
+
export declare const AAVE_V4_KELP_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
17
|
+
export declare const AAVE_V4_LIDO_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
18
|
+
export declare const AAVE_V4_MAIN_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
19
|
+
export declare const AaveV4Spokes: (networkId: NetworkNumber) => {
|
|
20
|
+
readonly aave_v4_bluechip_spoke: AaveV4SpokeInfo;
|
|
21
|
+
readonly aave_v4_ethena_spoke: AaveV4SpokeInfo;
|
|
22
|
+
readonly aave_v4_etherfi_spoke: AaveV4SpokeInfo;
|
|
23
|
+
readonly aave_v4_gold_spoke: AaveV4SpokeInfo;
|
|
24
|
+
readonly aave_v4_kelp_spoke: AaveV4SpokeInfo;
|
|
25
|
+
readonly aave_v4_lido_spoke: AaveV4SpokeInfo;
|
|
26
|
+
readonly aave_v4_main_spoke: AaveV4SpokeInfo;
|
|
27
|
+
};
|
|
28
|
+
export declare const getAaveV4SpokeTypeInfo: (type: AaveV4SpokesType, network?: NetworkNumber) => AaveV4SpokeInfo;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAaveV4SpokeTypeInfo = exports.AaveV4Spokes = exports.AAVE_V4_MAIN_SPOKE = exports.AAVE_V4_LIDO_SPOKE = exports.AAVE_V4_KELP_SPOKE = exports.AAVE_V4_GOLD_SPOKE = exports.AAVE_V4_ETHERFI_SPOKE = exports.AAVE_V4_ETHENA_SPOKE = exports.AAVE_V4_BLUECHIP_SPOKE = exports.getAaveV4HubByAddress = exports.getAaveV4HubTypeInfo = exports.AaveV4Hubs = exports.AAVE_V4_PRIME_HUB = exports.AAVE_V4_PLUS_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: '0x3Ed2C9829FBCab6015E331a0352F8ae148217D70',
|
|
11
|
+
});
|
|
12
|
+
exports.AAVE_V4_CORE_HUB = AAVE_V4_CORE_HUB;
|
|
13
|
+
const AAVE_V4_PLUS_HUB = (networkId) => ({
|
|
14
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
15
|
+
label: 'Plus Hub',
|
|
16
|
+
value: types_1.AaveV4HubsType.AaveV4PlusHub,
|
|
17
|
+
address: '0xcb8C80026248f92c6DE735264c23c8e22922C562',
|
|
18
|
+
});
|
|
19
|
+
exports.AAVE_V4_PLUS_HUB = AAVE_V4_PLUS_HUB;
|
|
20
|
+
const AAVE_V4_PRIME_HUB = (networkId) => ({
|
|
21
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
22
|
+
label: 'Prime Hub',
|
|
23
|
+
value: types_1.AaveV4HubsType.AaveV4PrimeHub,
|
|
24
|
+
address: '0xea40581231Ca775e6A3d7c129cF231D292B85f20',
|
|
25
|
+
});
|
|
26
|
+
exports.AAVE_V4_PRIME_HUB = AAVE_V4_PRIME_HUB;
|
|
27
|
+
const AaveV4Hubs = (networkId) => ({
|
|
28
|
+
[types_1.AaveV4HubsType.AaveV4CoreHub]: (0, exports.AAVE_V4_CORE_HUB)(networkId),
|
|
29
|
+
[types_1.AaveV4HubsType.AaveV4PlusHub]: (0, exports.AAVE_V4_PLUS_HUB)(networkId),
|
|
30
|
+
[types_1.AaveV4HubsType.AaveV4PrimeHub]: (0, exports.AAVE_V4_PRIME_HUB)(networkId),
|
|
31
|
+
});
|
|
32
|
+
exports.AaveV4Hubs = AaveV4Hubs;
|
|
33
|
+
const getAaveV4HubTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Hubs)(network !== null && network !== void 0 ? network : types_1.NetworkNumber.Eth))[type]);
|
|
34
|
+
exports.getAaveV4HubTypeInfo = getAaveV4HubTypeInfo;
|
|
35
|
+
const getAaveV4HubByAddress = (networkId, address) => Object.values((0, exports.AaveV4Hubs)(networkId)).find(hub => hub.address.toLowerCase() === address.toLowerCase());
|
|
36
|
+
exports.getAaveV4HubByAddress = getAaveV4HubByAddress;
|
|
37
|
+
// SPOKES
|
|
38
|
+
const AAVE_V4_BLUECHIP_SPOKE = (networkId) => ({
|
|
39
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
40
|
+
label: 'Bluechip Spoke',
|
|
41
|
+
value: types_1.AaveV4SpokesType.AaveV4BluechipSpoke,
|
|
42
|
+
url: 'bluechip',
|
|
43
|
+
address: '0x637F9E189332a2821e5B046E2d7EEFae2405d6c5',
|
|
44
|
+
hubs: [
|
|
45
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
46
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
47
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
exports.AAVE_V4_BLUECHIP_SPOKE = AAVE_V4_BLUECHIP_SPOKE;
|
|
51
|
+
const AAVE_V4_ETHENA_SPOKE = (networkId) => ({
|
|
52
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
53
|
+
label: 'Ethena Spoke',
|
|
54
|
+
value: types_1.AaveV4SpokesType.AaveV4EthenaSpoke,
|
|
55
|
+
url: 'ethena',
|
|
56
|
+
address: '0x4054a9EbfcdB692599a8dF61eb0b3484F2d279D4',
|
|
57
|
+
hubs: [
|
|
58
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
59
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
60
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
exports.AAVE_V4_ETHENA_SPOKE = AAVE_V4_ETHENA_SPOKE;
|
|
64
|
+
const AAVE_V4_ETHERFI_SPOKE = (networkId) => ({
|
|
65
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
66
|
+
label: 'Etherfi Spoke',
|
|
67
|
+
value: types_1.AaveV4SpokesType.AaveV4EtherfiSpoke,
|
|
68
|
+
url: 'etherfi',
|
|
69
|
+
address: '0x4054a9EbfcdB692599a8dF61eb0b3484F2d279D4',
|
|
70
|
+
hubs: [
|
|
71
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
72
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
73
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
exports.AAVE_V4_ETHERFI_SPOKE = AAVE_V4_ETHERFI_SPOKE;
|
|
77
|
+
const AAVE_V4_GOLD_SPOKE = (networkId) => ({
|
|
78
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
79
|
+
label: 'Gold Spoke',
|
|
80
|
+
value: types_1.AaveV4SpokesType.AaveV4GoldSpoke,
|
|
81
|
+
url: 'gold',
|
|
82
|
+
address: '0x0DC7ccE912Afab8B49031A0A95DB74531741C2c4',
|
|
83
|
+
hubs: [
|
|
84
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
85
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
86
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
exports.AAVE_V4_GOLD_SPOKE = AAVE_V4_GOLD_SPOKE;
|
|
90
|
+
const AAVE_V4_KELP_SPOKE = (networkId) => ({
|
|
91
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
92
|
+
label: 'Kelp Spoke',
|
|
93
|
+
value: types_1.AaveV4SpokesType.AaveV4KelpSpoke,
|
|
94
|
+
url: 'kelp',
|
|
95
|
+
address: '0x8aC76d950a3D03F9E1d857b5AAFFdA3f86C1e9AA',
|
|
96
|
+
hubs: [
|
|
97
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
98
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
99
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
exports.AAVE_V4_KELP_SPOKE = AAVE_V4_KELP_SPOKE;
|
|
103
|
+
const AAVE_V4_LIDO_SPOKE = (networkId) => ({
|
|
104
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
105
|
+
label: 'Lido Spoke',
|
|
106
|
+
value: types_1.AaveV4SpokesType.AaveV4LidoSpoke,
|
|
107
|
+
url: 'lido',
|
|
108
|
+
address: '0x4D4a7b3Ce709b4362D7095a4A0105bDFDb5dA2a7',
|
|
109
|
+
hubs: [
|
|
110
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
111
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
112
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
exports.AAVE_V4_LIDO_SPOKE = AAVE_V4_LIDO_SPOKE;
|
|
116
|
+
const AAVE_V4_MAIN_SPOKE = (networkId) => ({
|
|
117
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
118
|
+
label: 'Main Spoke',
|
|
119
|
+
value: types_1.AaveV4SpokesType.AaveV4MainSpoke,
|
|
120
|
+
url: 'main',
|
|
121
|
+
address: '0x46539e9123A18c427e6b4DFF114c28CF405Cb023',
|
|
122
|
+
hubs: [
|
|
123
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
124
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
125
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
exports.AAVE_V4_MAIN_SPOKE = AAVE_V4_MAIN_SPOKE;
|
|
129
|
+
const AaveV4Spokes = (networkId) => ({
|
|
130
|
+
[types_1.AaveV4SpokesType.AaveV4BluechipSpoke]: (0, exports.AAVE_V4_BLUECHIP_SPOKE)(networkId),
|
|
131
|
+
[types_1.AaveV4SpokesType.AaveV4EthenaSpoke]: (0, exports.AAVE_V4_ETHENA_SPOKE)(networkId),
|
|
132
|
+
[types_1.AaveV4SpokesType.AaveV4EtherfiSpoke]: (0, exports.AAVE_V4_ETHERFI_SPOKE)(networkId),
|
|
133
|
+
[types_1.AaveV4SpokesType.AaveV4GoldSpoke]: (0, exports.AAVE_V4_GOLD_SPOKE)(networkId),
|
|
134
|
+
[types_1.AaveV4SpokesType.AaveV4KelpSpoke]: (0, exports.AAVE_V4_KELP_SPOKE)(networkId),
|
|
135
|
+
[types_1.AaveV4SpokesType.AaveV4LidoSpoke]: (0, exports.AAVE_V4_LIDO_SPOKE)(networkId),
|
|
136
|
+
[types_1.AaveV4SpokesType.AaveV4MainSpoke]: (0, exports.AAVE_V4_MAIN_SPOKE)(networkId),
|
|
137
|
+
});
|
|
138
|
+
exports.AaveV4Spokes = AaveV4Spokes;
|
|
139
|
+
const getAaveV4SpokeTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Spokes)(network !== null && network !== void 0 ? network : types_1.NetworkNumber.Eth))[type]);
|
|
140
|
+
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; } });
|
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([
|
|
@@ -5,6 +5,12 @@ export declare const isEligibleForEthenaUSDeRewards: (usedAssets: MMUsedAssets,
|
|
|
5
5
|
isEligible: boolean;
|
|
6
6
|
eligibleUSDAmount: string;
|
|
7
7
|
};
|
|
8
|
+
export declare const isEligibleForEthenaGHORewards: (usedAssets: MMUsedAssets, { healthRatio }: {
|
|
9
|
+
healthRatio: string;
|
|
10
|
+
}) => {
|
|
11
|
+
isEligible: boolean;
|
|
12
|
+
eligibleUSDAmount: string;
|
|
13
|
+
};
|
|
8
14
|
export declare const isEligibleForAaveV3ArbitrumEthSupply: (usedAssets: MMUsedAssets) => {
|
|
9
15
|
isEligible: boolean;
|
|
10
16
|
eligibleUSDAmount: string;
|
|
@@ -3,34 +3,51 @@ 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.EligibilityMapping = exports.isEligibleForAaveV3ArbitrumETHLSBorrow = exports.isEligibleForAaveV3ArbitrumEthSupply = exports.isEligibleForEthenaUSDeRewards = void 0;
|
|
6
|
+
exports.EligibilityMapping = exports.isEligibleForAaveV3ArbitrumETHLSBorrow = exports.isEligibleForAaveV3ArbitrumEthSupply = exports.isEligibleForEthenaGHORewards = exports.isEligibleForEthenaUSDeRewards = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const common_1 = require("../types/common");
|
|
9
|
-
const
|
|
10
|
-
var _a, _b;
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.
|
|
9
|
+
const isEligibleForEthenaPairRewards = (usedAssets, { healthRatio }, { baseSymbol, pairSymbol, allowedBorrowAssets, maxHealthRatio, rewardSymbol, }) => {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const baseSuppliedUsd = ((_a = usedAssets[baseSymbol]) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
|
|
12
|
+
const pairSuppliedUsd = ((_b = usedAssets[pairSymbol]) === null || _b === void 0 ? void 0 : _b.suppliedUsd) || '0';
|
|
13
|
+
const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.isSupplied && asset.symbol !== baseSymbol && asset.symbol !== pairSymbol);
|
|
14
14
|
if (anythingElseSupplied)
|
|
15
15
|
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
16
|
-
const totalAmountSupplied = new decimal_js_1.default(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const totalAmountSupplied = new decimal_js_1.default(baseSuppliedUsd).add(pairSuppliedUsd);
|
|
17
|
+
if (totalAmountSupplied.eq(0))
|
|
18
|
+
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
19
|
+
const percentageInBase = new decimal_js_1.default(baseSuppliedUsd).div(totalAmountSupplied).toNumber();
|
|
20
|
+
if (percentageInBase < 0.45 || percentageInBase > 0.55)
|
|
21
|
+
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
22
|
+
const percentageInPair = new decimal_js_1.default(pairSuppliedUsd).div(totalAmountSupplied).toNumber();
|
|
23
|
+
if (percentageInPair < 0.45 || percentageInPair > 0.55)
|
|
24
|
+
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
24
25
|
const anythingBorrowedNotAllowed = Object.values(usedAssets).some((asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol));
|
|
25
26
|
if (anythingBorrowedNotAllowed)
|
|
26
27
|
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
27
|
-
if (new decimal_js_1.default(healthRatio).gte(
|
|
28
|
-
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
29
|
-
const halfAmountSupplied =
|
|
30
|
-
const
|
|
31
|
-
|
|
28
|
+
if (new decimal_js_1.default(healthRatio).gte(maxHealthRatio))
|
|
29
|
+
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
30
|
+
const halfAmountSupplied = totalAmountSupplied.div(2);
|
|
31
|
+
const rewardSuppliedUsd = ((_c = usedAssets[rewardSymbol]) === null || _c === void 0 ? void 0 : _c.suppliedUsd) || '0';
|
|
32
|
+
const eligibleUSDAmount = decimal_js_1.default.min(rewardSuppliedUsd, halfAmountSupplied).toString();
|
|
33
|
+
return { isEligible: true, eligibleUSDAmount };
|
|
32
34
|
};
|
|
35
|
+
const isEligibleForEthenaUSDeRewards = (usedAssets, { healthRatio }) => isEligibleForEthenaPairRewards(usedAssets, { healthRatio }, {
|
|
36
|
+
baseSymbol: 'USDe',
|
|
37
|
+
pairSymbol: 'sUSDe',
|
|
38
|
+
allowedBorrowAssets: ['USDC', 'USDT', 'USDS'],
|
|
39
|
+
maxHealthRatio: '2.5',
|
|
40
|
+
rewardSymbol: 'USDe',
|
|
41
|
+
});
|
|
33
42
|
exports.isEligibleForEthenaUSDeRewards = isEligibleForEthenaUSDeRewards;
|
|
43
|
+
const isEligibleForEthenaGHORewards = (usedAssets, { healthRatio }) => isEligibleForEthenaPairRewards(usedAssets, { healthRatio }, {
|
|
44
|
+
baseSymbol: 'syrupUSDT',
|
|
45
|
+
pairSymbol: 'GHO',
|
|
46
|
+
allowedBorrowAssets: ['USDT'],
|
|
47
|
+
maxHealthRatio: '2',
|
|
48
|
+
rewardSymbol: 'GHO',
|
|
49
|
+
});
|
|
50
|
+
exports.isEligibleForEthenaGHORewards = isEligibleForEthenaGHORewards;
|
|
34
51
|
const isEligibleForAaveV3ArbitrumEthSupply = (usedAssets) => {
|
|
35
52
|
var _a, _b;
|
|
36
53
|
const ETHAmountSupplied = ((_a = usedAssets.ETH) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
|
|
@@ -58,4 +75,5 @@ exports.EligibilityMapping = {
|
|
|
58
75
|
[common_1.IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: exports.isEligibleForAaveV3ArbitrumEthSupply,
|
|
59
76
|
[common_1.IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: exports.isEligibleForAaveV3ArbitrumETHLSBorrow,
|
|
60
77
|
[common_1.IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasma]: exports.isEligibleForEthenaUSDeRewards,
|
|
78
|
+
[common_1.IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasmaGHO]: exports.isEligibleForEthenaGHORewards,
|
|
61
79
|
};
|
package/cjs/staking/staking.js
CHANGED
|
@@ -72,7 +72,7 @@ exports.STAKING_ASSETS = [
|
|
|
72
72
|
'cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH',
|
|
73
73
|
'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS', 'tETH', 'PT sUSDe Sep', 'PT USDe Sep',
|
|
74
74
|
'PT sUSDe Nov', 'PT USDe Nov', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'syrupUSDC', 'wstUSR',
|
|
75
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
75
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'GHO',
|
|
76
76
|
];
|
|
77
77
|
exports.getStakingApy = (0, memoizee_1.default)((asset_1, ...args_1) => __awaiter(void 0, [asset_1, ...args_1], void 0, function* (asset, network = common_1.NetworkNumber.Eth) {
|
|
78
78
|
try {
|
|
@@ -117,7 +117,7 @@ exports.getStakingApy = (0, memoizee_1.default)((asset_1, ...args_1) => __awaite
|
|
|
117
117
|
if (asset === 'tETH')
|
|
118
118
|
return yield getApyFromDfsApi('tETH');
|
|
119
119
|
if (asset === 'USDe')
|
|
120
|
-
return yield getApyFromDfsApi('USDe');
|
|
120
|
+
return yield getApyFromDfsApi('USDe', network);
|
|
121
121
|
if (asset === 'PT sUSDe Nov')
|
|
122
122
|
return yield getApyFromDfsApi('PT sUSDe Nov', network);
|
|
123
123
|
if (asset === 'PT USDe Nov')
|
|
@@ -146,6 +146,8 @@ exports.getStakingApy = (0, memoizee_1.default)((asset_1, ...args_1) => __awaite
|
|
|
146
146
|
return yield getApyFromDfsApi('PT USDe May', network);
|
|
147
147
|
if (asset === 'PT srUSDe Apr')
|
|
148
148
|
return yield getApyFromDfsApi('PT srUSDe Apr', network);
|
|
149
|
+
if (asset === 'GHO')
|
|
150
|
+
return yield getApyFromDfsApi('GHO', network);
|
|
149
151
|
}
|
|
150
152
|
catch (e) {
|
|
151
153
|
console.error(`Failed to fetch APY for ${asset}`);
|