@defisaver/positions-sdk 2.1.96 → 2.1.98-aave-v4-apy-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +64 -64
- package/cjs/aaveV3/index.js +3 -3
- package/cjs/aaveV4/index.js +2 -0
- package/cjs/config/contracts.d.ts +61 -1
- package/cjs/config/contracts.js +2 -2
- package/cjs/contracts.d.ts +2963 -82
- package/cjs/helpers/aaveV4Helpers/index.d.ts +11 -1
- package/cjs/helpers/aaveV4Helpers/index.js +58 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/savings/morphoVaults/index.js +17 -17
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +2 -1
- package/cjs/types/aaveV4.d.ts +2 -0
- package/esm/aaveV3/index.js +3 -3
- package/esm/aaveV4/index.js +2 -0
- package/esm/config/contracts.d.ts +61 -1
- package/esm/config/contracts.js +2 -2
- package/esm/contracts.d.ts +2963 -82
- package/esm/helpers/aaveV4Helpers/index.d.ts +11 -1
- package/esm/helpers/aaveV4Helpers/index.js +56 -0
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/savings/morphoVaults/index.js +17 -17
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +2 -1
- package/esm/types/aaveV4.d.ts +2 -0
- package/package.json +48 -48
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +634 -634
- package/src/aaveV3/merit.ts +97 -97
- package/src/aaveV3/merkl.ts +74 -74
- package/src/aaveV4/index.ts +238 -236
- package/src/aaveV4/lend.ts +185 -185
- package/src/claiming/aaveV3.ts +154 -154
- package/src/claiming/compV3.ts +22 -22
- package/src/claiming/ethena.ts +61 -61
- package/src/claiming/index.ts +12 -12
- package/src/claiming/king.ts +66 -66
- package/src/claiming/morphoBlue.ts +118 -118
- package/src/claiming/spark.ts +225 -225
- package/src/compoundV2/index.ts +245 -245
- package/src/compoundV3/index.ts +280 -280
- package/src/config/contracts.ts +1357 -1357
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +183 -183
- package/src/curveUsd/index.ts +254 -254
- package/src/eulerV2/index.ts +330 -330
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1800 -1800
- package/src/helpers/aaveHelpers/index.ts +203 -203
- package/src/helpers/aaveV4Helpers/index.ts +349 -291
- package/src/helpers/compoundHelpers/index.ts +280 -280
- package/src/helpers/curveUsdHelpers/index.ts +44 -44
- package/src/helpers/eulerHelpers/index.ts +230 -230
- package/src/helpers/fluidHelpers/index.ts +338 -338
- package/src/helpers/index.ts +11 -11
- package/src/helpers/liquityV2Helpers/index.ts +85 -85
- package/src/helpers/llamaLendHelpers/index.ts +56 -56
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +406 -406
- package/src/helpers/sparkHelpers/index.ts +170 -170
- package/src/index.ts +51 -51
- package/src/liquity/index.ts +161 -161
- package/src/liquityV2/index.ts +703 -703
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +225 -225
- package/src/markets/aave/index.ts +118 -118
- package/src/markets/aave/marketAssets.ts +54 -54
- package/src/markets/aaveV4/index.ts +191 -191
- package/src/markets/compound/index.ts +243 -243
- package/src/markets/compound/marketsAssets.ts +97 -97
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2900 -2900
- package/src/markets/index.ts +29 -29
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +1370 -1370
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -12
- package/src/moneymarket/moneymarketCommonService.ts +91 -91
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +606 -606
- package/src/savings/index.ts +111 -111
- package/src/savings/makerDsr/index.ts +53 -53
- package/src/savings/makerDsr/options.ts +9 -9
- package/src/savings/morphoVaults/index.ts +80 -80
- package/src/savings/morphoVaults/options.ts +193 -193
- package/src/savings/skyOptions/index.ts +95 -95
- package/src/savings/skyOptions/options.ts +10 -10
- package/src/savings/sparkSavingsVaults/index.ts +60 -60
- package/src/savings/sparkSavingsVaults/options.ts +35 -35
- package/src/savings/summerVaults/index.ts +56 -56
- package/src/savings/summerVaults/options.ts +117 -117
- package/src/savings/yearnV3Vaults/index.ts +61 -61
- package/src/savings/yearnV3Vaults/options.ts +55 -55
- package/src/savings/yearnVaults/index.ts +73 -73
- package/src/savings/yearnVaults/options.ts +32 -32
- package/src/services/priceService.ts +278 -278
- package/src/services/utils.ts +122 -117
- package/src/services/viem.ts +57 -57
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +460 -460
- package/src/staking/eligibility.ts +105 -105
- package/src/staking/index.ts +1 -1
- package/src/staking/staking.ts +201 -201
- package/src/types/aave.ts +200 -200
- package/src/types/aaveV4.ts +179 -177
- package/src/types/claiming.ts +114 -114
- package/src/types/common.ts +117 -117
- package/src/types/compound.ts +147 -147
- package/src/types/curveUsd.ts +125 -125
- package/src/types/euler.ts +177 -177
- package/src/types/fluid.ts +486 -486
- package/src/types/index.ts +16 -16
- package/src/types/liquity.ts +31 -31
- package/src/types/liquityV2.ts +130 -130
- package/src/types/llamaLend.ts +163 -163
- package/src/types/maker.ts +64 -64
- package/src/types/merit.ts +1 -1
- package/src/types/merkl.ts +70 -70
- package/src/types/morphoBlue.ts +228 -228
- package/src/types/portfolio.ts +64 -64
- package/src/types/savings/index.ts +25 -25
- package/src/types/savings/makerDsr.ts +13 -13
- package/src/types/savings/morphoVaults.ts +32 -32
- package/src/types/savings/sky.ts +14 -14
- package/src/types/savings/sparkSavingsVaults.ts +15 -15
- package/src/types/savings/summerVaults.ts +24 -24
- package/src/types/savings/yearnV3Vaults.ts +17 -17
- package/src/types/savings/yearnVaults.ts +14 -14
- package/src/types/spark.ts +136 -136
- package/src/umbrella/index.ts +69 -69
- package/src/umbrella/umbrellaUtils.ts +29 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets, LeverageType, NetworkNumber } from '../../types';
|
|
1
|
+
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4SpokeInfo, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets, EthereumProvider, LeverageType, NetworkNumber } from '../../types';
|
|
2
2
|
export declare const calcUserRiskPremiumBps: (usedAssets: AaveV4UsedReserveAssets, assetsData: AaveV4AssetsData) => number;
|
|
3
3
|
export declare const getApyAfterValuesEstimation: (usedAssets: AaveV4UsedReserveAssets, assetsData: AaveV4AssetsData) => Record<string, {
|
|
4
4
|
borrowRate: string;
|
|
@@ -23,3 +23,13 @@ export declare const aaveV4GetAggregatedPositionData: ({ usedAssets, assetsData,
|
|
|
23
23
|
network: NetworkNumber;
|
|
24
24
|
useUserCollateralFactor?: boolean;
|
|
25
25
|
}) => AaveV4AggregatedPositionData;
|
|
26
|
+
export declare const getAaveV4ApyAfterValuesEstimation: (selectedSpoke: AaveV4SpokeInfo, assetsData: AaveV4AssetsData, actions: [{
|
|
27
|
+
action: string;
|
|
28
|
+
amount: string;
|
|
29
|
+
asset: string;
|
|
30
|
+
}], provider: EthereumProvider, network: NetworkNumber) => Promise<{
|
|
31
|
+
[key: string]: {
|
|
32
|
+
supplyRate: string;
|
|
33
|
+
borrowRate: string;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.aaveV4GetAggregatedPositionData = exports.isLeveragedPosAaveV4 = exports.aaveV4GetCollateralFactor = exports.calculateNetApyAaveV4 = exports.getApyAfterValuesEstimation = exports.calcUserRiskPremiumBps = void 0;
|
|
15
|
+
exports.getAaveV4ApyAfterValuesEstimation = exports.aaveV4GetAggregatedPositionData = exports.isLeveragedPosAaveV4 = exports.aaveV4GetCollateralFactor = exports.calculateNetApyAaveV4 = exports.getApyAfterValuesEstimation = exports.calcUserRiskPremiumBps = void 0;
|
|
7
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
8
18
|
const moneymarket_1 = require("../../moneymarket");
|
|
9
19
|
const staking_1 = require("../../staking");
|
|
10
20
|
const types_1 = require("../../types");
|
|
21
|
+
const constants_1 = require("../../constants");
|
|
22
|
+
const contracts_1 = require("../../contracts");
|
|
23
|
+
const viem_1 = require("../../services/viem");
|
|
11
24
|
const calcUserRiskPremiumBps = (usedAssets, assetsData) => {
|
|
12
25
|
const collaterals = [];
|
|
13
26
|
const debts = [];
|
|
@@ -231,3 +244,47 @@ const aaveV4GetAggregatedPositionData = ({ usedAssets, assetsData, network, useU
|
|
|
231
244
|
return payload;
|
|
232
245
|
};
|
|
233
246
|
exports.aaveV4GetAggregatedPositionData = aaveV4GetAggregatedPositionData;
|
|
247
|
+
const getAaveV4ApyAfterValuesEstimationInner = (selectedSpoke, assetsData, actions, client, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
|
+
const params = actions.map(({ action, asset, amount }) => {
|
|
249
|
+
const isDebtAsset = constants_1.borrowOperations.includes(action);
|
|
250
|
+
const assetData = assetsData[asset];
|
|
251
|
+
const amountInWei = (0, tokens_1.assetAmountInWei)(amount, assetData.symbol);
|
|
252
|
+
let liquidityAdded;
|
|
253
|
+
let liquidityTaken;
|
|
254
|
+
if (isDebtAsset) {
|
|
255
|
+
liquidityAdded = action === 'payback' ? amountInWei : '0';
|
|
256
|
+
liquidityTaken = action === 'borrow' ? amountInWei : '0';
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
liquidityAdded = action === 'collateral' ? amountInWei : '0';
|
|
260
|
+
liquidityTaken = action === 'withdraw' ? amountInWei : '0';
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
reserveId: BigInt(assetData.reserveId),
|
|
264
|
+
liquidityAdded: BigInt(liquidityAdded),
|
|
265
|
+
liquidityTaken: BigInt(liquidityTaken),
|
|
266
|
+
isDebtAsset,
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
const viewContract = (0, contracts_1.AaveV4ViewContractViem)(client, network);
|
|
270
|
+
const data = yield viewContract.read.getApyAfterValuesEstimation([selectedSpoke.address, params]);
|
|
271
|
+
const rates = {};
|
|
272
|
+
data.forEach((item) => {
|
|
273
|
+
const { hubDrawnRateEstimation, hubTotalDrawnEstimation, hubTotalLiquidityEstimation, hubSwept, liquidityFee, reserveId, } = item;
|
|
274
|
+
const drawnRate = new decimal_js_1.default(hubDrawnRateEstimation.toString()).div(new decimal_js_1.default(10).pow(27));
|
|
275
|
+
const borrowApr = drawnRate.mul(100);
|
|
276
|
+
const assetData = Object.values(assetsData).find(({ reserveId: rId }) => rId === Number(reserveId));
|
|
277
|
+
const totalDrawn = new decimal_js_1.default(hubTotalDrawnEstimation.toString());
|
|
278
|
+
const swept = new decimal_js_1.default(hubSwept.toString());
|
|
279
|
+
const hubUtilizationDenominator = totalDrawn.add(swept).add(hubTotalLiquidityEstimation.toString());
|
|
280
|
+
const hubUtilization = hubUtilizationDenominator.isZero() ? new decimal_js_1.default(0) : totalDrawn.div(hubUtilizationDenominator);
|
|
281
|
+
const supplyApr = borrowApr.mul(hubUtilization).mul((assetData === null || assetData === void 0 ? void 0 : assetData.premiumMultiplier) || '0').mul(new decimal_js_1.default(1).minus((assetData === null || assetData === void 0 ? void 0 : assetData.liquidityFee) || '0'));
|
|
282
|
+
rates[`${assetData === null || assetData === void 0 ? void 0 : assetData.symbol}-${assetData === null || assetData === void 0 ? void 0 : assetData.reserveId}`] = {
|
|
283
|
+
borrowRate: (0, moneymarket_1.aprToApy)(borrowApr.toString()),
|
|
284
|
+
supplyRate: (0, moneymarket_1.aprToApy)(supplyApr.toString()),
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
return rates;
|
|
288
|
+
});
|
|
289
|
+
const getAaveV4ApyAfterValuesEstimation = (selectedSpoke, assetsData, actions, provider, network) => __awaiter(void 0, void 0, void 0, function* () { return getAaveV4ApyAfterValuesEstimationInner(selectedSpoke, assetsData, actions, (0, viem_1.getViemProvider)(provider, network), network); });
|
|
290
|
+
exports.getAaveV4ApyAfterValuesEstimation = getAaveV4ApyAfterValuesEstimation;
|
|
@@ -139,73 +139,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, provider, network)
|
|
|
139
139
|
});
|
|
140
140
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
141
141
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
142
|
-
const MARKET_QUERY = `
|
|
143
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
144
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
145
|
-
reallocatableLiquidityAssets
|
|
146
|
-
targetBorrowUtilization
|
|
147
|
-
loanAsset {
|
|
148
|
-
address
|
|
149
|
-
decimals
|
|
150
|
-
priceUsd
|
|
151
|
-
}
|
|
152
|
-
state {
|
|
153
|
-
liquidityAssets
|
|
154
|
-
borrowAssets
|
|
155
|
-
supplyAssets
|
|
156
|
-
}
|
|
157
|
-
publicAllocatorSharedLiquidity {
|
|
158
|
-
assets
|
|
159
|
-
vault {
|
|
160
|
-
address
|
|
161
|
-
name
|
|
162
|
-
}
|
|
163
|
-
allocationMarket {
|
|
164
|
-
uniqueKey
|
|
165
|
-
loanAsset {
|
|
166
|
-
address
|
|
167
|
-
}
|
|
168
|
-
collateralAsset {
|
|
169
|
-
address
|
|
170
|
-
}
|
|
171
|
-
irmAddress
|
|
172
|
-
oracle {
|
|
173
|
-
address
|
|
174
|
-
}
|
|
175
|
-
lltv
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
loanAsset {
|
|
179
|
-
address
|
|
180
|
-
}
|
|
181
|
-
collateralAsset {
|
|
182
|
-
address
|
|
183
|
-
}
|
|
184
|
-
oracle {
|
|
185
|
-
address
|
|
186
|
-
}
|
|
187
|
-
irmAddress
|
|
188
|
-
lltv
|
|
189
|
-
}
|
|
190
|
-
}
|
|
142
|
+
const MARKET_QUERY = `
|
|
143
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
144
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
145
|
+
reallocatableLiquidityAssets
|
|
146
|
+
targetBorrowUtilization
|
|
147
|
+
loanAsset {
|
|
148
|
+
address
|
|
149
|
+
decimals
|
|
150
|
+
priceUsd
|
|
151
|
+
}
|
|
152
|
+
state {
|
|
153
|
+
liquidityAssets
|
|
154
|
+
borrowAssets
|
|
155
|
+
supplyAssets
|
|
156
|
+
}
|
|
157
|
+
publicAllocatorSharedLiquidity {
|
|
158
|
+
assets
|
|
159
|
+
vault {
|
|
160
|
+
address
|
|
161
|
+
name
|
|
162
|
+
}
|
|
163
|
+
allocationMarket {
|
|
164
|
+
uniqueKey
|
|
165
|
+
loanAsset {
|
|
166
|
+
address
|
|
167
|
+
}
|
|
168
|
+
collateralAsset {
|
|
169
|
+
address
|
|
170
|
+
}
|
|
171
|
+
irmAddress
|
|
172
|
+
oracle {
|
|
173
|
+
address
|
|
174
|
+
}
|
|
175
|
+
lltv
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
loanAsset {
|
|
179
|
+
address
|
|
180
|
+
}
|
|
181
|
+
collateralAsset {
|
|
182
|
+
address
|
|
183
|
+
}
|
|
184
|
+
oracle {
|
|
185
|
+
address
|
|
186
|
+
}
|
|
187
|
+
irmAddress
|
|
188
|
+
lltv
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
191
|
`;
|
|
192
|
-
const REWARDS_QUERY = `
|
|
193
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
194
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
195
|
-
uniqueKey
|
|
196
|
-
state {
|
|
197
|
-
rewards {
|
|
198
|
-
amountPerSuppliedToken
|
|
199
|
-
supplyApr
|
|
200
|
-
amountPerBorrowedToken
|
|
201
|
-
borrowApr
|
|
202
|
-
asset {
|
|
203
|
-
address
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
192
|
+
const REWARDS_QUERY = `
|
|
193
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
194
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
195
|
+
uniqueKey
|
|
196
|
+
state {
|
|
197
|
+
rewards {
|
|
198
|
+
amountPerSuppliedToken
|
|
199
|
+
supplyApr
|
|
200
|
+
amountPerBorrowedToken
|
|
201
|
+
borrowApr
|
|
202
|
+
asset {
|
|
203
|
+
address
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
209
|
`;
|
|
210
210
|
/**
|
|
211
211
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -54,23 +54,23 @@ const morphoVaultsOptions = __importStar(require("./options"));
|
|
|
54
54
|
exports.morphoVaultsOptions = morphoVaultsOptions;
|
|
55
55
|
const viem_1 = require("../../services/viem");
|
|
56
56
|
const contracts_1 = require("../../contracts");
|
|
57
|
-
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
58
|
-
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
59
|
-
id,
|
|
60
|
-
dailyApy,
|
|
61
|
-
dailyApys {
|
|
62
|
-
apy, netApy
|
|
63
|
-
},
|
|
64
|
-
monthlyApys {
|
|
65
|
-
apy, netApy
|
|
66
|
-
},
|
|
67
|
-
liquidity {
|
|
68
|
-
underlying, usd,
|
|
69
|
-
},
|
|
70
|
-
asset {
|
|
71
|
-
priceUsd
|
|
72
|
-
}
|
|
73
|
-
}
|
|
57
|
+
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
58
|
+
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
59
|
+
id,
|
|
60
|
+
dailyApy,
|
|
61
|
+
dailyApys {
|
|
62
|
+
apy, netApy
|
|
63
|
+
},
|
|
64
|
+
monthlyApys {
|
|
65
|
+
apy, netApy
|
|
66
|
+
},
|
|
67
|
+
liquidity {
|
|
68
|
+
underlying, usd,
|
|
69
|
+
},
|
|
70
|
+
asset {
|
|
71
|
+
priceUsd
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
74
|
}`;
|
|
75
75
|
const MORPHO_BLUE_API = 'https://blue-api.morpho.org/graphql';
|
|
76
76
|
const _getMorphoVaultData = (provider, network, morphoVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const bytesToString: (hex: string) => string;
|
|
|
16
16
|
* Map an input value from one range (minInput, maxInput) to a value in another range (minOutput, maxOutput)
|
|
17
17
|
*/
|
|
18
18
|
export declare const mapRange: (input: number | string, minInput: number | string, maxInput: number | string, minOutput: number | string, maxOutput: number | string) => number;
|
|
19
|
-
export declare const isEnabledOnBitmap: (bitmap: number, assetId: number) =>
|
|
19
|
+
export declare const isEnabledOnBitmap: (bitmap: string | bigint | number, assetId: string | bigint | number) => boolean;
|
|
20
20
|
export declare const MAXUINT: string;
|
|
21
21
|
export declare const isMaxUint: (amount: string) => boolean;
|
|
22
22
|
export declare const isMainnetNetwork: (network: NetworkNumber) => network is NetworkNumber.Eth;
|
package/cjs/services/utils.js
CHANGED
|
@@ -47,8 +47,9 @@ const mapRange = (input, minInput, maxInput, minOutput, maxOutput) => {
|
|
|
47
47
|
return new decimal_js_1.default(minOutput).plus(new decimal_js_1.default(slope).mul(new decimal_js_1.default(input).minus(minInput))).toDP(2).toNumber();
|
|
48
48
|
};
|
|
49
49
|
exports.mapRange = mapRange;
|
|
50
|
+
const isEnabledOnBitmap = (bitmap, assetId) => (
|
|
50
51
|
// eslint-disable-next-line no-bitwise
|
|
51
|
-
|
|
52
|
+
((BigInt(bitmap) >> BigInt(assetId)) & BigInt(1)) === BigInt(1));
|
|
52
53
|
exports.isEnabledOnBitmap = isEnabledOnBitmap;
|
|
53
54
|
exports.MAXUINT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
54
55
|
const isMaxUint = (amount) => (0, exports.compareAddresses)(exports.MAXUINT, amount);
|
package/cjs/types/aaveV4.d.ts
CHANGED
|
@@ -107,6 +107,8 @@ export interface AaveV4ReserveAssetData {
|
|
|
107
107
|
utilization: string;
|
|
108
108
|
/** Hub `liquidity` for this assetId (underlying amount), used for pool-level borrow/withdraw limits */
|
|
109
109
|
hubLiquidity: string;
|
|
110
|
+
premiumMultiplier: string;
|
|
111
|
+
liquidityFee: string;
|
|
110
112
|
}
|
|
111
113
|
export type AaveV4AssetsData = Record<string, AaveV4ReserveAssetData>;
|
|
112
114
|
export interface AaveV4UsedReserveAsset {
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -98,11 +98,11 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
98
98
|
const symbol = market.assets[i];
|
|
99
99
|
// eslint-disable-next-line guard-for-in
|
|
100
100
|
for (const eModeIndex in eModeCategoriesData) {
|
|
101
|
-
if (isEnabledOnBitmap(
|
|
101
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].collateralBitmap, Number(tokenMarket.assetId)))
|
|
102
102
|
eModeCategoriesData[eModeIndex].collateralAssets.push(symbol);
|
|
103
|
-
if (isEnabledOnBitmap(
|
|
103
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].borrowableBitmap, Number(tokenMarket.assetId)))
|
|
104
104
|
eModeCategoriesData[eModeIndex].borrowAssets.push(symbol);
|
|
105
|
-
if (isEnabledOnBitmap(
|
|
105
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].ltvzeroBitmap, Number(tokenMarket.assetId)))
|
|
106
106
|
eModeCategoriesData[eModeIndex].ltvZeroAssets.push(symbol);
|
|
107
107
|
}
|
|
108
108
|
const borrowCap = tokenMarket.borrowCap.toString();
|
package/esm/aaveV4/index.js
CHANGED
|
@@ -121,6 +121,8 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
|
|
|
121
121
|
canBePayBacked: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
|
|
122
122
|
utilization,
|
|
123
123
|
hubLiquidity,
|
|
124
|
+
premiumMultiplier: premiumMultiplier.toString(),
|
|
125
|
+
liquidityFee: liquidityFee.toString(),
|
|
124
126
|
});
|
|
125
127
|
});
|
|
126
128
|
export function _getAaveV4SpokeData(provider_1, network_1, market_1) {
|
|
@@ -97696,6 +97696,66 @@ export declare const YearnV3Vault: {
|
|
|
97696
97696
|
};
|
|
97697
97697
|
export declare const AaveV4View: {
|
|
97698
97698
|
readonly abi: readonly [{
|
|
97699
|
+
readonly inputs: readonly [{
|
|
97700
|
+
readonly internalType: "address";
|
|
97701
|
+
readonly name: "_spoke";
|
|
97702
|
+
readonly type: "address";
|
|
97703
|
+
}, {
|
|
97704
|
+
readonly components: readonly [{
|
|
97705
|
+
readonly internalType: "uint256";
|
|
97706
|
+
readonly name: "reserveId";
|
|
97707
|
+
readonly type: "uint256";
|
|
97708
|
+
}, {
|
|
97709
|
+
readonly internalType: "uint256";
|
|
97710
|
+
readonly name: "liquidityAdded";
|
|
97711
|
+
readonly type: "uint256";
|
|
97712
|
+
}, {
|
|
97713
|
+
readonly internalType: "uint256";
|
|
97714
|
+
readonly name: "liquidityTaken";
|
|
97715
|
+
readonly type: "uint256";
|
|
97716
|
+
}, {
|
|
97717
|
+
readonly internalType: "bool";
|
|
97718
|
+
readonly name: "isDebtAsset";
|
|
97719
|
+
readonly type: "bool";
|
|
97720
|
+
}];
|
|
97721
|
+
readonly internalType: "struct AaveV4View.LiquidityChangeParams[]";
|
|
97722
|
+
readonly name: "_reserveParams";
|
|
97723
|
+
readonly type: "tuple[]";
|
|
97724
|
+
}];
|
|
97725
|
+
readonly name: "getApyAfterValuesEstimation";
|
|
97726
|
+
readonly outputs: readonly [{
|
|
97727
|
+
readonly components: readonly [{
|
|
97728
|
+
readonly internalType: "uint256";
|
|
97729
|
+
readonly name: "reserveId";
|
|
97730
|
+
readonly type: "uint256";
|
|
97731
|
+
}, {
|
|
97732
|
+
readonly internalType: "uint256";
|
|
97733
|
+
readonly name: "hubDrawnRateEstimation";
|
|
97734
|
+
readonly type: "uint256";
|
|
97735
|
+
}, {
|
|
97736
|
+
readonly internalType: "uint256";
|
|
97737
|
+
readonly name: "hubTotalDrawnEstimation";
|
|
97738
|
+
readonly type: "uint256";
|
|
97739
|
+
}, {
|
|
97740
|
+
readonly internalType: "uint256";
|
|
97741
|
+
readonly name: "hubTotalLiquidityEstimation";
|
|
97742
|
+
readonly type: "uint256";
|
|
97743
|
+
}, {
|
|
97744
|
+
readonly internalType: "uint256";
|
|
97745
|
+
readonly name: "hubSwept";
|
|
97746
|
+
readonly type: "uint256";
|
|
97747
|
+
}, {
|
|
97748
|
+
readonly internalType: "uint16";
|
|
97749
|
+
readonly name: "liquidityFee";
|
|
97750
|
+
readonly type: "uint16";
|
|
97751
|
+
}];
|
|
97752
|
+
readonly internalType: "struct AaveV4View.EstimatedRates[]";
|
|
97753
|
+
readonly name: "";
|
|
97754
|
+
readonly type: "tuple[]";
|
|
97755
|
+
}];
|
|
97756
|
+
readonly stateMutability: "view";
|
|
97757
|
+
readonly type: "function";
|
|
97758
|
+
}, {
|
|
97699
97759
|
readonly inputs: readonly [{
|
|
97700
97760
|
readonly internalType: "address";
|
|
97701
97761
|
readonly name: "_eoa";
|
|
@@ -99241,7 +99301,7 @@ export declare const AaveV4View: {
|
|
|
99241
99301
|
}];
|
|
99242
99302
|
readonly networks: {
|
|
99243
99303
|
readonly "1": {
|
|
99244
|
-
readonly address: "
|
|
99304
|
+
readonly address: "0xeCa884900ccC0481F1b65707a80eb294d1245F68";
|
|
99245
99305
|
};
|
|
99246
99306
|
};
|
|
99247
99307
|
};
|