@1delta/margin-fetcher 0.0.316 → 0.0.318
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/dist/index.js +753 -197
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/fetchLenderAll.d.ts.map +1 -1
- package/dist/lending/public-data/fetchLenderExt.d.ts.map +1 -1
- package/dist/lending/public-data/midnight/apiClient.d.ts +21 -0
- package/dist/lending/public-data/midnight/apiClient.d.ts.map +1 -0
- package/dist/lending/public-data/midnight/convertPublic.d.ts +25 -0
- package/dist/lending/public-data/midnight/convertPublic.d.ts.map +1 -0
- package/dist/lending/public-data/midnight/fetchPublic.d.ts +12 -0
- package/dist/lending/public-data/midnight/fetchPublic.d.ts.map +1 -0
- package/dist/lending/public-data/midnight/index.d.ts +6 -0
- package/dist/lending/public-data/midnight/index.d.ts.map +1 -0
- package/dist/lending/public-data/midnight/live.test.d.ts +2 -0
- package/dist/lending/public-data/midnight/live.test.d.ts.map +1 -0
- package/dist/lending/public-data/midnight/math.d.ts +22 -0
- package/dist/lending/public-data/midnight/math.d.ts.map +1 -0
- package/dist/lending/public-data/midnight/math.test.d.ts +2 -0
- package/dist/lending/public-data/midnight/math.test.d.ts.map +1 -0
- package/dist/lending/public-data/midnight/types.d.ts +45 -0
- package/dist/lending/public-data/midnight/types.d.ts.map +1 -0
- package/dist/lending/user-data/abis.d.ts.map +1 -1
- package/dist/lending/user-data/fetch-balances/parse.d.ts.map +1 -1
- package/dist/lending/user-data/fetch-balances/prepare.d.ts.map +1 -1
- package/dist/lending/user-data/midnight/index.d.ts +3 -0
- package/dist/lending/user-data/midnight/index.d.ts.map +1 -0
- package/dist/lending/user-data/midnight/userCallBuild.d.ts +16 -0
- package/dist/lending/user-data/midnight/userCallBuild.d.ts.map +1 -0
- package/dist/lending/user-data/midnight/userCallParse.d.ts +17 -0
- package/dist/lending/user-data/midnight/userCallParse.d.ts.map +1 -0
- package/dist/prices/oracle-prices/fetchOraclePrices.d.ts +1 -1
- package/dist/prices/oracle-prices/fetchOraclePrices.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/index.d.ts +1 -0
- package/dist/prices/oracle-prices/fetchers/index.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/midnight.d.ts +86 -0
- package/dist/prices/oracle-prices/fetchers/midnight.d.ts.map +1 -0
- package/dist/prices/oracle-prices/index.d.ts +1 -0
- package/dist/prices/oracle-prices/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, encodeFunctionData, formatUnits, isAddress, getAddress, decodeFunctionResult, decodeAbiParameters, AbiEncodingLengthMismatchError, concatHex, pad, InvalidAddressError, stringToHex, boolToHex, integerRegex, numberToHex, bytesRegex, BytesSizeMismatchError, arrayRegex, UnsupportedPackedAbiType } from './chunk-Z3MGRQJR.js';
|
|
2
2
|
import './chunk-BYTNVMX7.js';
|
|
3
3
|
import './chunk-PR4QN5HX.js';
|
|
4
|
-
import { Lender, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isFluid, isGearboxV3, isYLDR, isCompoundV3Type, isLista, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
4
|
+
import { Lender, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isFluid, isGearboxV3, isMidnight, isYLDR, isCompoundV3Type, isLista, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
|
|
5
5
|
export { isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isCompoundV3Type, isInit, isMorphoType, isMultiMarket, isYLDR } from '@1delta/lender-registry';
|
|
6
|
-
import { aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, aaveReserves, compoundV3Reserves, morphoTypeMarkets, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, aaveTokens, morphoTypeVaults, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, parseAaveV4SpokeLenderKey, gearboxAccountCompressor, compoundV2Tokens, aaveOracles, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, fetchTokenLists, fetchTokenList, aaveV4Oracles } from '@1delta/data-sdk';
|
|
6
|
+
import { aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, aaveReserves, compoundV3Reserves, morphoTypeMarkets, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, aaveTokens, morphoTypeVaults, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, parseAaveV4SpokeLenderKey, gearboxAccountCompressor, compoundV2Tokens, aaveOracles, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, fetchTokenLists, fetchTokenList, aaveV4Oracles, resolveMidnightApiBase } from '@1delta/data-sdk';
|
|
7
7
|
import lodash from 'lodash';
|
|
8
8
|
import { getEvmClient, getEvmChain, getEvmClientUniversal, multicallRetryUniversal } from '@1delta/providers';
|
|
9
|
-
import { MetaMorphoAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, MoolahVaultAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, GearboxCreditAccountCompressorV310Abi } from '@1delta/abis';
|
|
9
|
+
import { MetaMorphoAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, MoolahVaultAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, GearboxCreditAccountCompressorV310Abi } from '@1delta/abis';
|
|
10
10
|
export { MorphoLensAbi } from '@1delta/abis';
|
|
11
11
|
import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, InitMarginAddresses, getLstAcceptedInputs } from '@1delta/calldata-sdk';
|
|
12
12
|
import { proxyNativeFetch } from '@1delta/proxy-fetch';
|
|
@@ -7501,6 +7501,9 @@ var getLendersForChain = (c) => {
|
|
|
7501
7501
|
if (dolomiteConfigs()?.[c]?.dolomiteMargin) {
|
|
7502
7502
|
lenders.push(Lender.DOLOMITE);
|
|
7503
7503
|
}
|
|
7504
|
+
if (midnightConfig()?.[c]?.midnight) {
|
|
7505
|
+
lenders.push(Lender.MORPHO_MIDNIGHT);
|
|
7506
|
+
}
|
|
7504
7507
|
return lenders.filter((l) => !isExcludedLender(l));
|
|
7505
7508
|
};
|
|
7506
7509
|
var filterLendersByProtocol = (allLenders, protocolList) => {
|
|
@@ -13036,7 +13039,7 @@ var MathLib;
|
|
|
13036
13039
|
return x * y / denominator;
|
|
13037
13040
|
}
|
|
13038
13041
|
MathLib2.mulDivDown = mulDivDown;
|
|
13039
|
-
function
|
|
13042
|
+
function mulDivUp2(x, y, denominator) {
|
|
13040
13043
|
x = BigInt(x);
|
|
13041
13044
|
y = BigInt(y);
|
|
13042
13045
|
denominator = BigInt(denominator);
|
|
@@ -13044,7 +13047,7 @@ var MathLib;
|
|
|
13044
13047
|
const roundup = x * y % denominator > 0 ? 1n : 0n;
|
|
13045
13048
|
return x * y / denominator + roundup;
|
|
13046
13049
|
}
|
|
13047
|
-
MathLib2.mulDivUp =
|
|
13050
|
+
MathLib2.mulDivUp = mulDivUp2;
|
|
13048
13051
|
function mulDiv(x, y, denominator, rounding) {
|
|
13049
13052
|
return MathLib2[`mulDiv${rounding}`](x, y, denominator);
|
|
13050
13053
|
}
|
|
@@ -13151,7 +13154,7 @@ var MathLib;
|
|
|
13151
13154
|
} else {
|
|
13152
13155
|
const _newRateAtTarget = (la) => MathLib2.min(
|
|
13153
13156
|
MathLib2.max(
|
|
13154
|
-
MathLib2.wMulDown(startRateAtTarget,
|
|
13157
|
+
MathLib2.wMulDown(startRateAtTarget, wExp2(la)),
|
|
13155
13158
|
MIN_RATE_AT_TARGET
|
|
13156
13159
|
),
|
|
13157
13160
|
MAX_RATE_AT_TARGET
|
|
@@ -13180,7 +13183,7 @@ var MathLib;
|
|
|
13180
13183
|
const LN_WEI_INT = -41446531673892822312n;
|
|
13181
13184
|
const WEXP_UPPER_BOUND = 93859467695000404319n;
|
|
13182
13185
|
const WEXP_UPPER_VALUE = 57716089161558943949701069502944508345128422502756744429568n;
|
|
13183
|
-
function
|
|
13186
|
+
function wExp2(x) {
|
|
13184
13187
|
x = BigInt(x);
|
|
13185
13188
|
if (x < LN_WEI_INT) return 0n;
|
|
13186
13189
|
if (x >= WEXP_UPPER_BOUND) return WEXP_UPPER_VALUE;
|
|
@@ -13191,7 +13194,7 @@ var MathLib;
|
|
|
13191
13194
|
if (q >= 0n) return expR << q;
|
|
13192
13195
|
return expR >> -q;
|
|
13193
13196
|
}
|
|
13194
|
-
MathLib2.wExp =
|
|
13197
|
+
MathLib2.wExp = wExp2;
|
|
13195
13198
|
function _getBorrowRate(startUtilization, startRateAtTarget, elapsed) {
|
|
13196
13199
|
startUtilization = BigInt(startUtilization);
|
|
13197
13200
|
startRateAtTarget = BigInt(startRateAtTarget);
|
|
@@ -13215,7 +13218,7 @@ var MathLib;
|
|
|
13215
13218
|
} else {
|
|
13216
13219
|
const _newRateAtTarget = (linearAdaptation2) => MathLib2.min(
|
|
13217
13220
|
MathLib2.max(
|
|
13218
|
-
MathLib2.wMulDown(startRateAtTarget,
|
|
13221
|
+
MathLib2.wMulDown(startRateAtTarget, wExp2(linearAdaptation2)),
|
|
13219
13222
|
MIN_RATE_AT_TARGET
|
|
13220
13223
|
),
|
|
13221
13224
|
MAX_RATE_AT_TARGET
|
|
@@ -19582,7 +19585,7 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
19582
19585
|
{ self: market.silo0, other: market.silo1 },
|
|
19583
19586
|
{ self: market.silo1, other: market.silo0 }
|
|
19584
19587
|
];
|
|
19585
|
-
const
|
|
19588
|
+
const toBigInt15 = (v) => {
|
|
19586
19589
|
if (v === void 0 || v === null || v === "0x") return 0n;
|
|
19587
19590
|
if (typeof v === "bigint") return v;
|
|
19588
19591
|
try {
|
|
@@ -19594,8 +19597,8 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
19594
19597
|
for (let s = 0; s < 2; s++) {
|
|
19595
19598
|
const { self, other } = sides[s];
|
|
19596
19599
|
const slot = s * SILO_V2_CALLS_PER_SIDE;
|
|
19597
|
-
const totalAssetsRaw =
|
|
19598
|
-
const debtAssetsRaw =
|
|
19600
|
+
const totalAssetsRaw = toBigInt15(data[slot]);
|
|
19601
|
+
const debtAssetsRaw = toBigInt15(data[slot + 1]);
|
|
19599
19602
|
const irmConfigRaw = data[slot + 2];
|
|
19600
19603
|
const decimals = self.decimals;
|
|
19601
19604
|
const totalDeposits = Number(formatUnits(totalAssetsRaw, decimals));
|
|
@@ -19750,7 +19753,7 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
19750
19753
|
{ self: market.silo0, other: market.silo1 },
|
|
19751
19754
|
{ self: market.silo1, other: market.silo0 }
|
|
19752
19755
|
];
|
|
19753
|
-
const
|
|
19756
|
+
const toBigInt15 = (v) => {
|
|
19754
19757
|
if (v === void 0 || v === null || v === "0x") return 0n;
|
|
19755
19758
|
if (typeof v === "bigint") return v;
|
|
19756
19759
|
try {
|
|
@@ -19762,8 +19765,8 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
19762
19765
|
for (let s = 0; s < 2; s++) {
|
|
19763
19766
|
const { self, other } = sides[s];
|
|
19764
19767
|
const slot = s * SILO_V3_CALLS_PER_SIDE;
|
|
19765
|
-
const totalAssetsRaw =
|
|
19766
|
-
const debtAssetsRaw =
|
|
19768
|
+
const totalAssetsRaw = toBigInt15(data[slot]);
|
|
19769
|
+
const debtAssetsRaw = toBigInt15(data[slot + 1]);
|
|
19767
19770
|
const irmConfigRaw = data[slot + 2];
|
|
19768
19771
|
const decimals = self.decimals;
|
|
19769
19772
|
const totalDeposits = Number(formatUnits(totalAssetsRaw, decimals));
|
|
@@ -20751,6 +20754,308 @@ var getLenderPublicData = async (chainId, lenders, prices, additionalYields, mul
|
|
|
20751
20754
|
}
|
|
20752
20755
|
return lenderData;
|
|
20753
20756
|
};
|
|
20757
|
+
var warn = (...args) => {
|
|
20758
|
+
};
|
|
20759
|
+
function midnightApiBaseUrl(chainId) {
|
|
20760
|
+
return resolveMidnightApiBase(chainId);
|
|
20761
|
+
}
|
|
20762
|
+
var toBig2 = (v) => {
|
|
20763
|
+
try {
|
|
20764
|
+
if (v == null) return 0n;
|
|
20765
|
+
if (typeof v === "bigint") return v;
|
|
20766
|
+
if (typeof v === "number") return BigInt(Math.trunc(v));
|
|
20767
|
+
return BigInt(String(v));
|
|
20768
|
+
} catch {
|
|
20769
|
+
return 0n;
|
|
20770
|
+
}
|
|
20771
|
+
};
|
|
20772
|
+
function parseLevel(raw) {
|
|
20773
|
+
const tick = toBig2(raw?.tick);
|
|
20774
|
+
const units = toBig2(raw?.units);
|
|
20775
|
+
let assets = toBig2(raw?.assets);
|
|
20776
|
+
if (assets === 0n && units > 0n && raw?.price != null) {
|
|
20777
|
+
assets = toBig2(raw.price) * units / 1000000000000000000n;
|
|
20778
|
+
}
|
|
20779
|
+
return { tick, units, assets };
|
|
20780
|
+
}
|
|
20781
|
+
function reduceTop(bids, asks) {
|
|
20782
|
+
let bestBorrowTick;
|
|
20783
|
+
let bestSupplyTick;
|
|
20784
|
+
let borrowDepthUnits = 0n;
|
|
20785
|
+
let borrowDepthAssets = 0n;
|
|
20786
|
+
let supplyDepthUnits = 0n;
|
|
20787
|
+
let supplyDepthAssets = 0n;
|
|
20788
|
+
for (const l of bids) {
|
|
20789
|
+
borrowDepthUnits += l.units;
|
|
20790
|
+
borrowDepthAssets += l.assets;
|
|
20791
|
+
if (bestBorrowTick === void 0 || l.tick > bestBorrowTick) bestBorrowTick = l.tick;
|
|
20792
|
+
}
|
|
20793
|
+
for (const l of asks) {
|
|
20794
|
+
supplyDepthUnits += l.units;
|
|
20795
|
+
supplyDepthAssets += l.assets;
|
|
20796
|
+
if (bestSupplyTick === void 0 || l.tick < bestSupplyTick) bestSupplyTick = l.tick;
|
|
20797
|
+
}
|
|
20798
|
+
return {
|
|
20799
|
+
bestBorrowTick,
|
|
20800
|
+
bestSupplyTick,
|
|
20801
|
+
borrowDepthUnits,
|
|
20802
|
+
borrowDepthAssets,
|
|
20803
|
+
supplyDepthUnits,
|
|
20804
|
+
supplyDepthAssets
|
|
20805
|
+
};
|
|
20806
|
+
}
|
|
20807
|
+
var ApiBookSource = class {
|
|
20808
|
+
constructor(baseUrl, fetchImpl = fetch) {
|
|
20809
|
+
this.baseUrl = baseUrl;
|
|
20810
|
+
this.fetchImpl = fetchImpl;
|
|
20811
|
+
}
|
|
20812
|
+
baseUrl;
|
|
20813
|
+
fetchImpl;
|
|
20814
|
+
async getBookTop(marketId) {
|
|
20815
|
+
const url = `${this.baseUrl}/books/${marketId}`;
|
|
20816
|
+
try {
|
|
20817
|
+
const res = await this.fetchImpl(url);
|
|
20818
|
+
if (!res.ok) {
|
|
20819
|
+
warn(`book ${marketId} \u2192 HTTP ${res.status}`);
|
|
20820
|
+
return null;
|
|
20821
|
+
}
|
|
20822
|
+
const json = await res.json();
|
|
20823
|
+
const book = json?.data ?? json;
|
|
20824
|
+
const bids = Array.isArray(book?.bids) ? book.bids.map(parseLevel) : [];
|
|
20825
|
+
const asks = Array.isArray(book?.asks) ? book.asks.map(parseLevel) : [];
|
|
20826
|
+
return reduceTop(bids, asks);
|
|
20827
|
+
} catch (e) {
|
|
20828
|
+
warn(`book ${marketId} fetch failed:`, e?.message ?? e);
|
|
20829
|
+
return null;
|
|
20830
|
+
}
|
|
20831
|
+
}
|
|
20832
|
+
};
|
|
20833
|
+
function createMidnightBookSource(chainId, fetchImpl = fetch) {
|
|
20834
|
+
return new ApiBookSource(midnightApiBaseUrl(chainId), fetchImpl);
|
|
20835
|
+
}
|
|
20836
|
+
|
|
20837
|
+
// src/lending/public-data/midnight/fetchPublic.ts
|
|
20838
|
+
async function fetchMidnightMarkets(chainId, source = createMidnightBookSource(chainId)) {
|
|
20839
|
+
const markets = midnightMarketsByChain(chainId);
|
|
20840
|
+
if (markets.length === 0) return [];
|
|
20841
|
+
return Promise.all(
|
|
20842
|
+
markets.map(async (config) => ({
|
|
20843
|
+
config,
|
|
20844
|
+
top: await source.getBookTop(config.marketId).catch(() => null)
|
|
20845
|
+
}))
|
|
20846
|
+
);
|
|
20847
|
+
}
|
|
20848
|
+
|
|
20849
|
+
// src/lending/public-data/midnight/math.ts
|
|
20850
|
+
var WAD2 = 1000000000000000000n;
|
|
20851
|
+
var WAD_SQUARED = 1000000000000000000000000000000000000n;
|
|
20852
|
+
var LN_ONE_PLUS_DELTA = 4987541511039073n;
|
|
20853
|
+
var LN_2 = 693147180559945309n;
|
|
20854
|
+
var EXP_OFFSET = 322611214989459870n;
|
|
20855
|
+
var MAX_TICK = 6744n;
|
|
20856
|
+
var PRICE_ROUNDING_STEP = 100000000000n;
|
|
20857
|
+
var SECONDS_PER_YEAR7 = 31536000n;
|
|
20858
|
+
var mulDivUp = (x, y, d) => (x * y + (d - 1n)) / d;
|
|
20859
|
+
var divHalfDownUnchecked = (x, d) => (x + (d - 1n) / 2n) / d;
|
|
20860
|
+
function wExp(x) {
|
|
20861
|
+
if (x < 0n) return WAD_SQUARED / wExp(-x);
|
|
20862
|
+
const q = (x + EXP_OFFSET) / LN_2;
|
|
20863
|
+
const r = x - q * LN_2;
|
|
20864
|
+
const secondTerm = r * r / (2n * WAD2);
|
|
20865
|
+
const thirdTerm = secondTerm * r / (3n * WAD2);
|
|
20866
|
+
const expR = WAD2 + r + secondTerm + thirdTerm;
|
|
20867
|
+
return expR << q;
|
|
20868
|
+
}
|
|
20869
|
+
function tickToPrice(tick) {
|
|
20870
|
+
if (tick < 0n || tick > MAX_TICK)
|
|
20871
|
+
throw new Error(`midnight tick out of range: ${tick}`);
|
|
20872
|
+
const exponent = LN_ONE_PLUS_DELTA * (MAX_TICK / 2n - tick);
|
|
20873
|
+
const rawPrice = divHalfDownUnchecked(WAD_SQUARED, WAD2 + wExp(exponent));
|
|
20874
|
+
return divHalfDownUnchecked(rawPrice, PRICE_ROUNDING_STEP) * PRICE_ROUNDING_STEP;
|
|
20875
|
+
}
|
|
20876
|
+
function tickToRate(tick) {
|
|
20877
|
+
const price2 = tickToPrice(tick);
|
|
20878
|
+
if (price2 === 0n) throw new Error("midnight tick price is zero");
|
|
20879
|
+
return mulDivUp(WAD2, WAD2, price2) - WAD2;
|
|
20880
|
+
}
|
|
20881
|
+
function tickToApr(tick, timeToMaturity) {
|
|
20882
|
+
if (timeToMaturity <= 0n) return 0n;
|
|
20883
|
+
return mulDivUp(tickToRate(tick), SECONDS_PER_YEAR7, timeToMaturity);
|
|
20884
|
+
}
|
|
20885
|
+
function tickToAprNumber(tick, timeToMaturity) {
|
|
20886
|
+
return Number(tickToApr(tick, timeToMaturity)) / 1e18;
|
|
20887
|
+
}
|
|
20888
|
+
|
|
20889
|
+
// src/lending/public-data/midnight/convertPublic.ts
|
|
20890
|
+
var nowSec = () => Math.floor(Date.now() / 1e3);
|
|
20891
|
+
function midnightLenderKey(marketId) {
|
|
20892
|
+
return "MORPHO_MIDNIGHT_" + marketId.slice(2).toUpperCase();
|
|
20893
|
+
}
|
|
20894
|
+
function currencyFor(address, decimals, tokens) {
|
|
20895
|
+
const lower = address.toLowerCase();
|
|
20896
|
+
return tokens[lower] ?? {
|
|
20897
|
+
address: lower,
|
|
20898
|
+
symbol: "",
|
|
20899
|
+
name: "",
|
|
20900
|
+
decimals
|
|
20901
|
+
};
|
|
20902
|
+
}
|
|
20903
|
+
function convertMidnightMarketsToResponse(raw, chainId, prices = {}, _additionalYields = {
|
|
20904
|
+
intrinsicYields: {},
|
|
20905
|
+
lenderRewards: {},
|
|
20906
|
+
loaded: true
|
|
20907
|
+
}, tokens = {}) {
|
|
20908
|
+
const out = {};
|
|
20909
|
+
const now = nowSec();
|
|
20910
|
+
for (const { config, top } of raw) {
|
|
20911
|
+
if (!config?.marketId || !config.loanToken) continue;
|
|
20912
|
+
const m = midnightLenderKey(config.marketId);
|
|
20913
|
+
const maturity = Number(config.maturity);
|
|
20914
|
+
const ttm = maturity - now;
|
|
20915
|
+
const matured = ttm <= 0;
|
|
20916
|
+
const ttmBig = BigInt(Math.max(0, ttm));
|
|
20917
|
+
const supplyAprPct = top?.bestSupplyTick != null && !matured ? tickToAprNumber(top.bestSupplyTick, ttmBig) * 100 : 0;
|
|
20918
|
+
const borrowAprPct = top?.bestBorrowTick != null && !matured ? tickToAprNumber(top.bestBorrowTick, ttmBig) * 100 : 0;
|
|
20919
|
+
const terms = borrowAprPct > 0 && !matured ? [
|
|
20920
|
+
{
|
|
20921
|
+
termId: 0,
|
|
20922
|
+
durationSecs: Math.max(0, ttm),
|
|
20923
|
+
durationDays: ttm / 86400,
|
|
20924
|
+
apr: borrowAprPct
|
|
20925
|
+
}
|
|
20926
|
+
] : void 0;
|
|
20927
|
+
const loanAddr = config.loanToken.toLowerCase();
|
|
20928
|
+
const loanPrice = prices[loanAddr] ?? 0;
|
|
20929
|
+
const supplyLiquidity = formatNr(top?.supplyDepthAssets ?? 0n, config.loanDecimals);
|
|
20930
|
+
const borrowLiquidity = formatNr(top?.borrowDepthAssets ?? 0n, config.loanDecimals);
|
|
20931
|
+
const entry = { data: {} };
|
|
20932
|
+
const loanUid = createMarketUid(chainId, m, loanAddr);
|
|
20933
|
+
entry.data[loanUid] = {
|
|
20934
|
+
marketUid: loanUid,
|
|
20935
|
+
name: "Loan " + (tokens[loanAddr]?.symbol ?? ""),
|
|
20936
|
+
poolId: loanAddr,
|
|
20937
|
+
underlying: loanAddr,
|
|
20938
|
+
asset: currencyFor(loanAddr, config.loanDecimals, tokens),
|
|
20939
|
+
totalDeposits: supplyLiquidity,
|
|
20940
|
+
totalDebtStable: 0,
|
|
20941
|
+
totalDebt: 0,
|
|
20942
|
+
totalLiquidity: borrowLiquidity,
|
|
20943
|
+
borrowLiquidity,
|
|
20944
|
+
totalLiquidityUSD: borrowLiquidity * loanPrice,
|
|
20945
|
+
borrowLiquidityUSD: borrowLiquidity * loanPrice,
|
|
20946
|
+
totalDepositsUSD: supplyLiquidity * loanPrice,
|
|
20947
|
+
totalDebtStableUSD: 0,
|
|
20948
|
+
totalDebtUSD: 0,
|
|
20949
|
+
utilization: 0,
|
|
20950
|
+
depositRate: supplyAprPct,
|
|
20951
|
+
variableBorrowRate: borrowAprPct,
|
|
20952
|
+
// Midnight is fixed-rate: expose the fixed borrow APR on stableBorrowRate
|
|
20953
|
+
// too, so fixed-rate consumers pick it up like a term product.
|
|
20954
|
+
stableBorrowRate: borrowAprPct,
|
|
20955
|
+
intrinsicYield: 0,
|
|
20956
|
+
rewards: void 0,
|
|
20957
|
+
decimals: config.loanDecimals,
|
|
20958
|
+
config: {
|
|
20959
|
+
0: {
|
|
20960
|
+
category: 0,
|
|
20961
|
+
borrowCollateralFactor: 0,
|
|
20962
|
+
collateralFactor: 0,
|
|
20963
|
+
borrowFactor: 1,
|
|
20964
|
+
liquidationPenalty: 0,
|
|
20965
|
+
closeFactor: 1,
|
|
20966
|
+
collateralDisabled: true,
|
|
20967
|
+
debtDisabled: false
|
|
20968
|
+
}
|
|
20969
|
+
},
|
|
20970
|
+
closeFactor: 1,
|
|
20971
|
+
collateralActive: false,
|
|
20972
|
+
borrowingEnabled: !matured,
|
|
20973
|
+
depositsEnabled: !matured,
|
|
20974
|
+
hasStable: false,
|
|
20975
|
+
// Midnight borrowing is fixed-term (carried via `terms` + `maturity` on
|
|
20976
|
+
// params.market), but it IS borrowable — do NOT mark variable borrow
|
|
20977
|
+
// disabled, or borrowable-only filters would hide the market.
|
|
20978
|
+
variableBorrowDisabled: false,
|
|
20979
|
+
isActive: true,
|
|
20980
|
+
isFrozen: false
|
|
20981
|
+
};
|
|
20982
|
+
config.collateralParams.forEach((c) => {
|
|
20983
|
+
const collAddr = c.token.toLowerCase();
|
|
20984
|
+
const ltv = parseLtv(c.lltv);
|
|
20985
|
+
const liquidationPenalty = liquidationPenaltyFromLltv(ltv);
|
|
20986
|
+
const collUid = createMarketUid(chainId, m, collAddr);
|
|
20987
|
+
entry.data[collUid] = {
|
|
20988
|
+
marketUid: collUid,
|
|
20989
|
+
name: "Collateral " + (tokens[collAddr]?.symbol ?? ""),
|
|
20990
|
+
poolId: collAddr,
|
|
20991
|
+
underlying: collAddr,
|
|
20992
|
+
asset: currencyFor(collAddr, c.decimals, tokens),
|
|
20993
|
+
totalDeposits: 0,
|
|
20994
|
+
totalDebtStable: 0,
|
|
20995
|
+
totalDebt: 0,
|
|
20996
|
+
totalLiquidity: 0,
|
|
20997
|
+
borrowLiquidity: 0,
|
|
20998
|
+
totalLiquidityUSD: 0,
|
|
20999
|
+
borrowLiquidityUSD: 0,
|
|
21000
|
+
totalDepositsUSD: 0,
|
|
21001
|
+
totalDebtStableUSD: 0,
|
|
21002
|
+
totalDebtUSD: 0,
|
|
21003
|
+
utilization: 0,
|
|
21004
|
+
depositRate: 0,
|
|
21005
|
+
variableBorrowRate: 0,
|
|
21006
|
+
stableBorrowRate: 0,
|
|
21007
|
+
intrinsicYield: 0,
|
|
21008
|
+
rewards: void 0,
|
|
21009
|
+
decimals: c.decimals,
|
|
21010
|
+
config: {
|
|
21011
|
+
0: {
|
|
21012
|
+
category: 0,
|
|
21013
|
+
borrowCollateralFactor: ltv,
|
|
21014
|
+
collateralFactor: ltv,
|
|
21015
|
+
borrowFactor: 1,
|
|
21016
|
+
liquidationPenalty,
|
|
21017
|
+
closeFactor: 1,
|
|
21018
|
+
collateralDisabled: false,
|
|
21019
|
+
debtDisabled: true
|
|
21020
|
+
}
|
|
21021
|
+
},
|
|
21022
|
+
closeFactor: 1,
|
|
21023
|
+
collateralActive: true,
|
|
21024
|
+
borrowingEnabled: false,
|
|
21025
|
+
depositsEnabled: !matured,
|
|
21026
|
+
hasStable: false,
|
|
21027
|
+
isActive: true,
|
|
21028
|
+
isFrozen: false
|
|
21029
|
+
};
|
|
21030
|
+
});
|
|
21031
|
+
const primaryCollateral = config.collateralParams[0];
|
|
21032
|
+
entry.params = {
|
|
21033
|
+
market: {
|
|
21034
|
+
lender: m,
|
|
21035
|
+
name: config.name,
|
|
21036
|
+
loanDecimals: config.loanDecimals,
|
|
21037
|
+
collateralDecimals: primaryCollateral?.decimals,
|
|
21038
|
+
id: config.marketId,
|
|
21039
|
+
lltv: primaryCollateral?.lltv ?? "0",
|
|
21040
|
+
oracle: primaryCollateral?.oracle ?? zeroAddress,
|
|
21041
|
+
irm: zeroAddress,
|
|
21042
|
+
collateralAddress: primaryCollateral?.token ?? zeroAddress,
|
|
21043
|
+
loanAddress: loanAddr,
|
|
21044
|
+
// Fixed-term rate card (single maturity); undefined when no live rate.
|
|
21045
|
+
terms,
|
|
21046
|
+
// Midnight-specific extras (consumed by calldata / worker-api resolvers)
|
|
21047
|
+
maturity: config.maturity,
|
|
21048
|
+
rcfThreshold: config.rcfThreshold,
|
|
21049
|
+
enterGate: config.enterGate,
|
|
21050
|
+
liquidatorGate: config.liquidatorGate,
|
|
21051
|
+
collateralParams: config.collateralParams
|
|
21052
|
+
}
|
|
21053
|
+
};
|
|
21054
|
+
entry.chainId = chainId;
|
|
21055
|
+
out[m] = entry;
|
|
21056
|
+
}
|
|
21057
|
+
return out;
|
|
21058
|
+
}
|
|
20754
21059
|
|
|
20755
21060
|
// src/lending/public-data/silo-v2/fetchPublic.ts
|
|
20756
21061
|
var BASE_URL2 = "https://api-v3.silo.finance";
|
|
@@ -21348,16 +21653,25 @@ function convertDolomiteSubgraphMarkets(raw, chainId, prices, additionalYields,
|
|
|
21348
21653
|
}
|
|
21349
21654
|
return { data: result, chainId };
|
|
21350
21655
|
}
|
|
21351
|
-
var
|
|
21656
|
+
var warn2 = (...args) => {
|
|
21352
21657
|
};
|
|
21353
21658
|
async function getLenderDataFromApi(lender, chainId, prices, additionalYields, includeUnlisted = false) {
|
|
21354
21659
|
if (isMorphoType(lender))
|
|
21355
21660
|
return await fetchMorphoMarkets(chainId, includeUnlisted);
|
|
21661
|
+
if (isMidnight(lender)) return await fetchMidnightMarkets(chainId);
|
|
21356
21662
|
return {};
|
|
21357
21663
|
}
|
|
21358
21664
|
function convertLenderDataFromApi(lender, chainId, data, prices, additionalYields, list = {}) {
|
|
21359
21665
|
if (isMorphoType(lender))
|
|
21360
21666
|
return convertMarketsToMorphoResponse(data, chainId, additionalYields, list);
|
|
21667
|
+
if (isMidnight(lender))
|
|
21668
|
+
return convertMidnightMarketsToResponse(
|
|
21669
|
+
data,
|
|
21670
|
+
chainId,
|
|
21671
|
+
prices,
|
|
21672
|
+
additionalYields,
|
|
21673
|
+
list
|
|
21674
|
+
);
|
|
21361
21675
|
return {};
|
|
21362
21676
|
}
|
|
21363
21677
|
var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYields, tokenList = async () => {
|
|
@@ -21398,7 +21712,7 @@ var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYield
|
|
|
21398
21712
|
const listResult = settled[0];
|
|
21399
21713
|
const list = listResult.status === "fulfilled" ? listResult.value : {};
|
|
21400
21714
|
if (listResult.status === "rejected") {
|
|
21401
|
-
|
|
21715
|
+
warn2(
|
|
21402
21716
|
`[lending] tokenList fetch failed on chain ${chainId}:`,
|
|
21403
21717
|
listResult.reason
|
|
21404
21718
|
);
|
|
@@ -21420,13 +21734,13 @@ var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYield
|
|
|
21420
21734
|
if (converted[lk]) lenderData[lk] = converted[lk];
|
|
21421
21735
|
}
|
|
21422
21736
|
} catch (e) {
|
|
21423
|
-
|
|
21737
|
+
warn2(
|
|
21424
21738
|
`[lending] Silo v2 API convert failed on chain ${chainId}:`,
|
|
21425
21739
|
e?.message ?? e
|
|
21426
21740
|
);
|
|
21427
21741
|
}
|
|
21428
21742
|
} else {
|
|
21429
|
-
|
|
21743
|
+
warn2(
|
|
21430
21744
|
`[lending] Silo v2 API fetch failed on chain ${chainId}:`,
|
|
21431
21745
|
siloV2Result.reason?.message ?? siloV2Result.reason
|
|
21432
21746
|
);
|
|
@@ -21448,13 +21762,13 @@ var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYield
|
|
|
21448
21762
|
if (converted[lk]) lenderData[lk] = converted[lk];
|
|
21449
21763
|
}
|
|
21450
21764
|
} catch (e) {
|
|
21451
|
-
|
|
21765
|
+
warn2(
|
|
21452
21766
|
`[lending] Silo v3 API convert failed on chain ${chainId}:`,
|
|
21453
21767
|
e?.message ?? e
|
|
21454
21768
|
);
|
|
21455
21769
|
}
|
|
21456
21770
|
} else {
|
|
21457
|
-
|
|
21771
|
+
warn2(
|
|
21458
21772
|
`[lending] Silo v3 API fetch failed on chain ${chainId}:`,
|
|
21459
21773
|
siloV3Result.reason?.message ?? siloV3Result.reason
|
|
21460
21774
|
);
|
|
@@ -21464,7 +21778,7 @@ var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYield
|
|
|
21464
21778
|
try {
|
|
21465
21779
|
const result = settled[i + 3];
|
|
21466
21780
|
if (result.status === "rejected") {
|
|
21467
|
-
|
|
21781
|
+
warn2(
|
|
21468
21782
|
`[lending] API fetch failed for ${otherLenders[i]} on chain ${chainId}:`,
|
|
21469
21783
|
result.reason?.message ?? result.reason
|
|
21470
21784
|
);
|
|
@@ -21508,13 +21822,13 @@ var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYield
|
|
|
21508
21822
|
);
|
|
21509
21823
|
for (const lk of dolomiteLenders) lenderData[lk] = converted;
|
|
21510
21824
|
} catch (e) {
|
|
21511
|
-
|
|
21825
|
+
warn2(
|
|
21512
21826
|
`[lending] Dolomite subgraph convert failed on chain ${chainId}:`,
|
|
21513
21827
|
e?.message ?? e
|
|
21514
21828
|
);
|
|
21515
21829
|
}
|
|
21516
21830
|
} else if (dolomiteResult.status === "rejected") {
|
|
21517
|
-
|
|
21831
|
+
warn2(
|
|
21518
21832
|
`[lending] Dolomite subgraph fetch failed on chain ${chainId}:`,
|
|
21519
21833
|
dolomiteResult.reason?.message ?? dolomiteResult.reason
|
|
21520
21834
|
);
|
|
@@ -21522,7 +21836,7 @@ var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYield
|
|
|
21522
21836
|
}
|
|
21523
21837
|
return lenderData;
|
|
21524
21838
|
};
|
|
21525
|
-
var
|
|
21839
|
+
var warn3 = (...args) => {
|
|
21526
21840
|
};
|
|
21527
21841
|
function lenderApiOnly(lender, chainId) {
|
|
21528
21842
|
if (lender === Lender.MORPHO_BLUE) {
|
|
@@ -21541,6 +21855,7 @@ function lenderApiOnly(lender, chainId) {
|
|
|
21541
21855
|
if (chainId === "4114") return false;
|
|
21542
21856
|
return true;
|
|
21543
21857
|
}
|
|
21858
|
+
if (isMidnight(lender)) return true;
|
|
21544
21859
|
return false;
|
|
21545
21860
|
}
|
|
21546
21861
|
function lenderApiWithOnChainFallback(lender, chainId) {
|
|
@@ -21568,7 +21883,7 @@ var getLenderPublicDataAll = async (chainId, lenders, prices, additionalYields,
|
|
|
21568
21883
|
includeUnlistedMorphoMarkets
|
|
21569
21884
|
);
|
|
21570
21885
|
} catch (e) {
|
|
21571
|
-
|
|
21886
|
+
warn3(
|
|
21572
21887
|
`[lending] API fetch failed for chain ${chainId}:`,
|
|
21573
21888
|
e?.message ?? e
|
|
21574
21889
|
);
|
|
@@ -21591,7 +21906,7 @@ var getLenderPublicDataAll = async (chainId, lenders, prices, additionalYields,
|
|
|
21591
21906
|
tokenList
|
|
21592
21907
|
);
|
|
21593
21908
|
} catch (e) {
|
|
21594
|
-
|
|
21909
|
+
warn3(
|
|
21595
21910
|
`[lending] on-chain fetch failed for chain ${chainId}:`,
|
|
21596
21911
|
e?.message ?? e
|
|
21597
21912
|
);
|
|
@@ -22231,6 +22546,28 @@ var buildDolomiteUserCall = async (chainId, _lender, account, accountNumbers) =>
|
|
|
22231
22546
|
params: [{ owner: account, number }]
|
|
22232
22547
|
}));
|
|
22233
22548
|
};
|
|
22549
|
+
var midnightMarketCallCount = (collateralCount) => 1 + collateralCount;
|
|
22550
|
+
var buildMidnightUserCall = (chainId, _lender, account) => {
|
|
22551
|
+
const midnight = midnightConfig()?.[chainId]?.midnight;
|
|
22552
|
+
const markets = midnightMarketsByChain(chainId);
|
|
22553
|
+
if (!midnight || markets.length === 0) return [];
|
|
22554
|
+
const calls = [];
|
|
22555
|
+
for (const market of markets) {
|
|
22556
|
+
calls.push({
|
|
22557
|
+
address: midnight,
|
|
22558
|
+
name: "position",
|
|
22559
|
+
params: [market.marketId, account]
|
|
22560
|
+
});
|
|
22561
|
+
for (let index = 0; index < market.collateralParams.length; index++) {
|
|
22562
|
+
calls.push({
|
|
22563
|
+
address: midnight,
|
|
22564
|
+
name: "collateral",
|
|
22565
|
+
params: [market.marketId, account, BigInt(index)]
|
|
22566
|
+
});
|
|
22567
|
+
}
|
|
22568
|
+
}
|
|
22569
|
+
return calls;
|
|
22570
|
+
};
|
|
22234
22571
|
|
|
22235
22572
|
// src/lending/user-data/fetch-balances/prepare.ts
|
|
22236
22573
|
async function buildUserCall(chainId, lender, account, params, getClient) {
|
|
@@ -22246,6 +22583,7 @@ async function buildUserCall(chainId, lender, account, params, getClient) {
|
|
|
22246
22583
|
params,
|
|
22247
22584
|
getClient
|
|
22248
22585
|
);
|
|
22586
|
+
if (isMidnight(lender)) return buildMidnightUserCall(chainId, lender, account);
|
|
22249
22587
|
if (isCompoundV3Type(lender))
|
|
22250
22588
|
return buildCompoundV3UserCall(chainId, lender, account);
|
|
22251
22589
|
if (isEulerType(lender))
|
|
@@ -24474,6 +24812,118 @@ function normalizeUnderlying3(token) {
|
|
|
24474
24812
|
const lower = token.toLowerCase();
|
|
24475
24813
|
return Object.values(WETH_BY_CHAIN).includes(lower) ? zeroAddress : lower;
|
|
24476
24814
|
}
|
|
24815
|
+
function toBigInt10(v) {
|
|
24816
|
+
if (v === void 0 || v === null || v === "0x") return 0n;
|
|
24817
|
+
if (typeof v === "bigint") return v;
|
|
24818
|
+
try {
|
|
24819
|
+
return BigInt(v);
|
|
24820
|
+
} catch {
|
|
24821
|
+
return 0n;
|
|
24822
|
+
}
|
|
24823
|
+
}
|
|
24824
|
+
function readDebtUnits(positionResult) {
|
|
24825
|
+
if (Array.isArray(positionResult)) return toBigInt10(positionResult[4]);
|
|
24826
|
+
if (positionResult && typeof positionResult === "object")
|
|
24827
|
+
return toBigInt10(positionResult.debt);
|
|
24828
|
+
return 0n;
|
|
24829
|
+
}
|
|
24830
|
+
var getMidnightUserDataConverter = (_lender, chainId, account, meta) => {
|
|
24831
|
+
const markets = midnightMarketsByChain(chainId);
|
|
24832
|
+
const totalCalls = markets.reduce(
|
|
24833
|
+
(sum, m) => sum + midnightMarketCallCount(m.collateralParams.length),
|
|
24834
|
+
0
|
|
24835
|
+
);
|
|
24836
|
+
return [
|
|
24837
|
+
(data) => {
|
|
24838
|
+
if (!data || data.length < totalCalls) return void 0;
|
|
24839
|
+
const out = {};
|
|
24840
|
+
let cursor = 0;
|
|
24841
|
+
for (const market of markets) {
|
|
24842
|
+
const positionResult = data[cursor];
|
|
24843
|
+
const collateralResults = market.collateralParams.map(
|
|
24844
|
+
(_c, i) => data[cursor + 1 + i]
|
|
24845
|
+
);
|
|
24846
|
+
cursor += midnightMarketCallCount(market.collateralParams.length);
|
|
24847
|
+
const lenderKey = midnightLenderKey(market.marketId);
|
|
24848
|
+
const metaMap = meta?.[lenderKey];
|
|
24849
|
+
if (!metaMap) continue;
|
|
24850
|
+
const loanAddr = market.loanToken.toLowerCase();
|
|
24851
|
+
const loanUid = createMarketUid(chainId, lenderKey, loanAddr);
|
|
24852
|
+
const loanMeta = metaMap[loanUid];
|
|
24853
|
+
const loanDisplayPrice = loanMeta ? getDisplayPrice(loanMeta) : 0;
|
|
24854
|
+
const loanOraclePrice = loanMeta ? getOraclePrice(loanMeta) : 0;
|
|
24855
|
+
const loanPriceHist = loanMeta?.price?.priceUsd24h ?? loanDisplayPrice;
|
|
24856
|
+
const debtUnits = readDebtUnits(positionResult);
|
|
24857
|
+
const debtStr = parseRawAmount(debtUnits.toString(), market.loanDecimals);
|
|
24858
|
+
const debtNum = Number(debtStr);
|
|
24859
|
+
const posData = {};
|
|
24860
|
+
let anyBalance = debtUnits > 0n;
|
|
24861
|
+
let depositsUSD24h = 0;
|
|
24862
|
+
posData[loanUid] = {
|
|
24863
|
+
marketUid: loanUid,
|
|
24864
|
+
underlying: loanAddr,
|
|
24865
|
+
deposits: "0",
|
|
24866
|
+
debt: debtStr,
|
|
24867
|
+
debtStable: "0",
|
|
24868
|
+
depositsUSD: 0,
|
|
24869
|
+
debtUSD: debtNum * loanDisplayPrice,
|
|
24870
|
+
debtStableUSD: 0,
|
|
24871
|
+
depositsUSDOracle: 0,
|
|
24872
|
+
debtUSDOracle: debtNum * loanOraclePrice,
|
|
24873
|
+
debtStableUSDOracle: 0,
|
|
24874
|
+
stableBorrowRate: "0",
|
|
24875
|
+
collateralEnabled: false,
|
|
24876
|
+
claimableRewards: 0
|
|
24877
|
+
};
|
|
24878
|
+
market.collateralParams.forEach((c, i) => {
|
|
24879
|
+
const collAmt = toBigInt10(collateralResults[i]);
|
|
24880
|
+
if (collAmt === 0n) return;
|
|
24881
|
+
anyBalance = true;
|
|
24882
|
+
const collAddr = c.token.toLowerCase();
|
|
24883
|
+
const collUid = createMarketUid(chainId, lenderKey, collAddr);
|
|
24884
|
+
const collMeta = metaMap[collUid];
|
|
24885
|
+
const collDec = collMeta?.asset?.decimals ?? c.decimals;
|
|
24886
|
+
const collDisplayPrice = collMeta ? getDisplayPrice(collMeta) : 0;
|
|
24887
|
+
const collOraclePrice = collMeta ? getOraclePrice(collMeta) : 0;
|
|
24888
|
+
const collPriceHist = collMeta?.price?.priceUsd24h ?? collDisplayPrice;
|
|
24889
|
+
const depositsStr = parseRawAmount(collAmt.toString(), collDec);
|
|
24890
|
+
const depositsNum = Number(depositsStr);
|
|
24891
|
+
depositsUSD24h += depositsNum * collPriceHist;
|
|
24892
|
+
posData[collUid] = {
|
|
24893
|
+
marketUid: collUid,
|
|
24894
|
+
underlying: collAddr,
|
|
24895
|
+
deposits: depositsStr,
|
|
24896
|
+
debt: "0",
|
|
24897
|
+
debtStable: "0",
|
|
24898
|
+
depositsUSD: depositsNum * collDisplayPrice,
|
|
24899
|
+
debtUSD: 0,
|
|
24900
|
+
debtStableUSD: 0,
|
|
24901
|
+
depositsUSDOracle: depositsNum * collOraclePrice,
|
|
24902
|
+
debtUSDOracle: 0,
|
|
24903
|
+
debtStableUSDOracle: 0,
|
|
24904
|
+
stableBorrowRate: "0",
|
|
24905
|
+
collateralEnabled: true,
|
|
24906
|
+
claimableRewards: 0
|
|
24907
|
+
};
|
|
24908
|
+
});
|
|
24909
|
+
if (!anyBalance) continue;
|
|
24910
|
+
const userData = createMultiAccountTypeUserState(
|
|
24911
|
+
{
|
|
24912
|
+
chainId,
|
|
24913
|
+
account,
|
|
24914
|
+
lendingPositions: { "0": posData },
|
|
24915
|
+
modes: { "0": 0 }
|
|
24916
|
+
},
|
|
24917
|
+
metaMap,
|
|
24918
|
+
{ "0": { totalDeposits24h: depositsUSD24h, totalDebt24h: debtNum * loanPriceHist } }
|
|
24919
|
+
);
|
|
24920
|
+
if (userData && userData.data.length > 0) out[lenderKey] = userData;
|
|
24921
|
+
}
|
|
24922
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
24923
|
+
},
|
|
24924
|
+
totalCalls
|
|
24925
|
+
];
|
|
24926
|
+
};
|
|
24477
24927
|
|
|
24478
24928
|
// src/lending/user-data/fetch-balances/parse.ts
|
|
24479
24929
|
function getUserDataConverter(lender, chainId, account, params, meta) {
|
|
@@ -24495,6 +24945,8 @@ function getUserDataConverter(lender, chainId, account, params, meta) {
|
|
|
24495
24945
|
params,
|
|
24496
24946
|
meta
|
|
24497
24947
|
);
|
|
24948
|
+
if (isMidnight(lender))
|
|
24949
|
+
return getMidnightUserDataConverter(lender, chainId, account, meta);
|
|
24498
24950
|
if (isCompoundV3Type(lender))
|
|
24499
24951
|
return getCompoundV3UserDataConverter(
|
|
24500
24952
|
lender,
|
|
@@ -29249,6 +29701,7 @@ var getAbi2 = (lender) => {
|
|
|
29249
29701
|
if (isCompoundV3(lender))
|
|
29250
29702
|
return [...CometAbi, ...CometExtAbi, ...CometRewardsAbi];
|
|
29251
29703
|
if (isMorphoType(lender)) return [...MorphoBlueAbi, ...MorphoLensAbi];
|
|
29704
|
+
if (isMidnight(lender)) return [...MidnightAbi];
|
|
29252
29705
|
if (isInit(lender)) return InitLensAbi;
|
|
29253
29706
|
if (isEulerType(lender)) return accountLensAbi;
|
|
29254
29707
|
if (isCompoundV2Type(lender))
|
|
@@ -32436,8 +32889,8 @@ var TIMEOUT_MS = 8e3;
|
|
|
32436
32889
|
var slisBnbFetcher = {
|
|
32437
32890
|
label: "SLISBNB",
|
|
32438
32891
|
fetch: async () => {
|
|
32439
|
-
const
|
|
32440
|
-
const url = `${HISTORY_URL}?name=slisBNBRate&cycle=1&startTime=${
|
|
32892
|
+
const nowSec2 = Math.floor(Date.now() / 1e3);
|
|
32893
|
+
const url = `${HISTORY_URL}?name=slisBNBRate&cycle=1&startTime=${nowSec2 - LOOKBACK_SECONDS}&endTime=${nowSec2}`;
|
|
32441
32894
|
const controller = new AbortController();
|
|
32442
32895
|
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
32443
32896
|
try {
|
|
@@ -33772,6 +34225,86 @@ var morphoFetcher = {
|
|
|
33772
34225
|
parse: parseMorphoResults,
|
|
33773
34226
|
getAbi: getMorphoAbi
|
|
33774
34227
|
};
|
|
34228
|
+
function getMidnightCalls(chainId) {
|
|
34229
|
+
const markets = midnightMarketsByChain(chainId);
|
|
34230
|
+
if (markets.length === 0) return [];
|
|
34231
|
+
const results = [];
|
|
34232
|
+
for (const market of markets) {
|
|
34233
|
+
if (!market.marketId || !market.loanToken) continue;
|
|
34234
|
+
const legs = [];
|
|
34235
|
+
const calls = [];
|
|
34236
|
+
for (const c of market.collateralParams ?? []) {
|
|
34237
|
+
if (!c.oracle || !c.token) continue;
|
|
34238
|
+
legs.push({
|
|
34239
|
+
collateralAsset: c.token.toLowerCase(),
|
|
34240
|
+
collateralDecimals: c.decimals,
|
|
34241
|
+
oracle: c.oracle
|
|
34242
|
+
});
|
|
34243
|
+
calls.push({ address: c.oracle, name: "price", params: [] });
|
|
34244
|
+
}
|
|
34245
|
+
if (legs.length === 0) continue;
|
|
34246
|
+
results.push({
|
|
34247
|
+
calls,
|
|
34248
|
+
meta: {
|
|
34249
|
+
marketId: market.marketId,
|
|
34250
|
+
loanAsset: market.loanToken.toLowerCase(),
|
|
34251
|
+
loanDecimals: market.loanDecimals,
|
|
34252
|
+
legs
|
|
34253
|
+
},
|
|
34254
|
+
lender: midnightLenderKey(market.marketId)
|
|
34255
|
+
});
|
|
34256
|
+
}
|
|
34257
|
+
return results;
|
|
34258
|
+
}
|
|
34259
|
+
function parseMidnightResults(data, meta, context) {
|
|
34260
|
+
const { chainId, usdPrices, tokenList } = context;
|
|
34261
|
+
const entries = [];
|
|
34262
|
+
const loanAsset = meta.loanAsset;
|
|
34263
|
+
const loanDecimals = meta.loanDecimals ?? tokenList?.[loanAsset]?.decimals ?? 18;
|
|
34264
|
+
const loanOracleKey = tokenList?.[loanAsset]?.assetGroup ?? `${chainId}-${loanAsset}`;
|
|
34265
|
+
const loanAssetUSD = usdPrices[loanOracleKey] ?? usdPrices[loanAsset];
|
|
34266
|
+
if (!loanAssetUSD) return entries;
|
|
34267
|
+
const lenderKey = midnightLenderKey(meta.marketId);
|
|
34268
|
+
entries.push({
|
|
34269
|
+
asset: loanAsset,
|
|
34270
|
+
price: 1,
|
|
34271
|
+
priceUSD: loanAssetUSD,
|
|
34272
|
+
marketUid: createMarketUid(chainId, lenderKey, loanAsset),
|
|
34273
|
+
targetLender: lenderKey,
|
|
34274
|
+
description: "Midnight loan asset",
|
|
34275
|
+
staticBase: true,
|
|
34276
|
+
baseAsset: loanAsset
|
|
34277
|
+
});
|
|
34278
|
+
meta.legs.forEach((leg, i) => {
|
|
34279
|
+
const rawPrice = data[i];
|
|
34280
|
+
if (!rawPrice || rawPrice === "0x") return;
|
|
34281
|
+
const collateralDecimals = leg.collateralDecimals ?? tokenList?.[leg.collateralAsset]?.decimals ?? 18;
|
|
34282
|
+
const priceDebtToCollateral = formatMorphoPrice(
|
|
34283
|
+
rawPrice.toString(),
|
|
34284
|
+
loanDecimals,
|
|
34285
|
+
collateralDecimals
|
|
34286
|
+
);
|
|
34287
|
+
if (isNaN(priceDebtToCollateral) || priceDebtToCollateral === 0) return;
|
|
34288
|
+
entries.push({
|
|
34289
|
+
asset: leg.collateralAsset,
|
|
34290
|
+
price: priceDebtToCollateral,
|
|
34291
|
+
// raw: collateral price in loan asset terms
|
|
34292
|
+
priceUSD: priceDebtToCollateral * loanAssetUSD,
|
|
34293
|
+
marketUid: createMarketUid(chainId, lenderKey, leg.collateralAsset),
|
|
34294
|
+
targetLender: lenderKey,
|
|
34295
|
+
baseAsset: loanAsset
|
|
34296
|
+
});
|
|
34297
|
+
});
|
|
34298
|
+
return entries;
|
|
34299
|
+
}
|
|
34300
|
+
function getMidnightAbi() {
|
|
34301
|
+
return ProxyOracleAbi;
|
|
34302
|
+
}
|
|
34303
|
+
var midnightFetcher = {
|
|
34304
|
+
getCalls: getMidnightCalls,
|
|
34305
|
+
parse: parseMidnightResults,
|
|
34306
|
+
getAbi: getMidnightAbi
|
|
34307
|
+
};
|
|
33775
34308
|
var CompoundV2OracleAbi = [
|
|
33776
34309
|
{
|
|
33777
34310
|
inputs: [{ internalType: "address", name: "cToken", type: "address" }],
|
|
@@ -35366,6 +35899,11 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
35366
35899
|
}),
|
|
35367
35900
|
getCallsErrors
|
|
35368
35901
|
) : [];
|
|
35902
|
+
const midnightResults = isActive("midnight") ? safeGetCalls(
|
|
35903
|
+
"midnight",
|
|
35904
|
+
() => midnightFetcher.getCalls(chainId),
|
|
35905
|
+
getCallsErrors
|
|
35906
|
+
) : [];
|
|
35369
35907
|
const siloV2Results = isActive("silov2") ? safeGetCalls(
|
|
35370
35908
|
"siloV2",
|
|
35371
35909
|
() => siloV2Fetcher.getCalls(chainId),
|
|
@@ -35433,6 +35971,12 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
35433
35971
|
morphoFetcher.parse,
|
|
35434
35972
|
ProxyOracleAbi
|
|
35435
35973
|
);
|
|
35974
|
+
const midnightGroup = buildGroup(
|
|
35975
|
+
"midnight",
|
|
35976
|
+
midnightResults,
|
|
35977
|
+
midnightFetcher.parse,
|
|
35978
|
+
ProxyOracleAbi
|
|
35979
|
+
);
|
|
35436
35980
|
const siloV2Group = buildGroup(
|
|
35437
35981
|
"siloV2",
|
|
35438
35982
|
siloV2Results,
|
|
@@ -35471,6 +36015,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
35471
36015
|
eulerGroup,
|
|
35472
36016
|
aaveV4Group,
|
|
35473
36017
|
morphoGroup,
|
|
36018
|
+
midnightGroup,
|
|
35474
36019
|
siloV2Group,
|
|
35475
36020
|
siloV3Group,
|
|
35476
36021
|
fluidGroup,
|
|
@@ -35506,6 +36051,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
35506
36051
|
fluidData,
|
|
35507
36052
|
gearboxV3Data,
|
|
35508
36053
|
dolomiteData,
|
|
36054
|
+
midnightData,
|
|
35509
36055
|
morphoGqlEntries,
|
|
35510
36056
|
siloV2GqlEntries,
|
|
35511
36057
|
siloV3GqlEntries
|
|
@@ -35582,6 +36128,14 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
35582
36128
|
allowFailure,
|
|
35583
36129
|
rpcOverrides
|
|
35584
36130
|
),
|
|
36131
|
+
executeGroup(
|
|
36132
|
+
midnightGroup,
|
|
36133
|
+
chainId,
|
|
36134
|
+
chainBatchSize,
|
|
36135
|
+
retries,
|
|
36136
|
+
allowFailure,
|
|
36137
|
+
rpcOverrides
|
|
36138
|
+
),
|
|
35585
36139
|
morphoGqlPromise,
|
|
35586
36140
|
siloV2GqlPromise,
|
|
35587
36141
|
siloV3GqlPromise
|
|
@@ -35632,6 +36186,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
35632
36186
|
{ group: fluidGroup, data: fluidData },
|
|
35633
36187
|
{ group: gearboxV3Group, data: gearboxV3Data },
|
|
35634
36188
|
{ group: dolomiteGroup, data: dolomiteData },
|
|
36189
|
+
{ group: midnightGroup, data: midnightData },
|
|
35635
36190
|
...siloV2GqlEntries != null ? [] : [{ group: siloV2Group, data: siloV2Data }],
|
|
35636
36191
|
...siloV3GqlEntries != null ? [] : [{ group: siloV3Group, data: siloV3Data }],
|
|
35637
36192
|
// In hybrid mode the on-chain multicall ran too — surface its errors.
|
|
@@ -35825,6 +36380,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
35825
36380
|
}
|
|
35826
36381
|
parseTrackers(morphoGroup, morphoData.results, false);
|
|
35827
36382
|
}
|
|
36383
|
+
parseTrackers(midnightGroup, midnightData.results, false);
|
|
35828
36384
|
const totalFailedCalls = trackerDiags.reduce(
|
|
35829
36385
|
(sum, d) => sum + d.failedCalls,
|
|
35830
36386
|
0
|
|
@@ -40174,7 +40730,7 @@ var Multicall3BalanceAbi = [
|
|
|
40174
40730
|
outputs: [{ type: "uint256" }]
|
|
40175
40731
|
}
|
|
40176
40732
|
];
|
|
40177
|
-
var
|
|
40733
|
+
var toBigInt11 = (v) => {
|
|
40178
40734
|
if (v === void 0 || v === null) return void 0;
|
|
40179
40735
|
if (typeof v === "bigint") return v;
|
|
40180
40736
|
if (typeof v === "number") return BigInt(v);
|
|
@@ -40198,12 +40754,12 @@ var readerBeetsStS = (entry) => ({
|
|
|
40198
40754
|
],
|
|
40199
40755
|
abis: [TotalSupplyAbi, BeetsStSAbi, BeetsStSAbi],
|
|
40200
40756
|
parse: ([supply, rate, pool]) => {
|
|
40201
|
-
const totalSupply =
|
|
40202
|
-
const exchangeRate =
|
|
40757
|
+
const totalSupply = toBigInt11(supply);
|
|
40758
|
+
const exchangeRate = toBigInt11(rate);
|
|
40203
40759
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40204
40760
|
return void 0;
|
|
40205
40761
|
}
|
|
40206
|
-
const liquidity =
|
|
40762
|
+
const liquidity = toBigInt11(pool);
|
|
40207
40763
|
return {
|
|
40208
40764
|
totalAssets: totalSupply * exchangeRate / ONE_E186,
|
|
40209
40765
|
totalSupply,
|
|
@@ -40244,12 +40800,12 @@ var readerBenqiSavax = (entry) => ({
|
|
|
40244
40800
|
],
|
|
40245
40801
|
abis: [TotalSupplyAbi, BenqiSavaxAbi, BenqiSavaxAbi],
|
|
40246
40802
|
parse: ([supply, rate, totalPooled]) => {
|
|
40247
|
-
const totalSupply =
|
|
40248
|
-
const exchangeRate =
|
|
40803
|
+
const totalSupply = toBigInt11(supply);
|
|
40804
|
+
const exchangeRate = toBigInt11(rate);
|
|
40249
40805
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40250
40806
|
return void 0;
|
|
40251
40807
|
}
|
|
40252
|
-
const totalAssets =
|
|
40808
|
+
const totalAssets = toBigInt11(totalPooled) ?? totalSupply * exchangeRate / ONE_E186;
|
|
40253
40809
|
return {
|
|
40254
40810
|
totalAssets,
|
|
40255
40811
|
totalSupply,
|
|
@@ -40263,7 +40819,7 @@ var readerBgtWrapper1to1 = (entry) => ({
|
|
|
40263
40819
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40264
40820
|
abis: [TotalSupplyAbi],
|
|
40265
40821
|
parse: ([supply]) => {
|
|
40266
|
-
const totalSupply =
|
|
40822
|
+
const totalSupply = toBigInt11(supply);
|
|
40267
40823
|
if (totalSupply === void 0) return void 0;
|
|
40268
40824
|
return {
|
|
40269
40825
|
totalAssets: totalSupply,
|
|
@@ -40292,8 +40848,8 @@ var readerDineroBeraEth = (entry) => ({
|
|
|
40292
40848
|
],
|
|
40293
40849
|
abis: [TotalSupplyAbi, DineroBeraEthAbi],
|
|
40294
40850
|
parse: ([supply, rate]) => {
|
|
40295
|
-
const totalSupply =
|
|
40296
|
-
const exchangeRate =
|
|
40851
|
+
const totalSupply = toBigInt11(supply);
|
|
40852
|
+
const exchangeRate = toBigInt11(rate);
|
|
40297
40853
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40298
40854
|
return void 0;
|
|
40299
40855
|
}
|
|
@@ -40314,9 +40870,9 @@ var readerErc4626 = (entry) => ({
|
|
|
40314
40870
|
],
|
|
40315
40871
|
abis: [Erc4626ReadAbi, TotalSupplyAbi, Erc4626ReadAbi],
|
|
40316
40872
|
parse: ([assets, supply, rate]) => {
|
|
40317
|
-
const totalAssets =
|
|
40318
|
-
const totalSupply =
|
|
40319
|
-
const exchangeRate =
|
|
40873
|
+
const totalAssets = toBigInt11(assets);
|
|
40874
|
+
const totalSupply = toBigInt11(supply);
|
|
40875
|
+
const exchangeRate = toBigInt11(rate);
|
|
40320
40876
|
if (totalAssets === void 0 || totalSupply === void 0 || exchangeRate === void 0) {
|
|
40321
40877
|
return void 0;
|
|
40322
40878
|
}
|
|
@@ -40331,9 +40887,9 @@ var readerErc4626PreviewRedeem = (entry) => ({
|
|
|
40331
40887
|
],
|
|
40332
40888
|
abis: [Erc4626PreviewRedeemAbi, TotalSupplyAbi, Erc4626PreviewRedeemAbi],
|
|
40333
40889
|
parse: ([assets, supply, rate]) => {
|
|
40334
|
-
const totalAssets =
|
|
40335
|
-
const totalSupply =
|
|
40336
|
-
const exchangeRate =
|
|
40890
|
+
const totalAssets = toBigInt11(assets);
|
|
40891
|
+
const totalSupply = toBigInt11(supply);
|
|
40892
|
+
const exchangeRate = toBigInt11(rate);
|
|
40337
40893
|
if (totalAssets === void 0 || totalSupply === void 0 || exchangeRate === void 0) {
|
|
40338
40894
|
return void 0;
|
|
40339
40895
|
}
|
|
@@ -40393,15 +40949,15 @@ var readerEtherFiWeEth = (entry) => {
|
|
|
40393
40949
|
calls,
|
|
40394
40950
|
abis,
|
|
40395
40951
|
parse: (slice) => {
|
|
40396
|
-
const totalSupply =
|
|
40397
|
-
const exchangeRate =
|
|
40952
|
+
const totalSupply = toBigInt11(slice[0]);
|
|
40953
|
+
const exchangeRate = toBigInt11(slice[1]);
|
|
40398
40954
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40399
40955
|
return void 0;
|
|
40400
40956
|
}
|
|
40401
40957
|
let liquidity;
|
|
40402
40958
|
if (lp) {
|
|
40403
|
-
const lpBalance =
|
|
40404
|
-
const locked =
|
|
40959
|
+
const lpBalance = toBigInt11(slice[2]);
|
|
40960
|
+
const locked = toBigInt11(slice[3]);
|
|
40405
40961
|
if (lpBalance !== void 0 && locked !== void 0) {
|
|
40406
40962
|
liquidity = lpBalance > locked ? lpBalance - locked : 0n;
|
|
40407
40963
|
}
|
|
@@ -40435,7 +40991,7 @@ var readerHyperbeatBeHype = (entry) => {
|
|
|
40435
40991
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40436
40992
|
abis: [TotalSupplyAbi],
|
|
40437
40993
|
parse: ([supply]) => {
|
|
40438
|
-
const totalSupply =
|
|
40994
|
+
const totalSupply = toBigInt11(supply);
|
|
40439
40995
|
if (totalSupply === void 0) return void 0;
|
|
40440
40996
|
return {
|
|
40441
40997
|
totalAssets: totalSupply,
|
|
@@ -40452,8 +41008,8 @@ var readerHyperbeatBeHype = (entry) => {
|
|
|
40452
41008
|
],
|
|
40453
41009
|
abis: [TotalSupplyAbi, HyperbeatStakingCoreAbi],
|
|
40454
41010
|
parse: ([supply, rate]) => {
|
|
40455
|
-
const totalSupply =
|
|
40456
|
-
const exchangeRate =
|
|
41011
|
+
const totalSupply = toBigInt11(supply);
|
|
41012
|
+
const exchangeRate = toBigInt11(rate);
|
|
40457
41013
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40458
41014
|
return void 0;
|
|
40459
41015
|
}
|
|
@@ -40485,7 +41041,7 @@ var readerKelpRsEth = (entry) => {
|
|
|
40485
41041
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40486
41042
|
abis: [TotalSupplyAbi],
|
|
40487
41043
|
parse: ([supply]) => {
|
|
40488
|
-
const totalSupply =
|
|
41044
|
+
const totalSupply = toBigInt11(supply);
|
|
40489
41045
|
if (totalSupply === void 0) return void 0;
|
|
40490
41046
|
return {
|
|
40491
41047
|
totalAssets: totalSupply,
|
|
@@ -40502,8 +41058,8 @@ var readerKelpRsEth = (entry) => {
|
|
|
40502
41058
|
],
|
|
40503
41059
|
abis: [TotalSupplyAbi, KelpLrtOracleAbi],
|
|
40504
41060
|
parse: ([supply, rate]) => {
|
|
40505
|
-
const totalSupply =
|
|
40506
|
-
const exchangeRate =
|
|
41061
|
+
const totalSupply = toBigInt11(supply);
|
|
41062
|
+
const exchangeRate = toBigInt11(rate);
|
|
40507
41063
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40508
41064
|
return void 0;
|
|
40509
41065
|
}
|
|
@@ -40535,7 +41091,7 @@ var readerKinetiqKHype = (entry) => {
|
|
|
40535
41091
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40536
41092
|
abis: [TotalSupplyAbi],
|
|
40537
41093
|
parse: ([supply]) => {
|
|
40538
|
-
const totalSupply =
|
|
41094
|
+
const totalSupply = toBigInt11(supply);
|
|
40539
41095
|
if (totalSupply === void 0) return void 0;
|
|
40540
41096
|
return {
|
|
40541
41097
|
totalAssets: totalSupply,
|
|
@@ -40552,8 +41108,8 @@ var readerKinetiqKHype = (entry) => {
|
|
|
40552
41108
|
],
|
|
40553
41109
|
abis: [TotalSupplyAbi, KinetiqStakingAccountantAbi],
|
|
40554
41110
|
parse: ([supply, rate]) => {
|
|
40555
|
-
const totalSupply =
|
|
40556
|
-
const exchangeRate =
|
|
41111
|
+
const totalSupply = toBigInt11(supply);
|
|
41112
|
+
const exchangeRate = toBigInt11(rate);
|
|
40557
41113
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40558
41114
|
return void 0;
|
|
40559
41115
|
}
|
|
@@ -40593,12 +41149,12 @@ var readerLairStKaia = (entry) => ({
|
|
|
40593
41149
|
],
|
|
40594
41150
|
abis: [TotalSupplyAbi, LairStKaiaAbi, LairStKaiaAbi],
|
|
40595
41151
|
parse: ([supply, rate, totalStaking]) => {
|
|
40596
|
-
const totalSupply =
|
|
40597
|
-
const exchangeRate =
|
|
41152
|
+
const totalSupply = toBigInt11(supply);
|
|
41153
|
+
const exchangeRate = toBigInt11(rate);
|
|
40598
41154
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40599
41155
|
return void 0;
|
|
40600
41156
|
}
|
|
40601
|
-
const totalAssets =
|
|
41157
|
+
const totalAssets = toBigInt11(totalStaking) ?? totalSupply * exchangeRate / ONE_E186;
|
|
40602
41158
|
return {
|
|
40603
41159
|
totalAssets,
|
|
40604
41160
|
totalSupply,
|
|
@@ -40626,8 +41182,8 @@ var readerLidoWstEth = (entry) => ({
|
|
|
40626
41182
|
],
|
|
40627
41183
|
abis: [TotalSupplyAbi, LidoWstEthAbi],
|
|
40628
41184
|
parse: ([supply, rate]) => {
|
|
40629
|
-
const totalSupply =
|
|
40630
|
-
const exchangeRate =
|
|
41185
|
+
const totalSupply = toBigInt11(supply);
|
|
41186
|
+
const exchangeRate = toBigInt11(rate);
|
|
40631
41187
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40632
41188
|
return void 0;
|
|
40633
41189
|
}
|
|
@@ -40665,7 +41221,7 @@ var readerListaSlisBnb = (entry) => {
|
|
|
40665
41221
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40666
41222
|
abis: [TotalSupplyAbi],
|
|
40667
41223
|
parse: ([supply]) => {
|
|
40668
|
-
const totalSupply =
|
|
41224
|
+
const totalSupply = toBigInt11(supply);
|
|
40669
41225
|
if (totalSupply === void 0) return void 0;
|
|
40670
41226
|
return {
|
|
40671
41227
|
totalAssets: totalSupply,
|
|
@@ -40683,12 +41239,12 @@ var readerListaSlisBnb = (entry) => {
|
|
|
40683
41239
|
],
|
|
40684
41240
|
abis: [TotalSupplyAbi, ListaStakeManagerReadAbi, ListaStakeManagerReadAbi],
|
|
40685
41241
|
parse: ([supply, rate, pooled]) => {
|
|
40686
|
-
const totalSupply =
|
|
40687
|
-
const exchangeRate =
|
|
41242
|
+
const totalSupply = toBigInt11(supply);
|
|
41243
|
+
const exchangeRate = toBigInt11(rate);
|
|
40688
41244
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40689
41245
|
return void 0;
|
|
40690
41246
|
}
|
|
40691
|
-
const pooledBnb =
|
|
41247
|
+
const pooledBnb = toBigInt11(pooled);
|
|
40692
41248
|
const totalAssets = pooledBnb ?? totalSupply * exchangeRate / ONE_E186;
|
|
40693
41249
|
return { totalAssets, totalSupply, exchangeRate };
|
|
40694
41250
|
}
|
|
@@ -40714,7 +41270,7 @@ var readerMantleMEth = (entry) => {
|
|
|
40714
41270
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40715
41271
|
abis: [TotalSupplyAbi],
|
|
40716
41272
|
parse: ([supply]) => {
|
|
40717
|
-
const totalSupply =
|
|
41273
|
+
const totalSupply = toBigInt11(supply);
|
|
40718
41274
|
if (totalSupply === void 0) return void 0;
|
|
40719
41275
|
return {
|
|
40720
41276
|
totalAssets: totalSupply,
|
|
@@ -40731,8 +41287,8 @@ var readerMantleMEth = (entry) => {
|
|
|
40731
41287
|
],
|
|
40732
41288
|
abis: [TotalSupplyAbi, MantleStakingAbi],
|
|
40733
41289
|
parse: ([supply, rate]) => {
|
|
40734
|
-
const totalSupply =
|
|
40735
|
-
const exchangeRate =
|
|
41290
|
+
const totalSupply = toBigInt11(supply);
|
|
41291
|
+
const exchangeRate = toBigInt11(rate);
|
|
40736
41292
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40737
41293
|
return void 0;
|
|
40738
41294
|
}
|
|
@@ -40753,7 +41309,7 @@ var readerOffChain = (entry) => {
|
|
|
40753
41309
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40754
41310
|
abis: [TotalSupplyAbi],
|
|
40755
41311
|
parse: ([supply]) => {
|
|
40756
|
-
const totalSupply =
|
|
41312
|
+
const totalSupply = toBigInt11(supply);
|
|
40757
41313
|
if (totalSupply === void 0) return void 0;
|
|
40758
41314
|
return {
|
|
40759
41315
|
totalAssets: rescaleDecimals(totalSupply, shareDec, underlyingDec),
|
|
@@ -40787,7 +41343,7 @@ var readerRenzoEzEth = (entry) => {
|
|
|
40787
41343
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40788
41344
|
abis: [TotalSupplyAbi],
|
|
40789
41345
|
parse: ([supply]) => {
|
|
40790
|
-
const totalSupply =
|
|
41346
|
+
const totalSupply = toBigInt11(supply);
|
|
40791
41347
|
if (totalSupply === void 0) return void 0;
|
|
40792
41348
|
return {
|
|
40793
41349
|
totalAssets: totalSupply,
|
|
@@ -40804,9 +41360,9 @@ var readerRenzoEzEth = (entry) => {
|
|
|
40804
41360
|
],
|
|
40805
41361
|
abis: [TotalSupplyAbi, RenzoRestakeManagerAbi],
|
|
40806
41362
|
parse: ([supply, tvls]) => {
|
|
40807
|
-
const totalSupply =
|
|
41363
|
+
const totalSupply = toBigInt11(supply);
|
|
40808
41364
|
if (totalSupply === void 0 || totalSupply === 0n) return void 0;
|
|
40809
|
-
const totalTvl = Array.isArray(tvls) && tvls.length >= 3 ?
|
|
41365
|
+
const totalTvl = Array.isArray(tvls) && tvls.length >= 3 ? toBigInt11(tvls[2]) : void 0;
|
|
40810
41366
|
if (totalTvl === void 0) return void 0;
|
|
40811
41367
|
return {
|
|
40812
41368
|
totalAssets: totalTvl,
|
|
@@ -40860,12 +41416,12 @@ var readerRocketReth = (entry) => {
|
|
|
40860
41416
|
calls,
|
|
40861
41417
|
abis,
|
|
40862
41418
|
parse: (slice) => {
|
|
40863
|
-
const totalSupply =
|
|
40864
|
-
const exchangeRate =
|
|
41419
|
+
const totalSupply = toBigInt11(slice[0]);
|
|
41420
|
+
const exchangeRate = toBigInt11(slice[1]);
|
|
40865
41421
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40866
41422
|
return void 0;
|
|
40867
41423
|
}
|
|
40868
|
-
const liquidity = depositPool ?
|
|
41424
|
+
const liquidity = depositPool ? toBigInt11(slice[2]) : void 0;
|
|
40869
41425
|
return {
|
|
40870
41426
|
totalAssets: totalSupply * exchangeRate / ONE_E186,
|
|
40871
41427
|
totalSupply,
|
|
@@ -40904,7 +41460,7 @@ var readerStaderEthx = (entry) => {
|
|
|
40904
41460
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40905
41461
|
abis: [TotalSupplyAbi],
|
|
40906
41462
|
parse: ([supply]) => {
|
|
40907
|
-
const totalSupply =
|
|
41463
|
+
const totalSupply = toBigInt11(supply);
|
|
40908
41464
|
if (totalSupply === void 0) return void 0;
|
|
40909
41465
|
return {
|
|
40910
41466
|
totalAssets: totalSupply,
|
|
@@ -40921,8 +41477,8 @@ var readerStaderEthx = (entry) => {
|
|
|
40921
41477
|
],
|
|
40922
41478
|
abis: [TotalSupplyAbi, StaderEthxAbi],
|
|
40923
41479
|
parse: ([supply, rate]) => {
|
|
40924
|
-
const totalSupply =
|
|
40925
|
-
const exchangeRate =
|
|
41480
|
+
const totalSupply = toBigInt11(supply);
|
|
41481
|
+
const exchangeRate = toBigInt11(rate);
|
|
40926
41482
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
40927
41483
|
return void 0;
|
|
40928
41484
|
}
|
|
@@ -40950,10 +41506,10 @@ var readerStaderMaticX = (entry) => {
|
|
|
40950
41506
|
],
|
|
40951
41507
|
abis: [TotalSupplyAbi, StaderMaticXAbi],
|
|
40952
41508
|
parse: ([supply, tup]) => {
|
|
40953
|
-
const totalSupply =
|
|
41509
|
+
const totalSupply = toBigInt11(supply);
|
|
40954
41510
|
if (!Array.isArray(tup) || tup.length < 3) return void 0;
|
|
40955
|
-
const amountInMatic =
|
|
40956
|
-
const totalPooledMatic =
|
|
41511
|
+
const amountInMatic = toBigInt11(tup[0]);
|
|
41512
|
+
const totalPooledMatic = toBigInt11(tup[2]);
|
|
40957
41513
|
if (totalSupply === void 0 || amountInMatic === void 0) {
|
|
40958
41514
|
return void 0;
|
|
40959
41515
|
}
|
|
@@ -40986,7 +41542,7 @@ var readerStakeWiseOsEth = (entry) => {
|
|
|
40986
41542
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
40987
41543
|
abis: [TotalSupplyAbi],
|
|
40988
41544
|
parse: ([supply]) => {
|
|
40989
|
-
const totalSupply =
|
|
41545
|
+
const totalSupply = toBigInt11(supply);
|
|
40990
41546
|
if (totalSupply === void 0) return void 0;
|
|
40991
41547
|
return {
|
|
40992
41548
|
totalAssets: totalSupply,
|
|
@@ -41003,8 +41559,8 @@ var readerStakeWiseOsEth = (entry) => {
|
|
|
41003
41559
|
],
|
|
41004
41560
|
abis: [TotalSupplyAbi, StakeWiseOsTokenAbi],
|
|
41005
41561
|
parse: ([supply, rate]) => {
|
|
41006
|
-
const totalSupply =
|
|
41007
|
-
const exchangeRate =
|
|
41562
|
+
const totalSupply = toBigInt11(supply);
|
|
41563
|
+
const exchangeRate = toBigInt11(rate);
|
|
41008
41564
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
41009
41565
|
return void 0;
|
|
41010
41566
|
}
|
|
@@ -41036,7 +41592,7 @@ var readerStCelo = (entry) => {
|
|
|
41036
41592
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
41037
41593
|
abis: [TotalSupplyAbi],
|
|
41038
41594
|
parse: ([supply]) => {
|
|
41039
|
-
const totalSupply =
|
|
41595
|
+
const totalSupply = toBigInt11(supply);
|
|
41040
41596
|
if (totalSupply === void 0) return void 0;
|
|
41041
41597
|
return {
|
|
41042
41598
|
totalAssets: totalSupply,
|
|
@@ -41053,8 +41609,8 @@ var readerStCelo = (entry) => {
|
|
|
41053
41609
|
],
|
|
41054
41610
|
abis: [TotalSupplyAbi, StCeloManagerAbi],
|
|
41055
41611
|
parse: ([supply, rate]) => {
|
|
41056
|
-
const totalSupply =
|
|
41057
|
-
const exchangeRate =
|
|
41612
|
+
const totalSupply = toBigInt11(supply);
|
|
41613
|
+
const exchangeRate = toBigInt11(rate);
|
|
41058
41614
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
41059
41615
|
return void 0;
|
|
41060
41616
|
}
|
|
@@ -41086,8 +41642,8 @@ var readerSwellGetRate = (entry) => ({
|
|
|
41086
41642
|
],
|
|
41087
41643
|
abis: [TotalSupplyAbi, SwellGetRateAbi],
|
|
41088
41644
|
parse: ([supply, rate]) => {
|
|
41089
|
-
const totalSupply =
|
|
41090
|
-
const exchangeRate =
|
|
41645
|
+
const totalSupply = toBigInt11(supply);
|
|
41646
|
+
const exchangeRate = toBigInt11(rate);
|
|
41091
41647
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
41092
41648
|
return void 0;
|
|
41093
41649
|
}
|
|
@@ -41118,7 +41674,7 @@ var readerValantisWstHype = (entry) => {
|
|
|
41118
41674
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
41119
41675
|
abis: [TotalSupplyAbi],
|
|
41120
41676
|
parse: ([supply]) => {
|
|
41121
|
-
const totalSupply =
|
|
41677
|
+
const totalSupply = toBigInt11(supply);
|
|
41122
41678
|
if (totalSupply === void 0) return void 0;
|
|
41123
41679
|
return {
|
|
41124
41680
|
totalAssets: totalSupply,
|
|
@@ -41135,8 +41691,8 @@ var readerValantisWstHype = (entry) => {
|
|
|
41135
41691
|
],
|
|
41136
41692
|
abis: [TotalSupplyAbi, ValantisStHypeAbi],
|
|
41137
41693
|
parse: ([supply, rate]) => {
|
|
41138
|
-
const totalSupply =
|
|
41139
|
-
const exchangeRate =
|
|
41694
|
+
const totalSupply = toBigInt11(supply);
|
|
41695
|
+
const exchangeRate = toBigInt11(rate);
|
|
41140
41696
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
41141
41697
|
return void 0;
|
|
41142
41698
|
}
|
|
@@ -41170,7 +41726,7 @@ var readerVedaAccountant = (entry) => {
|
|
|
41170
41726
|
calls: [{ address: entry.address, name: "totalSupply", params: [] }],
|
|
41171
41727
|
abis: [TotalSupplyAbi],
|
|
41172
41728
|
parse: ([supply]) => {
|
|
41173
|
-
const totalSupply =
|
|
41729
|
+
const totalSupply = toBigInt11(supply);
|
|
41174
41730
|
if (totalSupply === void 0) return void 0;
|
|
41175
41731
|
return {
|
|
41176
41732
|
totalAssets: rescaleDecimals(totalSupply, shareDec, underlyingDec),
|
|
@@ -41188,8 +41744,8 @@ var readerVedaAccountant = (entry) => {
|
|
|
41188
41744
|
],
|
|
41189
41745
|
abis: [TotalSupplyAbi, VedaAccountantGetRateAbi],
|
|
41190
41746
|
parse: ([supply, rate]) => {
|
|
41191
|
-
const totalSupply =
|
|
41192
|
-
const rawRate =
|
|
41747
|
+
const totalSupply = toBigInt11(supply);
|
|
41748
|
+
const rawRate = toBigInt11(rate);
|
|
41193
41749
|
if (totalSupply === void 0 || rawRate === void 0) return void 0;
|
|
41194
41750
|
const exchangeRate = rawRate * scale;
|
|
41195
41751
|
return {
|
|
@@ -41224,8 +41780,8 @@ var readerAnkrRatio = (entry) => ({
|
|
|
41224
41780
|
],
|
|
41225
41781
|
abis: [TotalSupplyAbi, AnkrRatioAbi],
|
|
41226
41782
|
parse: ([supply, ratio]) => {
|
|
41227
|
-
const totalSupply =
|
|
41228
|
-
const r =
|
|
41783
|
+
const totalSupply = toBigInt11(supply);
|
|
41784
|
+
const r = toBigInt11(ratio);
|
|
41229
41785
|
if (totalSupply === void 0 || r === void 0 || r === 0n) {
|
|
41230
41786
|
return void 0;
|
|
41231
41787
|
}
|
|
@@ -41268,8 +41824,8 @@ var readerCoreEarnRate = (entry) => {
|
|
|
41268
41824
|
],
|
|
41269
41825
|
abis: [CoreEarnRateAbi, TotalSupplyAbi],
|
|
41270
41826
|
parse: ([rate, supply]) => {
|
|
41271
|
-
const r =
|
|
41272
|
-
const totalSupply =
|
|
41827
|
+
const r = toBigInt11(rate);
|
|
41828
|
+
const totalSupply = toBigInt11(supply);
|
|
41273
41829
|
if (r === void 0 || r === 0n || totalSupply === void 0) {
|
|
41274
41830
|
return void 0;
|
|
41275
41831
|
}
|
|
@@ -41290,8 +41846,8 @@ var readerCoreStakedRatio = (entry) => {
|
|
|
41290
41846
|
],
|
|
41291
41847
|
abis: [CoreTotalStakedAbi, TotalSupplyAbi],
|
|
41292
41848
|
parse: ([staked, supply]) => {
|
|
41293
|
-
const totalStaked =
|
|
41294
|
-
const totalSupply =
|
|
41849
|
+
const totalStaked = toBigInt11(staked);
|
|
41850
|
+
const totalSupply = toBigInt11(supply);
|
|
41295
41851
|
if (totalStaked === void 0 || totalSupply === void 0 || totalSupply === 0n) {
|
|
41296
41852
|
return void 0;
|
|
41297
41853
|
}
|
|
@@ -41335,12 +41891,12 @@ var readerStellaStDot = (entry) => ({
|
|
|
41335
41891
|
],
|
|
41336
41892
|
abis: [TotalSupplyAbi, StellaStDotAbi, StellaStDotAbi],
|
|
41337
41893
|
parse: ([supply, rate, pooled]) => {
|
|
41338
|
-
const totalSupply =
|
|
41339
|
-
const exchangeRate =
|
|
41894
|
+
const totalSupply = toBigInt11(supply);
|
|
41895
|
+
const exchangeRate = toBigInt11(rate);
|
|
41340
41896
|
if (totalSupply === void 0 || exchangeRate === void 0) {
|
|
41341
41897
|
return void 0;
|
|
41342
41898
|
}
|
|
41343
|
-
const totalAssets =
|
|
41899
|
+
const totalAssets = toBigInt11(pooled) ?? totalSupply * exchangeRate / ONE_E186;
|
|
41344
41900
|
return {
|
|
41345
41901
|
totalAssets,
|
|
41346
41902
|
totalSupply,
|
|
@@ -41375,8 +41931,8 @@ var readerKintsuSMon = (entry) => ({
|
|
|
41375
41931
|
],
|
|
41376
41932
|
abis: [KintsuSMonAbi, KintsuSMonAbi],
|
|
41377
41933
|
parse: ([pooled, shares]) => {
|
|
41378
|
-
const totalAssets =
|
|
41379
|
-
const totalSupply =
|
|
41934
|
+
const totalAssets = toBigInt11(pooled);
|
|
41935
|
+
const totalSupply = toBigInt11(shares);
|
|
41380
41936
|
if (totalAssets === void 0 || totalSupply === void 0) return void 0;
|
|
41381
41937
|
const exchangeRate = totalSupply > 0n ? totalAssets * ONE_E186 / totalSupply : ONE_E186;
|
|
41382
41938
|
return { totalAssets, totalSupply, exchangeRate };
|
|
@@ -41893,7 +42449,7 @@ var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList
|
|
|
41893
42449
|
const validatorsByAddress = new Map(validatorEntries);
|
|
41894
42450
|
const idleByAddress = /* @__PURE__ */ new Map();
|
|
41895
42451
|
idleEntries.forEach((e, i) => {
|
|
41896
|
-
const bal =
|
|
42452
|
+
const bal = toBigInt11(idleResults[i]);
|
|
41897
42453
|
if (bal !== void 0) idleByAddress.set(e.address.toLowerCase(), bal);
|
|
41898
42454
|
});
|
|
41899
42455
|
const rawResults = new Array(allCalls.length);
|
|
@@ -42023,7 +42579,7 @@ var BeetsStSWithdrawalAbi = [
|
|
|
42023
42579
|
];
|
|
42024
42580
|
|
|
42025
42581
|
// src/vaults/lst/withdrawals/readers/shared.ts
|
|
42026
|
-
var
|
|
42582
|
+
var toBigInt12 = (v) => {
|
|
42027
42583
|
if (v === void 0 || v === null) return void 0;
|
|
42028
42584
|
if (typeof v === "bigint") return v;
|
|
42029
42585
|
if (typeof v === "number") return BigInt(v);
|
|
@@ -42038,7 +42594,7 @@ var toBigInt11 = (v) => {
|
|
|
42038
42594
|
return void 0;
|
|
42039
42595
|
};
|
|
42040
42596
|
var toNumber = (v) => {
|
|
42041
|
-
const b =
|
|
42597
|
+
const b = toBigInt12(v);
|
|
42042
42598
|
if (b === void 0) return void 0;
|
|
42043
42599
|
if (b > BigInt(Number.MAX_SAFE_INTEGER)) return void 0;
|
|
42044
42600
|
return Number(b);
|
|
@@ -42075,7 +42631,7 @@ var readerBeets = {
|
|
|
42075
42631
|
const out = [];
|
|
42076
42632
|
for (let i = 0; i < reqs.length; i++) {
|
|
42077
42633
|
const r = reqs[i];
|
|
42078
|
-
const amount =
|
|
42634
|
+
const amount = toBigInt12(r.assetAmount);
|
|
42079
42635
|
const ts = toNumber(r.requestTimestamp);
|
|
42080
42636
|
const isWithdrawn = Boolean(r.isWithdrawn);
|
|
42081
42637
|
if (amount === void 0 || ts === void 0) continue;
|
|
@@ -42167,13 +42723,13 @@ var readerBeHype = {
|
|
|
42167
42723
|
const q = stage2[i * 2];
|
|
42168
42724
|
const canClaim = Boolean(stage2[i * 2 + 1]);
|
|
42169
42725
|
if (!q) continue;
|
|
42170
|
-
const hypeAmount = Array.isArray(q) ?
|
|
42726
|
+
const hypeAmount = Array.isArray(q) ? toBigInt12(q[2]) : toBigInt12(q.hypeAmount);
|
|
42171
42727
|
if (hypeAmount === void 0) continue;
|
|
42172
42728
|
out.push({
|
|
42173
42729
|
lst: entry.lst,
|
|
42174
42730
|
brand: entry.brand,
|
|
42175
42731
|
symbol: entry.symbol,
|
|
42176
|
-
requestId: String(
|
|
42732
|
+
requestId: String(toBigInt12(ids[i]) ?? i),
|
|
42177
42733
|
amountUnderlying: hypeAmount.toString(),
|
|
42178
42734
|
status: canClaim ? "claimable" : "pending"
|
|
42179
42735
|
});
|
|
@@ -42276,7 +42832,7 @@ var readerBenqi = {
|
|
|
42276
42832
|
for (let i = 0; i < reqs.length; i++) {
|
|
42277
42833
|
const r = reqs[i];
|
|
42278
42834
|
const startedAt = toNumber(r.startedAt);
|
|
42279
|
-
const shareAmount =
|
|
42835
|
+
const shareAmount = toBigInt12(r.shareAmount);
|
|
42280
42836
|
if (startedAt === void 0 || shareAmount === void 0) continue;
|
|
42281
42837
|
const readyAt = startedAt + cooldown;
|
|
42282
42838
|
const expiresAt = readyAt + claimWindow;
|
|
@@ -42339,8 +42895,8 @@ var readerBeraPaw = {
|
|
|
42339
42895
|
}
|
|
42340
42896
|
const pos = res[0];
|
|
42341
42897
|
if (!pos) return [];
|
|
42342
|
-
const queued = Array.isArray(pos) ?
|
|
42343
|
-
const available = Array.isArray(pos) ?
|
|
42898
|
+
const queued = Array.isArray(pos) ? toBigInt12(pos[0]) : toBigInt12(pos.queued);
|
|
42899
|
+
const available = Array.isArray(pos) ? toBigInt12(pos[1]) : toBigInt12(pos.available);
|
|
42344
42900
|
const out = [];
|
|
42345
42901
|
if (available !== void 0 && available > 0n) {
|
|
42346
42902
|
out.push({
|
|
@@ -42422,7 +42978,7 @@ var readerIbera = {
|
|
|
42422
42978
|
return [];
|
|
42423
42979
|
}
|
|
42424
42980
|
const length = toNumber(stage1[0]) ?? 0;
|
|
42425
|
-
const frontier =
|
|
42981
|
+
const frontier = toBigInt12(stage1[1]) ?? 0n;
|
|
42426
42982
|
if (length === 0) return [];
|
|
42427
42983
|
const start = length > MAX_SCAN ? length - MAX_SCAN : 0;
|
|
42428
42984
|
const ids = Array.from({ length: length - start }, (_3, k) => start + k);
|
|
@@ -42446,7 +43002,7 @@ var readerIbera = {
|
|
|
42446
43002
|
const r = stage2[k];
|
|
42447
43003
|
if (!r) continue;
|
|
42448
43004
|
const receiver = Array.isArray(r) ? r[2] : r.receiver;
|
|
42449
|
-
const amount = Array.isArray(r) ?
|
|
43005
|
+
const amount = Array.isArray(r) ? toBigInt12(r[3]) : toBigInt12(r.amount);
|
|
42450
43006
|
if (typeof receiver !== "string" || receiver.toLowerCase() !== target || amount === void 0 || amount === 0n) {
|
|
42451
43007
|
continue;
|
|
42452
43008
|
}
|
|
@@ -42519,7 +43075,7 @@ var readerPrimeStaking = {
|
|
|
42519
43075
|
return [];
|
|
42520
43076
|
}
|
|
42521
43077
|
const length = toNumber(stage1[0]) ?? 0;
|
|
42522
|
-
const frontier =
|
|
43078
|
+
const frontier = toBigInt12(stage1[1]) ?? 0n;
|
|
42523
43079
|
if (length === 0) return [];
|
|
42524
43080
|
const start = length > MAX_SCAN2 ? length - MAX_SCAN2 : 0;
|
|
42525
43081
|
const ids = Array.from({ length: length - start }, (_3, k) => start + k);
|
|
@@ -42543,7 +43099,7 @@ var readerPrimeStaking = {
|
|
|
42543
43099
|
const r = stage2[k];
|
|
42544
43100
|
if (!r) continue;
|
|
42545
43101
|
const receiver = Array.isArray(r) ? r[1] : r.receiver;
|
|
42546
|
-
const assets = Array.isArray(r) ?
|
|
43102
|
+
const assets = Array.isArray(r) ? toBigInt12(r[3]) : toBigInt12(r.assets);
|
|
42547
43103
|
const processed = Array.isArray(r) ? r[4] : r.processed;
|
|
42548
43104
|
if (typeof receiver !== "string" || receiver.toLowerCase() !== target || assets === void 0 || assets === 0n) {
|
|
42549
43105
|
continue;
|
|
@@ -42613,8 +43169,8 @@ var readerErc7540 = {
|
|
|
42613
43169
|
],
|
|
42614
43170
|
abi: [Erc7540Abi, Erc7540Abi]
|
|
42615
43171
|
});
|
|
42616
|
-
const pending =
|
|
42617
|
-
const claimable =
|
|
43172
|
+
const pending = toBigInt12(stage1[0]) ?? 0n;
|
|
43173
|
+
const claimable = toBigInt12(stage1[1]) ?? 0n;
|
|
42618
43174
|
const out = [];
|
|
42619
43175
|
if (claimable > 0n) {
|
|
42620
43176
|
const stage2 = await multicallRetry({
|
|
@@ -42628,7 +43184,7 @@ var readerErc7540 = {
|
|
|
42628
43184
|
],
|
|
42629
43185
|
abi: [Erc7540Abi]
|
|
42630
43186
|
});
|
|
42631
|
-
const amount =
|
|
43187
|
+
const amount = toBigInt12(stage2[0]) ?? claimable;
|
|
42632
43188
|
out.push({
|
|
42633
43189
|
lst: entry.lst,
|
|
42634
43190
|
brand: entry.brand,
|
|
@@ -42682,11 +43238,11 @@ var readerEthenaCooldown = {
|
|
|
42682
43238
|
let cooldownEnd;
|
|
42683
43239
|
let amount;
|
|
42684
43240
|
if (Array.isArray(cell)) {
|
|
42685
|
-
cooldownEnd =
|
|
42686
|
-
amount =
|
|
43241
|
+
cooldownEnd = toBigInt12(cell[0]);
|
|
43242
|
+
amount = toBigInt12(cell[1]);
|
|
42687
43243
|
} else if (cell && typeof cell === "object") {
|
|
42688
|
-
cooldownEnd =
|
|
42689
|
-
amount =
|
|
43244
|
+
cooldownEnd = toBigInt12(cell.cooldownEnd);
|
|
43245
|
+
amount = toBigInt12(cell.underlyingAmount);
|
|
42690
43246
|
}
|
|
42691
43247
|
if (!amount || amount === 0n) return [];
|
|
42692
43248
|
const readyAt = Number(cooldownEnd ?? 0n);
|
|
@@ -42781,7 +43337,7 @@ var readerEtherFi = {
|
|
|
42781
43337
|
calls: enumCalls,
|
|
42782
43338
|
abi: enumCalls.map(() => EtherFiWithdrawRequestAbi)
|
|
42783
43339
|
});
|
|
42784
|
-
const ids = stage2.map(
|
|
43340
|
+
const ids = stage2.map(toBigInt12).filter((v) => v !== void 0);
|
|
42785
43341
|
if (ids.length === 0) return [];
|
|
42786
43342
|
const detailCalls = ids.flatMap((id) => [
|
|
42787
43343
|
{ address: entry.withdrawalContract, name: "getRequest", params: [id] },
|
|
@@ -42801,7 +43357,7 @@ var readerEtherFi = {
|
|
|
42801
43357
|
const isValid = Boolean(stage3[i * 3 + 2]);
|
|
42802
43358
|
if (!req) continue;
|
|
42803
43359
|
if (!isValid) continue;
|
|
42804
|
-
const amount =
|
|
43360
|
+
const amount = toBigInt12(req.amountOfEEth);
|
|
42805
43361
|
if (amount === void 0) continue;
|
|
42806
43362
|
out.push({
|
|
42807
43363
|
lst: entry.lst,
|
|
@@ -42896,7 +43452,7 @@ var readerKelp = {
|
|
|
42896
43452
|
}
|
|
42897
43453
|
],
|
|
42898
43454
|
abi: [KelpWithdrawalManagerAbi]
|
|
42899
|
-
}).then((res) =>
|
|
43455
|
+
}).then((res) => toBigInt12(res[0]) ?? 0n)
|
|
42900
43456
|
]);
|
|
42901
43457
|
lengths = storageReads;
|
|
42902
43458
|
currentBlock = block;
|
|
@@ -42926,9 +43482,9 @@ var readerKelp = {
|
|
|
42926
43482
|
for (let i = 0; i < detailCalls.length; i++) {
|
|
42927
43483
|
const r = stage2[i];
|
|
42928
43484
|
if (!r) continue;
|
|
42929
|
-
const expected = Array.isArray(r) ?
|
|
42930
|
-
const startBlock = Array.isArray(r) ?
|
|
42931
|
-
const nonce = Array.isArray(r) ?
|
|
43485
|
+
const expected = Array.isArray(r) ? toBigInt12(r[1]) : toBigInt12(r.expectedAssetAmount);
|
|
43486
|
+
const startBlock = Array.isArray(r) ? toBigInt12(r[2]) : toBigInt12(r.withdrawalStartBlock);
|
|
43487
|
+
const nonce = Array.isArray(r) ? toBigInt12(r[3]) : toBigInt12(r.userNonce);
|
|
42932
43488
|
if (expected === void 0 || startBlock === void 0) continue;
|
|
42933
43489
|
const claimable = currentBlock >= startBlock + delayBlocks;
|
|
42934
43490
|
out.push({
|
|
@@ -43005,7 +43561,7 @@ var readerLido = {
|
|
|
43005
43561
|
abi: [LidoWithdrawalQueueAbi, LidoWithdrawalQueueAbi]
|
|
43006
43562
|
});
|
|
43007
43563
|
const ids = stage1[0];
|
|
43008
|
-
const frontier =
|
|
43564
|
+
const frontier = toBigInt12(stage1[1]) ?? 0n;
|
|
43009
43565
|
if (!Array.isArray(ids) || ids.length === 0) return [];
|
|
43010
43566
|
const stage2 = await multicallRetry({
|
|
43011
43567
|
chain: chainId,
|
|
@@ -43022,10 +43578,10 @@ var readerLido = {
|
|
|
43022
43578
|
if (!Array.isArray(statuses)) return [];
|
|
43023
43579
|
const out = [];
|
|
43024
43580
|
for (let i = 0; i < ids.length; i++) {
|
|
43025
|
-
const id =
|
|
43581
|
+
const id = toBigInt12(ids[i]);
|
|
43026
43582
|
const s = statuses[i];
|
|
43027
43583
|
if (id === void 0 || !s) continue;
|
|
43028
|
-
const amountOfStETH =
|
|
43584
|
+
const amountOfStETH = toBigInt12(s.amountOfStETH);
|
|
43029
43585
|
const isFinalized = Boolean(s.isFinalized);
|
|
43030
43586
|
const isClaimed = Boolean(s.isClaimed);
|
|
43031
43587
|
if (amountOfStETH === void 0) continue;
|
|
@@ -43134,11 +43690,11 @@ var readerLista = {
|
|
|
43134
43690
|
const status = stage2[i];
|
|
43135
43691
|
if (!status) continue;
|
|
43136
43692
|
const isClaimable = Array.isArray(status) ? Boolean(status[0]) : Boolean(status._isClaimable);
|
|
43137
|
-
const bnbAmount = Array.isArray(status) ?
|
|
43138
|
-
const snbnbAmount = Array.isArray(req) ?
|
|
43693
|
+
const bnbAmount = Array.isArray(status) ? toBigInt12(status[1]) : toBigInt12(status._amount);
|
|
43694
|
+
const snbnbAmount = Array.isArray(req) ? toBigInt12(req[1]) : toBigInt12(req?.amountInSnBnb);
|
|
43139
43695
|
const amount = bnbAmount ?? snbnbAmount;
|
|
43140
43696
|
if (amount === void 0) continue;
|
|
43141
|
-
const uuid = Array.isArray(req) ?
|
|
43697
|
+
const uuid = Array.isArray(req) ? toBigInt12(req[0]) : toBigInt12(req?.uuid);
|
|
43142
43698
|
out.push({
|
|
43143
43699
|
lst: entry.lst,
|
|
43144
43700
|
brand: entry.brand,
|
|
@@ -43223,7 +43779,7 @@ var readerRenzo = {
|
|
|
43223
43779
|
for (let i = 0; i < count; i++) {
|
|
43224
43780
|
const tup = stage2[i];
|
|
43225
43781
|
if (!Array.isArray(tup) || tup.length < 5) continue;
|
|
43226
|
-
const amountToRedeem =
|
|
43782
|
+
const amountToRedeem = toBigInt12(tup[2]);
|
|
43227
43783
|
const createdAt = toNumber(tup[4]);
|
|
43228
43784
|
if (amountToRedeem === void 0 || createdAt === void 0) continue;
|
|
43229
43785
|
const readyAt = createdAt + cooldown;
|
|
@@ -43296,9 +43852,9 @@ var readerStaderEthx2 = {
|
|
|
43296
43852
|
]
|
|
43297
43853
|
});
|
|
43298
43854
|
const ids = stage1[0];
|
|
43299
|
-
const frontier =
|
|
43855
|
+
const frontier = toBigInt12(stage1[1]) ?? 0n;
|
|
43300
43856
|
if (!Array.isArray(ids) || ids.length === 0) return [];
|
|
43301
|
-
const idBigInts = ids.map(
|
|
43857
|
+
const idBigInts = ids.map(toBigInt12).filter((v) => v !== void 0);
|
|
43302
43858
|
const detailCalls = idBigInts.map((id) => ({
|
|
43303
43859
|
address: entry.withdrawalContract,
|
|
43304
43860
|
name: "userWithdrawRequests",
|
|
@@ -43314,8 +43870,8 @@ var readerStaderEthx2 = {
|
|
|
43314
43870
|
const id = idBigInts[i];
|
|
43315
43871
|
const tup = stage2[i];
|
|
43316
43872
|
if (!Array.isArray(tup) || tup.length < 5) continue;
|
|
43317
|
-
const ethExpected =
|
|
43318
|
-
const ethFinalized =
|
|
43873
|
+
const ethExpected = toBigInt12(tup[2]) ?? 0n;
|
|
43874
|
+
const ethFinalized = toBigInt12(tup[3]) ?? 0n;
|
|
43319
43875
|
const isFinalized = id < frontier && ethFinalized > 0n;
|
|
43320
43876
|
const queuePosition = isFinalized ? 0 : Number(id - frontier);
|
|
43321
43877
|
out.push({
|
|
@@ -43394,13 +43950,13 @@ var readerStaderMaticX2 = {
|
|
|
43394
43950
|
});
|
|
43395
43951
|
const arr = stage1[0];
|
|
43396
43952
|
if (!Array.isArray(arr)) return [];
|
|
43397
|
-
const currentEpoch = stakeManager ?
|
|
43398
|
-
const delay = stakeManager ?
|
|
43953
|
+
const currentEpoch = stakeManager ? toBigInt12(stage1[1]) ?? 0n : 0n;
|
|
43954
|
+
const delay = stakeManager ? toBigInt12(stage1[2]) ?? 0n : 0n;
|
|
43399
43955
|
const out = [];
|
|
43400
43956
|
for (let i = 0; i < arr.length; i++) {
|
|
43401
43957
|
const r = arr[i];
|
|
43402
|
-
const amount =
|
|
43403
|
-
const requestEpoch =
|
|
43958
|
+
const amount = toBigInt12(r.amount) ?? 0n;
|
|
43959
|
+
const requestEpoch = toBigInt12(r.requestEpoch);
|
|
43404
43960
|
if (requestEpoch === void 0) continue;
|
|
43405
43961
|
const ready = stakeManager ? currentEpoch >= requestEpoch + delay : false;
|
|
43406
43962
|
out.push({
|
|
@@ -43487,9 +44043,9 @@ var readerMantle = {
|
|
|
43487
44043
|
if (typeof requester === "string" && requester.toLowerCase() !== lcUser) {
|
|
43488
44044
|
continue;
|
|
43489
44045
|
}
|
|
43490
|
-
const ethRequested = Array.isArray(detail) ?
|
|
44046
|
+
const ethRequested = Array.isArray(detail) ? toBigInt12(detail[3]) : toBigInt12(detail.ethRequested);
|
|
43491
44047
|
const isFinalized = Array.isArray(info) ? Boolean(info[0]) : Boolean(info.isFinalized);
|
|
43492
|
-
const claimable = Array.isArray(info) ?
|
|
44048
|
+
const claimable = Array.isArray(info) ? toBigInt12(info[1]) : toBigInt12(info.claimableAmount);
|
|
43493
44049
|
if (ethRequested === void 0) continue;
|
|
43494
44050
|
out.push({
|
|
43495
44051
|
lst: entry.lst,
|
|
@@ -43568,8 +44124,8 @@ var readerPuffer = {
|
|
|
43568
44124
|
calls,
|
|
43569
44125
|
abi: calls.map(() => PufferWithdrawalManagerAbi)
|
|
43570
44126
|
});
|
|
43571
|
-
const finalizedBatch =
|
|
43572
|
-
const batchSize =
|
|
44127
|
+
const finalizedBatch = toBigInt12(results[detailCalls.length]) ?? 0n;
|
|
44128
|
+
const batchSize = toBigInt12(results[detailCalls.length + 1]) ?? 0n;
|
|
43573
44129
|
const out = [];
|
|
43574
44130
|
const lcUser = user.toLowerCase();
|
|
43575
44131
|
for (let i = 0; i < ids.length; i++) {
|
|
@@ -43579,7 +44135,7 @@ var readerPuffer = {
|
|
|
43579
44135
|
if (typeof recipient === "string" && recipient.toLowerCase() !== lcUser) {
|
|
43580
44136
|
continue;
|
|
43581
44137
|
}
|
|
43582
|
-
const pufETHAmount = Array.isArray(d) ?
|
|
44138
|
+
const pufETHAmount = Array.isArray(d) ? toBigInt12(d[0]) : toBigInt12(d.pufETHAmount);
|
|
43583
44139
|
if (pufETHAmount === void 0) continue;
|
|
43584
44140
|
const batchIdx = batchSize > 0n ? ids[i] / batchSize : 0n;
|
|
43585
44141
|
const claimable = batchIdx <= finalizedBatch;
|
|
@@ -43677,7 +44233,7 @@ var readerKinetiq = {
|
|
|
43677
44233
|
for (let i = 0; i < count; i++) {
|
|
43678
44234
|
const r = stage2[i];
|
|
43679
44235
|
if (!r) continue;
|
|
43680
|
-
const hypeAmount = Array.isArray(r) ?
|
|
44236
|
+
const hypeAmount = Array.isArray(r) ? toBigInt12(r[0]) : toBigInt12(r.hypeAmount);
|
|
43681
44237
|
const timestamp = Array.isArray(r) ? toNumber(r[4]) : toNumber(r.timestamp);
|
|
43682
44238
|
if (hypeAmount === void 0 || hypeAmount === 0n || timestamp === void 0) {
|
|
43683
44239
|
continue;
|
|
@@ -43805,7 +44361,7 @@ var readerStakeWise = {
|
|
|
43805
44361
|
const claimedByIdx = /* @__PURE__ */ new Map();
|
|
43806
44362
|
for (let i = 0; i < onChainChecks.length; i++) {
|
|
43807
44363
|
const cell = checkResults[i];
|
|
43808
|
-
const claimed = Array.isArray(cell) ?
|
|
44364
|
+
const claimed = Array.isArray(cell) ? toBigInt12(cell[2]) : toBigInt12(cell?.claimedAssets);
|
|
43809
44365
|
if (claimed !== void 0 && claimed > 0n) {
|
|
43810
44366
|
claimedByIdx.set(onChainChecks[i].idx, claimed);
|
|
43811
44367
|
}
|
|
@@ -43813,7 +44369,7 @@ var readerStakeWise = {
|
|
|
43813
44369
|
const out = [];
|
|
43814
44370
|
for (let i = 0; i < requests.length; i++) {
|
|
43815
44371
|
const r = requests[i];
|
|
43816
|
-
const amount =
|
|
44372
|
+
const amount = toBigInt12(r.totalAssets) ?? 0n;
|
|
43817
44373
|
const onChainClaimed = claimedByIdx.get(i);
|
|
43818
44374
|
const claimable = onChainClaimed !== void 0 || r.isClaimable;
|
|
43819
44375
|
out.push({
|
|
@@ -43870,7 +44426,7 @@ var readerStCelo2 = {
|
|
|
43870
44426
|
const timestamps = cell[1] ?? [];
|
|
43871
44427
|
const out = [];
|
|
43872
44428
|
for (let i = 0; i < values.length; i++) {
|
|
43873
|
-
const amount =
|
|
44429
|
+
const amount = toBigInt12(values[i]);
|
|
43874
44430
|
const readyAt = toNumber(timestamps[i]);
|
|
43875
44431
|
if (amount === void 0 || readyAt === void 0) continue;
|
|
43876
44432
|
out.push({
|
|
@@ -43915,11 +44471,11 @@ var readerStellaUnbond = {
|
|
|
43915
44471
|
let waiting;
|
|
43916
44472
|
let unbonded;
|
|
43917
44473
|
if (Array.isArray(cell)) {
|
|
43918
|
-
waiting =
|
|
43919
|
-
unbonded =
|
|
44474
|
+
waiting = toBigInt12(cell[0]);
|
|
44475
|
+
unbonded = toBigInt12(cell[1]);
|
|
43920
44476
|
} else if (cell && typeof cell === "object") {
|
|
43921
|
-
waiting =
|
|
43922
|
-
unbonded =
|
|
44477
|
+
waiting = toBigInt12(cell.waiting);
|
|
44478
|
+
unbonded = toBigInt12(cell.unbonded);
|
|
43923
44479
|
}
|
|
43924
44480
|
const out = [];
|
|
43925
44481
|
if (unbonded && unbonded > 0n) {
|
|
@@ -44009,7 +44565,7 @@ var readerSwell = {
|
|
|
44009
44565
|
abi: [SwellRswExitAbi, SwellRswExitAbi]
|
|
44010
44566
|
});
|
|
44011
44567
|
const count = toNumber(stage1[0]) ?? 0;
|
|
44012
|
-
const lastProcessed =
|
|
44568
|
+
const lastProcessed = toBigInt12(stage1[1]) ?? 0n;
|
|
44013
44569
|
if (count === 0) return [];
|
|
44014
44570
|
const enumCalls = Array.from({ length: count }, (_3, i) => ({
|
|
44015
44571
|
address: entry.withdrawalContract,
|
|
@@ -44021,7 +44577,7 @@ var readerSwell = {
|
|
|
44021
44577
|
calls: enumCalls,
|
|
44022
44578
|
abi: enumCalls.map(() => SwellRswExitAbi)
|
|
44023
44579
|
});
|
|
44024
|
-
const ids = stage2.map(
|
|
44580
|
+
const ids = stage2.map(toBigInt12).filter((v) => v !== void 0);
|
|
44025
44581
|
if (ids.length === 0) return [];
|
|
44026
44582
|
const detailCalls = ids.map((id) => ({
|
|
44027
44583
|
address: entry.withdrawalContract,
|
|
@@ -44038,7 +44594,7 @@ var readerSwell = {
|
|
|
44038
44594
|
const id = ids[i];
|
|
44039
44595
|
const r = stage3[i];
|
|
44040
44596
|
if (!r) continue;
|
|
44041
|
-
const amount =
|
|
44597
|
+
const amount = toBigInt12(r.amount);
|
|
44042
44598
|
if (amount === void 0) continue;
|
|
44043
44599
|
const claimable = id <= lastProcessed;
|
|
44044
44600
|
out.push({
|
|
@@ -44112,14 +44668,14 @@ var readerValantis = {
|
|
|
44112
44668
|
for (let i = 0; i < burns.length; i++) {
|
|
44113
44669
|
const b = burns[i];
|
|
44114
44670
|
if (!b) continue;
|
|
44115
|
-
const amount = Array.isArray(b) ?
|
|
44671
|
+
const amount = Array.isArray(b) ? toBigInt12(b[0]) : toBigInt12(b.amount);
|
|
44116
44672
|
const completed = Array.isArray(b) ? Boolean(b[2]) : Boolean(b.completed);
|
|
44117
44673
|
if (amount === void 0 || completed) continue;
|
|
44118
44674
|
out.push({
|
|
44119
44675
|
lst: entry.lst,
|
|
44120
44676
|
brand: entry.brand,
|
|
44121
44677
|
symbol: entry.symbol,
|
|
44122
|
-
requestId: String(
|
|
44678
|
+
requestId: String(toBigInt12(ids[i]) ?? i),
|
|
44123
44679
|
amountUnderlying: amount.toString(),
|
|
44124
44680
|
status: redeemable[i] ? "claimable" : "pending"
|
|
44125
44681
|
});
|
|
@@ -44192,7 +44748,7 @@ var readerTruFin = {
|
|
|
44192
44748
|
if (typeof recipient === "string" && recipient.toLowerCase() !== lcUser) {
|
|
44193
44749
|
continue;
|
|
44194
44750
|
}
|
|
44195
|
-
const amount = Array.isArray(w) ?
|
|
44751
|
+
const amount = Array.isArray(w) ? toBigInt12(w[1]) : toBigInt12(w.amount);
|
|
44196
44752
|
if (amount === void 0 || amount === 0n) continue;
|
|
44197
44753
|
out.push({
|
|
44198
44754
|
lst: entry.lst,
|
|
@@ -44288,7 +44844,7 @@ var readerYieldNest = {
|
|
|
44288
44844
|
calls: enumCalls,
|
|
44289
44845
|
abi: enumCalls.map(() => YieldNestWithdrawalQueueAbi)
|
|
44290
44846
|
});
|
|
44291
|
-
const ids = stage2.map(
|
|
44847
|
+
const ids = stage2.map(toBigInt12).filter((v) => v !== void 0);
|
|
44292
44848
|
if (ids.length === 0) return [];
|
|
44293
44849
|
const detailCalls = ids.map((id) => ({
|
|
44294
44850
|
address: entry.withdrawalContract,
|
|
@@ -44307,7 +44863,7 @@ var readerYieldNest = {
|
|
|
44307
44863
|
const id = ids[i];
|
|
44308
44864
|
const r = stage3[i];
|
|
44309
44865
|
if (!r) continue;
|
|
44310
|
-
const amount =
|
|
44866
|
+
const amount = toBigInt12(r.amount);
|
|
44311
44867
|
const created = toNumber(r.creationTimestamp);
|
|
44312
44868
|
const processed = Boolean(r.processed);
|
|
44313
44869
|
if (amount === void 0 || created === void 0) continue;
|
|
@@ -44900,7 +45456,7 @@ var getLstWithdrawalRegistry = (chainId, extraEntries) => {
|
|
|
44900
45456
|
const extra = extraEntries.filter((e) => !seen.has(e.lst.toLowerCase()));
|
|
44901
45457
|
return extra.length === 0 ? base : [...base, ...extra];
|
|
44902
45458
|
};
|
|
44903
|
-
var
|
|
45459
|
+
var warn4 = (...args) => {
|
|
44904
45460
|
};
|
|
44905
45461
|
var getLstWithdrawalRequests = async (user, chainId, multicallRetry, options) => {
|
|
44906
45462
|
const entries = getLstWithdrawalRegistry(chainId, options?.extraEntries);
|
|
@@ -44915,7 +45471,7 @@ var getLstWithdrawalRequests = async (user, chainId, multicallRetry, options) =>
|
|
|
44915
45471
|
try {
|
|
44916
45472
|
return await reader.fetch(lcUser, multicallRetry, chainId, entry, ids);
|
|
44917
45473
|
} catch (e) {
|
|
44918
|
-
|
|
45474
|
+
warn4(
|
|
44919
45475
|
`[lst-withdrawals] ${entry.brand} ${entry.symbol} (${entry.lst}) failed:`,
|
|
44920
45476
|
e?.message ?? e
|
|
44921
45477
|
);
|
|
@@ -44960,7 +45516,7 @@ var Erc4626ReadAbi2 = [
|
|
|
44960
45516
|
|
|
44961
45517
|
// src/vaults/savings/readers/shared.ts
|
|
44962
45518
|
var ONE_E188 = 10n ** 18n;
|
|
44963
|
-
var
|
|
45519
|
+
var toBigInt13 = (v) => {
|
|
44964
45520
|
if (v === void 0 || v === null) return void 0;
|
|
44965
45521
|
if (typeof v === "bigint") return v;
|
|
44966
45522
|
if (typeof v === "number") return BigInt(v);
|
|
@@ -44991,9 +45547,9 @@ var readerErc46262 = (entry) => {
|
|
|
44991
45547
|
],
|
|
44992
45548
|
abis: [Erc4626ReadAbi2, TotalSupplyAbi2, Erc4626ReadAbi2],
|
|
44993
45549
|
parse: ([assets, supply, rate]) => {
|
|
44994
|
-
const totalAssets =
|
|
44995
|
-
const totalSupply =
|
|
44996
|
-
const convertToAssetsRaw =
|
|
45550
|
+
const totalAssets = toBigInt13(assets);
|
|
45551
|
+
const totalSupply = toBigInt13(supply);
|
|
45552
|
+
const convertToAssetsRaw = toBigInt13(rate);
|
|
44997
45553
|
if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
|
|
44998
45554
|
return void 0;
|
|
44999
45555
|
}
|
|
@@ -45828,7 +46384,7 @@ var resolveAaveEarnCuratorName = (chainId, owner) => {
|
|
|
45828
46384
|
|
|
45829
46385
|
// src/vaults/aave-earn/fetchPublic.ts
|
|
45830
46386
|
var BRAND2 = "Aave";
|
|
45831
|
-
var
|
|
46387
|
+
var toBigInt14 = (v) => {
|
|
45832
46388
|
if (v === void 0 || v === null) return void 0;
|
|
45833
46389
|
if (typeof v === "bigint") return v;
|
|
45834
46390
|
if (typeof v === "number") return BigInt(v);
|
|
@@ -45888,15 +46444,15 @@ var fetchAaveEarnVaults = async (chainId, multicallRetry, prices = {}, tokenList
|
|
|
45888
46444
|
const token = v.usedReserve.underlyingToken;
|
|
45889
46445
|
const underlyingLc = token.address.toLowerCase();
|
|
45890
46446
|
const assetDecimals = token.decimals;
|
|
45891
|
-
const shareDecOnChain =
|
|
46447
|
+
const shareDecOnChain = toBigInt14(slice[1]);
|
|
45892
46448
|
const decimals = shareDecOnChain !== void 0 ? Number(shareDecOnChain) : assetDecimals;
|
|
45893
|
-
const totalSupply =
|
|
46449
|
+
const totalSupply = toBigInt14(slice[2]);
|
|
45894
46450
|
if (totalSupply === void 0) continue;
|
|
45895
46451
|
const shareUnit = 10n ** BigInt(decimals);
|
|
45896
46452
|
const underlyingUnit = 10n ** BigInt(assetDecimals);
|
|
45897
|
-
const convertToAssets =
|
|
46453
|
+
const convertToAssets = toBigInt14(slice[3]) ?? 0n;
|
|
45898
46454
|
const convertToShares = convertToAssets > 0n ? shareUnit * underlyingUnit / convertToAssets : 0n;
|
|
45899
|
-
const totalAssets =
|
|
46455
|
+
const totalAssets = toBigInt14(slice[0]) ?? totalSupply * convertToAssets / shareUnit;
|
|
45900
46456
|
const totalAssetsFormatted = Number(totalAssets) / 10 ** assetDecimals;
|
|
45901
46457
|
const asset = tokenList[underlyingLc];
|
|
45902
46458
|
const priceUsd = prices[underlyingLc] ?? (v.balance?.usdPerToken != null ? num2(v.balance.usdPerToken) : void 0);
|
|
@@ -47915,7 +48471,7 @@ function buildVaultLookup(data) {
|
|
|
47915
48471
|
addEntries(data.yearn, "yearn");
|
|
47916
48472
|
return map;
|
|
47917
48473
|
}
|
|
47918
|
-
var
|
|
48474
|
+
var warn5 = (...args) => {
|
|
47919
48475
|
};
|
|
47920
48476
|
var HYPERCORE_PROVIDER_CHAIN = "999";
|
|
47921
48477
|
var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices = {}, tokenList = {}, options) => {
|
|
@@ -47928,7 +48484,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
47928
48484
|
fetchFluidFTokens(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
47929
48485
|
out.fluid = res;
|
|
47930
48486
|
}).catch((e) => {
|
|
47931
|
-
|
|
48487
|
+
warn5(
|
|
47932
48488
|
`[vaults] fluid fetch failed for chain ${chainId}:`,
|
|
47933
48489
|
e?.message ?? e
|
|
47934
48490
|
);
|
|
@@ -47940,7 +48496,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
47940
48496
|
fetchGearboxV3Pools(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
47941
48497
|
out.gearbox = res;
|
|
47942
48498
|
}).catch((e) => {
|
|
47943
|
-
|
|
48499
|
+
warn5(
|
|
47944
48500
|
`[vaults] gearbox fetch failed for chain ${chainId}:`,
|
|
47945
48501
|
e?.message ?? e
|
|
47946
48502
|
);
|
|
@@ -47952,7 +48508,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
47952
48508
|
fetchMorphoVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
47953
48509
|
out.morpho = res;
|
|
47954
48510
|
}).catch((e) => {
|
|
47955
|
-
|
|
48511
|
+
warn5(
|
|
47956
48512
|
`[vaults] morpho fetch failed for chain ${chainId}:`,
|
|
47957
48513
|
e?.message ?? e
|
|
47958
48514
|
);
|
|
@@ -47964,7 +48520,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
47964
48520
|
fetchListaVaultsFromChain(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
47965
48521
|
out.lista = res;
|
|
47966
48522
|
}).catch((e) => {
|
|
47967
|
-
|
|
48523
|
+
warn5(
|
|
47968
48524
|
`[vaults] lista fetch failed for chain ${chainId}:`,
|
|
47969
48525
|
e?.message ?? e
|
|
47970
48526
|
);
|
|
@@ -47979,7 +48535,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
47979
48535
|
}).then((res) => {
|
|
47980
48536
|
out.silo = res;
|
|
47981
48537
|
}).catch((e) => {
|
|
47982
|
-
|
|
48538
|
+
warn5(
|
|
47983
48539
|
`[vaults] silo fetch failed for chain ${chainId}:`,
|
|
47984
48540
|
e?.message ?? e
|
|
47985
48541
|
);
|
|
@@ -47991,7 +48547,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
47991
48547
|
fetchEulerEarnVaults(chainId, prices, tokenList, multicallRetry).then((res) => {
|
|
47992
48548
|
out["euler-earn"] = res;
|
|
47993
48549
|
}).catch((e) => {
|
|
47994
|
-
|
|
48550
|
+
warn5(
|
|
47995
48551
|
`[vaults] euler-earn fetch failed for chain ${chainId}:`,
|
|
47996
48552
|
e?.message ?? e
|
|
47997
48553
|
);
|
|
@@ -48003,7 +48559,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48003
48559
|
fetchLstShareTokens(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
48004
48560
|
out.lst = res;
|
|
48005
48561
|
}).catch((e) => {
|
|
48006
|
-
|
|
48562
|
+
warn5(
|
|
48007
48563
|
`[vaults] lst fetch failed for chain ${chainId}:`,
|
|
48008
48564
|
e?.message ?? e
|
|
48009
48565
|
);
|
|
@@ -48015,7 +48571,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48015
48571
|
fetchSavingsVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
48016
48572
|
out.savings = res;
|
|
48017
48573
|
}).catch((e) => {
|
|
48018
|
-
|
|
48574
|
+
warn5(
|
|
48019
48575
|
`[vaults] savings fetch failed for chain ${chainId}:`,
|
|
48020
48576
|
e?.message ?? e
|
|
48021
48577
|
);
|
|
@@ -48027,7 +48583,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48027
48583
|
fetchLagoonVaults(chainId, prices, tokenList).then((res) => {
|
|
48028
48584
|
out.lagoon = res;
|
|
48029
48585
|
}).catch((e) => {
|
|
48030
|
-
|
|
48586
|
+
warn5(
|
|
48031
48587
|
`[vaults] lagoon fetch failed for chain ${chainId}:`,
|
|
48032
48588
|
e?.message ?? e
|
|
48033
48589
|
);
|
|
@@ -48039,7 +48595,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48039
48595
|
fetchAaveEarnVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
48040
48596
|
out["aave-earn"] = res;
|
|
48041
48597
|
}).catch((e) => {
|
|
48042
|
-
|
|
48598
|
+
warn5(
|
|
48043
48599
|
`[vaults] aave-earn fetch failed for chain ${chainId}:`,
|
|
48044
48600
|
e?.message ?? e
|
|
48045
48601
|
);
|
|
@@ -48051,7 +48607,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48051
48607
|
fetchUpshiftVaults(chainId, prices, tokenList).then((res) => {
|
|
48052
48608
|
out.upshift = res;
|
|
48053
48609
|
}).catch((e) => {
|
|
48054
|
-
|
|
48610
|
+
warn5(
|
|
48055
48611
|
`[vaults] upshift fetch failed for chain ${chainId}:`,
|
|
48056
48612
|
e?.message ?? e
|
|
48057
48613
|
);
|
|
@@ -48063,7 +48619,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48063
48619
|
fetchYearnVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
48064
48620
|
out.yearn = res;
|
|
48065
48621
|
}).catch((e) => {
|
|
48066
|
-
|
|
48622
|
+
warn5(
|
|
48067
48623
|
`[vaults] yearn fetch failed for chain ${chainId}:`,
|
|
48068
48624
|
e?.message ?? e
|
|
48069
48625
|
);
|
|
@@ -48075,7 +48631,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48075
48631
|
fetchHypercoreVaults().then((res) => {
|
|
48076
48632
|
out.hypercore = res;
|
|
48077
48633
|
}).catch((e) => {
|
|
48078
|
-
|
|
48634
|
+
warn5(
|
|
48079
48635
|
`[vaults] hypercore fetch failed for chain ${chainId}:`,
|
|
48080
48636
|
e?.message ?? e
|
|
48081
48637
|
);
|
|
@@ -48087,7 +48643,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48087
48643
|
fetchGmxVaults(chainId, multicallRetry).then((res) => {
|
|
48088
48644
|
out.gmx = res;
|
|
48089
48645
|
}).catch((e) => {
|
|
48090
|
-
|
|
48646
|
+
warn5(
|
|
48091
48647
|
`[vaults] gmx fetch failed for chain ${chainId}:`,
|
|
48092
48648
|
e?.message ?? e
|
|
48093
48649
|
);
|
|
@@ -48103,7 +48659,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
48103
48659
|
);
|
|
48104
48660
|
if (fees) out.gmxExecutionFees = fees;
|
|
48105
48661
|
})().catch((e) => {
|
|
48106
|
-
|
|
48662
|
+
warn5(
|
|
48107
48663
|
`[vaults] gmx execution-fee fetch failed for chain ${chainId}:`,
|
|
48108
48664
|
e?.message ?? e
|
|
48109
48665
|
);
|