@defisaver/positions-sdk 2.1.52-aave-v4 → 2.1.52-dev-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +64 -64
- package/cjs/config/contracts.d.ts +0 -1277
- package/cjs/config/contracts.js +0 -9
- package/cjs/contracts.d.ts +0 -23120
- package/cjs/contracts.js +1 -2
- package/cjs/fluid/index.d.ts +3 -3
- package/cjs/helpers/aaveHelpers/index.d.ts +2 -2
- package/cjs/helpers/aaveHelpers/index.js +18 -2
- package/cjs/helpers/compoundHelpers/index.js +1 -1
- package/cjs/helpers/eulerHelpers/index.d.ts +2 -2
- package/cjs/helpers/eulerHelpers/index.js +6 -5
- package/cjs/helpers/fluidHelpers/index.js +2 -1
- package/cjs/helpers/index.d.ts +0 -1
- package/cjs/helpers/index.js +1 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +67 -67
- package/cjs/helpers/sparkHelpers/index.js +1 -1
- package/cjs/index.d.ts +1 -2
- package/cjs/index.js +1 -3
- package/cjs/markets/index.d.ts +0 -1
- package/cjs/markets/index.js +1 -3
- package/cjs/moneymarket/moneymarketCommonService.d.ts +3 -3
- package/cjs/moneymarket/moneymarketCommonService.js +14 -6
- package/cjs/portfolio/index.js +0 -20
- package/cjs/savings/morphoVaults/index.js +17 -17
- package/cjs/types/aave.d.ts +3 -2
- package/cjs/types/common.d.ts +8 -0
- package/cjs/types/common.js +10 -1
- package/cjs/types/compound.d.ts +2 -2
- package/cjs/types/curveUsd.d.ts +2 -2
- package/cjs/types/euler.d.ts +2 -2
- package/cjs/types/fluid.d.ts +2 -2
- package/cjs/types/index.d.ts +0 -1
- package/cjs/types/index.js +0 -1
- package/cjs/types/liquityV2.d.ts +3 -3
- package/cjs/types/llamaLend.d.ts +2 -2
- package/cjs/types/morphoBlue.d.ts +3 -3
- package/cjs/types/portfolio.d.ts +0 -4
- package/cjs/types/spark.d.ts +2 -2
- package/esm/config/contracts.d.ts +0 -1277
- package/esm/config/contracts.js +0 -8
- package/esm/contracts.d.ts +0 -23120
- package/esm/contracts.js +0 -1
- package/esm/fluid/index.d.ts +3 -3
- package/esm/helpers/aaveHelpers/index.d.ts +2 -2
- package/esm/helpers/aaveHelpers/index.js +18 -2
- package/esm/helpers/compoundHelpers/index.js +2 -2
- package/esm/helpers/eulerHelpers/index.d.ts +2 -2
- package/esm/helpers/eulerHelpers/index.js +6 -5
- package/esm/helpers/fluidHelpers/index.js +2 -1
- package/esm/helpers/index.d.ts +0 -1
- package/esm/helpers/index.js +0 -1
- package/esm/helpers/morphoBlueHelpers/index.js +68 -68
- package/esm/helpers/sparkHelpers/index.js +2 -2
- package/esm/index.d.ts +1 -2
- package/esm/index.js +1 -2
- package/esm/markets/index.d.ts +0 -1
- package/esm/markets/index.js +0 -1
- package/esm/moneymarket/moneymarketCommonService.d.ts +3 -3
- package/esm/moneymarket/moneymarketCommonService.js +14 -6
- package/esm/portfolio/index.js +1 -21
- package/esm/savings/morphoVaults/index.js +17 -17
- package/esm/types/aave.d.ts +3 -2
- package/esm/types/common.d.ts +8 -0
- package/esm/types/common.js +9 -0
- package/esm/types/compound.d.ts +2 -2
- package/esm/types/curveUsd.d.ts +2 -2
- package/esm/types/euler.d.ts +2 -2
- package/esm/types/fluid.d.ts +2 -2
- package/esm/types/fluid.js +1 -1
- package/esm/types/index.d.ts +0 -1
- package/esm/types/index.js +0 -1
- package/esm/types/liquityV2.d.ts +3 -3
- package/esm/types/llamaLend.d.ts +2 -2
- package/esm/types/morphoBlue.d.ts +3 -3
- package/esm/types/portfolio.d.ts +0 -4
- package/esm/types/spark.d.ts +2 -2
- package/package.json +48 -48
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +635 -635
- package/src/aaveV3/merit.ts +97 -97
- package/src/aaveV3/merkl.ts +74 -74
- package/src/claiming/aaveV3.ts +154 -154
- package/src/claiming/compV3.ts +22 -22
- package/src/claiming/ethena.ts +61 -61
- package/src/claiming/index.ts +12 -12
- package/src/claiming/king.ts +66 -66
- package/src/claiming/morphoBlue.ts +118 -118
- package/src/claiming/spark.ts +225 -225
- package/src/compoundV2/index.ts +244 -244
- package/src/compoundV3/index.ts +274 -274
- package/src/config/contracts.ts +1320 -1328
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +172 -174
- package/src/curveUsd/index.ts +254 -254
- package/src/eulerV2/index.ts +324 -324
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1800 -1800
- package/src/helpers/aaveHelpers/index.ts +207 -191
- package/src/helpers/compoundHelpers/index.ts +283 -283
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +222 -222
- package/src/helpers/fluidHelpers/index.ts +326 -326
- package/src/helpers/index.ts +10 -11
- package/src/helpers/liquityV2Helpers/index.ts +82 -82
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +396 -396
- package/src/helpers/sparkHelpers/index.ts +160 -158
- package/src/index.ts +49 -51
- package/src/liquity/index.ts +159 -159
- package/src/liquityV2/index.ts +703 -703
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +118 -118
- package/src/markets/aave/marketAssets.ts +54 -54
- package/src/markets/compound/index.ts +243 -243
- package/src/markets/compound/marketsAssets.ts +97 -97
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2900 -2900
- package/src/markets/index.ts +25 -26
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +988 -988
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -12
- package/src/moneymarket/moneymarketCommonService.ts +92 -85
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +586 -606
- package/src/savings/index.ts +95 -95
- package/src/savings/makerDsr/index.ts +53 -53
- package/src/savings/makerDsr/options.ts +9 -9
- package/src/savings/morphoVaults/index.ts +80 -80
- package/src/savings/morphoVaults/options.ts +193 -193
- package/src/savings/skyOptions/index.ts +95 -95
- package/src/savings/skyOptions/options.ts +10 -10
- package/src/savings/sparkSavingsVaults/index.ts +60 -60
- package/src/savings/sparkSavingsVaults/options.ts +35 -35
- package/src/savings/yearnV3Vaults/index.ts +61 -61
- package/src/savings/yearnV3Vaults/options.ts +55 -55
- package/src/savings/yearnVaults/index.ts +73 -73
- package/src/savings/yearnVaults/options.ts +32 -32
- package/src/services/priceService.ts +278 -278
- package/src/services/utils.ts +115 -115
- package/src/services/viem.ts +57 -57
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +459 -459
- package/src/staking/eligibility.ts +53 -53
- package/src/staking/index.ts +1 -1
- package/src/staking/staking.ts +192 -192
- package/src/types/aave.ts +200 -198
- package/src/types/claiming.ts +114 -114
- package/src/types/common.ts +116 -107
- package/src/types/compound.ts +145 -144
- package/src/types/curveUsd.ts +123 -123
- package/src/types/euler.ts +176 -175
- package/src/types/fluid.ts +485 -483
- package/src/types/index.ts +15 -16
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +128 -126
- package/src/types/llamaLend.ts +161 -159
- package/src/types/maker.ts +63 -63
- package/src/types/merit.ts +1 -1
- package/src/types/merkl.ts +70 -70
- package/src/types/morphoBlue.ts +202 -202
- package/src/types/portfolio.ts +60 -64
- package/src/types/savings/index.ts +23 -23
- package/src/types/savings/makerDsr.ts +13 -13
- package/src/types/savings/morphoVaults.ts +32 -32
- package/src/types/savings/sky.ts +14 -14
- package/src/types/savings/sparkSavingsVaults.ts +15 -15
- package/src/types/savings/yearnV3Vaults.ts +17 -17
- package/src/types/savings/yearnVaults.ts +14 -14
- package/src/types/spark.ts +135 -134
- package/src/umbrella/index.ts +69 -69
- package/src/umbrella/umbrellaUtils.ts +29 -29
- package/cjs/aaveV4/index.d.ts +0 -7
- package/cjs/aaveV4/index.js +0 -174
- package/cjs/helpers/aaveV4Helpers/index.d.ts +0 -13
- package/cjs/helpers/aaveV4Helpers/index.js +0 -109
- package/cjs/markets/aaveV4/index.d.ts +0 -13
- package/cjs/markets/aaveV4/index.js +0 -39
- package/cjs/types/aaveV4.d.ts +0 -137
- package/cjs/types/aaveV4.js +0 -11
- package/esm/aaveV4/index.d.ts +0 -7
- package/esm/aaveV4/index.js +0 -165
- package/esm/helpers/aaveV4Helpers/index.d.ts +0 -13
- package/esm/helpers/aaveV4Helpers/index.js +0 -100
- package/esm/markets/aaveV4/index.d.ts +0 -13
- package/esm/markets/aaveV4/index.js +0 -29
- package/esm/types/aaveV4.d.ts +0 -137
- package/esm/types/aaveV4.js +0 -8
- package/src/aaveV4/index.ts +0 -176
- package/src/helpers/aaveV4Helpers/index.ts +0 -121
- package/src/markets/aaveV4/index.ts +0 -42
- package/src/types/aaveV4.ts +0 -151
package/esm/contracts.js
CHANGED
|
@@ -132,4 +132,3 @@ export const StkAAVEViem = createViemContractFromConfigFunc('StkAAVE');
|
|
|
132
132
|
export const YearnViewContractViem = createViemContractFromConfigFunc('YearnView');
|
|
133
133
|
export const MakerDsrContractViem = createViemContractFromConfigFunc('MakerDsr');
|
|
134
134
|
export const SkySavingsContractView = createViemContractFromConfigFunc('SkySavings');
|
|
135
|
-
export const AaveV4ViewContractViem = createViemContractFromConfigFunc('AaveV4View');
|
package/esm/fluid/index.d.ts
CHANGED
|
@@ -130,7 +130,7 @@ export declare const _getUserPositions: (provider: PublicClient, network: Networ
|
|
|
130
130
|
collRatio: string;
|
|
131
131
|
minRatio: string;
|
|
132
132
|
totalInterestUsd: string;
|
|
133
|
-
leveragedType?:
|
|
133
|
+
leveragedType?: import("../types/common").LeverageType;
|
|
134
134
|
leveragedAsset?: string;
|
|
135
135
|
liquidationPrice?: string;
|
|
136
136
|
leveragedLsdAssetRatio?: string;
|
|
@@ -161,7 +161,7 @@ export declare const getUserPositions: (provider: EthereumProvider, network: Net
|
|
|
161
161
|
collRatio: string;
|
|
162
162
|
minRatio: string;
|
|
163
163
|
totalInterestUsd: string;
|
|
164
|
-
leveragedType?:
|
|
164
|
+
leveragedType?: import("../types/common").LeverageType;
|
|
165
165
|
leveragedAsset?: string;
|
|
166
166
|
liquidationPrice?: string;
|
|
167
167
|
leveragedLsdAssetRatio?: string;
|
|
@@ -192,7 +192,7 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
|
|
|
192
192
|
collRatio: string;
|
|
193
193
|
minRatio: string;
|
|
194
194
|
totalInterestUsd: string;
|
|
195
|
-
leveragedType?:
|
|
195
|
+
leveragedType?: import("../types/common").LeverageType;
|
|
196
196
|
leveragedAsset?: string;
|
|
197
197
|
liquidationPrice?: string;
|
|
198
198
|
leveragedLsdAssetRatio?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AaveHelperCommon, AaveMarketInfo, AaveV3AggregatedPositionData, AaveV3AssetsData, AaveV3UsedAssets, AaveVersions } from '../../types';
|
|
1
|
+
import { AaveHelperCommon, AaveMarketInfo, AaveV3AggregatedPositionData, AaveV3AssetsData, AaveV3UsedAsset, AaveV3UsedAssets, AaveVersions } from '../../types';
|
|
2
2
|
import { EthereumProvider, NetworkNumber } from '../../types/common';
|
|
3
3
|
export declare const AAVE_V3_MARKETS: AaveVersions[];
|
|
4
4
|
export declare const isAaveV2: ({ selectedMarket }: {
|
|
@@ -17,7 +17,7 @@ export declare const aaveV3IsInSiloedMode: ({ usedAssets, assetsData }: {
|
|
|
17
17
|
}) => boolean;
|
|
18
18
|
export declare const aaveAnyGetCollSuppliedAssets: ({ usedAssets }: {
|
|
19
19
|
usedAssets: AaveV3UsedAssets;
|
|
20
|
-
}) =>
|
|
20
|
+
}) => AaveV3UsedAsset[];
|
|
21
21
|
export declare const aaveAnyGetSuppliableAssets: ({ usedAssets, eModeCategory, assetsData, selectedMarket, network, ...rest }: AaveHelperCommon) => {
|
|
22
22
|
symbol: string;
|
|
23
23
|
canBeCollateral: boolean;
|
|
@@ -25,6 +25,7 @@ import { getNativeAssetFromWrapped, getWrappedNativeAssetFromUnwrapped } from '.
|
|
|
25
25
|
import { aprToApy, calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos, } from '../../moneymarket';
|
|
26
26
|
import { calculateNetApy } from '../../staking';
|
|
27
27
|
import { borrowOperations } from '../../constants';
|
|
28
|
+
import { LeverageType, } from '../../types/common';
|
|
28
29
|
import { AaveLoanInfoV2ContractViem, AaveV3ViewContractViem } from '../../contracts';
|
|
29
30
|
import { getViemProvider } from '../../services/viem';
|
|
30
31
|
export const AAVE_V3_MARKETS = [AaveVersions.AaveV3, AaveVersions.AaveV3Lido, AaveVersions.AaveV3Etherfi];
|
|
@@ -89,12 +90,27 @@ export const aaveAnyGetAggregatedPositionData = (_a) => {
|
|
|
89
90
|
payload.liquidationPrice = '';
|
|
90
91
|
if (leveragedType !== '') {
|
|
91
92
|
let assetPrice = data.assetsData[leveragedAsset].price;
|
|
92
|
-
if (leveragedType ===
|
|
93
|
+
if (leveragedType === LeverageType.LsdLeverage) {
|
|
93
94
|
// Treat ETH like a stablecoin in a long stETH position
|
|
94
95
|
payload.leveragedLsdAssetRatio = new Dec(assetsData[leveragedAsset].price).div(assetsData.ETH.price).toDP(18).toString();
|
|
95
96
|
assetPrice = new Dec(assetPrice).div(assetsData.ETH.price).toString();
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
if (leveragedType === LeverageType.VolatilePair) {
|
|
99
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
100
|
+
const borrowedAssetPrice = data.assetsData[borrowedAsset.symbol].price;
|
|
101
|
+
const leveragedAssetPrice = data.assetsData[leveragedAsset].price;
|
|
102
|
+
const isReverse = new Dec(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
103
|
+
if (isReverse) {
|
|
104
|
+
payload.leveragedType = LeverageType.VolatilePairReverse;
|
|
105
|
+
payload.currentVolatilePairRatio = new Dec(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
106
|
+
assetPrice = new Dec(borrowedAssetPrice).div(assetPrice).toString();
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
assetPrice = new Dec(assetPrice).div(borrowedAssetPrice).toString();
|
|
110
|
+
payload.currentVolatilePairRatio = new Dec(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
payload.liquidationPrice = calcLeverageLiqPrice(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
98
114
|
}
|
|
99
115
|
payload.minCollRatio = new Dec(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
100
116
|
payload.collLiquidationRatio = new Dec(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
@@ -25,7 +25,7 @@ import { addToArrayIf, getEthAmountForDecimals, handleWbtcLegacy, wethToEth, } f
|
|
|
25
25
|
import { BLOCKS_IN_A_YEAR, borrowOperations, SECONDS_PER_YEAR } from '../../constants';
|
|
26
26
|
import { aprToApy, calcLeverageLiqPrice, calculateBorrowingAssetLimit, getAssetsTotal, isLeveragedPos, } from '../../moneymarket';
|
|
27
27
|
import { calculateNetApy, getStakingApy, STAKING_ASSETS } from '../../staking';
|
|
28
|
-
import { IncentiveKind, NetworkNumber, } from '../../types/common';
|
|
28
|
+
import { IncentiveKind, LeverageType, NetworkNumber, } from '../../types/common';
|
|
29
29
|
import { CompoundLoanInfoContractViem, CompV3ViewContractViem } from '../../contracts';
|
|
30
30
|
import { getViemProvider } from '../../services/viem';
|
|
31
31
|
export const formatMarketData = (data, network, baseAssetPrice) => {
|
|
@@ -140,7 +140,7 @@ export const getCompoundV3AggregatedData = (_a) => {
|
|
|
140
140
|
if (leveragedType !== '') {
|
|
141
141
|
payload.leveragedAsset = leveragedAsset;
|
|
142
142
|
let assetPrice = assetsData[leveragedAsset].price;
|
|
143
|
-
if (leveragedType ===
|
|
143
|
+
if (leveragedType === LeverageType.LsdLeverage) {
|
|
144
144
|
payload.leveragedLsdAssetRatio = new Dec(assetsData[leveragedAsset].price).div(assetsData.ETH.price).toString();
|
|
145
145
|
assetPrice = new Dec(assetPrice).div(assetsData.ETH.price).toString();
|
|
146
146
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
|
|
1
|
+
import { EthAddress, EthereumProvider, LeverageType, NetworkNumber } from '../../types/common';
|
|
2
2
|
import { EulerV2AggregatedPositionData, EulerV2AssetsData, EulerV2UsedAssets } from '../../types';
|
|
3
3
|
export declare const isLeveragedPos: (usedAssets: EulerV2UsedAssets, dustLimit?: number) => {
|
|
4
|
-
leveragedType:
|
|
4
|
+
leveragedType: LeverageType;
|
|
5
5
|
leveragedAsset: string;
|
|
6
6
|
leveragedVault: string;
|
|
7
7
|
};
|
|
@@ -20,6 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
};
|
|
21
21
|
import Dec from 'decimal.js';
|
|
22
22
|
import { assetAmountInWei } from '@defisaver/tokens';
|
|
23
|
+
import { LeverageType, } from '../../types/common';
|
|
23
24
|
import { calcLeverageLiqPrice, getAssetsTotal, STABLE_ASSETS, } from '../../moneymarket';
|
|
24
25
|
import { calculateNetApy } from '../../staking';
|
|
25
26
|
import { EulerV2ViewContractViem } from '../../contracts';
|
|
@@ -57,27 +58,27 @@ export const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
|
57
58
|
const isLsdLeveraged = supplyUnstable === 1 && borrowUnstable === 1 && shortAsset === 'ETH' && ['stETH', 'wstETH', 'cbETH', 'rETH'].includes(longAsset);
|
|
58
59
|
if (isLong) {
|
|
59
60
|
return {
|
|
60
|
-
leveragedType:
|
|
61
|
+
leveragedType: LeverageType.Long,
|
|
61
62
|
leveragedAsset: longAsset,
|
|
62
63
|
leveragedVault: leverageAssetVault,
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
if (isShort) {
|
|
66
67
|
return {
|
|
67
|
-
leveragedType:
|
|
68
|
+
leveragedType: LeverageType.Short,
|
|
68
69
|
leveragedAsset: shortAsset,
|
|
69
70
|
leveragedVault: leverageAssetVault,
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
if (isLsdLeveraged) {
|
|
73
74
|
return {
|
|
74
|
-
leveragedType:
|
|
75
|
+
leveragedType: LeverageType.LsdLeverage,
|
|
75
76
|
leveragedAsset: longAsset,
|
|
76
77
|
leveragedVault: leverageAssetVault,
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
return {
|
|
80
|
-
leveragedType:
|
|
81
|
+
leveragedType: LeverageType.None,
|
|
81
82
|
leveragedAsset: '',
|
|
82
83
|
leveragedVault: '',
|
|
83
84
|
};
|
|
@@ -106,7 +107,7 @@ export const getEulerV2AggregatedData = (_a) => {
|
|
|
106
107
|
if (leveragedType !== '') {
|
|
107
108
|
payload.leveragedAsset = leveragedAsset;
|
|
108
109
|
let assetPrice = assetsData[leveragedVault.toLowerCase()].price;
|
|
109
|
-
if (leveragedType ===
|
|
110
|
+
if (leveragedType === LeverageType.LsdLeverage) {
|
|
110
111
|
const ethAsset = Object.values(assetsData).find((asset) => ['WETH', 'ETH'].includes(asset.symbol));
|
|
111
112
|
if (ethAsset) {
|
|
112
113
|
payload.leveragedLsdAssetRatio = new Dec(assetsData[leveragedVault.toLowerCase()].price).div(ethAsset.price).toString();
|
|
@@ -3,6 +3,7 @@ import { assetAmountInEth } from '@defisaver/tokens';
|
|
|
3
3
|
import { FluidVaultType, } from '../../types';
|
|
4
4
|
import { calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos } from '../../moneymarket';
|
|
5
5
|
import { calculateNetApy } from '../../staking';
|
|
6
|
+
import { LeverageType } from '../../types/common';
|
|
6
7
|
import { getEthAmountForDecimals } from '../../services/utils';
|
|
7
8
|
const calculateNetApyDex = ({ marketData, suppliedUsd, borrowedUsd }) => {
|
|
8
9
|
const { borrowRate, supplyRate, incentiveBorrowRate, incentiveSupplyRate, tradingBorrowRate, tradingSupplyRate, } = marketData;
|
|
@@ -49,7 +50,7 @@ export const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, },
|
|
|
49
50
|
if (leveragedType !== '') {
|
|
50
51
|
payload.leveragedAsset = leveragedAsset;
|
|
51
52
|
let assetPrice = assetsData[leveragedAsset].price;
|
|
52
|
-
if (leveragedType ===
|
|
53
|
+
if (leveragedType === LeverageType.LsdLeverage) {
|
|
53
54
|
// Treat ETH like a stablecoin in a long stETH position
|
|
54
55
|
payload.leveragedLsdAssetRatio = new Dec(assetsData[leveragedAsset].price).div(assetsData.ETH.price).toDP(18).toString();
|
|
55
56
|
assetPrice = new Dec(assetPrice).div(assetsData.ETH.price).toString();
|
package/esm/helpers/index.d.ts
CHANGED
package/esm/helpers/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import Dec from 'decimal.js';
|
|
|
11
11
|
import { assetAmountInWei, getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
12
|
import { aprToApy, calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos, } from '../../moneymarket';
|
|
13
13
|
import { calculateNetApy } from '../../staking';
|
|
14
|
-
import { NetworkNumber, } from '../../types/common';
|
|
14
|
+
import { LeverageType, NetworkNumber, } from '../../types/common';
|
|
15
15
|
import { borrowOperations, SECONDS_PER_YEAR, WAD } from '../../constants';
|
|
16
16
|
import { MorphoBlueViewContractViem } from '../../contracts';
|
|
17
17
|
import { compareAddresses, DEFAULT_TIMEOUT, wethToEth } from '../../services/utils';
|
|
@@ -45,7 +45,7 @@ export const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, ma
|
|
|
45
45
|
if (leveragedType !== '') {
|
|
46
46
|
payload.leveragedAsset = leveragedAsset;
|
|
47
47
|
let assetPrice = assetsData[leveragedAsset].price;
|
|
48
|
-
if (leveragedType ===
|
|
48
|
+
if (leveragedType === LeverageType.LsdLeverage) {
|
|
49
49
|
// Treat ETH like a stablecoin in a long stETH position
|
|
50
50
|
payload.leveragedLsdAssetRatio = new Dec(assetsData[leveragedAsset].price).div(assetsData.ETH.price).toDP(18).toString();
|
|
51
51
|
assetPrice = new Dec(assetPrice).div(assetsData.ETH.price).toString();
|
|
@@ -118,73 +118,73 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, provider, n
|
|
|
118
118
|
return { borrowRate, supplyRate };
|
|
119
119
|
});
|
|
120
120
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
121
|
-
const MARKET_QUERY = `
|
|
122
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
123
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
124
|
-
reallocatableLiquidityAssets
|
|
125
|
-
targetBorrowUtilization
|
|
126
|
-
loanAsset {
|
|
127
|
-
address
|
|
128
|
-
decimals
|
|
129
|
-
priceUsd
|
|
130
|
-
}
|
|
131
|
-
state {
|
|
132
|
-
liquidityAssets
|
|
133
|
-
borrowAssets
|
|
134
|
-
supplyAssets
|
|
135
|
-
}
|
|
136
|
-
publicAllocatorSharedLiquidity {
|
|
137
|
-
assets
|
|
138
|
-
vault {
|
|
139
|
-
address
|
|
140
|
-
name
|
|
141
|
-
}
|
|
142
|
-
allocationMarket {
|
|
143
|
-
uniqueKey
|
|
144
|
-
loanAsset {
|
|
145
|
-
address
|
|
146
|
-
}
|
|
147
|
-
collateralAsset {
|
|
148
|
-
address
|
|
149
|
-
}
|
|
150
|
-
irmAddress
|
|
151
|
-
oracle {
|
|
152
|
-
address
|
|
153
|
-
}
|
|
154
|
-
lltv
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
loanAsset {
|
|
158
|
-
address
|
|
159
|
-
}
|
|
160
|
-
collateralAsset {
|
|
161
|
-
address
|
|
162
|
-
}
|
|
163
|
-
oracle {
|
|
164
|
-
address
|
|
165
|
-
}
|
|
166
|
-
irmAddress
|
|
167
|
-
lltv
|
|
168
|
-
}
|
|
169
|
-
}
|
|
121
|
+
const MARKET_QUERY = `
|
|
122
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
123
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
124
|
+
reallocatableLiquidityAssets
|
|
125
|
+
targetBorrowUtilization
|
|
126
|
+
loanAsset {
|
|
127
|
+
address
|
|
128
|
+
decimals
|
|
129
|
+
priceUsd
|
|
130
|
+
}
|
|
131
|
+
state {
|
|
132
|
+
liquidityAssets
|
|
133
|
+
borrowAssets
|
|
134
|
+
supplyAssets
|
|
135
|
+
}
|
|
136
|
+
publicAllocatorSharedLiquidity {
|
|
137
|
+
assets
|
|
138
|
+
vault {
|
|
139
|
+
address
|
|
140
|
+
name
|
|
141
|
+
}
|
|
142
|
+
allocationMarket {
|
|
143
|
+
uniqueKey
|
|
144
|
+
loanAsset {
|
|
145
|
+
address
|
|
146
|
+
}
|
|
147
|
+
collateralAsset {
|
|
148
|
+
address
|
|
149
|
+
}
|
|
150
|
+
irmAddress
|
|
151
|
+
oracle {
|
|
152
|
+
address
|
|
153
|
+
}
|
|
154
|
+
lltv
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
loanAsset {
|
|
158
|
+
address
|
|
159
|
+
}
|
|
160
|
+
collateralAsset {
|
|
161
|
+
address
|
|
162
|
+
}
|
|
163
|
+
oracle {
|
|
164
|
+
address
|
|
165
|
+
}
|
|
166
|
+
irmAddress
|
|
167
|
+
lltv
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
170
|
`;
|
|
171
|
-
const REWARDS_QUERY = `
|
|
172
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
173
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
174
|
-
uniqueKey
|
|
175
|
-
state {
|
|
176
|
-
rewards {
|
|
177
|
-
amountPerSuppliedToken
|
|
178
|
-
supplyApr
|
|
179
|
-
amountPerBorrowedToken
|
|
180
|
-
borrowApr
|
|
181
|
-
asset {
|
|
182
|
-
address
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
171
|
+
const REWARDS_QUERY = `
|
|
172
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
173
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
174
|
+
uniqueKey
|
|
175
|
+
state {
|
|
176
|
+
rewards {
|
|
177
|
+
amountPerSuppliedToken
|
|
178
|
+
supplyApr
|
|
179
|
+
amountPerBorrowedToken
|
|
180
|
+
borrowApr
|
|
181
|
+
asset {
|
|
182
|
+
address
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
188
|
`;
|
|
189
189
|
/**
|
|
190
190
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -24,7 +24,7 @@ import { aprToApy, calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos, } from
|
|
|
24
24
|
import { calculateNetApy } from '../../staking';
|
|
25
25
|
import { ethToWeth, getNativeAssetFromWrapped, wethToEth } from '../../services/utils';
|
|
26
26
|
import { SparkViewContractViem } from '../../contracts';
|
|
27
|
-
import { NetworkNumber } from '../../types/common';
|
|
27
|
+
import { LeverageType, NetworkNumber, } from '../../types/common';
|
|
28
28
|
import { borrowOperations } from '../../constants';
|
|
29
29
|
import { getViemProvider } from '../../services/viem';
|
|
30
30
|
export const sparkIsInIsolationMode = ({ usedAssets, assetsData }) => Object.values(usedAssets).some(({ symbol, collateral }) => collateral && assetsData[symbol].isIsolated);
|
|
@@ -81,7 +81,7 @@ export const sparkGetAggregatedPositionData = (_a) => {
|
|
|
81
81
|
if (leveragedType !== '') {
|
|
82
82
|
payload.leveragedAsset = leveragedAsset;
|
|
83
83
|
let assetPrice = data.assetsData[leveragedAsset].price; // TODO sparkPrice or price??
|
|
84
|
-
if (leveragedType ===
|
|
84
|
+
if (leveragedType === LeverageType.LsdLeverage) {
|
|
85
85
|
// Treat ETH like a stablecoin in a long stETH position
|
|
86
86
|
payload.leveragedLsdAssetRatio = new Dec(assetsData[leveragedAsset].price).div(assetsData.ETH.price).toDP(18).toString();
|
|
87
87
|
assetPrice = new Dec(assetPrice).div(assetsData.ETH.price).toString();
|
package/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import './setup';
|
|
2
2
|
import * as fluid from './fluid';
|
|
3
|
-
import * as aaveV4 from './aaveV4';
|
|
4
3
|
import * as aaveV3 from './aaveV3';
|
|
5
4
|
import * as aaveV2 from './aaveV2';
|
|
6
5
|
import * as compoundV3 from './compoundV3';
|
|
@@ -22,4 +21,4 @@ import * as portfolio from './portfolio';
|
|
|
22
21
|
import * as claiming from './claiming';
|
|
23
22
|
import * as savings from './savings';
|
|
24
23
|
export * from './types';
|
|
25
|
-
export { aaveV2, aaveV3,
|
|
24
|
+
export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import './setup';
|
|
2
2
|
import * as fluid from './fluid';
|
|
3
|
-
import * as aaveV4 from './aaveV4';
|
|
4
3
|
import * as aaveV3 from './aaveV3';
|
|
5
4
|
import * as aaveV2 from './aaveV2';
|
|
6
5
|
import * as compoundV3 from './compoundV3';
|
|
@@ -22,4 +21,4 @@ import * as portfolio from './portfolio';
|
|
|
22
21
|
import * as claiming from './claiming';
|
|
23
22
|
import * as savings from './savings';
|
|
24
23
|
export * from './types';
|
|
25
|
-
export { aaveV2, aaveV3,
|
|
24
|
+
export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
|
package/esm/markets/index.d.ts
CHANGED
|
@@ -7,4 +7,3 @@ 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/esm/markets/index.js
CHANGED
|
@@ -7,4 +7,3 @@ 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';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { MMUsedAssets } from '../types/common';
|
|
1
|
+
import { LeverageType, MMUsedAssets } from '../types/common';
|
|
2
2
|
export declare const getAssetsTotal: (assets: object, filter: any, transform: any) => any;
|
|
3
3
|
export declare const calcLongLiqPrice: (assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
|
|
4
4
|
export declare const calcShortLiqPrice: (assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
|
|
5
|
-
export declare const calcLeverageLiqPrice: (leverageType:
|
|
5
|
+
export declare const calcLeverageLiqPrice: (leverageType: LeverageType, assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
|
|
6
6
|
export declare const calculateBorrowingAssetLimit: (assetBorrowedUsd: string, borrowLimitUsd: string) => string;
|
|
7
7
|
export declare const STABLE_ASSETS: string[];
|
|
8
8
|
export declare const isLeveragedPos: (usedAssets: MMUsedAssets, dustLimit?: number) => {
|
|
9
|
-
leveragedType:
|
|
9
|
+
leveragedType: LeverageType;
|
|
10
10
|
leveragedAsset: string;
|
|
11
11
|
};
|
|
12
12
|
export declare const aprToApy: (interest: string | number, frequency?: number) => string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import { BLOCKS_IN_A_YEAR } from '../constants';
|
|
3
|
+
import { LeverageType } from '../types/common';
|
|
3
4
|
export const getAssetsTotal = (assets, filter, transform) => Object.values(assets)
|
|
4
5
|
.filter(filter)
|
|
5
6
|
.map(transform)
|
|
@@ -8,9 +9,9 @@ export const getAssetsTotal = (assets, filter, transform) => Object.values(asset
|
|
|
8
9
|
export const calcLongLiqPrice = (assetPrice, borrowedUsd, borrowLimitUsd) => new Dec(assetPrice).mul(borrowedUsd).div(borrowLimitUsd).toString();
|
|
9
10
|
export const calcShortLiqPrice = (assetPrice, borrowedUsd, borrowLimitUsd) => new Dec(assetPrice).div(borrowedUsd).mul(borrowLimitUsd).toString();
|
|
10
11
|
export const calcLeverageLiqPrice = (leverageType, assetPrice, borrowedUsd, borrowLimitUsd) => {
|
|
11
|
-
if (leverageType ===
|
|
12
|
+
if (leverageType === LeverageType.Short || leverageType === LeverageType.VolatilePairReverse)
|
|
12
13
|
return calcShortLiqPrice(assetPrice, borrowedUsd, borrowLimitUsd);
|
|
13
|
-
if (leverageType ===
|
|
14
|
+
if (leverageType === LeverageType.Long || leverageType === LeverageType.LsdLeverage || leverageType === LeverageType.VolatilePair)
|
|
14
15
|
return calcLongLiqPrice(assetPrice, borrowedUsd, borrowLimitUsd);
|
|
15
16
|
console.error('invalid leverageType', leverageType);
|
|
16
17
|
return '0';
|
|
@@ -49,26 +50,33 @@ export const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
|
49
50
|
const isShort = supplyStable > 0 && supplyUnstable === 0 && borrowUnstable === 1 && borrowStable === 0;
|
|
50
51
|
// lsd -> liquid staking derivative
|
|
51
52
|
const isLsdLeveraged = supplyUnstable === 1 && borrowUnstable === 1 && shortAsset === 'ETH' && ['stETH', 'wstETH', 'cbETH', 'rETH', 'ezETH', 'weETH'].includes(longAsset);
|
|
53
|
+
const isVolatilePair = supplyUnstable === 1 && borrowUnstable === 1 && supplyStable === 0 && borrowStable === 0;
|
|
52
54
|
if (isLong) {
|
|
53
55
|
return {
|
|
54
|
-
leveragedType:
|
|
56
|
+
leveragedType: LeverageType.Long,
|
|
55
57
|
leveragedAsset: longAsset,
|
|
56
58
|
};
|
|
57
59
|
}
|
|
58
60
|
if (isShort) {
|
|
59
61
|
return {
|
|
60
|
-
leveragedType:
|
|
62
|
+
leveragedType: LeverageType.Short,
|
|
61
63
|
leveragedAsset: shortAsset,
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
if (isLsdLeveraged) {
|
|
65
67
|
return {
|
|
66
|
-
leveragedType:
|
|
68
|
+
leveragedType: LeverageType.LsdLeverage,
|
|
69
|
+
leveragedAsset: longAsset,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (isVolatilePair) {
|
|
73
|
+
return {
|
|
74
|
+
leveragedType: LeverageType.VolatilePair,
|
|
67
75
|
leveragedAsset: longAsset,
|
|
68
76
|
};
|
|
69
77
|
}
|
|
70
78
|
return {
|
|
71
|
-
leveragedType:
|
|
79
|
+
leveragedType: LeverageType.None,
|
|
72
80
|
leveragedAsset: '',
|
|
73
81
|
};
|
|
74
82
|
};
|
package/esm/portfolio/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { NetworkNumber } from '../types/common';
|
|
12
|
-
import { AaveMarkets,
|
|
12
|
+
import { AaveMarkets, CompoundMarkets, CrvUsdMarkets, EulerV2Markets, LiquityV2Markets, LlamaLendMarkets, MorphoBlueMarkets, SparkMarkets, } from '../markets';
|
|
13
13
|
import { _getMorphoBlueAccountData, _getMorphoBlueMarketData, getMorphoEarn } from '../morphoBlue';
|
|
14
14
|
import { AaveVersions, CompoundVersions, } from '../types';
|
|
15
15
|
import { _getCompoundV3AccountData, _getCompoundV3MarketsData } from '../compoundV3';
|
|
@@ -34,7 +34,6 @@ import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
|
|
|
34
34
|
import { fetchMorphoBlueRewards } from '../claiming/morphoBlue';
|
|
35
35
|
import { getKingRewards } from '../claiming/king';
|
|
36
36
|
import { fetchEthenaAirdropRewards } from '../claiming/ethena';
|
|
37
|
-
import { _getAaveV4AccountData, _getAaveV4SpokeData } from '../aaveV4';
|
|
38
37
|
export function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1) {
|
|
39
38
|
return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
|
|
40
39
|
const isMainnet = network === NetworkNumber.Eth;
|
|
@@ -51,7 +50,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
51
50
|
const llamaLendMarkets = [NetworkNumber.Eth, NetworkNumber.Arb].includes(network) ? Object.values(LlamaLendMarkets(network)).filter((market) => market.chainIds.includes(network)) : [];
|
|
52
51
|
const liquityV2Markets = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)) : [];
|
|
53
52
|
const liquityV2MarketsStaking = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)).filter(market => !market.isLegacy) : [];
|
|
54
|
-
const aaveV4Spokes = Object.values(AaveV4Spokes(network)).filter((market) => market.chainIds.includes(network));
|
|
55
53
|
const args = [network, { batch: { multicall: { batchSize: isSim ? 500000 : 2500000 } } }];
|
|
56
54
|
const client = getViemProvider(provider, ...args);
|
|
57
55
|
const defaultClient = getViemProvider(defaultProvider, ...args);
|
|
@@ -66,7 +64,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
66
64
|
const crvUsdMarketsData = {};
|
|
67
65
|
const llamaLendMarketsData = {};
|
|
68
66
|
const liquityV2MarketsData = {};
|
|
69
|
-
const aaveV4SpokesData = {};
|
|
70
67
|
const markets = {
|
|
71
68
|
morphoMarketsData,
|
|
72
69
|
compoundV3MarketsData,
|
|
@@ -78,7 +75,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
78
75
|
crvUsdMarketsData,
|
|
79
76
|
llamaLendMarketsData,
|
|
80
77
|
liquityV2MarketsData,
|
|
81
|
-
aaveV4SpokesData,
|
|
82
78
|
};
|
|
83
79
|
const positions = {};
|
|
84
80
|
const stakingPositions = {};
|
|
@@ -87,7 +83,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
87
83
|
for (const address of allAddresses) {
|
|
88
84
|
positions[address.toLowerCase()] = {
|
|
89
85
|
aaveV3: {},
|
|
90
|
-
aaveV4: {},
|
|
91
86
|
morphoBlue: {},
|
|
92
87
|
compoundV3: {},
|
|
93
88
|
spark: {},
|
|
@@ -153,10 +148,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
153
148
|
const marketData = yield _getAaveV3MarketData(client, network, market);
|
|
154
149
|
aaveV3MarketsData[market.value] = marketData;
|
|
155
150
|
})),
|
|
156
|
-
...aaveV4Spokes.map((spoke) => __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
const spokeData = yield _getAaveV4SpokeData(client, network, spoke);
|
|
158
|
-
aaveV4SpokesData[spoke.value] = spokeData;
|
|
159
|
-
})),
|
|
160
151
|
...aaveV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
161
152
|
const marketData = yield _getAaveV2MarketsData(client, network, market);
|
|
162
153
|
aaveV2MarketsData[market.value] = marketData;
|
|
@@ -426,17 +417,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
426
417
|
positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
427
418
|
}
|
|
428
419
|
}))).flat(),
|
|
429
|
-
...aaveV4Spokes.map((spoke) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
430
|
-
try {
|
|
431
|
-
const accData = yield _getAaveV4AccountData(client, network, aaveV4SpokesData[spoke.value], address);
|
|
432
|
-
if (new Dec(accData.suppliedUsd).gt(0))
|
|
433
|
-
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: '', data: accData };
|
|
434
|
-
}
|
|
435
|
-
catch (error) {
|
|
436
|
-
console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
|
|
437
|
-
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
|
|
438
|
-
}
|
|
439
|
-
}))).flat(),
|
|
440
420
|
...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
441
421
|
try {
|
|
442
422
|
const [accDataPromise, earnDataPromise] = yield Promise.allSettled([
|
|
@@ -14,23 +14,23 @@ import * as morphoVaultsOptions from './options';
|
|
|
14
14
|
import { getViemProvider } from '../../services/viem';
|
|
15
15
|
import { getMorphoVaultContractViem } from '../../contracts';
|
|
16
16
|
export { morphoVaultsOptions, };
|
|
17
|
-
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
18
|
-
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
19
|
-
id,
|
|
20
|
-
dailyApy,
|
|
21
|
-
dailyApys {
|
|
22
|
-
apy, netApy
|
|
23
|
-
},
|
|
24
|
-
monthlyApys {
|
|
25
|
-
apy, netApy
|
|
26
|
-
},
|
|
27
|
-
liquidity {
|
|
28
|
-
underlying, usd,
|
|
29
|
-
},
|
|
30
|
-
asset {
|
|
31
|
-
priceUsd
|
|
32
|
-
}
|
|
33
|
-
}
|
|
17
|
+
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
18
|
+
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
19
|
+
id,
|
|
20
|
+
dailyApy,
|
|
21
|
+
dailyApys {
|
|
22
|
+
apy, netApy
|
|
23
|
+
},
|
|
24
|
+
monthlyApys {
|
|
25
|
+
apy, netApy
|
|
26
|
+
},
|
|
27
|
+
liquidity {
|
|
28
|
+
underlying, usd,
|
|
29
|
+
},
|
|
30
|
+
asset {
|
|
31
|
+
priceUsd
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
34
|
}`;
|
|
35
35
|
const MORPHO_BLUE_API = 'https://blue-api.morpho.org/graphql';
|
|
36
36
|
export const _getMorphoVaultData = (provider, network, morphoVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
package/esm/types/aave.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IncentiveData, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
1
|
+
import { IncentiveData, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
2
2
|
export declare enum AaveVersions {
|
|
3
3
|
AaveV1 = "v1",
|
|
4
4
|
AaveV2 = "v2default",
|
|
@@ -161,7 +161,7 @@ export interface AaveV3AggregatedPositionData {
|
|
|
161
161
|
totalInterestUsd: string;
|
|
162
162
|
liqRatio: string;
|
|
163
163
|
liqPercent: string;
|
|
164
|
-
leveragedType:
|
|
164
|
+
leveragedType: LeverageType;
|
|
165
165
|
leveragedAsset?: string;
|
|
166
166
|
leveragedLsdAssetRatio?: string;
|
|
167
167
|
liquidationPrice?: string;
|
|
@@ -169,6 +169,7 @@ export interface AaveV3AggregatedPositionData {
|
|
|
169
169
|
collLiquidationRatio?: string;
|
|
170
170
|
healthRatio?: string;
|
|
171
171
|
minHealthRatio?: string;
|
|
172
|
+
currentVolatilePairRatio?: string;
|
|
172
173
|
}
|
|
173
174
|
export interface AaveHelperCommon {
|
|
174
175
|
usedAssets: any;
|
package/esm/types/common.d.ts
CHANGED
|
@@ -8,6 +8,14 @@ export declare enum IncentiveEligibilityId {
|
|
|
8
8
|
AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
|
|
9
9
|
AaveV3EthenaLiquidLeveragePlasma = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL"
|
|
10
10
|
}
|
|
11
|
+
export declare enum LeverageType {
|
|
12
|
+
Long = "long",
|
|
13
|
+
Short = "short",
|
|
14
|
+
LsdLeverage = "lsd-leverage",
|
|
15
|
+
VolatilePair = "volatile-pair",
|
|
16
|
+
VolatilePairReverse = "volatile-pair-reverse",
|
|
17
|
+
None = ""
|
|
18
|
+
}
|
|
11
19
|
export interface IncentiveData {
|
|
12
20
|
token: string;
|
|
13
21
|
apy: string;
|