@defisaver/positions-sdk 2.1.79 → 2.1.82
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 +243 -0
- package/cjs/aaveV4/lend.d.ts +55 -0
- package/cjs/aaveV4/lend.js +131 -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/eulerV2/index.d.ts +1 -2
- package/cjs/eulerV2/index.js +4 -5
- package/cjs/helpers/aaveV4Helpers/index.d.ts +25 -0
- package/cjs/helpers/aaveV4Helpers/index.js +233 -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/aaveV4/index.d.ts +34 -0
- package/cjs/markets/aaveV4/index.js +182 -0
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/moneymarket/moneymarketCommonService.js +1 -1
- package/cjs/portfolio/index.js +20 -0
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +3 -3
- package/cjs/types/aaveV4.d.ts +159 -0
- package/cjs/types/aaveV4.js +22 -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 +200 -0
- package/esm/aaveV4/lend.d.ts +55 -0
- package/esm/aaveV4/lend.js +124 -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/eulerV2/index.d.ts +1 -2
- package/esm/eulerV2/index.js +5 -6
- package/esm/helpers/aaveV4Helpers/index.d.ts +25 -0
- package/esm/helpers/aaveV4Helpers/index.js +221 -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/aaveV4/index.d.ts +34 -0
- package/esm/markets/aaveV4/index.js +161 -0
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/moneymarket/moneymarketCommonService.js +1 -1
- package/esm/portfolio/index.js +21 -1
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +1 -1
- package/esm/types/aaveV4.d.ts +159 -0
- package/esm/types/aaveV4.js +19 -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 +221 -0
- package/src/aaveV4/lend.ts +185 -0
- package/src/config/contracts.ts +8 -0
- package/src/contracts.ts +2 -0
- package/src/eulerV2/index.ts +12 -7
- package/src/helpers/aaveV4Helpers/index.ts +291 -0
- package/src/helpers/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/markets/aaveV4/index.ts +191 -0
- package/src/markets/index.ts +6 -1
- package/src/moneymarket/moneymarketCommonService.ts +1 -1
- package/src/portfolio/index.ts +20 -0
- package/src/services/utils.ts +1 -1
- package/src/types/aaveV4.ts +175 -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.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.getErc4626ContractViem = 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 = exports.AaveRewardsControllerViem = void 0;
|
|
37
|
+
exports.AaveV4ViewContractViem = exports.SkySavingsContractView = exports.MakerDsrContractViem = exports.YearnViewContractViem = exports.StkAAVEViem = exports.LiquityV2sBoldVaultViem = exports.AaveRewardsControllerViem = void 0;
|
|
38
38
|
const viem_1 = require("viem");
|
|
39
39
|
const configRaw = __importStar(require("./config/contracts"));
|
|
40
40
|
// @ts-ignore
|
|
@@ -186,3 +186,4 @@ exports.StkAAVEViem = (0, exports.createViemContractFromConfigFunc)('StkAAVE');
|
|
|
186
186
|
exports.YearnViewContractViem = (0, exports.createViemContractFromConfigFunc)('YearnView');
|
|
187
187
|
exports.MakerDsrContractViem = (0, exports.createViemContractFromConfigFunc)('MakerDsr');
|
|
188
188
|
exports.SkySavingsContractView = (0, exports.createViemContractFromConfigFunc)('SkySavings');
|
|
189
|
+
exports.AaveV4ViewContractViem = (0, exports.createViemContractFromConfigFunc)('AaveV4View');
|
package/cjs/eulerV2/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
|
-
import { EthAddress, EthereumProvider, NetworkNumber } from '../types
|
|
3
|
-
import { EulerV2AssetsData, EulerV2FullMarketData, EulerV2Market, EulerV2MarketInfoData, EulerV2PositionData } from '../types';
|
|
2
|
+
import { EulerV2AssetsData, EulerV2FullMarketData, EulerV2Market, EulerV2MarketInfoData, EulerV2PositionData, EthAddress, EthereumProvider, NetworkNumber } from '../types';
|
|
4
3
|
export declare const EMPTY_USED_ASSET: {
|
|
5
4
|
isSupplied: boolean;
|
|
6
5
|
isBorrowed: boolean;
|
package/cjs/eulerV2/index.js
CHANGED
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getEulerV2AccountData = exports._getEulerV2AccountData = exports.EMPTY_EULER_V2_DATA = exports.getEulerV2MarketsData = exports._getEulerV2MarketsData = exports.EMPTY_USED_ASSET = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
|
-
const common_1 = require("../types/common");
|
|
19
18
|
const staking_1 = require("../staking");
|
|
20
19
|
const utils_1 = require("../services/utils");
|
|
21
20
|
const types_1 = require("../types");
|
|
@@ -65,7 +64,7 @@ const _getEulerV2MarketsData = (provider, network, selectedMarket) => __awaiter(
|
|
|
65
64
|
collateralFactor: new decimal_js_1.default(collateral.borrowLTV).div(10000).toString(),
|
|
66
65
|
totalBorrow: (0, utils_1.getEthAmountForDecimals)(collateral.totalBorrows.toString(), decimals), // parse
|
|
67
66
|
cash: (0, utils_1.getEthAmountForDecimals)(collateral.cash.toString(), decimals),
|
|
68
|
-
supplyCap: (0, utils_1.
|
|
67
|
+
supplyCap: (0, utils_1.isMaxUint)(collateral.supplyCap.toString()) ? collateral.supplyCap.toString() : (0, utils_1.getEthAmountForDecimals)(collateral.supplyCap.toString(), decimals),
|
|
69
68
|
borrowCap: '0',
|
|
70
69
|
price: isInUSD ? (0, tokens_1.assetAmountInEth)(collateral.assetPriceInUnit.toString()) : new decimal_js_1.default((0, tokens_1.assetAmountInEth)(collateral.assetPriceInUnit.toString())).mul(usdPrice).toString(), // 1e18 -> price in unitOfAccount (so it could be USD or any other token)
|
|
71
70
|
canBeBorrowed: false,
|
|
@@ -83,7 +82,7 @@ const _getEulerV2MarketsData = (provider, network, selectedMarket) => __awaiter(
|
|
|
83
82
|
coll.supplyIncentives.push({
|
|
84
83
|
apy: yield (0, staking_1.getStakingApy)(coll.symbol),
|
|
85
84
|
token: coll.symbol,
|
|
86
|
-
incentiveKind:
|
|
85
|
+
incentiveKind: types_1.IncentiveKind.Staking,
|
|
87
86
|
description: `Native ${coll.symbol} yield.`,
|
|
88
87
|
});
|
|
89
88
|
}
|
|
@@ -105,8 +104,8 @@ const _getEulerV2MarketsData = (provider, network, selectedMarket) => __awaiter(
|
|
|
105
104
|
decimals,
|
|
106
105
|
totalBorrow: (0, utils_1.getEthAmountForDecimals)(data.totalBorrows.toString(), decimals), // parse
|
|
107
106
|
cash: (0, utils_1.getEthAmountForDecimals)(data.cash.toString(), decimals),
|
|
108
|
-
supplyCap: (0, utils_1.
|
|
109
|
-
borrowCap: (0, utils_1.
|
|
107
|
+
supplyCap: (0, utils_1.isMaxUint)(data.supplyCap.toString()) ? data.supplyCap.toString() : (0, utils_1.getEthAmountForDecimals)(data.supplyCap.toString(), decimals),
|
|
108
|
+
borrowCap: (0, utils_1.isMaxUint)(data.supplyCap.toString()) ? data.borrowCap.toString() : (0, utils_1.getEthAmountForDecimals)(data.borrowCap.toString(), decimals),
|
|
110
109
|
price: isInUSD ? (0, tokens_1.assetAmountInEth)(data.assetPriceInUnit.toString()) : new decimal_js_1.default((0, tokens_1.assetAmountInEth)(data.assetPriceInUnit.toString())).mul(usdPrice).toString(), // 1e18 -> price in unitOfAccount (so it could be USD or any other token)
|
|
111
110
|
sortIndex: 0,
|
|
112
111
|
canBeBorrowed: true,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets, LeverageType, NetworkNumber } from '../../types';
|
|
2
|
+
export declare const calcUserRiskPremiumBps: (usedAssets: AaveV4UsedReserveAssets, assetsData: AaveV4AssetsData) => number;
|
|
3
|
+
export declare const getApyAfterValuesEstimation: (usedAssets: AaveV4UsedReserveAssets, assetsData: AaveV4AssetsData) => Record<string, {
|
|
4
|
+
borrowRate: string;
|
|
5
|
+
supplyRate: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const calculateNetApyAaveV4: ({ usedAssets, assetsData, }: {
|
|
8
|
+
usedAssets: AaveV4UsedReserveAssets;
|
|
9
|
+
assetsData: AaveV4AssetsData;
|
|
10
|
+
}) => {
|
|
11
|
+
netApy: string;
|
|
12
|
+
totalInterestUsd: string;
|
|
13
|
+
incentiveUsd: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const aaveV4GetCollateralFactor: (assetData: AaveV4ReserveAssetData, usedAssetData: AaveV4UsedReserveAsset, useUserCollateralFactor?: boolean) => number;
|
|
16
|
+
export declare const isLeveragedPosAaveV4: (usedAssets: AaveV4UsedReserveAssets, dustLimit?: number) => {
|
|
17
|
+
leveragedType: LeverageType;
|
|
18
|
+
leveragedAsset: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const aaveV4GetAggregatedPositionData: ({ usedAssets, assetsData, network, useUserCollateralFactor, }: {
|
|
21
|
+
usedAssets: AaveV4UsedReserveAssets;
|
|
22
|
+
assetsData: AaveV4AssetsData;
|
|
23
|
+
network: NetworkNumber;
|
|
24
|
+
useUserCollateralFactor?: boolean;
|
|
25
|
+
}) => AaveV4AggregatedPositionData;
|
|
@@ -0,0 +1,233 @@
|
|
|
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 = exports.calculateNetApyAaveV4 = exports.getApyAfterValuesEstimation = exports.calcUserRiskPremiumBps = void 0;
|
|
7
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
+
const moneymarket_1 = require("../../moneymarket");
|
|
9
|
+
const staking_1 = require("../../staking");
|
|
10
|
+
const types_1 = require("../../types");
|
|
11
|
+
const calcUserRiskPremiumBps = (usedAssets, assetsData) => {
|
|
12
|
+
const collaterals = [];
|
|
13
|
+
const debts = [];
|
|
14
|
+
Object.entries(usedAssets).forEach(([identifier, asset]) => {
|
|
15
|
+
const reserveData = assetsData[identifier];
|
|
16
|
+
if (!reserveData)
|
|
17
|
+
return;
|
|
18
|
+
const borrowedUsdDec = new decimal_js_1.default(asset.borrowedUsd || '0');
|
|
19
|
+
if (asset.isBorrowed && borrowedUsdDec.gt(0)) {
|
|
20
|
+
debts.push({ valueUsd: borrowedUsdDec });
|
|
21
|
+
}
|
|
22
|
+
const suppliedUsdDec = new decimal_js_1.default(asset.suppliedUsd || '0');
|
|
23
|
+
const isActiveCollateral = asset.collateral
|
|
24
|
+
&& asset.isSupplied
|
|
25
|
+
&& asset.collateralFactor > 0
|
|
26
|
+
&& suppliedUsdDec.gt(0);
|
|
27
|
+
if (isActiveCollateral) {
|
|
28
|
+
// collateralRisk is stored as a fraction (e.g. 0.25), convert back to bps
|
|
29
|
+
const riskBps = new decimal_js_1.default(reserveData.collateralRisk).mul(10000).toNumber();
|
|
30
|
+
collaterals.push({
|
|
31
|
+
riskBps,
|
|
32
|
+
valueUsd: suppliedUsdDec,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const totalDebtUsd = debts.reduce((sum, d) => sum.add(d.valueUsd), new decimal_js_1.default(0));
|
|
37
|
+
if (totalDebtUsd.lte(0)) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
// sort by risk ASC, value DESC
|
|
41
|
+
collaterals.sort((a, b) => {
|
|
42
|
+
if (a.riskBps !== b.riskBps)
|
|
43
|
+
return a.riskBps - b.riskBps;
|
|
44
|
+
return b.valueUsd.comparedTo(a.valueUsd);
|
|
45
|
+
});
|
|
46
|
+
let debtLeftToCover = totalDebtUsd;
|
|
47
|
+
let numerator = new decimal_js_1.default(0); // sum(coveredUsd * riskBps)
|
|
48
|
+
let coveredDebt = new decimal_js_1.default(0); // sum(coveredUsd)
|
|
49
|
+
collaterals.forEach(({ riskBps, valueUsd }) => {
|
|
50
|
+
if (debtLeftToCover.lte(0))
|
|
51
|
+
return;
|
|
52
|
+
const coveredUsd = decimal_js_1.default.min(valueUsd, debtLeftToCover);
|
|
53
|
+
numerator = numerator.add(coveredUsd.mul(riskBps));
|
|
54
|
+
coveredDebt = coveredDebt.add(coveredUsd);
|
|
55
|
+
debtLeftToCover = debtLeftToCover.sub(coveredUsd);
|
|
56
|
+
});
|
|
57
|
+
if (coveredDebt.lte(0)) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
const riskPremiumBps = numerator.div(coveredDebt);
|
|
61
|
+
return riskPremiumBps.toNumber();
|
|
62
|
+
};
|
|
63
|
+
exports.calcUserRiskPremiumBps = calcUserRiskPremiumBps;
|
|
64
|
+
const getApyAfterValuesEstimation = (usedAssets, assetsData) => {
|
|
65
|
+
const riskPremiumBps = (0, exports.calcUserRiskPremiumBps)(usedAssets, assetsData);
|
|
66
|
+
const riskPremiumFraction = new decimal_js_1.default(riskPremiumBps).div(10000); // bps to fraction
|
|
67
|
+
const result = {};
|
|
68
|
+
Object.entries(assetsData).forEach(([identifier, assetData]) => {
|
|
69
|
+
const drawnRate = new decimal_js_1.default(assetData.drawnRate);
|
|
70
|
+
const baseBorrowApr = drawnRate.mul(100);
|
|
71
|
+
// finalBorrowRate = baseBorrowRate * (1 + riskPremiumFraction)
|
|
72
|
+
const userBorrowApr = baseBorrowApr.mul(new decimal_js_1.default(1).add(riskPremiumFraction));
|
|
73
|
+
result[identifier] = {
|
|
74
|
+
borrowRate: (0, moneymarket_1.aprToApy)(userBorrowApr.toString()),
|
|
75
|
+
// Supply rate is market-level (not user-specific), use existing value
|
|
76
|
+
supplyRate: assetData.supplyRate,
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
82
|
+
const calculateNetApyAaveV4 = ({ usedAssets, assetsData, }) => {
|
|
83
|
+
const riskPremiumBps = (0, exports.calcUserRiskPremiumBps)(usedAssets, assetsData);
|
|
84
|
+
const riskPremiumFraction = new decimal_js_1.default(riskPremiumBps).div(10000);
|
|
85
|
+
const sumValues = Object.entries(usedAssets).reduce((_acc, [identifier, usedAsset]) => {
|
|
86
|
+
const acc = Object.assign({}, _acc);
|
|
87
|
+
const assetData = assetsData[identifier];
|
|
88
|
+
if (!assetData)
|
|
89
|
+
return acc;
|
|
90
|
+
if (usedAsset.isSupplied) {
|
|
91
|
+
const amount = usedAsset.suppliedUsd;
|
|
92
|
+
acc.suppliedUsd = new decimal_js_1.default(acc.suppliedUsd).add(amount).toString();
|
|
93
|
+
const supplyInterest = (0, staking_1.calculateInterestEarned)(amount, assetData.supplyRate, 'year', true);
|
|
94
|
+
acc.supplyInterest = new decimal_js_1.default(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
95
|
+
if (assetData.supplyIncentives) {
|
|
96
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
97
|
+
const incentiveInterest = (0, staking_1.calculateInterestEarned)(amount, supplyIncentive.apy, 'year', true);
|
|
98
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (usedAsset.isBorrowed) {
|
|
103
|
+
const amount = usedAsset.borrowedUsd;
|
|
104
|
+
acc.borrowedUsd = new decimal_js_1.default(acc.borrowedUsd).add(amount).toString();
|
|
105
|
+
// User borrow rate = baseRate * (1 + riskPremiumFraction)
|
|
106
|
+
const drawnRate = new decimal_js_1.default(assetData.drawnRate);
|
|
107
|
+
const baseBorrowApr = drawnRate.mul(100);
|
|
108
|
+
const userBorrowApr = baseBorrowApr.mul(new decimal_js_1.default(1).add(riskPremiumFraction));
|
|
109
|
+
const userBorrowRate = (0, moneymarket_1.aprToApy)(userBorrowApr.toString());
|
|
110
|
+
const borrowInterest = (0, staking_1.calculateInterestEarned)(amount, userBorrowRate, 'year', true);
|
|
111
|
+
acc.borrowInterest = new decimal_js_1.default(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
112
|
+
if (assetData.borrowIncentives) {
|
|
113
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
114
|
+
const incentiveInterest = (0, staking_1.calculateInterestEarned)(amount, borrowIncentive.apy, 'year', true);
|
|
115
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return acc;
|
|
120
|
+
}, {
|
|
121
|
+
borrowInterest: '0', supplyInterest: '0', incentiveUsd: '0', borrowedUsd: '0', suppliedUsd: '0',
|
|
122
|
+
});
|
|
123
|
+
const { borrowedUsd, suppliedUsd, borrowInterest, supplyInterest, incentiveUsd, } = sumValues;
|
|
124
|
+
const totalInterestUsd = new decimal_js_1.default(borrowInterest).add(supplyInterest).add(incentiveUsd).toString();
|
|
125
|
+
const balance = new decimal_js_1.default(suppliedUsd).sub(borrowedUsd);
|
|
126
|
+
const netApy = balance.isZero() ? '0' : new decimal_js_1.default(totalInterestUsd).div(balance).times(100).toString();
|
|
127
|
+
return { netApy, totalInterestUsd, incentiveUsd };
|
|
128
|
+
};
|
|
129
|
+
exports.calculateNetApyAaveV4 = calculateNetApyAaveV4;
|
|
130
|
+
const aaveV4GetCollateralFactor = (assetData, usedAssetData, useUserCollateralFactor = false) => (useUserCollateralFactor ? usedAssetData.collateralFactor : assetData.collateralFactor);
|
|
131
|
+
exports.aaveV4GetCollateralFactor = aaveV4GetCollateralFactor;
|
|
132
|
+
const isLeveragedPosAaveV4 = (usedAssets, dustLimit = 5) => {
|
|
133
|
+
let borrowUnstable = 0;
|
|
134
|
+
let supplyStable = 0;
|
|
135
|
+
let borrowStable = 0;
|
|
136
|
+
let supplyUnstable = 0;
|
|
137
|
+
let longAsset = '';
|
|
138
|
+
let shortAsset = '';
|
|
139
|
+
Object.values(usedAssets).forEach(({ symbol, suppliedUsd, borrowedUsd, collateral, reserveId, }) => {
|
|
140
|
+
const spokeAsset = `${symbol}-${reserveId}`;
|
|
141
|
+
const isSupplied = (+suppliedUsd) > dustLimit; // ignore dust like <limit leftover supply
|
|
142
|
+
const isBorrowed = (+borrowedUsd) > dustLimit; // ignore dust like <limit leftover supply
|
|
143
|
+
if (isSupplied && moneymarket_1.STABLE_ASSETS.includes(symbol) && collateral)
|
|
144
|
+
supplyStable += 1;
|
|
145
|
+
if (isBorrowed && moneymarket_1.STABLE_ASSETS.includes(symbol))
|
|
146
|
+
borrowStable += 1;
|
|
147
|
+
if (isBorrowed && !moneymarket_1.STABLE_ASSETS.includes(symbol)) {
|
|
148
|
+
borrowUnstable += 1;
|
|
149
|
+
shortAsset = spokeAsset;
|
|
150
|
+
}
|
|
151
|
+
if (isSupplied && !moneymarket_1.STABLE_ASSETS.includes(symbol) && collateral) {
|
|
152
|
+
supplyUnstable += 1;
|
|
153
|
+
longAsset = spokeAsset;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const isLong = borrowStable > 0 && borrowUnstable === 0 && supplyUnstable === 1 && supplyStable === 0;
|
|
157
|
+
const isShort = supplyStable > 0 && supplyUnstable === 0 && borrowUnstable === 1 && borrowStable === 0;
|
|
158
|
+
const isVolatilePair = supplyUnstable === 1 && borrowUnstable === 1 && supplyStable === 0 && borrowStable === 0;
|
|
159
|
+
if (isLong) {
|
|
160
|
+
return {
|
|
161
|
+
leveragedType: types_1.LeverageType.Long,
|
|
162
|
+
leveragedAsset: longAsset,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (isShort) {
|
|
166
|
+
return {
|
|
167
|
+
leveragedType: types_1.LeverageType.Short,
|
|
168
|
+
leveragedAsset: shortAsset,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (isVolatilePair) {
|
|
172
|
+
return {
|
|
173
|
+
leveragedType: types_1.LeverageType.VolatilePair,
|
|
174
|
+
leveragedAsset: longAsset,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
leveragedType: types_1.LeverageType.None,
|
|
179
|
+
leveragedAsset: '',
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
exports.isLeveragedPosAaveV4 = isLeveragedPosAaveV4;
|
|
183
|
+
const aaveV4GetAggregatedPositionData = ({ usedAssets, assetsData, network, useUserCollateralFactor = false, }) => {
|
|
184
|
+
const payload = {};
|
|
185
|
+
payload.suppliedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedUsd }) => suppliedUsd);
|
|
186
|
+
payload.suppliedCollateralUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ suppliedUsd }) => suppliedUsd);
|
|
187
|
+
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)));
|
|
188
|
+
payload.liquidationLimitUsd = payload.borrowLimitUsd;
|
|
189
|
+
payload.borrowedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd);
|
|
190
|
+
payload.drawnUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ drawnUsd }) => drawnUsd);
|
|
191
|
+
payload.premiumUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ premiumUsd }) => premiumUsd);
|
|
192
|
+
const leftToBorrowUsd = new decimal_js_1.default(payload.borrowLimitUsd).sub(payload.borrowedUsd);
|
|
193
|
+
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
194
|
+
payload.ratio = +payload.suppliedUsd ? new decimal_js_1.default(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
195
|
+
payload.minRatio = '100';
|
|
196
|
+
payload.collRatio = +payload.suppliedUsd ? new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
197
|
+
payload.liqRatio = new decimal_js_1.default(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
|
|
198
|
+
payload.liqPercent = new decimal_js_1.default(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
199
|
+
const { leveragedType, leveragedAsset } = (0, exports.isLeveragedPosAaveV4)(usedAssets);
|
|
200
|
+
payload.leveragedType = leveragedType;
|
|
201
|
+
payload.leveragedAsset = leveragedAsset;
|
|
202
|
+
payload.liquidationPrice = '';
|
|
203
|
+
if (leveragedType !== '') {
|
|
204
|
+
const leveragedAssetData = assetsData[leveragedAsset];
|
|
205
|
+
let assetPrice = (leveragedAssetData === null || leveragedAssetData === void 0 ? void 0 : leveragedAssetData.price) || '0';
|
|
206
|
+
if (leveragedType === types_1.LeverageType.VolatilePair) {
|
|
207
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
208
|
+
const borrowedAssetPrice = assetsData[`${borrowedAsset.symbol}-${borrowedAsset.reserveId}`].price;
|
|
209
|
+
const leveragedAssetPrice = assetsData[leveragedAsset].price;
|
|
210
|
+
const isReverse = new decimal_js_1.default(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
211
|
+
if (isReverse) {
|
|
212
|
+
payload.leveragedType = types_1.LeverageType.VolatilePairReverse;
|
|
213
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
214
|
+
assetPrice = new decimal_js_1.default(borrowedAssetPrice).div(assetPrice).toString();
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(borrowedAssetPrice).toString();
|
|
218
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
222
|
+
}
|
|
223
|
+
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
224
|
+
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
225
|
+
payload.healthRatio = new decimal_js_1.default(payload.liquidationLimitUsd).div(payload.borrowedUsd).toDP(4).toString();
|
|
226
|
+
payload.minHealthRatio = new decimal_js_1.default(payload.liquidationLimitUsd).div(payload.borrowLimitUsd).toDP(4).toString();
|
|
227
|
+
const { netApy, incentiveUsd, totalInterestUsd } = (0, exports.calculateNetApyAaveV4)({ usedAssets, assetsData });
|
|
228
|
+
payload.netApy = netApy;
|
|
229
|
+
payload.incentiveUsd = incentiveUsd;
|
|
230
|
+
payload.totalInterestUsd = totalInterestUsd;
|
|
231
|
+
return payload;
|
|
232
|
+
};
|
|
233
|
+
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"));
|
|
@@ -0,0 +1,34 @@
|
|
|
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_CORRELATED_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
14
|
+
export declare const AAVE_V4_ETHENA_ECOSYSTEM_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
15
|
+
export declare const AAVE_V4_ETHERFI_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
16
|
+
export declare const AAVE_V4_FOREX_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
17
|
+
export declare const AAVE_V4_GOLD_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
18
|
+
export declare const AAVE_V4_KELP_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
19
|
+
export declare const AAVE_V4_LIDO_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
20
|
+
export declare const AAVE_V4_LOMBARD_BTC_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
21
|
+
export declare const AAVE_V4_MAIN_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
22
|
+
export declare const AaveV4Spokes: (networkId: NetworkNumber) => {
|
|
23
|
+
readonly aave_v4_bluechip_spoke: AaveV4SpokeInfo;
|
|
24
|
+
readonly aave_v4_ethena_correlated_spoke: AaveV4SpokeInfo;
|
|
25
|
+
readonly aave_v4_ethena_ecosystem_spoke: AaveV4SpokeInfo;
|
|
26
|
+
readonly aave_v4_etherfi_spoke: AaveV4SpokeInfo;
|
|
27
|
+
readonly aave_v4_forex_spoke: AaveV4SpokeInfo;
|
|
28
|
+
readonly aave_v4_gold_spoke: AaveV4SpokeInfo;
|
|
29
|
+
readonly aave_v4_kelp_spoke: AaveV4SpokeInfo;
|
|
30
|
+
readonly aave_v4_lido_spoke: AaveV4SpokeInfo;
|
|
31
|
+
readonly aave_v4_lombard_btc_spoke: AaveV4SpokeInfo;
|
|
32
|
+
readonly aave_v4_main_spoke: AaveV4SpokeInfo;
|
|
33
|
+
};
|
|
34
|
+
export declare const getAaveV4SpokeTypeInfo: (type: AaveV4SpokesType, network?: NetworkNumber) => AaveV4SpokeInfo;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAaveV4SpokeTypeInfo = exports.AaveV4Spokes = exports.AAVE_V4_MAIN_SPOKE = exports.AAVE_V4_LOMBARD_BTC_SPOKE = exports.AAVE_V4_LIDO_SPOKE = exports.AAVE_V4_KELP_SPOKE = exports.AAVE_V4_GOLD_SPOKE = exports.AAVE_V4_FOREX_SPOKE = exports.AAVE_V4_ETHERFI_SPOKE = exports.AAVE_V4_ETHENA_ECOSYSTEM_SPOKE = exports.AAVE_V4_ETHENA_CORRELATED_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: '0xCca852Bc40e560adC3b1Cc58CA5b55638ce826c9',
|
|
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: '0x06002e9c4412CB7814a791eA3666D905871E536A',
|
|
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: '0x943827DCA022D0F354a8a8c332dA1e5Eb9f9F931',
|
|
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',
|
|
41
|
+
value: types_1.AaveV4SpokesType.AaveV4BluechipSpoke,
|
|
42
|
+
url: 'bluechip',
|
|
43
|
+
address: '0x973a023A77420ba610f06b3858aD991Df6d85A08',
|
|
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_CORRELATED_SPOKE = (networkId) => ({
|
|
52
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
53
|
+
label: 'Ethena Correlated',
|
|
54
|
+
value: types_1.AaveV4SpokesType.AaveV4EthenaCorrelatedSpoke,
|
|
55
|
+
url: 'ethena-correlated',
|
|
56
|
+
address: '0x58131E79531caB1d52301228d1f7b842F26B9649',
|
|
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_CORRELATED_SPOKE = AAVE_V4_ETHENA_CORRELATED_SPOKE;
|
|
64
|
+
const AAVE_V4_ETHENA_ECOSYSTEM_SPOKE = (networkId) => ({
|
|
65
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
66
|
+
label: 'Ethena Ecosystem',
|
|
67
|
+
value: types_1.AaveV4SpokesType.AaveV4EthenaEcosystemSpoke,
|
|
68
|
+
url: 'ethena-ecosystem',
|
|
69
|
+
address: '0xba1B3D55D249692b669A164024A838309B7508AF',
|
|
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_ETHENA_ECOSYSTEM_SPOKE = AAVE_V4_ETHENA_ECOSYSTEM_SPOKE;
|
|
77
|
+
const AAVE_V4_ETHERFI_SPOKE = (networkId) => ({
|
|
78
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
79
|
+
label: 'Etherfi',
|
|
80
|
+
value: types_1.AaveV4SpokesType.AaveV4EtherfiSpoke,
|
|
81
|
+
url: 'etherfi',
|
|
82
|
+
address: '0xbF10BDfE177dE0336aFD7fcCF80A904E15386219',
|
|
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_ETHERFI_SPOKE = AAVE_V4_ETHERFI_SPOKE;
|
|
90
|
+
const AAVE_V4_FOREX_SPOKE = (networkId) => ({
|
|
91
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
92
|
+
label: 'Forex',
|
|
93
|
+
value: types_1.AaveV4SpokesType.AaveV4ForexSpoke,
|
|
94
|
+
url: 'forex',
|
|
95
|
+
address: '0xD8B93635b8C6d0fF98CbE90b5988E3F2d1Cd9da1',
|
|
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_FOREX_SPOKE = AAVE_V4_FOREX_SPOKE;
|
|
103
|
+
const AAVE_V4_GOLD_SPOKE = (networkId) => ({
|
|
104
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
105
|
+
label: 'Gold',
|
|
106
|
+
value: types_1.AaveV4SpokesType.AaveV4GoldSpoke,
|
|
107
|
+
url: 'gold',
|
|
108
|
+
address: '0x65407b940966954b23dfA3caA5C0702bB42984DC',
|
|
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_GOLD_SPOKE = AAVE_V4_GOLD_SPOKE;
|
|
116
|
+
const AAVE_V4_KELP_SPOKE = (networkId) => ({
|
|
117
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
118
|
+
label: 'Kelp',
|
|
119
|
+
value: types_1.AaveV4SpokesType.AaveV4KelpSpoke,
|
|
120
|
+
url: 'kelp',
|
|
121
|
+
address: '0x3131FE68C4722e726fe6B2819ED68e514395B9a4',
|
|
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_KELP_SPOKE = AAVE_V4_KELP_SPOKE;
|
|
129
|
+
const AAVE_V4_LIDO_SPOKE = (networkId) => ({
|
|
130
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
131
|
+
label: 'Lido',
|
|
132
|
+
value: types_1.AaveV4SpokesType.AaveV4LidoSpoke,
|
|
133
|
+
url: 'lido',
|
|
134
|
+
address: '0xe1900480ac69f0B296841Cd01cC37546d92F35Cd',
|
|
135
|
+
hubs: [
|
|
136
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
137
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
138
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
exports.AAVE_V4_LIDO_SPOKE = AAVE_V4_LIDO_SPOKE;
|
|
142
|
+
const AAVE_V4_LOMBARD_BTC_SPOKE = (networkId) => ({
|
|
143
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
144
|
+
label: 'Lombard BTC',
|
|
145
|
+
value: types_1.AaveV4SpokesType.AaveV4LombardBtcSpoke,
|
|
146
|
+
url: 'lombard-btc',
|
|
147
|
+
address: '0x7EC68b5695e803e98a21a9A05d744F28b0a7753D',
|
|
148
|
+
hubs: [
|
|
149
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
150
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
151
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
exports.AAVE_V4_LOMBARD_BTC_SPOKE = AAVE_V4_LOMBARD_BTC_SPOKE;
|
|
155
|
+
const AAVE_V4_MAIN_SPOKE = (networkId) => ({
|
|
156
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
157
|
+
label: 'Main',
|
|
158
|
+
value: types_1.AaveV4SpokesType.AaveV4MainSpoke,
|
|
159
|
+
url: 'main',
|
|
160
|
+
address: '0x94e7A5dCbE816e498b89aB752661904E2F56c485',
|
|
161
|
+
hubs: [
|
|
162
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
163
|
+
(0, exports.AAVE_V4_PLUS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
164
|
+
(0, exports.AAVE_V4_PRIME_HUB)(types_1.NetworkNumber.Eth).address,
|
|
165
|
+
],
|
|
166
|
+
});
|
|
167
|
+
exports.AAVE_V4_MAIN_SPOKE = AAVE_V4_MAIN_SPOKE;
|
|
168
|
+
const AaveV4Spokes = (networkId) => ({
|
|
169
|
+
[types_1.AaveV4SpokesType.AaveV4BluechipSpoke]: (0, exports.AAVE_V4_BLUECHIP_SPOKE)(networkId),
|
|
170
|
+
[types_1.AaveV4SpokesType.AaveV4EthenaCorrelatedSpoke]: (0, exports.AAVE_V4_ETHENA_CORRELATED_SPOKE)(networkId),
|
|
171
|
+
[types_1.AaveV4SpokesType.AaveV4EthenaEcosystemSpoke]: (0, exports.AAVE_V4_ETHENA_ECOSYSTEM_SPOKE)(networkId),
|
|
172
|
+
[types_1.AaveV4SpokesType.AaveV4EtherfiSpoke]: (0, exports.AAVE_V4_ETHERFI_SPOKE)(networkId),
|
|
173
|
+
[types_1.AaveV4SpokesType.AaveV4ForexSpoke]: (0, exports.AAVE_V4_FOREX_SPOKE)(networkId),
|
|
174
|
+
[types_1.AaveV4SpokesType.AaveV4GoldSpoke]: (0, exports.AAVE_V4_GOLD_SPOKE)(networkId),
|
|
175
|
+
[types_1.AaveV4SpokesType.AaveV4KelpSpoke]: (0, exports.AAVE_V4_KELP_SPOKE)(networkId),
|
|
176
|
+
[types_1.AaveV4SpokesType.AaveV4LidoSpoke]: (0, exports.AAVE_V4_LIDO_SPOKE)(networkId),
|
|
177
|
+
[types_1.AaveV4SpokesType.AaveV4LombardBtcSpoke]: (0, exports.AAVE_V4_LOMBARD_BTC_SPOKE)(networkId),
|
|
178
|
+
[types_1.AaveV4SpokesType.AaveV4MainSpoke]: (0, exports.AAVE_V4_MAIN_SPOKE)(networkId),
|
|
179
|
+
});
|
|
180
|
+
exports.AaveV4Spokes = AaveV4Spokes;
|
|
181
|
+
const getAaveV4SpokeTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Spokes)(network !== null && network !== void 0 ? network : types_1.NetworkNumber.Eth))[type]);
|
|
182
|
+
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; } });
|
|
@@ -32,7 +32,7 @@ exports.STABLE_ASSETS = [
|
|
|
32
32
|
'DAI', 'USDC', 'USDT', 'TUSD', 'USDP', 'GUSD', 'BUSD', 'SUSD', 'FRAX', 'LUSD', 'USDC.e', 'GHO', 'sDAI', 'USDA',
|
|
33
33
|
'USDe', 'sUSDe', 'USDS', 'sUSDS', 'USR', 'EURC', 'BOLD', 'BOLD Legacy', 'RLUSD', 'PT sUSDe July', 'PT eUSDe May',
|
|
34
34
|
'USDtb', 'eUSDe', 'PT USDe July', 'PT eUSDe Aug', 'PT sUSDe Sep', 'PT USDe Sep', 'PT sUSDe Nov', 'PT USDe Nov', 'PT sUSDe Jan', 'PT USDe Jan',
|
|
35
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
35
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'frxUSD',
|
|
36
36
|
];
|
|
37
37
|
const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
38
38
|
let borrowUnstable = 0;
|