@defisaver/positions-sdk 2.1.127-midnight-8-dev → 2.1.127-midnight-9-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.js +26 -10
- package/cjs/aaveV4/merkl.d.ts +2 -1
- package/cjs/aaveV4/merkl.js +42 -35
- package/cjs/config/contracts.d.ts +0 -938
- package/cjs/config/contracts.js +2 -8
- package/cjs/contracts.d.ts +0 -23433
- package/cjs/contracts.js +2 -3
- package/cjs/helpers/aaveV4Helpers/index.d.ts +7 -1
- package/cjs/helpers/aaveV4Helpers/index.js +22 -10
- package/cjs/helpers/index.d.ts +0 -1
- package/cjs/helpers/index.js +1 -2
- 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/markets/morphoBlue/index.d.ts +6 -0
- package/cjs/markets/morphoBlue/index.js +53 -2
- package/cjs/portfolio/discovery.d.ts +1 -1
- package/cjs/portfolio/discovery.js +1 -1
- package/cjs/portfolio/index.js +0 -32
- package/cjs/services/utils.d.ts +1 -0
- package/cjs/services/utils.js +3 -1
- package/cjs/staking/staking.js +1 -2
- package/cjs/types/aaveV4.d.ts +5 -0
- package/cjs/types/common.d.ts +4 -0
- package/cjs/types/common.js +6 -1
- package/cjs/types/index.d.ts +0 -1
- package/cjs/types/index.js +0 -1
- package/cjs/types/merkl.d.ts +3 -4
- package/cjs/types/morphoBlue.d.ts +3 -0
- package/cjs/types/morphoBlue.js +3 -0
- package/cjs/types/portfolio.d.ts +0 -4
- package/esm/aaveV4/index.js +27 -11
- package/esm/aaveV4/merkl.d.ts +2 -1
- package/esm/aaveV4/merkl.js +41 -35
- package/esm/config/contracts.d.ts +0 -938
- package/esm/config/contracts.js +0 -6
- package/esm/contracts.d.ts +0 -23433
- package/esm/contracts.js +0 -1
- package/esm/helpers/aaveV4Helpers/index.d.ts +7 -1
- package/esm/helpers/aaveV4Helpers/index.js +21 -10
- package/esm/helpers/index.d.ts +0 -1
- package/esm/helpers/index.js +0 -1
- 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/markets/morphoBlue/index.d.ts +6 -0
- package/esm/markets/morphoBlue/index.js +48 -0
- package/esm/portfolio/discovery.d.ts +1 -1
- package/esm/portfolio/discovery.js +1 -1
- package/esm/portfolio/index.js +1 -33
- package/esm/services/utils.d.ts +1 -0
- package/esm/services/utils.js +1 -0
- package/esm/staking/staking.js +1 -2
- package/esm/types/aaveV4.d.ts +5 -0
- package/esm/types/common.d.ts +4 -0
- package/esm/types/common.js +5 -0
- package/esm/types/index.d.ts +0 -1
- package/esm/types/index.js +0 -1
- package/esm/types/merkl.d.ts +3 -4
- package/esm/types/morphoBlue.d.ts +3 -0
- package/esm/types/morphoBlue.js +3 -0
- package/esm/types/portfolio.d.ts +0 -4
- package/package.json +1 -1
- package/src/aaveV4/index.ts +29 -11
- package/src/aaveV4/merkl.ts +41 -32
- package/src/config/contracts.ts +0 -6
- package/src/contracts.ts +0 -1
- package/src/helpers/aaveV4Helpers/index.ts +22 -9
- package/src/helpers/index.ts +0 -1
- package/src/index.ts +0 -2
- package/src/markets/index.ts +0 -1
- package/src/markets/morphoBlue/index.ts +49 -1
- package/src/portfolio/discovery.ts +1 -1
- package/src/portfolio/index.ts +0 -33
- package/src/services/utils.ts +2 -0
- package/src/staking/staking.ts +1 -2
- package/src/types/aaveV4.ts +5 -0
- package/src/types/common.ts +5 -0
- package/src/types/index.ts +0 -1
- package/src/types/merkl.ts +3 -3
- package/src/types/morphoBlue.ts +3 -0
- package/src/types/portfolio.ts +0 -4
- package/cjs/eulerV2/index.d.ts +0 -47
- package/cjs/eulerV2/index.js +0 -225
- package/cjs/helpers/eulerHelpers/index.d.ts +0 -22
- package/cjs/helpers/eulerHelpers/index.js +0 -231
- package/cjs/markets/euler/index.d.ts +0 -8
- package/cjs/markets/euler/index.js +0 -30
- package/cjs/types/euler.d.ts +0 -153
- package/cjs/types/euler.js +0 -14
- package/esm/eulerV2/index.d.ts +0 -47
- package/esm/eulerV2/index.js +0 -215
- package/esm/helpers/eulerHelpers/index.d.ts +0 -22
- package/esm/helpers/eulerHelpers/index.js +0 -218
- package/esm/markets/euler/index.d.ts +0 -8
- package/esm/markets/euler/index.js +0 -24
- package/esm/types/euler.d.ts +0 -153
- package/esm/types/euler.js +0 -11
- package/src/eulerV2/index.ts +0 -331
- package/src/helpers/eulerHelpers/index.ts +0 -232
- package/src/markets/euler/index.ts +0 -27
- package/src/types/euler.ts +0 -178
package/esm/contracts.js
CHANGED
|
@@ -107,7 +107,6 @@ export const WstETHPriceFeedContractViem = createViemContractFromConfigFunc('Wst
|
|
|
107
107
|
export const CompV3ViewContractViem = createViemContractFromConfigFunc('CompV3View');
|
|
108
108
|
export const SparkViewContractViem = createViemContractFromConfigFunc('SparkView');
|
|
109
109
|
export const SparkIncentiveDataProviderContractViem = createViemContractFromConfigFunc('SparkIncentiveDataProvider');
|
|
110
|
-
export const EulerV2ViewContractViem = createViemContractFromConfigFunc('EulerV2View');
|
|
111
110
|
export const CrvUSDViewContractViem = createViemContractFromConfigFunc('crvUSDView');
|
|
112
111
|
export const CrvUSDFactoryContractViem = createViemContractFromConfigFunc('crvUSDFactory');
|
|
113
112
|
export const LlamaLendViewContractViem = createViemContractFromConfigFunc('LlamaLendView');
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4SpokeInfo, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets, EthereumProvider, LeverageType, NetworkNumber } from '../../types';
|
|
1
|
+
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4SpokeInfo, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets, EthereumProvider, IncentiveData, IncentiveSide, LeverageType, NetworkNumber } from '../../types';
|
|
2
2
|
export declare const calcUserRiskPremiumBps: (usedAssets: AaveV4UsedReserveAssets, assetsData: AaveV4AssetsData) => number;
|
|
3
|
+
/**
|
|
4
|
+
* The incentives that actually accrue to a position on this reserve for the given side: the
|
|
5
|
+
* intrinsic (staking) incentives plus the single applicable Merkl reward. Display surfaces should
|
|
6
|
+
* use this rather than picking a scoped list directly, so badges always match the net APY math.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getAaveV4ApplicableIncentives: (assetData: AaveV4ReserveAssetData, side: IncentiveSide) => IncentiveData[];
|
|
3
9
|
export declare const calculateNetApyAaveV4: ({ usedAssets, assetsData, }: {
|
|
4
10
|
usedAssets: AaveV4UsedReserveAssets;
|
|
5
11
|
assetsData: AaveV4AssetsData;
|
|
@@ -11,7 +11,7 @@ import Dec from 'decimal.js';
|
|
|
11
11
|
import { assetAmountInWei } from '@defisaver/tokens';
|
|
12
12
|
import { aprToApy, calcLeverageLiqPrice, getAssetsTotal, STABLE_ASSETS, } from '../../moneymarket';
|
|
13
13
|
import { calculateInterestEarned } from '../../staking';
|
|
14
|
-
import { LeverageType, } from '../../types';
|
|
14
|
+
import { IncentiveSide, LeverageType, } from '../../types';
|
|
15
15
|
import { borrowOperations } from '../../constants';
|
|
16
16
|
import { AaveV4ViewContractViem } from '../../contracts';
|
|
17
17
|
import { getViemProvider } from '../../services/viem';
|
|
@@ -69,14 +69,25 @@ export const calcUserRiskPremiumBps = (usedAssets, assetsData) => {
|
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
71
71
|
* `spokeXIncentives`/`hubXIncentives` are each the intrinsic `base` list with at most one Merkl
|
|
72
|
-
* reward appended (see attachAaveV4MerklIncentives).
|
|
73
|
-
*
|
|
72
|
+
* reward appended (see attachAaveV4MerklIncentives). Merkl regularly publishes the same reward
|
|
73
|
+
* stream at both scopes (a spoke campaign and a hub campaign covering the same borrows, e.g. USDC
|
|
74
|
+
* borrowed from the Prime Hub via the Bluechip Spoke), so the scopes must never be summed — the
|
|
75
|
+
* more specific spoke reward wins and the hub reward only applies when no spoke campaign exists,
|
|
76
|
+
* which is also what every per-asset APY badge (and Aave's own UI) shows.
|
|
74
77
|
*/
|
|
75
|
-
const mergeScopedIncentives = (base = [], spokeScoped, hubScoped) =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
...
|
|
79
|
-
|
|
78
|
+
const mergeScopedIncentives = (base = [], spokeScoped, hubScoped) => {
|
|
79
|
+
const spokeExtras = spokeScoped ? spokeScoped.slice(base.length) : [];
|
|
80
|
+
const hubExtras = hubScoped ? hubScoped.slice(base.length) : [];
|
|
81
|
+
return [...base, ...(spokeExtras.length ? spokeExtras : hubExtras)];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The incentives that actually accrue to a position on this reserve for the given side: the
|
|
85
|
+
* intrinsic (staking) incentives plus the single applicable Merkl reward. Display surfaces should
|
|
86
|
+
* use this rather than picking a scoped list directly, so badges always match the net APY math.
|
|
87
|
+
*/
|
|
88
|
+
export const getAaveV4ApplicableIncentives = (assetData, side) => (side === IncentiveSide.Supply
|
|
89
|
+
? mergeScopedIncentives(assetData.supplyIncentives, assetData.spokeSupplyIncentives, assetData.hubSupplyIncentives)
|
|
90
|
+
: mergeScopedIncentives(assetData.borrowIncentives, assetData.spokeBorrowIncentives, assetData.hubBorrowIncentives));
|
|
80
91
|
export const calculateNetApyAaveV4 = ({ usedAssets, assetsData, }) => {
|
|
81
92
|
const riskPremiumBps = calcUserRiskPremiumBps(usedAssets, assetsData);
|
|
82
93
|
const riskPremiumFraction = new Dec(riskPremiumBps).div(10000);
|
|
@@ -90,7 +101,7 @@ export const calculateNetApyAaveV4 = ({ usedAssets, assetsData, }) => {
|
|
|
90
101
|
acc.suppliedUsd = new Dec(acc.suppliedUsd).add(amount).toString();
|
|
91
102
|
const supplyInterest = calculateInterestEarned(amount, assetData.supplyRate, 'year', true);
|
|
92
103
|
acc.supplyInterest = new Dec(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
93
|
-
const supplyIncentives =
|
|
104
|
+
const supplyIncentives = getAaveV4ApplicableIncentives(assetData, IncentiveSide.Supply);
|
|
94
105
|
for (const supplyIncentive of supplyIncentives) {
|
|
95
106
|
const incentiveInterest = calculateInterestEarned(amount, supplyIncentive.apy, 'year', true);
|
|
96
107
|
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
@@ -106,7 +117,7 @@ export const calculateNetApyAaveV4 = ({ usedAssets, assetsData, }) => {
|
|
|
106
117
|
const userBorrowRate = aprToApy(userBorrowApr.toString());
|
|
107
118
|
const borrowInterest = calculateInterestEarned(amount, userBorrowRate, 'year', true);
|
|
108
119
|
acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
109
|
-
const borrowIncentives =
|
|
120
|
+
const borrowIncentives = getAaveV4ApplicableIncentives(assetData, IncentiveSide.Borrow);
|
|
110
121
|
for (const borrowIncentive of borrowIncentives) {
|
|
111
122
|
const incentiveInterest = calculateInterestEarned(amount, borrowIncentive.apy, 'year', true);
|
|
112
123
|
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
package/esm/helpers/index.d.ts
CHANGED
|
@@ -7,6 +7,5 @@ export * as morphoBlueHelpers from './morphoBlueHelpers';
|
|
|
7
7
|
export * as morphoMidnightHelpers from './morphoMidnightHelpers';
|
|
8
8
|
export * as llamaLendHelpers from './llamaLendHelpers';
|
|
9
9
|
export * as liquityV2Helpers from './liquityV2Helpers';
|
|
10
|
-
export * as eulerV2Helpers from './eulerHelpers';
|
|
11
10
|
export * as fluidHelpers from './fluidHelpers';
|
|
12
11
|
export * as aaveV4Helpers from './aaveV4Helpers';
|
package/esm/helpers/index.js
CHANGED
|
@@ -7,6 +7,5 @@ export * as morphoBlueHelpers from './morphoBlueHelpers';
|
|
|
7
7
|
export * as morphoMidnightHelpers from './morphoMidnightHelpers';
|
|
8
8
|
export * as llamaLendHelpers from './llamaLendHelpers';
|
|
9
9
|
export * as liquityV2Helpers from './liquityV2Helpers';
|
|
10
|
-
export * as eulerV2Helpers from './eulerHelpers';
|
|
11
10
|
export * as fluidHelpers from './fluidHelpers';
|
|
12
11
|
export * as aaveV4Helpers from './aaveV4Helpers';
|
package/esm/index.d.ts
CHANGED
|
@@ -18,9 +18,8 @@ import * as exchange from './exchange';
|
|
|
18
18
|
import * as morphoBlue from './morphoBlue';
|
|
19
19
|
import * as morphoMidnight from './morphoMidnight';
|
|
20
20
|
import * as llamaLend from './llamaLend';
|
|
21
|
-
import * as eulerV2 from './eulerV2';
|
|
22
21
|
import * as portfolio from './portfolio';
|
|
23
22
|
import * as claiming from './claiming';
|
|
24
23
|
import * as savings from './savings';
|
|
25
24
|
export * from './types';
|
|
26
|
-
export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, morphoMidnight, llamaLend,
|
|
25
|
+
export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, morphoMidnight, llamaLend, fluid, portfolio, claiming, savings, };
|
package/esm/index.js
CHANGED
|
@@ -18,9 +18,8 @@ import * as exchange from './exchange';
|
|
|
18
18
|
import * as morphoBlue from './morphoBlue';
|
|
19
19
|
import * as morphoMidnight from './morphoMidnight';
|
|
20
20
|
import * as llamaLend from './llamaLend';
|
|
21
|
-
import * as eulerV2 from './eulerV2';
|
|
22
21
|
import * as portfolio from './portfolio';
|
|
23
22
|
import * as claiming from './claiming';
|
|
24
23
|
import * as savings from './savings';
|
|
25
24
|
export * from './types';
|
|
26
|
-
export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, morphoMidnight, llamaLend,
|
|
25
|
+
export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, morphoMidnight, llamaLend, fluid, portfolio, claiming, savings, };
|
package/esm/markets/index.d.ts
CHANGED
|
@@ -6,6 +6,5 @@ export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
|
|
|
6
6
|
export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, } from './morphoMidnight';
|
|
7
7
|
export { LlamaLendMarkets } from './llamaLend';
|
|
8
8
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
9
|
-
export { EulerV2Markets } from './euler';
|
|
10
9
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
11
10
|
export { AaveV4Spokes, findAaveV4SpokeByAddress } from './aaveV4';
|
package/esm/markets/index.js
CHANGED
|
@@ -6,6 +6,5 @@ export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
|
|
|
6
6
|
export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, } from './morphoMidnight';
|
|
7
7
|
export { LlamaLendMarkets } from './llamaLend';
|
|
8
8
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
9
|
-
export { EulerV2Markets } from './euler';
|
|
10
9
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
11
10
|
export { AaveV4Spokes, findAaveV4SpokeByAddress } from './aaveV4';
|
|
@@ -65,6 +65,8 @@ export declare const MORPHO_BLUE_WBTC_USDT_860: (networkId?: NetworkNumber) => M
|
|
|
65
65
|
export declare const MORPHO_BLUE_WSTETH_USDT_860: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
66
66
|
export declare const MORPHO_BLUE_SYRUPUSDC_RLUSD_915: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
67
67
|
export declare const MORPHO_BLUE_WEETH_USDC_770: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
68
|
+
export declare const MORPHO_BLUE_WEETH_USDC_860: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
69
|
+
export declare const MORPHO_BLUE_WEETH_USDC_860_85252BB8: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
68
70
|
export declare const MORPHO_BLUE_ETH_USDC_860_94B823E6: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
69
71
|
export declare const MORPHO_BLUE_USD3_USDC_915: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
70
72
|
export declare const MORPHO_BLUE_STUSDS_USDC_860: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
@@ -72,6 +74,7 @@ export declare const MORPHO_BLUE_CBBTC_RLUSD_860: (networkId?: NetworkNumber) =>
|
|
|
72
74
|
export declare const MORPHO_BLUE_WBTC_ETH_915: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
73
75
|
export declare const MORPHO_BLUE_CBBTC_ETH_915_12DBF493: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
74
76
|
export declare const MORPHO_BLUE_WEETH_USDT_860: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
77
|
+
export declare const MORPHO_BLUE_WEETH_USDT_860_A6A4C1F1: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
75
78
|
export declare const MORPHO_BLUE_SYRUPUSDT_USDT_915: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
76
79
|
export declare const MORPHO_BLUE_CBBTC_PYUSD_860: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
77
80
|
export declare const MORPHO_BLUE_WEETH_USDT_770: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
@@ -185,6 +188,8 @@ export declare const MorphoBlueMarkets: (networkId: NetworkNumber) => {
|
|
|
185
188
|
readonly morphobluewstethusdt_860: MorphoBlueMarketData;
|
|
186
189
|
readonly morphobluesyrupusdcrlusd_915: MorphoBlueMarketData;
|
|
187
190
|
readonly morphoblueweethusdc_770: MorphoBlueMarketData;
|
|
191
|
+
readonly morphoblueweethusdc_860: MorphoBlueMarketData;
|
|
192
|
+
readonly morphoblueweethusdc_860_85252bb8: MorphoBlueMarketData;
|
|
188
193
|
readonly morphoblueethusdc_860_94b823e6: MorphoBlueMarketData;
|
|
189
194
|
readonly morphoblueusd3usdc_915: MorphoBlueMarketData;
|
|
190
195
|
readonly morphobluestusdsusdc_860: MorphoBlueMarketData;
|
|
@@ -192,6 +197,7 @@ export declare const MorphoBlueMarkets: (networkId: NetworkNumber) => {
|
|
|
192
197
|
readonly morphobluewbtceth_915: MorphoBlueMarketData;
|
|
193
198
|
readonly morphobluecbbtceth_915_12dbf493: MorphoBlueMarketData;
|
|
194
199
|
readonly morphoblueweethusdt_860: MorphoBlueMarketData;
|
|
200
|
+
readonly morphoblueweethusdt_860_a6a4c1f1: MorphoBlueMarketData;
|
|
195
201
|
readonly morphobluesyrupusdtusdt_915: MorphoBlueMarketData;
|
|
196
202
|
readonly morphobluecbbtcpyusd_860: MorphoBlueMarketData;
|
|
197
203
|
readonly morphoblueweethusdt_770: MorphoBlueMarketData;
|
|
@@ -991,6 +991,36 @@ export const MORPHO_BLUE_WEETH_USDC_770 = (networkId = NetworkNumber.Eth) => ({
|
|
|
991
991
|
marketId: '0x34377fc4f617c51818e92c79df31ff270c6a91bc94ad32e367fdf59b9f4ac5dd',
|
|
992
992
|
protocolName: 'morpho-blue',
|
|
993
993
|
});
|
|
994
|
+
export const MORPHO_BLUE_WEETH_USDC_860 = (networkId = NetworkNumber.Eth) => ({
|
|
995
|
+
chainIds: [NetworkNumber.Eth],
|
|
996
|
+
label: 'Morpho',
|
|
997
|
+
shortLabel: 'weETH/USDC',
|
|
998
|
+
value: MorphoBlueVersions.MorphoBlueWeEthUSDC_860,
|
|
999
|
+
url: 'weethusdc-61765602',
|
|
1000
|
+
loanToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
1001
|
+
collateralToken: '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee',
|
|
1002
|
+
oracle: '0x5635a2F38c5dFd1d8fDB176d9CB5AEFA07bf6A68',
|
|
1003
|
+
oracleType: MorphoBlueOracleType.MARKET_RATE,
|
|
1004
|
+
irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1005
|
+
lltv: 0.86,
|
|
1006
|
+
marketId: '0x61765602144e91e5ac9f9e98b8584eae308f9951596fd7f5e0f59f21cd2bf664',
|
|
1007
|
+
protocolName: 'morpho-blue',
|
|
1008
|
+
});
|
|
1009
|
+
export const MORPHO_BLUE_WEETH_USDC_860_85252BB8 = (networkId = NetworkNumber.Eth) => ({
|
|
1010
|
+
chainIds: [NetworkNumber.Eth],
|
|
1011
|
+
label: 'Morpho',
|
|
1012
|
+
shortLabel: 'weETH/USDC',
|
|
1013
|
+
value: MorphoBlueVersions.MorphoBlueWeEthUSDC_860_85252bb8,
|
|
1014
|
+
url: 'weethusdc-85252bb8',
|
|
1015
|
+
loanToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
1016
|
+
collateralToken: '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee',
|
|
1017
|
+
oracle: '0xa3A7A3ceFee206f9d7Fe00eC3C83324ED4228411',
|
|
1018
|
+
oracleType: MorphoBlueOracleType.MARKET_RATE,
|
|
1019
|
+
irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1020
|
+
lltv: 0.86,
|
|
1021
|
+
marketId: '0x85252bb8485c99bba46fe149c7dd2aad83672640f53c630890673cf1848ba16e',
|
|
1022
|
+
protocolName: 'morpho-blue',
|
|
1023
|
+
});
|
|
994
1024
|
export const MORPHO_BLUE_ETH_USDC_860_94B823E6 = (networkId = NetworkNumber.Eth) => ({
|
|
995
1025
|
chainIds: [NetworkNumber.Eth],
|
|
996
1026
|
label: 'Morpho',
|
|
@@ -1096,6 +1126,21 @@ export const MORPHO_BLUE_WEETH_USDT_860 = (networkId = NetworkNumber.Eth) => ({
|
|
|
1096
1126
|
marketId: '0xc2c53d2b868e163da71de14a5113cc2743fc9b5ad7488334720ed2846566a8f6',
|
|
1097
1127
|
protocolName: 'morpho-blue',
|
|
1098
1128
|
});
|
|
1129
|
+
export const MORPHO_BLUE_WEETH_USDT_860_A6A4C1F1 = (networkId = NetworkNumber.Eth) => ({
|
|
1130
|
+
chainIds: [NetworkNumber.Eth],
|
|
1131
|
+
label: 'Morpho',
|
|
1132
|
+
shortLabel: 'weETH/USDT',
|
|
1133
|
+
value: MorphoBlueVersions.MorphoBlueWeEthUSDT_860_a6a4c1f1,
|
|
1134
|
+
url: 'weethusdt-a6a4c1f1',
|
|
1135
|
+
loanToken: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
1136
|
+
collateralToken: '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee',
|
|
1137
|
+
oracle: '0xa3A7A3ceFee206f9d7Fe00eC3C83324ED4228411',
|
|
1138
|
+
oracleType: MorphoBlueOracleType.MARKET_RATE,
|
|
1139
|
+
irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1140
|
+
lltv: 0.86,
|
|
1141
|
+
marketId: '0xa6a4c1f15490a1ff39d9de3a366b408dd5647a436d8b179726d3e0562aff1292',
|
|
1142
|
+
protocolName: 'morpho-blue',
|
|
1143
|
+
});
|
|
1099
1144
|
export const MORPHO_BLUE_SYRUPUSDT_USDT_915 = (networkId = NetworkNumber.Eth) => ({
|
|
1100
1145
|
chainIds: [NetworkNumber.Eth],
|
|
1101
1146
|
label: 'Morpho',
|
|
@@ -1856,6 +1901,8 @@ export const MorphoBlueMarkets = (networkId) => ({
|
|
|
1856
1901
|
[MorphoBlueVersions.MorphoBlueWstEthUSDT_860]: MORPHO_BLUE_WSTETH_USDT_860(networkId),
|
|
1857
1902
|
[MorphoBlueVersions.MorphoBlueSyrupUSDCRLUSD_915]: MORPHO_BLUE_SYRUPUSDC_RLUSD_915(networkId),
|
|
1858
1903
|
[MorphoBlueVersions.MorphoBlueWeEthUSDC_770]: MORPHO_BLUE_WEETH_USDC_770(networkId),
|
|
1904
|
+
[MorphoBlueVersions.MorphoBlueWeEthUSDC_860]: MORPHO_BLUE_WEETH_USDC_860(networkId),
|
|
1905
|
+
[MorphoBlueVersions.MorphoBlueWeEthUSDC_860_85252bb8]: MORPHO_BLUE_WEETH_USDC_860_85252BB8(networkId),
|
|
1859
1906
|
[MorphoBlueVersions.MorphoBlueEthUSDC_860_94b823e6]: MORPHO_BLUE_ETH_USDC_860_94B823E6(networkId),
|
|
1860
1907
|
[MorphoBlueVersions.MorphoBlueUSD3USDC_915]: MORPHO_BLUE_USD3_USDC_915(networkId),
|
|
1861
1908
|
[MorphoBlueVersions.MorphoBlueStUSDSUSDC_860]: MORPHO_BLUE_STUSDS_USDC_860(networkId),
|
|
@@ -1863,6 +1910,7 @@ export const MorphoBlueMarkets = (networkId) => ({
|
|
|
1863
1910
|
[MorphoBlueVersions.MorphoBlueWBTCEth_915]: MORPHO_BLUE_WBTC_ETH_915(networkId),
|
|
1864
1911
|
[MorphoBlueVersions.MorphoBlueCbBTCEth_915_12dbf493]: MORPHO_BLUE_CBBTC_ETH_915_12DBF493(networkId),
|
|
1865
1912
|
[MorphoBlueVersions.MorphoBlueWeEthUSDT_860]: MORPHO_BLUE_WEETH_USDT_860(networkId),
|
|
1913
|
+
[MorphoBlueVersions.MorphoBlueWeEthUSDT_860_a6a4c1f1]: MORPHO_BLUE_WEETH_USDT_860_A6A4C1F1(networkId),
|
|
1866
1914
|
[MorphoBlueVersions.MorphoBlueSyrupUSDTUSDT_915]: MORPHO_BLUE_SYRUPUSDT_USDT_915(networkId),
|
|
1867
1915
|
[MorphoBlueVersions.MorphoBlueCbBTCPYUSD_860]: MORPHO_BLUE_CBBTC_PYUSD_860(networkId),
|
|
1868
1916
|
[MorphoBlueVersions.MorphoBlueWeEthUSDT_770]: MORPHO_BLUE_WEETH_USDT_770(networkId),
|
|
@@ -7,7 +7,7 @@ import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
|
7
7
|
* Uses one shared, multicall-batched viem client (same pattern as getPortfolioData) so all
|
|
8
8
|
* per-market reads collapse into a handful of RPC round trips.
|
|
9
9
|
*
|
|
10
|
-
* Not covered: Maker, Liquity, Liquity V2, Fluid
|
|
10
|
+
* Not covered: Maker, Liquity, Liquity V2, Fluid — these already expose cheap,
|
|
11
11
|
* user-scoped discovery entry points elsewhere in the SDK (e.g. _getUserCdps, _getUserPositionsPortfolio).
|
|
12
12
|
*/
|
|
13
13
|
export declare function getUserPositionsExistence(provider: EthereumProvider, network: NetworkNumber, address: EthAddress, isSim?: boolean): Promise<Record<string, boolean>>;
|
|
@@ -29,7 +29,7 @@ const hasAnyBalance = (balances) => ([balances.collateral, balances.debt].some((
|
|
|
29
29
|
* Uses one shared, multicall-batched viem client (same pattern as getPortfolioData) so all
|
|
30
30
|
* per-market reads collapse into a handful of RPC round trips.
|
|
31
31
|
*
|
|
32
|
-
* Not covered: Maker, Liquity, Liquity V2, Fluid
|
|
32
|
+
* Not covered: Maker, Liquity, Liquity V2, Fluid — these already expose cheap,
|
|
33
33
|
* user-scoped discovery entry points elsewhere in the SDK (e.g. _getUserCdps, _getUserPositionsPortfolio).
|
|
34
34
|
*/
|
|
35
35
|
export function getUserPositionsExistence(provider_1, network_1, address_1) {
|
package/esm/portfolio/index.js
CHANGED
|
@@ -9,13 +9,12 @@ 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, AaveV4Spokes, CompoundMarkets, CrvUsdMarkets,
|
|
12
|
+
import { AaveMarkets, AaveV4Spokes, CompoundMarkets, CrvUsdMarkets, LiquityV2Markets, LlamaLendMarkets, MorphoBlueMarkets, MorphoMidnightMarkets, SparkMarkets, } from '../markets';
|
|
13
13
|
import { _getMorphoBlueAccountData, _getMorphoBluePortfolioMarketData, getMorphoEarn } from '../morphoBlue';
|
|
14
14
|
import { _getMorphoMidnightAccountData, _getMorphoMidnightMarketData, getMorphoMidnightEarn } from '../morphoMidnight';
|
|
15
15
|
import { AaveVersions, CompoundVersions, } from '../types';
|
|
16
16
|
import { _getCompoundV3AccountData, _getCompoundV3MarketsData } from '../compoundV3';
|
|
17
17
|
import { _getSparkAccountData, _getSparkMarketsData } from '../spark';
|
|
18
|
-
import { _getEulerV2AccountData, _getEulerV2MarketsData } from '../eulerV2';
|
|
19
18
|
import { _getCurveUsdGlobalData, _getCurveUsdUserData } from '../curveUsd';
|
|
20
19
|
import { _getLlamaLendGlobalData, _getLlamaLendUserData } from '../llamaLend';
|
|
21
20
|
import { _getAaveV3AccountData, _getAaveV3MarketData, getStakeAaveData } from '../aaveV3';
|
|
@@ -27,7 +26,6 @@ import { getViemProvider } from '../services/viem';
|
|
|
27
26
|
import { _getLiquityTroveInfo, getLiquityStakingData } from '../liquity';
|
|
28
27
|
import { _getLiquityV2MarketData, getLiquitySAndYBold, getLiquityV2Staking } from '../liquityV2';
|
|
29
28
|
import { _getAllUserEarnPositionsWithFTokens, _getUserPositionsPortfolio } from '../fluid';
|
|
30
|
-
import { getEulerV2SubAccounts } from '../helpers/eulerHelpers';
|
|
31
29
|
import { getUmbrellaData } from '../umbrella';
|
|
32
30
|
import { getMeritUnclaimedRewards, getUnclaimedRewardsForAllMarkets } from '../claiming/aaveV3';
|
|
33
31
|
import { getCompoundV3Rewards } from '../claiming/compV3';
|
|
@@ -44,7 +42,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
44
42
|
const morphoMidnightMarkets = Object.values(MorphoMidnightMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
45
43
|
const compoundV3Markets = Object.values(CompoundMarkets(network)).filter((market) => market.chainIds.includes(network) && market.value !== CompoundVersions.CompoundV2);
|
|
46
44
|
const sparkMarkets = Object.values(SparkMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
47
|
-
const eulerV2Markets = Object.values(EulerV2Markets(network)).filter((market) => market.chainIds.includes(network));
|
|
48
45
|
const aaveV3Markets = [AaveVersions.AaveV3, AaveVersions.AaveV3Lido, AaveVersions.AaveV3Etherfi].map((version) => AaveMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
49
46
|
const aaveV2Markets = [AaveVersions.AaveV2].map((version) => AaveMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
50
47
|
const compoundV2Markets = [CompoundVersions.CompoundV2].map((version) => CompoundMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
@@ -60,7 +57,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
60
57
|
const morphoMidnightMarketsData = {};
|
|
61
58
|
const compoundV3MarketsData = {};
|
|
62
59
|
const sparkMarketsData = {};
|
|
63
|
-
const eulerV2MarketsData = {};
|
|
64
60
|
const aaveV3MarketsData = {};
|
|
65
61
|
const makerCdps = {};
|
|
66
62
|
const aaveV2MarketsData = {};
|
|
@@ -74,7 +70,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
74
70
|
morphoMidnightMarketsData,
|
|
75
71
|
compoundV3MarketsData,
|
|
76
72
|
sparkMarketsData,
|
|
77
|
-
eulerV2MarketsData,
|
|
78
73
|
aaveV3MarketsData,
|
|
79
74
|
aaveV2MarketsData,
|
|
80
75
|
compoundV2MarketsData,
|
|
@@ -95,7 +90,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
95
90
|
morphoMidnight: {},
|
|
96
91
|
compoundV3: {},
|
|
97
92
|
spark: {},
|
|
98
|
-
eulerV2: {},
|
|
99
93
|
maker: {},
|
|
100
94
|
aaveV2: {},
|
|
101
95
|
compoundV2: {},
|
|
@@ -153,10 +147,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
153
147
|
const marketData = yield _getSparkMarketsData(client, network, market);
|
|
154
148
|
sparkMarketsData[market.value] = marketData;
|
|
155
149
|
})),
|
|
156
|
-
...eulerV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
const marketData = yield _getEulerV2MarketsData(client, network, market);
|
|
158
|
-
eulerV2MarketsData[market.value] = marketData;
|
|
159
|
-
})),
|
|
160
150
|
...aaveV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
161
151
|
const marketData = yield _getAaveV3MarketData(client, network, market);
|
|
162
152
|
aaveV3MarketsData[market.value] = marketData;
|
|
@@ -539,28 +529,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
539
529
|
positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
540
530
|
}
|
|
541
531
|
}))).flat(),
|
|
542
|
-
...eulerV2Markets.map((market) => addresses.map((address) => {
|
|
543
|
-
const eulerV2SubAccounts = getEulerV2SubAccounts(address);
|
|
544
|
-
const eulerV2Addresses = [address, ...eulerV2SubAccounts];
|
|
545
|
-
return Promise.all(eulerV2Addresses.map((eulerAddress) => __awaiter(this, void 0, void 0, function* () {
|
|
546
|
-
try {
|
|
547
|
-
const accData = yield _getEulerV2AccountData(client, network, eulerAddress, eulerAddress, Object.assign({ selectedMarket: market }, eulerV2MarketsData[market.value]));
|
|
548
|
-
if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
|
|
549
|
-
if (!positions[address.toLowerCase()].eulerV2[market.value]) {
|
|
550
|
-
positions[address.toLowerCase()].eulerV2[market.value] = {};
|
|
551
|
-
}
|
|
552
|
-
positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = { error: '', data: accData };
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
catch (error) {
|
|
556
|
-
console.error(`Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}:`, error);
|
|
557
|
-
if (!positions[address.toLowerCase()].eulerV2[market.value]) {
|
|
558
|
-
positions[address.toLowerCase()].eulerV2[market.value] = {};
|
|
559
|
-
}
|
|
560
|
-
positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = { error: `Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}`, data: null };
|
|
561
|
-
}
|
|
562
|
-
})));
|
|
563
|
-
}).flat()).flat(),
|
|
564
532
|
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
565
533
|
var _a;
|
|
566
534
|
return (_a = makerCdps[address.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
|
package/esm/services/utils.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const getAbiItem: (abi: any, methodName: string) => any;
|
|
|
8
8
|
export declare const ADDRESS_REGEX: RegExp;
|
|
9
9
|
export declare const isAddress: (address: string) => boolean;
|
|
10
10
|
export declare const compareAddresses: (addr1?: string, addr2?: string) => boolean;
|
|
11
|
+
export declare const shortenAddress: (address?: string, start?: number, end?: number) => string;
|
|
11
12
|
export declare const getWeiAmountForDecimals: (amount: string | number, decimals: number) => string;
|
|
12
13
|
export declare const getEthAmountForDecimals: (amount: string | number, decimals: string | number) => string;
|
|
13
14
|
export declare const handleWbtcLegacy: (asset: string) => string;
|
package/esm/services/utils.js
CHANGED
|
@@ -10,6 +10,7 @@ export const getAbiItem = (abi, methodName) => abi.find((i) => i.name === method
|
|
|
10
10
|
export const ADDRESS_REGEX = /0x[0-9a-fA-F]{40}/;
|
|
11
11
|
export const isAddress = (address) => typeof address === 'string' && (new RegExp(ADDRESS_REGEX).test(address));
|
|
12
12
|
export const compareAddresses = (addr1 = '', addr2 = '') => addr1.toLowerCase() === addr2.toLowerCase();
|
|
13
|
+
export const shortenAddress = (address = '', start = 8, end = 4) => `${address.substring(0, start)}...${address.slice(-end)}`;
|
|
13
14
|
export const getWeiAmountForDecimals = (amount, decimals) => new Dec(amount).mul(Math.pow(10, decimals)).floor().toString();
|
|
14
15
|
export const getEthAmountForDecimals = (amount, decimals) => new Dec(amount).div(Math.pow(10, +decimals)).toString();
|
|
15
16
|
export const handleWbtcLegacy = (asset) => (asset === 'WBTC Legacy' ? 'WBTC' : asset);
|
package/esm/staking/staking.js
CHANGED
|
@@ -184,9 +184,8 @@ export const calculateInterestEarned = (principal, interest, type, apy = false)
|
|
|
184
184
|
};
|
|
185
185
|
export const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
186
186
|
const sumValues = Object.values(usedAssets).reduce((_acc, usedAsset) => {
|
|
187
|
-
var _a;
|
|
188
187
|
const acc = Object.assign({}, _acc);
|
|
189
|
-
const assetData = assetsData[usedAsset.symbol]
|
|
188
|
+
const assetData = assetsData[usedAsset.symbol];
|
|
190
189
|
if (usedAsset.isSupplied) {
|
|
191
190
|
const amount = usedAsset.suppliedUsd;
|
|
192
191
|
acc.suppliedUsd = new Dec(acc.suppliedUsd).add(amount).toString();
|
package/esm/types/aaveV4.d.ts
CHANGED
|
@@ -44,6 +44,11 @@ export interface AaveV4SpokeInfo {
|
|
|
44
44
|
value: AaveV4SpokesType;
|
|
45
45
|
url: string;
|
|
46
46
|
address: EthAddress;
|
|
47
|
+
/**
|
|
48
|
+
* Known hub addresses, used only to prefetch hub data in parallel with the spoke data.
|
|
49
|
+
* The on-chain reserves are the source of truth — hubs found there but missing here are
|
|
50
|
+
* fetched dynamically, so this list going stale can't break spoke loading.
|
|
51
|
+
*/
|
|
47
52
|
hubs: EthAddress[];
|
|
48
53
|
}
|
|
49
54
|
export interface AaveV4SpokeData {
|
package/esm/types/common.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export declare enum IncentiveKind {
|
|
|
2
2
|
Staking = "staking",
|
|
3
3
|
Reward = "reward"
|
|
4
4
|
}
|
|
5
|
+
export declare enum IncentiveSide {
|
|
6
|
+
Supply = "supply",
|
|
7
|
+
Borrow = "borrow"
|
|
8
|
+
}
|
|
5
9
|
export declare enum IncentiveEligibilityId {
|
|
6
10
|
AaveV3EthenaLiquidLeverage = "0x0dC599DBB180E64E42b87332FDeC3a551445ea44BORROW_BL",
|
|
7
11
|
AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
|
package/esm/types/common.js
CHANGED
|
@@ -3,6 +3,11 @@ export var IncentiveKind;
|
|
|
3
3
|
IncentiveKind["Staking"] = "staking";
|
|
4
4
|
IncentiveKind["Reward"] = "reward";
|
|
5
5
|
})(IncentiveKind || (IncentiveKind = {}));
|
|
6
|
+
export var IncentiveSide;
|
|
7
|
+
(function (IncentiveSide) {
|
|
8
|
+
IncentiveSide["Supply"] = "supply";
|
|
9
|
+
IncentiveSide["Borrow"] = "borrow";
|
|
10
|
+
})(IncentiveSide || (IncentiveSide = {}));
|
|
6
11
|
export var IncentiveEligibilityId;
|
|
7
12
|
(function (IncentiveEligibilityId) {
|
|
8
13
|
IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x0dC599DBB180E64E42b87332FDeC3a551445ea44BORROW_BL";
|
package/esm/types/index.d.ts
CHANGED
package/esm/types/index.js
CHANGED
package/esm/types/merkl.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress, IncentiveData } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData, IncentiveSide } from './common';
|
|
2
2
|
export declare enum OpportunityAction {
|
|
3
3
|
LEND = "LEND",
|
|
4
4
|
BORROW = "BORROW"
|
|
@@ -74,12 +74,11 @@ export type MerkleRewardMap = Record<EthAddress, {
|
|
|
74
74
|
borrow?: MerkleRewardInfo;
|
|
75
75
|
}>;
|
|
76
76
|
export type AaveV4MerklScopedReward = {
|
|
77
|
-
|
|
78
|
-
borrow?: IncentiveData;
|
|
77
|
+
[side in IncentiveSide]?: IncentiveData;
|
|
79
78
|
};
|
|
80
79
|
/**
|
|
81
80
|
* Aave V4 Merkl reward campaigns split by scope:
|
|
82
|
-
* - `hub`: keyed by
|
|
81
|
+
* - `hub`: keyed by `${hubAddress}_${underlyingAddress}` (both lowercase) — rewards for supplying/borrowing via a hub
|
|
83
82
|
* - `spoke`: keyed by `${spokeAddress}_${underlyingAddress}` (both lowercase) — rewards for supplying/borrowing on a spoke
|
|
84
83
|
*/
|
|
85
84
|
export type AaveV4MerklRewardMap = {
|
|
@@ -66,6 +66,8 @@ export declare enum MorphoBlueVersions {
|
|
|
66
66
|
MorphoBlueWstEthUSDT_860 = "morphobluewstethusdt_860",// wstETH/USDT 0.86
|
|
67
67
|
MorphoBlueSyrupUSDCRLUSD_915 = "morphobluesyrupusdcrlusd_915",// syrupUSDC/RLUSD 0.915
|
|
68
68
|
MorphoBlueWeEthUSDC_770 = "morphoblueweethusdc_770",// weETH/USDC 0.77
|
|
69
|
+
MorphoBlueWeEthUSDC_860 = "morphoblueweethusdc_860",// weETH/USDC 0.86
|
|
70
|
+
MorphoBlueWeEthUSDC_860_85252bb8 = "morphoblueweethusdc_860_85252bb8",// weETH/USDC 0.86
|
|
69
71
|
MorphoBlueEthUSDC_860_94b823e6 = "morphoblueethusdc_860_94b823e6",// ETH/USDC 0.86
|
|
70
72
|
MorphoBlueUSD3USDC_915 = "morphoblueusd3usdc_915",// USD3/USDC 0.915
|
|
71
73
|
MorphoBlueStUSDSUSDC_860 = "morphobluestusdsusdc_860",// stUSDS/USDC 0.86
|
|
@@ -73,6 +75,7 @@ export declare enum MorphoBlueVersions {
|
|
|
73
75
|
MorphoBlueWBTCEth_915 = "morphobluewbtceth_915",// WBTC/ETH 0.915
|
|
74
76
|
MorphoBlueCbBTCEth_915_12dbf493 = "morphobluecbbtceth_915_12dbf493",// cbBTC/ETH 0.915
|
|
75
77
|
MorphoBlueWeEthUSDT_860 = "morphoblueweethusdt_860",// weETH/USDT 0.86
|
|
78
|
+
MorphoBlueWeEthUSDT_860_a6a4c1f1 = "morphoblueweethusdt_860_a6a4c1f1",// weETH/USDT 0.86
|
|
76
79
|
MorphoBlueSyrupUSDTUSDT_915 = "morphobluesyrupusdtusdt_915",// syrupUSDT/USDT 0.915
|
|
77
80
|
MorphoBlueCbBTCPYUSD_860 = "morphobluecbbtcpyusd_860",// cbBTC/PYUSD 0.86
|
|
78
81
|
MorphoBlueWeEthUSDT_770 = "morphoblueweethusdt_770",// weETH/USDT 0.77
|
package/esm/types/morphoBlue.js
CHANGED
|
@@ -72,6 +72,8 @@ export var MorphoBlueVersions;
|
|
|
72
72
|
MorphoBlueVersions["MorphoBlueWstEthUSDT_860"] = "morphobluewstethusdt_860";
|
|
73
73
|
MorphoBlueVersions["MorphoBlueSyrupUSDCRLUSD_915"] = "morphobluesyrupusdcrlusd_915";
|
|
74
74
|
MorphoBlueVersions["MorphoBlueWeEthUSDC_770"] = "morphoblueweethusdc_770";
|
|
75
|
+
MorphoBlueVersions["MorphoBlueWeEthUSDC_860"] = "morphoblueweethusdc_860";
|
|
76
|
+
MorphoBlueVersions["MorphoBlueWeEthUSDC_860_85252bb8"] = "morphoblueweethusdc_860_85252bb8";
|
|
75
77
|
MorphoBlueVersions["MorphoBlueEthUSDC_860_94b823e6"] = "morphoblueethusdc_860_94b823e6";
|
|
76
78
|
MorphoBlueVersions["MorphoBlueUSD3USDC_915"] = "morphoblueusd3usdc_915";
|
|
77
79
|
MorphoBlueVersions["MorphoBlueStUSDSUSDC_860"] = "morphobluestusdsusdc_860";
|
|
@@ -79,6 +81,7 @@ export var MorphoBlueVersions;
|
|
|
79
81
|
MorphoBlueVersions["MorphoBlueWBTCEth_915"] = "morphobluewbtceth_915";
|
|
80
82
|
MorphoBlueVersions["MorphoBlueCbBTCEth_915_12dbf493"] = "morphobluecbbtceth_915_12dbf493";
|
|
81
83
|
MorphoBlueVersions["MorphoBlueWeEthUSDT_860"] = "morphoblueweethusdt_860";
|
|
84
|
+
MorphoBlueVersions["MorphoBlueWeEthUSDT_860_a6a4c1f1"] = "morphoblueweethusdt_860_a6a4c1f1";
|
|
82
85
|
MorphoBlueVersions["MorphoBlueSyrupUSDTUSDT_915"] = "morphobluesyrupusdtusdt_915";
|
|
83
86
|
MorphoBlueVersions["MorphoBlueCbBTCPYUSD_860"] = "morphobluecbbtcpyusd_860";
|
|
84
87
|
MorphoBlueVersions["MorphoBlueWeEthUSDT_770"] = "morphoblueweethusdt_770";
|
package/esm/types/portfolio.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { AaveV4AccountData, AaveV4SpokesType } from './aaveV4';
|
|
|
3
3
|
import { EthAddress } from './common';
|
|
4
4
|
import { CompoundV2PositionData, CompoundV3PositionData, CompoundVersions } from './compound';
|
|
5
5
|
import { CrvUSDUserData, CrvUSDVersions } from './curveUsd';
|
|
6
|
-
import { EulerV2PositionData, EulerV2Versions } from './euler';
|
|
7
6
|
import { FluidVaultData } from './fluid';
|
|
8
7
|
import { LiquityTroveInfo } from './liquity';
|
|
9
8
|
import { LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
|
|
@@ -31,9 +30,6 @@ export interface PortfolioPositionsDataForAddress {
|
|
|
31
30
|
spark: {
|
|
32
31
|
[key in SparkVersions]?: PortfolioProtocolData<SparkPositionData>;
|
|
33
32
|
};
|
|
34
|
-
eulerV2: {
|
|
35
|
-
[key in EulerV2Versions]?: Record<EthAddress, PortfolioProtocolData<EulerV2PositionData>>;
|
|
36
|
-
};
|
|
37
33
|
maker: {
|
|
38
34
|
[key: string]: PortfolioProtocolData<CdpData>;
|
|
39
35
|
};
|
package/package.json
CHANGED
package/src/aaveV4/index.ts
CHANGED
|
@@ -21,7 +21,9 @@ import {
|
|
|
21
21
|
} from '../types';
|
|
22
22
|
import { AaveV4ViewContractViem } from '../contracts';
|
|
23
23
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
isMaxUint, shortenAddress, wethToEth, wethToEthByAddress,
|
|
26
|
+
} from '../services/utils';
|
|
25
27
|
import { aaveV4GetAggregatedPositionData, calcUserRiskPremiumBps } from '../helpers/aaveV4Helpers';
|
|
26
28
|
import { findAaveV4SpokeByAddress, getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
27
29
|
import { aprToApy } from '../moneymarket';
|
|
@@ -56,10 +58,10 @@ const formatReserveAsset = async (reserveAsset: AaveV4ReserveAssetOnChain, hubAs
|
|
|
56
58
|
// tokens package. Flag it so consumers can render it read-only instead of feeding NaN into amounts.
|
|
57
59
|
const isUnsupported = assetInfo.symbol === '?';
|
|
58
60
|
const symbol = wethToEth(assetInfo.symbol);
|
|
61
|
+
// The hub registry only provides display metadata — a hub missing from it (newly deployed by
|
|
62
|
+
// Aave, SDK not yet updated) must not prevent the reserve from loading, so fall back to a
|
|
63
|
+
// generated label instead of failing.
|
|
59
64
|
const hubInfo = getAaveV4HubByAddress(network, reserveAsset.hub);
|
|
60
|
-
if (!hubInfo) {
|
|
61
|
-
throw new Error(`Hub not found with address: ${reserveAsset.hub}`);
|
|
62
|
-
}
|
|
63
65
|
|
|
64
66
|
const isStakingAsset = STAKING_ASSETS.includes(symbol);
|
|
65
67
|
const supplyIncentives: IncentiveData[] = [];
|
|
@@ -124,8 +126,8 @@ const formatReserveAsset = async (reserveAsset: AaveV4ReserveAssetOnChain, hubAs
|
|
|
124
126
|
decimals: reserveAsset.decimals,
|
|
125
127
|
isUnsupported,
|
|
126
128
|
underlying: reserveAsset.underlying,
|
|
127
|
-
hub: hubInfo.
|
|
128
|
-
hubName: hubInfo?.label
|
|
129
|
+
hub: hubInfo?.address ?? reserveAsset.hub,
|
|
130
|
+
hubName: hubInfo?.label ?? `Hub ${shortenAddress(reserveAsset.hub)}`,
|
|
129
131
|
assetId: reserveAsset.assetId,
|
|
130
132
|
reserveId,
|
|
131
133
|
paused: reserveAsset.paused,
|
|
@@ -163,16 +165,32 @@ const formatReserveAsset = async (reserveAsset: AaveV4ReserveAssetOnChain, hubAs
|
|
|
163
165
|
export async function _getAaveV4SpokeData(provider: Client, network: NetworkNumber, market: AaveV4SpokeInfo, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4SpokeData> {
|
|
164
166
|
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
165
167
|
|
|
166
|
-
const hubsData: Record<
|
|
168
|
+
const hubsData: Record<string, AaveV4HubOnChainData> = {};
|
|
169
|
+
const loadHubData = async (hubAddress: EthAddress) => {
|
|
170
|
+
hubsData[hubAddress.toLowerCase()] = await fetchHubData(viewContract, hubAddress);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// market.hubs is only a prefetch hint (lets known hubs load in parallel with the spoke data), so
|
|
174
|
+
// failures are tolerated here — any hub the reserves actually reference is (re)fetched below.
|
|
167
175
|
const [spokeData, merklCampaigns] = await Promise.all([
|
|
168
176
|
viewContract.read.getSpokeDataFull([market.address]),
|
|
169
177
|
getAaveV4MerkleCampaigns(network),
|
|
170
|
-
...market.hubs.map(
|
|
171
|
-
hubsData[hubAddress] = await fetchHubData(viewContract, hubAddress);
|
|
172
|
-
}),
|
|
178
|
+
...market.hubs.map((hubAddress) => loadHubData(hubAddress).catch(() => {})),
|
|
173
179
|
]);
|
|
174
180
|
|
|
175
|
-
|
|
181
|
+
// The on-chain reserves are the source of truth for which hubs the spoke uses — fetch any hub
|
|
182
|
+
// the prefetch didn't cover, so an asset listed from a hub unknown to the SDK can't break the spoke.
|
|
183
|
+
const missingHubs = [...new Set(spokeData[1].map((reserveAsset: AaveV4ReserveAssetOnChain) => reserveAsset.hub.toLowerCase() as EthAddress))]
|
|
184
|
+
.filter((hubAddress) => !hubsData[hubAddress]);
|
|
185
|
+
await Promise.all(missingHubs.map(loadHubData));
|
|
186
|
+
|
|
187
|
+
const reserveAssetsArray = (await Promise.all(spokeData[1].map(async (reserveAssetOnChain: AaveV4ReserveAssetOnChain, index: number) => {
|
|
188
|
+
const hubAsset = hubsData[reserveAssetOnChain.hub.toLowerCase()]?.assets[reserveAssetOnChain.assetId];
|
|
189
|
+
// A reserve whose hub-side asset data can't be resolved is skipped instead of failing the
|
|
190
|
+
// whole spoke (position math degrades for that one asset only).
|
|
191
|
+
if (!hubAsset) return null;
|
|
192
|
+
return formatReserveAsset(reserveAssetOnChain, hubAsset, index, +spokeData[0].oracleDecimals.toString(), network);
|
|
193
|
+
}))).filter((asset): asset is AaveV4ReserveAssetData => asset !== null);
|
|
176
194
|
|
|
177
195
|
const enrichedAssets = reserveAssetsArray.map((asset) => attachAaveV4MerklIncentives(asset, market.address, merklCampaigns));
|
|
178
196
|
|