@defisaver/positions-sdk 2.1.137 → 2.1.139
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 +1 -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/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/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/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/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/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/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/cjs/contracts.js
CHANGED
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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.
|
|
37
|
-
exports.UniswapTokenDistributorViem = exports.AaveV4ViewContractViem = exports.SkySavingsContractView = exports.MakerDsrContractViem = exports.YearnViewContractViem = exports.StkAAVEViem = exports.LiquityV2sBoldVaultViem =
|
|
36
|
+
exports.AaveRewardsControllerViem = exports.SparkRewardsControllerViem = exports.UUPSViem = exports.LiquityStabilityPoolViem = exports.LiquityLQTYStakingViem = exports.AaveUmbrellaViewViem = exports.AaveIncentivesControllerViem = exports.FluidViewContractViem = exports.LiquityV2LegacyViewContractViem = exports.LiquityV2ViewContractViem = exports.LiquityActivePoolContractViem = exports.LiquityPriceFeedContractViem = exports.LiquityTroveManagerContractViem = exports.LiquityCollSurplusPoolContractViem = exports.LiquityViewContractViem = exports.BTCPriceFeedContractViem = exports.WeETHPriceFeedContractViem = exports.ComptrollerContractViem = exports.CompoundLoanInfoContractViem = exports.McdJugContractViem = exports.McdDogContractViem = exports.McdSpotterContractViem = exports.McdVatContractViem = exports.McdViewContractViem = exports.McdGetCdpsContractViem = exports.LlamaLendViewContractViem = exports.CrvUSDFactoryContractViem = exports.CrvUSDViewContractViem = exports.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.UniswapTokenDistributorViem = exports.AaveV4ViewContractViem = exports.SkySavingsContractView = exports.MakerDsrContractViem = exports.YearnViewContractViem = exports.StkAAVEViem = exports.LiquityV2sBoldVaultViem = void 0;
|
|
38
38
|
const viem_1 = require("viem");
|
|
39
39
|
const configRaw = __importStar(require("./config/contracts"));
|
|
40
40
|
// @ts-ignore
|
|
@@ -152,7 +152,6 @@ exports.WstETHPriceFeedContractViem = (0, exports.createViemContractFromConfigFu
|
|
|
152
152
|
exports.CompV3ViewContractViem = (0, exports.createViemContractFromConfigFunc)('CompV3View');
|
|
153
153
|
exports.SparkViewContractViem = (0, exports.createViemContractFromConfigFunc)('SparkView');
|
|
154
154
|
exports.SparkIncentiveDataProviderContractViem = (0, exports.createViemContractFromConfigFunc)('SparkIncentiveDataProvider');
|
|
155
|
-
exports.EulerV2ViewContractViem = (0, exports.createViemContractFromConfigFunc)('EulerV2View');
|
|
156
155
|
exports.CrvUSDViewContractViem = (0, exports.createViemContractFromConfigFunc)('crvUSDView');
|
|
157
156
|
exports.CrvUSDFactoryContractViem = (0, exports.createViemContractFromConfigFunc)('crvUSDFactory');
|
|
158
157
|
exports.LlamaLendViewContractViem = (0, exports.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;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getAaveV4ApyAfterValuesEstimation = exports.aaveV4GetAggregatedPositionData = exports.isLeveragedPosAaveV4 = exports.aaveV4GetCollateralFactor = exports.calculateNetApyAaveV4 = exports.calcUserRiskPremiumBps = void 0;
|
|
15
|
+
exports.getAaveV4ApyAfterValuesEstimation = exports.aaveV4GetAggregatedPositionData = exports.isLeveragedPosAaveV4 = exports.aaveV4GetCollateralFactor = exports.calculateNetApyAaveV4 = exports.getAaveV4ApplicableIncentives = exports.calcUserRiskPremiumBps = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const moneymarket_1 = require("../../moneymarket");
|
|
@@ -76,14 +76,26 @@ const calcUserRiskPremiumBps = (usedAssets, assetsData) => {
|
|
|
76
76
|
exports.calcUserRiskPremiumBps = calcUserRiskPremiumBps;
|
|
77
77
|
/**
|
|
78
78
|
* `spokeXIncentives`/`hubXIncentives` are each the intrinsic `base` list with at most one Merkl
|
|
79
|
-
* reward appended (see attachAaveV4MerklIncentives).
|
|
80
|
-
*
|
|
79
|
+
* reward appended (see attachAaveV4MerklIncentives). Merkl regularly publishes the same reward
|
|
80
|
+
* stream at both scopes (a spoke campaign and a hub campaign covering the same borrows, e.g. USDC
|
|
81
|
+
* borrowed from the Prime Hub via the Bluechip Spoke), so the scopes must never be summed — the
|
|
82
|
+
* more specific spoke reward wins and the hub reward only applies when no spoke campaign exists,
|
|
83
|
+
* which is also what every per-asset APY badge (and Aave's own UI) shows.
|
|
81
84
|
*/
|
|
82
|
-
const mergeScopedIncentives = (base = [], spokeScoped, hubScoped) =>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
...
|
|
86
|
-
|
|
85
|
+
const mergeScopedIncentives = (base = [], spokeScoped, hubScoped) => {
|
|
86
|
+
const spokeExtras = spokeScoped ? spokeScoped.slice(base.length) : [];
|
|
87
|
+
const hubExtras = hubScoped ? hubScoped.slice(base.length) : [];
|
|
88
|
+
return [...base, ...(spokeExtras.length ? spokeExtras : hubExtras)];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The incentives that actually accrue to a position on this reserve for the given side: the
|
|
92
|
+
* intrinsic (staking) incentives plus the single applicable Merkl reward. Display surfaces should
|
|
93
|
+
* use this rather than picking a scoped list directly, so badges always match the net APY math.
|
|
94
|
+
*/
|
|
95
|
+
const getAaveV4ApplicableIncentives = (assetData, side) => (side === types_1.IncentiveSide.Supply
|
|
96
|
+
? mergeScopedIncentives(assetData.supplyIncentives, assetData.spokeSupplyIncentives, assetData.hubSupplyIncentives)
|
|
97
|
+
: mergeScopedIncentives(assetData.borrowIncentives, assetData.spokeBorrowIncentives, assetData.hubBorrowIncentives));
|
|
98
|
+
exports.getAaveV4ApplicableIncentives = getAaveV4ApplicableIncentives;
|
|
87
99
|
const calculateNetApyAaveV4 = ({ usedAssets, assetsData, }) => {
|
|
88
100
|
const riskPremiumBps = (0, exports.calcUserRiskPremiumBps)(usedAssets, assetsData);
|
|
89
101
|
const riskPremiumFraction = new decimal_js_1.default(riskPremiumBps).div(10000);
|
|
@@ -97,7 +109,7 @@ const calculateNetApyAaveV4 = ({ usedAssets, assetsData, }) => {
|
|
|
97
109
|
acc.suppliedUsd = new decimal_js_1.default(acc.suppliedUsd).add(amount).toString();
|
|
98
110
|
const supplyInterest = (0, staking_1.calculateInterestEarned)(amount, assetData.supplyRate, 'year', true);
|
|
99
111
|
acc.supplyInterest = new decimal_js_1.default(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
100
|
-
const supplyIncentives =
|
|
112
|
+
const supplyIncentives = (0, exports.getAaveV4ApplicableIncentives)(assetData, types_1.IncentiveSide.Supply);
|
|
101
113
|
for (const supplyIncentive of supplyIncentives) {
|
|
102
114
|
const incentiveInterest = (0, staking_1.calculateInterestEarned)(amount, supplyIncentive.apy, 'year', true);
|
|
103
115
|
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
@@ -113,7 +125,7 @@ const calculateNetApyAaveV4 = ({ usedAssets, assetsData, }) => {
|
|
|
113
125
|
const userBorrowRate = (0, moneymarket_1.aprToApy)(userBorrowApr.toString());
|
|
114
126
|
const borrowInterest = (0, staking_1.calculateInterestEarned)(amount, userBorrowRate, 'year', true);
|
|
115
127
|
acc.borrowInterest = new decimal_js_1.default(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
116
|
-
const borrowIncentives =
|
|
128
|
+
const borrowIncentives = (0, exports.getAaveV4ApplicableIncentives)(assetData, types_1.IncentiveSide.Borrow);
|
|
117
129
|
for (const borrowIncentive of borrowIncentives) {
|
|
118
130
|
const incentiveInterest = (0, staking_1.calculateInterestEarned)(amount, borrowIncentive.apy, 'year', true);
|
|
119
131
|
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
package/cjs/helpers/index.d.ts
CHANGED
|
@@ -6,6 +6,5 @@ export * as makerHelpers from './makerHelpers';
|
|
|
6
6
|
export * as morphoBlueHelpers from './morphoBlueHelpers';
|
|
7
7
|
export * as llamaLendHelpers from './llamaLendHelpers';
|
|
8
8
|
export * as liquityV2Helpers from './liquityV2Helpers';
|
|
9
|
-
export * as eulerV2Helpers from './eulerHelpers';
|
|
10
9
|
export * as fluidHelpers from './fluidHelpers';
|
|
11
10
|
export * as aaveV4Helpers from './aaveV4Helpers';
|
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.aaveV4Helpers = exports.fluidHelpers = exports.
|
|
36
|
+
exports.aaveV4Helpers = exports.fluidHelpers = 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"));
|
|
@@ -42,6 +42,5 @@ exports.makerHelpers = __importStar(require("./makerHelpers"));
|
|
|
42
42
|
exports.morphoBlueHelpers = __importStar(require("./morphoBlueHelpers"));
|
|
43
43
|
exports.llamaLendHelpers = __importStar(require("./llamaLendHelpers"));
|
|
44
44
|
exports.liquityV2Helpers = __importStar(require("./liquityV2Helpers"));
|
|
45
|
-
exports.eulerV2Helpers = __importStar(require("./eulerHelpers"));
|
|
46
45
|
exports.fluidHelpers = __importStar(require("./fluidHelpers"));
|
|
47
46
|
exports.aaveV4Helpers = __importStar(require("./aaveV4Helpers"));
|
package/cjs/index.d.ts
CHANGED
|
@@ -17,9 +17,8 @@ import * as helpers from './helpers';
|
|
|
17
17
|
import * as exchange from './exchange';
|
|
18
18
|
import * as morphoBlue from './morphoBlue';
|
|
19
19
|
import * as llamaLend from './llamaLend';
|
|
20
|
-
import * as eulerV2 from './eulerV2';
|
|
21
20
|
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, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend,
|
|
24
|
+
export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, fluid, portfolio, claiming, savings, };
|
package/cjs/index.js
CHANGED
|
@@ -36,7 +36,7 @@ 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.
|
|
39
|
+
exports.savings = exports.claiming = exports.portfolio = exports.fluid = 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;
|
|
@@ -74,8 +74,6 @@ const morphoBlue = __importStar(require("./morphoBlue"));
|
|
|
74
74
|
exports.morphoBlue = morphoBlue;
|
|
75
75
|
const llamaLend = __importStar(require("./llamaLend"));
|
|
76
76
|
exports.llamaLend = llamaLend;
|
|
77
|
-
const eulerV2 = __importStar(require("./eulerV2"));
|
|
78
|
-
exports.eulerV2 = eulerV2;
|
|
79
77
|
const portfolio = __importStar(require("./portfolio"));
|
|
80
78
|
exports.portfolio = portfolio;
|
|
81
79
|
const claiming = __importStar(require("./claiming"));
|
package/cjs/markets/index.d.ts
CHANGED
|
@@ -5,6 +5,5 @@ export { CrvUsdMarkets } from './curveUsd';
|
|
|
5
5
|
export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
|
|
6
6
|
export { LlamaLendMarkets } from './llamaLend';
|
|
7
7
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
8
|
-
export { EulerV2Markets } from './euler';
|
|
9
8
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
10
9
|
export { AaveV4Spokes, findAaveV4SpokeByAddress } 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.findAaveV4SpokeByAddress = exports.AaveV4Spokes = exports.getFluidMarketInfoByAddress = exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.
|
|
3
|
+
exports.findAaveV4SpokeByAddress = exports.AaveV4Spokes = exports.getFluidMarketInfoByAddress = exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = 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; } });
|
|
@@ -27,8 +27,6 @@ Object.defineProperty(exports, "LlamaLendMarkets", { enumerable: true, get: func
|
|
|
27
27
|
var liquityV2_1 = require("./liquityV2");
|
|
28
28
|
Object.defineProperty(exports, "LiquityV2Markets", { enumerable: true, get: function () { return liquityV2_1.LiquityV2Markets; } });
|
|
29
29
|
Object.defineProperty(exports, "findLiquityV2MarketByAddress", { enumerable: true, get: function () { return liquityV2_1.findLiquityV2MarketByAddress; } });
|
|
30
|
-
var euler_1 = require("./euler");
|
|
31
|
-
Object.defineProperty(exports, "EulerV2Markets", { enumerable: true, get: function () { return euler_1.EulerV2Markets; } });
|
|
32
30
|
var fluid_1 = require("./fluid");
|
|
33
31
|
Object.defineProperty(exports, "FluidMarkets", { enumerable: true, get: function () { return fluid_1.FluidMarkets; } });
|
|
34
32
|
Object.defineProperty(exports, "getFluidVersionsDataForNetwork", { enumerable: true, get: function () { return fluid_1.getFluidVersionsDataForNetwork; } });
|
|
@@ -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>>;
|
|
@@ -34,7 +34,7 @@ const hasAnyBalance = (balances) => ([balances.collateral, balances.debt].some((
|
|
|
34
34
|
* Uses one shared, multicall-batched viem client (same pattern as getPortfolioData) so all
|
|
35
35
|
* per-market reads collapse into a handful of RPC round trips.
|
|
36
36
|
*
|
|
37
|
-
* Not covered: Maker, Liquity, Liquity V2, Fluid
|
|
37
|
+
* Not covered: Maker, Liquity, Liquity V2, Fluid — these already expose cheap,
|
|
38
38
|
* user-scoped discovery entry points elsewhere in the SDK (e.g. _getUserCdps, _getUserPositionsPortfolio).
|
|
39
39
|
*/
|
|
40
40
|
function getUserPositionsExistence(provider_1, network_1, address_1) {
|
package/cjs/portfolio/index.js
CHANGED
|
@@ -34,7 +34,6 @@ const morphoBlue_1 = require("../morphoBlue");
|
|
|
34
34
|
const types_1 = require("../types");
|
|
35
35
|
const compoundV3_1 = require("../compoundV3");
|
|
36
36
|
const spark_1 = require("../spark");
|
|
37
|
-
const eulerV2_1 = require("../eulerV2");
|
|
38
37
|
const curveUsd_1 = require("../curveUsd");
|
|
39
38
|
const llamaLend_1 = require("../llamaLend");
|
|
40
39
|
const aaveV3_1 = require("../aaveV3");
|
|
@@ -46,7 +45,6 @@ const viem_1 = require("../services/viem");
|
|
|
46
45
|
const liquity_1 = require("../liquity");
|
|
47
46
|
const liquityV2_1 = require("../liquityV2");
|
|
48
47
|
const fluid_1 = require("../fluid");
|
|
49
|
-
const eulerHelpers_1 = require("../helpers/eulerHelpers");
|
|
50
48
|
const umbrella_1 = require("../umbrella");
|
|
51
49
|
const aaveV3_2 = require("../claiming/aaveV3");
|
|
52
50
|
const compV3_1 = require("../claiming/compV3");
|
|
@@ -62,7 +60,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
62
60
|
const morphoMarkets = Object.values((0, markets_1.MorphoBlueMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
63
61
|
const compoundV3Markets = Object.values((0, markets_1.CompoundMarkets)(network)).filter((market) => market.chainIds.includes(network) && market.value !== types_1.CompoundVersions.CompoundV2);
|
|
64
62
|
const sparkMarkets = Object.values((0, markets_1.SparkMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
65
|
-
const eulerV2Markets = Object.values((0, markets_1.EulerV2Markets)(network)).filter((market) => market.chainIds.includes(network));
|
|
66
63
|
const aaveV3Markets = [types_1.AaveVersions.AaveV3, types_1.AaveVersions.AaveV3Lido, types_1.AaveVersions.AaveV3Etherfi].map((version) => (0, markets_1.AaveMarkets)(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
67
64
|
const aaveV2Markets = [types_1.AaveVersions.AaveV2].map((version) => (0, markets_1.AaveMarkets)(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
68
65
|
const compoundV2Markets = [types_1.CompoundVersions.CompoundV2].map((version) => (0, markets_1.CompoundMarkets)(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
@@ -77,7 +74,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
77
74
|
const morphoMarketsData = {};
|
|
78
75
|
const compoundV3MarketsData = {};
|
|
79
76
|
const sparkMarketsData = {};
|
|
80
|
-
const eulerV2MarketsData = {};
|
|
81
77
|
const aaveV3MarketsData = {};
|
|
82
78
|
const makerCdps = {};
|
|
83
79
|
const aaveV2MarketsData = {};
|
|
@@ -90,7 +86,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
90
86
|
morphoMarketsData,
|
|
91
87
|
compoundV3MarketsData,
|
|
92
88
|
sparkMarketsData,
|
|
93
|
-
eulerV2MarketsData,
|
|
94
89
|
aaveV3MarketsData,
|
|
95
90
|
aaveV2MarketsData,
|
|
96
91
|
compoundV2MarketsData,
|
|
@@ -110,7 +105,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
110
105
|
morphoBlue: {},
|
|
111
106
|
compoundV3: {},
|
|
112
107
|
spark: {},
|
|
113
|
-
eulerV2: {},
|
|
114
108
|
maker: {},
|
|
115
109
|
aaveV2: {},
|
|
116
110
|
compoundV2: {},
|
|
@@ -163,10 +157,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
163
157
|
const marketData = yield (0, spark_1._getSparkMarketsData)(client, network, market);
|
|
164
158
|
sparkMarketsData[market.value] = marketData;
|
|
165
159
|
})),
|
|
166
|
-
...eulerV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const marketData = yield (0, eulerV2_1._getEulerV2MarketsData)(client, network, market);
|
|
168
|
-
eulerV2MarketsData[market.value] = marketData;
|
|
169
|
-
})),
|
|
170
160
|
...aaveV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
171
161
|
const marketData = yield (0, aaveV3_1._getAaveV3MarketData)(client, network, market);
|
|
172
162
|
aaveV3MarketsData[market.value] = marketData;
|
|
@@ -515,28 +505,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
515
505
|
positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
516
506
|
}
|
|
517
507
|
}))).flat(),
|
|
518
|
-
...eulerV2Markets.map((market) => addresses.map((address) => {
|
|
519
|
-
const eulerV2SubAccounts = (0, eulerHelpers_1.getEulerV2SubAccounts)(address);
|
|
520
|
-
const eulerV2Addresses = [address, ...eulerV2SubAccounts];
|
|
521
|
-
return Promise.all(eulerV2Addresses.map((eulerAddress) => __awaiter(this, void 0, void 0, function* () {
|
|
522
|
-
try {
|
|
523
|
-
const accData = yield (0, eulerV2_1._getEulerV2AccountData)(client, network, eulerAddress, eulerAddress, Object.assign({ selectedMarket: market }, eulerV2MarketsData[market.value]));
|
|
524
|
-
if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
|
|
525
|
-
if (!positions[address.toLowerCase()].eulerV2[market.value]) {
|
|
526
|
-
positions[address.toLowerCase()].eulerV2[market.value] = {};
|
|
527
|
-
}
|
|
528
|
-
positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = { error: '', data: accData };
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
catch (error) {
|
|
532
|
-
console.error(`Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}:`, error);
|
|
533
|
-
if (!positions[address.toLowerCase()].eulerV2[market.value]) {
|
|
534
|
-
positions[address.toLowerCase()].eulerV2[market.value] = {};
|
|
535
|
-
}
|
|
536
|
-
positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = { error: `Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}`, data: null };
|
|
537
|
-
}
|
|
538
|
-
})));
|
|
539
|
-
}).flat()).flat(),
|
|
540
508
|
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
541
509
|
var _a;
|
|
542
510
|
return (_a = makerCdps[address.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
|
package/cjs/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/cjs/services/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getNativeAssetFromWrapped = exports.getWrappedNativeAssetFromUnwrapped = exports.wxplToXpl = exports.xplToWxpl = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.convertHybridArraysToObjects = exports.LONGER_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.isMainnetNetwork = exports.isMaxUint = exports.MAXUINT = exports.isEnabledOnBitmap = exports.mapRange = exports.bytesToString = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.getWeiAmountForDecimals = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.addToArrayIf = exports.addToObjectIf = exports.isLayer2Network = void 0;
|
|
6
|
+
exports.getNativeAssetFromWrapped = exports.getWrappedNativeAssetFromUnwrapped = exports.wxplToXpl = exports.xplToWxpl = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.convertHybridArraysToObjects = exports.LONGER_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.isMainnetNetwork = exports.isMaxUint = exports.MAXUINT = exports.isEnabledOnBitmap = exports.mapRange = exports.bytesToString = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.getWeiAmountForDecimals = exports.shortenAddress = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.addToArrayIf = exports.addToObjectIf = exports.isLayer2Network = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const tokens_1 = require("@defisaver/tokens");
|
|
9
9
|
const common_1 = require("../types/common");
|
|
@@ -24,6 +24,8 @@ const isAddress = (address) => typeof address === 'string' && (new RegExp(export
|
|
|
24
24
|
exports.isAddress = isAddress;
|
|
25
25
|
const compareAddresses = (addr1 = '', addr2 = '') => addr1.toLowerCase() === addr2.toLowerCase();
|
|
26
26
|
exports.compareAddresses = compareAddresses;
|
|
27
|
+
const shortenAddress = (address = '', start = 8, end = 4) => `${address.substring(0, start)}...${address.slice(-end)}`;
|
|
28
|
+
exports.shortenAddress = shortenAddress;
|
|
27
29
|
const getWeiAmountForDecimals = (amount, decimals) => new decimal_js_1.default(amount).mul(Math.pow(10, decimals)).floor().toString();
|
|
28
30
|
exports.getWeiAmountForDecimals = getWeiAmountForDecimals;
|
|
29
31
|
const getEthAmountForDecimals = (amount, decimals) => new decimal_js_1.default(amount).div(Math.pow(10, +decimals)).toString();
|
package/cjs/staking/staking.js
CHANGED
|
@@ -191,9 +191,8 @@ const calculateInterestEarned = (principal, interest, type, apy = false) => {
|
|
|
191
191
|
exports.calculateInterestEarned = calculateInterestEarned;
|
|
192
192
|
const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
193
193
|
const sumValues = Object.values(usedAssets).reduce((_acc, usedAsset) => {
|
|
194
|
-
var _a;
|
|
195
194
|
const acc = Object.assign({}, _acc);
|
|
196
|
-
const assetData = assetsData[usedAsset.symbol]
|
|
195
|
+
const assetData = assetsData[usedAsset.symbol];
|
|
197
196
|
if (usedAsset.isSupplied) {
|
|
198
197
|
const amount = usedAsset.suppliedUsd;
|
|
199
198
|
acc.suppliedUsd = new decimal_js_1.default(acc.suppliedUsd).add(amount).toString();
|
package/cjs/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/cjs/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/cjs/types/common.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NetworkNumber = exports.LeverageType = exports.IncentiveEligibilityId = exports.IncentiveKind = void 0;
|
|
3
|
+
exports.NetworkNumber = exports.LeverageType = exports.IncentiveEligibilityId = exports.IncentiveSide = exports.IncentiveKind = void 0;
|
|
4
4
|
var IncentiveKind;
|
|
5
5
|
(function (IncentiveKind) {
|
|
6
6
|
IncentiveKind["Staking"] = "staking";
|
|
7
7
|
IncentiveKind["Reward"] = "reward";
|
|
8
8
|
})(IncentiveKind || (exports.IncentiveKind = IncentiveKind = {}));
|
|
9
|
+
var IncentiveSide;
|
|
10
|
+
(function (IncentiveSide) {
|
|
11
|
+
IncentiveSide["Supply"] = "supply";
|
|
12
|
+
IncentiveSide["Borrow"] = "borrow";
|
|
13
|
+
})(IncentiveSide || (exports.IncentiveSide = IncentiveSide = {}));
|
|
9
14
|
var IncentiveEligibilityId;
|
|
10
15
|
(function (IncentiveEligibilityId) {
|
|
11
16
|
IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x0dC599DBB180E64E42b87332FDeC3a551445ea44BORROW_BL";
|
package/cjs/types/index.d.ts
CHANGED
package/cjs/types/index.js
CHANGED
|
@@ -23,7 +23,6 @@ __exportStar(require("./liquityV2"), exports);
|
|
|
23
23
|
__exportStar(require("./maker"), exports);
|
|
24
24
|
__exportStar(require("./morphoBlue"), exports);
|
|
25
25
|
__exportStar(require("./llamaLend"), exports);
|
|
26
|
-
__exportStar(require("./euler"), exports);
|
|
27
26
|
__exportStar(require("./fluid"), exports);
|
|
28
27
|
__exportStar(require("./portfolio"), exports);
|
|
29
28
|
__exportStar(require("./merit"), exports);
|
package/cjs/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 = {
|
package/cjs/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';
|
|
@@ -27,9 +26,6 @@ export interface PortfolioPositionsDataForAddress {
|
|
|
27
26
|
spark: {
|
|
28
27
|
[key in SparkVersions]?: PortfolioProtocolData<SparkPositionData>;
|
|
29
28
|
};
|
|
30
|
-
eulerV2: {
|
|
31
|
-
[key in EulerV2Versions]?: Record<EthAddress, PortfolioProtocolData<EulerV2PositionData>>;
|
|
32
|
-
};
|
|
33
29
|
maker: {
|
|
34
30
|
[key: string]: PortfolioProtocolData<CdpData>;
|
|
35
31
|
};
|
package/esm/aaveV4/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { getViemProvider } from '../services/viem';
|
|
|
13
13
|
import { IncentiveKind, } from '../types';
|
|
14
14
|
import { AaveV4ViewContractViem } from '../contracts';
|
|
15
15
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
16
|
-
import { isMaxUint, wethToEth, wethToEthByAddress } from '../services/utils';
|
|
16
|
+
import { isMaxUint, shortenAddress, wethToEth, wethToEthByAddress, } from '../services/utils';
|
|
17
17
|
import { aaveV4GetAggregatedPositionData, calcUserRiskPremiumBps } from '../helpers/aaveV4Helpers';
|
|
18
18
|
import { findAaveV4SpokeByAddress, getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
19
19
|
import { aprToApy } from '../moneymarket';
|
|
@@ -39,16 +39,16 @@ const fetchHubData = (viewContract, hubAddress) => __awaiter(void 0, void 0, voi
|
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
41
|
const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
var _a, _b, _c, _d, _e, _f;
|
|
42
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
43
43
|
const assetInfo = getAssetInfoByAddress(reserveAsset.underlying, network);
|
|
44
44
|
// `@defisaver/tokens` returns a placeholder ('?', decimals NaN) when the underlying is not in the
|
|
45
45
|
// tokens package. Flag it so consumers can render it read-only instead of feeding NaN into amounts.
|
|
46
46
|
const isUnsupported = assetInfo.symbol === '?';
|
|
47
47
|
const symbol = wethToEth(assetInfo.symbol);
|
|
48
|
+
// The hub registry only provides display metadata — a hub missing from it (newly deployed by
|
|
49
|
+
// Aave, SDK not yet updated) must not prevent the reserve from loading, so fall back to a
|
|
50
|
+
// generated label instead of failing.
|
|
48
51
|
const hubInfo = getAaveV4HubByAddress(network, reserveAsset.hub);
|
|
49
|
-
if (!hubInfo) {
|
|
50
|
-
throw new Error(`Hub not found with address: ${reserveAsset.hub}`);
|
|
51
|
-
}
|
|
52
52
|
const isStakingAsset = STAKING_ASSETS.includes(symbol);
|
|
53
53
|
const supplyIncentives = [];
|
|
54
54
|
const borrowIncentives = [];
|
|
@@ -108,8 +108,8 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
|
|
|
108
108
|
decimals: reserveAsset.decimals,
|
|
109
109
|
isUnsupported,
|
|
110
110
|
underlying: reserveAsset.underlying,
|
|
111
|
-
hub: hubInfo.address,
|
|
112
|
-
hubName: hubInfo === null || hubInfo === void 0 ? void 0 : hubInfo.label
|
|
111
|
+
hub: (_g = hubInfo === null || hubInfo === void 0 ? void 0 : hubInfo.address) !== null && _g !== void 0 ? _g : reserveAsset.hub,
|
|
112
|
+
hubName: (_h = hubInfo === null || hubInfo === void 0 ? void 0 : hubInfo.label) !== null && _h !== void 0 ? _h : `Hub ${shortenAddress(reserveAsset.hub)}`,
|
|
113
113
|
assetId: reserveAsset.assetId,
|
|
114
114
|
reserveId,
|
|
115
115
|
paused: reserveAsset.paused,
|
|
@@ -147,14 +147,30 @@ export function _getAaveV4SpokeData(provider_1, network_1, market_1) {
|
|
|
147
147
|
return __awaiter(this, arguments, void 0, function* (provider, network, market, blockNumber = 'latest') {
|
|
148
148
|
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
149
149
|
const hubsData = {};
|
|
150
|
+
const loadHubData = (hubAddress) => __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
hubsData[hubAddress.toLowerCase()] = yield fetchHubData(viewContract, hubAddress);
|
|
152
|
+
});
|
|
153
|
+
// market.hubs is only a prefetch hint (lets known hubs load in parallel with the spoke data), so
|
|
154
|
+
// failures are tolerated here — any hub the reserves actually reference is (re)fetched below.
|
|
150
155
|
const [spokeData, merklCampaigns] = yield Promise.all([
|
|
151
156
|
viewContract.read.getSpokeDataFull([market.address]),
|
|
152
157
|
getAaveV4MerkleCampaigns(network),
|
|
153
|
-
...market.hubs.map((hubAddress) =>
|
|
154
|
-
hubsData[hubAddress] = yield fetchHubData(viewContract, hubAddress);
|
|
155
|
-
})),
|
|
158
|
+
...market.hubs.map((hubAddress) => loadHubData(hubAddress).catch(() => { })),
|
|
156
159
|
]);
|
|
157
|
-
|
|
160
|
+
// The on-chain reserves are the source of truth for which hubs the spoke uses — fetch any hub
|
|
161
|
+
// the prefetch didn't cover, so an asset listed from a hub unknown to the SDK can't break the spoke.
|
|
162
|
+
const missingHubs = [...new Set(spokeData[1].map((reserveAsset) => reserveAsset.hub.toLowerCase()))]
|
|
163
|
+
.filter((hubAddress) => !hubsData[hubAddress]);
|
|
164
|
+
yield Promise.all(missingHubs.map(loadHubData));
|
|
165
|
+
const reserveAssetsArray = (yield Promise.all(spokeData[1].map((reserveAssetOnChain, index) => __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
var _a;
|
|
167
|
+
const hubAsset = (_a = hubsData[reserveAssetOnChain.hub.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.assets[reserveAssetOnChain.assetId];
|
|
168
|
+
// A reserve whose hub-side asset data can't be resolved is skipped instead of failing the
|
|
169
|
+
// whole spoke (position math degrades for that one asset only).
|
|
170
|
+
if (!hubAsset)
|
|
171
|
+
return null;
|
|
172
|
+
return formatReserveAsset(reserveAssetOnChain, hubAsset, index, +spokeData[0].oracleDecimals.toString(), network);
|
|
173
|
+
})))).filter((asset) => asset !== null);
|
|
158
174
|
const enrichedAssets = reserveAssetsArray.map((asset) => attachAaveV4MerklIncentives(asset, market.address, merklCampaigns));
|
|
159
175
|
return {
|
|
160
176
|
assetsData: enrichedAssets.reduce((acc, reserveAsset) => {
|
package/esm/aaveV4/merkl.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AaveV4MerklRewardMap, AaveV4ReserveAssetData, NetworkNumber } from '../types';
|
|
1
|
+
import { AaveV4MerklRewardMap, AaveV4ReserveAssetData, MerklOpportunity, NetworkNumber } from '../types';
|
|
2
|
+
export declare const buildAaveV4MerklRewardMap: (opportunities: MerklOpportunity[], chainId: NetworkNumber) => AaveV4MerklRewardMap;
|
|
2
3
|
export declare const getAaveV4MerkleCampaigns: (chainId: NetworkNumber) => Promise<AaveV4MerklRewardMap>;
|
|
3
4
|
/**
|
|
4
5
|
* Returns a copy of the asset with scope-specific incentive arrays pre-combined with the asset's
|