@1delta/margin-fetcher 5.0.40 → 5.0.41

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 CHANGED
@@ -7,7 +7,7 @@ import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig
7
7
  import lodash from 'lodash';
8
8
  import { Chain } from '@1delta/chain-registry';
9
9
  import { multicallRetryUniversal, getEvmClient, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
10
- import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, Erc20Abi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FraxlendLeverAbi, FrankencoinPositionAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, CurvanceMarketManagerAbi, CurvanceCTokenAbi, GearboxCreditAccountCompressorV310Abi, UsddCdpManagerAbi, UsddProxyRegistryAbi, CurvanceProtocolReaderAbi, CurvanceCentralRegistryAbi, TermPriceConsumerAbi, CurvanceOracleManagerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
10
+ import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, Erc20Abi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FraxlendLeverAbi, FrankencoinPositionAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, FluidDexResolverAbi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, CurvanceMarketManagerAbi, CurvanceCTokenAbi, GearboxCreditAccountCompressorV310Abi, UsddCdpManagerAbi, UsddProxyRegistryAbi, CurvanceProtocolReaderAbi, CurvanceCentralRegistryAbi, TermPriceConsumerAbi, CurvanceOracleManagerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
11
11
  export { MorphoLensAbi } from '@1delta/abis';
12
12
  import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getLstAcceptedInputs, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, bandLtvCurve, InitMarginAddresses } from '@1delta/calldata-sdk';
13
13
  import { proxyNativeFetch } from '@1delta/proxy-fetch';
@@ -10121,11 +10121,11 @@ async function resolveListaBrokers(chainId, marketKeys, getClient = getEvmClient
10121
10121
  const moolah = morphoPools()?.LISTA_DAO?.[chainId];
10122
10122
  const out = {};
10123
10123
  if (!moolah || marketKeys.length === 0) return out;
10124
- const cache2 = BROKER_CACHE[chainId] ??= {};
10124
+ const cache4 = BROKER_CACHE[chainId] ??= {};
10125
10125
  const missing = [];
10126
10126
  for (const key3 of marketKeys) {
10127
10127
  const id = toBytes32MarketId(key3);
10128
- if (cache2[id] === void 0) missing.push(id);
10128
+ if (cache4[id] === void 0) missing.push(id);
10129
10129
  }
10130
10130
  if (missing.length > 0) {
10131
10131
  try {
@@ -10142,14 +10142,14 @@ async function resolveListaBrokers(chainId, marketKeys, getClient = getEvmClient
10142
10142
  results.forEach((r, i) => {
10143
10143
  const id = missing[i];
10144
10144
  const addr3 = r.status === "success" && r.result ? r.result : zeroAddress;
10145
- cache2[id] = addr3.toLowerCase();
10145
+ cache4[id] = addr3.toLowerCase();
10146
10146
  });
10147
10147
  } catch {
10148
10148
  }
10149
10149
  }
10150
10150
  for (const key3 of marketKeys) {
10151
10151
  const id = toBytes32MarketId(key3);
10152
- const broker = cache2[id];
10152
+ const broker = cache4[id];
10153
10153
  if (broker && broker !== zeroAddress) out[id] = broker;
10154
10154
  }
10155
10155
  return out;
@@ -10170,7 +10170,7 @@ async function fetchListaFixedTerms(chainId, marketKeys) {
10170
10170
  args: []
10171
10171
  }))
10172
10172
  });
10173
- const cache2 = FIXED_TERMS_CACHE[chainId] ??= {};
10173
+ const cache4 = FIXED_TERMS_CACHE[chainId] ??= {};
10174
10174
  results.forEach((r, i) => {
10175
10175
  const id = ids[i];
10176
10176
  if (r.status !== "success" || !r.result) return;
@@ -10184,7 +10184,7 @@ async function fetchListaFixedTerms(chainId, marketKeys) {
10184
10184
  };
10185
10185
  });
10186
10186
  out[id] = terms;
10187
- cache2[id] = terms;
10187
+ cache4[id] = terms;
10188
10188
  });
10189
10189
  } catch {
10190
10190
  }
@@ -18727,7 +18727,7 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
18727
18727
  { self: market.silo0, other: market.silo1 },
18728
18728
  { self: market.silo1, other: market.silo0 }
18729
18729
  ];
18730
- const toBigInt17 = (v) => {
18730
+ const toBigInt18 = (v) => {
18731
18731
  if (v === void 0 || v === null || v === "0x") return 0n;
18732
18732
  if (typeof v === "bigint") return v;
18733
18733
  try {
@@ -18739,8 +18739,8 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
18739
18739
  for (let s = 0; s < 2; s++) {
18740
18740
  const { self, other } = sides[s];
18741
18741
  const slot = s * SILO_V2_CALLS_PER_SIDE;
18742
- const totalAssetsRaw = toBigInt17(data[slot]);
18743
- const debtAssetsRaw = toBigInt17(data[slot + 1]);
18742
+ const totalAssetsRaw = toBigInt18(data[slot]);
18743
+ const debtAssetsRaw = toBigInt18(data[slot + 1]);
18744
18744
  const irmConfigRaw = data[slot + 2];
18745
18745
  const decimals = self.decimals;
18746
18746
  const totalDeposits = Number(formatUnits(totalAssetsRaw, decimals));
@@ -18895,7 +18895,7 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
18895
18895
  { self: market.silo0, other: market.silo1 },
18896
18896
  { self: market.silo1, other: market.silo0 }
18897
18897
  ];
18898
- const toBigInt17 = (v) => {
18898
+ const toBigInt18 = (v) => {
18899
18899
  if (v === void 0 || v === null || v === "0x") return 0n;
18900
18900
  if (typeof v === "bigint") return v;
18901
18901
  try {
@@ -18907,8 +18907,8 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
18907
18907
  for (let s = 0; s < 2; s++) {
18908
18908
  const { self, other } = sides[s];
18909
18909
  const slot = s * SILO_V3_CALLS_PER_SIDE;
18910
- const totalAssetsRaw = toBigInt17(data[slot]);
18911
- const debtAssetsRaw = toBigInt17(data[slot + 1]);
18910
+ const totalAssetsRaw = toBigInt18(data[slot]);
18911
+ const debtAssetsRaw = toBigInt18(data[slot + 1]);
18912
18912
  const irmConfigRaw = data[slot + 2];
18913
18913
  const decimals = self.decimals;
18914
18914
  const totalDeposits = Number(formatUnits(totalAssetsRaw, decimals));
@@ -19031,6 +19031,152 @@ var buildFluidCall = (chainId, _lender) => {
19031
19031
  ];
19032
19032
  };
19033
19033
 
19034
+ // src/lending/public-data/fluid/apiData.ts
19035
+ var FLUID_API_BASE = "https://api.fluid.instadapp.io/v2";
19036
+ var SUPPORTED_CHAINS = /* @__PURE__ */ new Set(["1", "56", "137", "8453", "9745", "42161"]);
19037
+ var TTL_MS = 6e4;
19038
+ var ZERO_ADDRESS4 = "0x0000000000000000000000000000000000000000";
19039
+ var cache = {};
19040
+ var inflight = /* @__PURE__ */ new Map();
19041
+ var isRealDex = (d) => !!d && String(d.id ?? "0") !== "0" && String(d.address ?? ZERO_ADDRESS4).toLowerCase() !== ZERO_ADDRESS4;
19042
+ var toBigInt6 = (v) => {
19043
+ try {
19044
+ return BigInt(v ?? 0);
19045
+ } catch {
19046
+ return 0n;
19047
+ }
19048
+ };
19049
+ var parseSide = (d, sideToken) => {
19050
+ if (!isRealDex(d)) return void 0;
19051
+ const token0PerShare = toBigInt6(d.token0PerShare);
19052
+ const token1PerShare = toBigInt6(d.token1PerShare);
19053
+ if (token0PerShare === 0n && token1PerShare === 0n) return void 0;
19054
+ const d0 = Number(sideToken?.token0?.decimals);
19055
+ const d1 = Number(sideToken?.token1?.decimals);
19056
+ if (!Number.isFinite(d0) || !Number.isFinite(d1)) return void 0;
19057
+ return {
19058
+ dex: String(d.address).toLowerCase(),
19059
+ token0PerShare,
19060
+ token1PerShare,
19061
+ token0Decimals: d0,
19062
+ token1Decimals: d1
19063
+ };
19064
+ };
19065
+ var parseChainPayload = (raw) => {
19066
+ const out = {};
19067
+ for (const v of raw ?? []) {
19068
+ const vaultId = Number(v?.id ?? NaN);
19069
+ if (!Number.isFinite(vaultId)) continue;
19070
+ const vaultType = Number(v?.type ?? 0);
19071
+ out[vaultId] = {
19072
+ vaultId,
19073
+ vaultType,
19074
+ supplyShares: parseSide(v?.supplyDexData, v?.supplyToken),
19075
+ borrowShares: parseSide(v?.borrowDexData, v?.borrowToken),
19076
+ supplyDexTradingRate: Number(v?.supplyRate?.dex?.trading ?? 0),
19077
+ borrowDexTradingRate: Number(v?.borrowRate?.dex?.trading ?? 0)
19078
+ };
19079
+ }
19080
+ return out;
19081
+ };
19082
+ var fetchFluidApiData = async (chainId) => {
19083
+ if (!SUPPORTED_CHAINS.has(chainId)) return void 0;
19084
+ const hit = cache[chainId];
19085
+ if (hit && Date.now() - hit.at < TTL_MS) return hit.data;
19086
+ const pending = inflight.get(chainId);
19087
+ if (pending) return pending;
19088
+ const run = (async () => {
19089
+ try {
19090
+ const res = await fetch(`${FLUID_API_BASE}/${chainId}/vaults`);
19091
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
19092
+ const json = await res.json();
19093
+ if (!Array.isArray(json)) throw new Error("unexpected payload");
19094
+ const data = parseChainPayload(json);
19095
+ cache[chainId] = { at: Date.now(), data };
19096
+ return data;
19097
+ } catch {
19098
+ const prev = cache[chainId]?.data;
19099
+ cache[chainId] = { at: Date.now(), data: prev };
19100
+ return prev;
19101
+ } finally {
19102
+ inflight.delete(chainId);
19103
+ }
19104
+ })();
19105
+ inflight.set(chainId, run);
19106
+ return run;
19107
+ };
19108
+ var getCachedFluidApiData = (chainId) => cache[chainId]?.data;
19109
+ var DEX_RESOLVER_FALLBACK = {
19110
+ "1": "0x11D80CfF056Cef4F9E6d23da8672fE9873e5cC07",
19111
+ "137": "0x11D80CfF056Cef4F9E6d23da8672fE9873e5cC07",
19112
+ "8453": "0x11D80CfF056Cef4F9E6d23da8672fE9873e5cC07",
19113
+ "42161": "0x11D80CfF056Cef4F9E6d23da8672fE9873e5cC07",
19114
+ "56": "0xAf572EfC84d905926F7b05C1B7bE04e4E89542B0",
19115
+ "9745": "0xAf572EfC84d905926F7b05C1B7bE04e4E89542B0"
19116
+ };
19117
+ var dexResolverFor = (chainId) => fluidResolvers()?.[chainId]?.dexResolver ?? DEX_RESOLVER_FALLBACK[chainId];
19118
+ var ZERO_ADDRESS5 = "0x0000000000000000000000000000000000000000";
19119
+ var TTL_MS2 = 6e4;
19120
+ var cache2 = {};
19121
+ var inflight2 = /* @__PURE__ */ new Map();
19122
+ var fetchFluidDexState = async (chainId, multicallRetry, extraDexAddresses = []) => {
19123
+ const resolver = dexResolverFor(chainId);
19124
+ if (!resolver) return void 0;
19125
+ const hit = cache2[chainId];
19126
+ if (hit && Date.now() - hit.at < TTL_MS2) return hit.data;
19127
+ const pending = inflight2.get(chainId);
19128
+ if (pending) return pending;
19129
+ const run = (async () => {
19130
+ try {
19131
+ const [addresses] = await multicallRetry({
19132
+ chain: chainId,
19133
+ calls: [{ address: resolver, name: "getAllDexAddresses", params: [] }],
19134
+ abi: [FluidDexResolverAbi]
19135
+ });
19136
+ const list = [
19137
+ ...new Set(
19138
+ [...addresses ?? [], ...extraDexAddresses].filter((a) => !!a && a !== ZERO_ADDRESS5).map((a) => a.toLowerCase())
19139
+ )
19140
+ ];
19141
+ if (!list.length) throw new Error("no dex addresses");
19142
+ const states = await multicallRetry({
19143
+ chain: chainId,
19144
+ calls: list.map((dex) => ({
19145
+ address: resolver,
19146
+ name: "getDexState",
19147
+ params: [dex]
19148
+ })),
19149
+ abi: list.map(() => FluidDexResolverAbi)
19150
+ });
19151
+ const data = {};
19152
+ for (let i = 0; i < list.length; i++) {
19153
+ const s = states?.[i];
19154
+ if (!s || s.token0PerSupplyShare === void 0) continue;
19155
+ data[list[i]] = {
19156
+ dex: list[i],
19157
+ token0PerSupplyShare: BigInt(s.token0PerSupplyShare ?? 0),
19158
+ token1PerSupplyShare: BigInt(s.token1PerSupplyShare ?? 0),
19159
+ token0PerBorrowShare: BigInt(s.token0PerBorrowShare ?? 0),
19160
+ token1PerBorrowShare: BigInt(s.token1PerBorrowShare ?? 0),
19161
+ totalSupplyShares: BigInt(s.totalSupplyShares ?? 0),
19162
+ totalBorrowShares: BigInt(s.totalBorrowShares ?? 0)
19163
+ };
19164
+ }
19165
+ cache2[chainId] = { at: Date.now(), data };
19166
+ return data;
19167
+ } catch {
19168
+ const prev = cache2[chainId]?.data;
19169
+ cache2[chainId] = { at: Date.now(), data: prev };
19170
+ return prev;
19171
+ } finally {
19172
+ inflight2.delete(chainId);
19173
+ }
19174
+ })();
19175
+ inflight2.set(chainId, run);
19176
+ return run;
19177
+ };
19178
+ var getCachedFluidDexState = (chainId) => cache2[chainId]?.data;
19179
+
19034
19180
  // src/lending/public-data/fluid/publicCallParse.ts
19035
19181
  var FLUID_EEE_LOWER = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
19036
19182
  var normalizeUnderlying = (addr3) => addr3 === FLUID_EEE_LOWER ? zeroAddress : addr3;
@@ -19069,6 +19215,8 @@ var getFluidPublicDataConverter = (_lender, chainId, prices, additionalYields, t
19069
19215
  if (data.length !== expectedNumberOfCalls) return void 0;
19070
19216
  const [vaultEntireData, overallTokensData] = data;
19071
19217
  const liquidityByToken = parseOverallTokensData(overallTokensData);
19218
+ const dexState = getCachedFluidDexState(chainId);
19219
+ const apiData = getCachedFluidApiData(chainId);
19072
19220
  const out = {};
19073
19221
  for (const vault of vaultEntireData ?? []) {
19074
19222
  const parsed = parseVault(
@@ -19077,7 +19225,9 @@ var getFluidPublicDataConverter = (_lender, chainId, prices, additionalYields, t
19077
19225
  prices,
19078
19226
  additionalYields,
19079
19227
  tokenList,
19080
- liquidityByToken
19228
+ liquidityByToken,
19229
+ apiData?.[Number(vault?.constantVariables?.vaultId ?? -1)],
19230
+ dexState
19081
19231
  );
19082
19232
  if (parsed) {
19083
19233
  out[parsed.lender] = {
@@ -19092,7 +19242,42 @@ var getFluidPublicDataConverter = (_lender, chainId, prices, additionalYields, t
19092
19242
  expectedNumberOfCalls
19093
19243
  ];
19094
19244
  };
19095
- function parseVault(vault, chainId, prices, additionalYields, tokenList, liquidityByToken = {}) {
19245
+ var SMART_DEBT_TRADING_SIGN = -1;
19246
+ var splitSide = (tokens, rawTotal, rawAvailable, simpleDecimals, shares, rateFor) => {
19247
+ if (!shares) {
19248
+ const token = tokens[0];
19249
+ if (!token) return [];
19250
+ return [
19251
+ {
19252
+ token,
19253
+ decimals: simpleDecimals,
19254
+ amount: Number(parseRawAmount(rawTotal.toString(), simpleDecimals)),
19255
+ available: Number(
19256
+ parseRawAmount(rawAvailable.toString(), simpleDecimals)
19257
+ ),
19258
+ rate: rateFor(token, 0)
19259
+ }
19260
+ ];
19261
+ }
19262
+ const perShare = shares.perShare;
19263
+ const decimals = shares.decimals;
19264
+ const legs = [];
19265
+ for (let i = 0; i < tokens.length && i < 2; i++) {
19266
+ const token = tokens[i];
19267
+ if (!token) continue;
19268
+ const amountRaw = rawTotal * perShare[i] / 10n ** 18n;
19269
+ const availableRaw = rawAvailable * perShare[i] / 10n ** 18n;
19270
+ legs.push({
19271
+ token,
19272
+ decimals: decimals[i],
19273
+ amount: Number(parseRawAmount(amountRaw.toString(), decimals[i])),
19274
+ available: Number(parseRawAmount(availableRaw.toString(), decimals[i])),
19275
+ rate: rateFor(token, i)
19276
+ });
19277
+ }
19278
+ return legs;
19279
+ };
19280
+ function parseVault(vault, chainId, prices, additionalYields, tokenList, liquidityByToken = {}, api, dexState) {
19096
19281
  const vaultAddress = (vault.vault ?? "").toLowerCase();
19097
19282
  const constants = vault.constantVariables;
19098
19283
  const configs = vault.configs;
@@ -19102,160 +19287,223 @@ function parseVault(vault, chainId, prices, additionalYields, tokenList, liquidi
19102
19287
  if (!vaultAddress || !constants || !configs || !rates || !totals) {
19103
19288
  return void 0;
19104
19289
  }
19105
- if (vault.isSmartCol || vault.isSmartDebt) return void 0;
19106
- const rawCollateral = (constants.supplyToken?.token0 ?? constants.supplyToken ?? "").toString().toLowerCase();
19107
- const rawLoan = (constants.borrowToken?.token0 ?? constants.borrowToken ?? "").toString().toLowerCase();
19108
- if (!rawCollateral || !rawLoan) return void 0;
19109
- const collateralAddress = normalizeUnderlying(rawCollateral);
19110
- const loanAddress = normalizeUnderlying(rawLoan);
19290
+ const isSmartCol = !!vault.isSmartCol;
19291
+ const isSmartDebt = !!vault.isSmartDebt;
19292
+ const sideTokens = (side, isSmart) => {
19293
+ const raw = side?.token0 !== void 0 ? side : { token0: side };
19294
+ const t0 = normalizeUnderlying((raw?.token0 ?? "").toString().toLowerCase());
19295
+ if (!isSmart) return [t0];
19296
+ const t1 = normalizeUnderlying((raw?.token1 ?? "").toString().toLowerCase());
19297
+ return [t0, t1];
19298
+ };
19299
+ const colTokens = sideTokens(constants.supplyToken, isSmartCol);
19300
+ const debtTokens = sideTokens(constants.borrowToken, isSmartDebt);
19301
+ if (!colTokens[0] || !debtTokens[0]) return void 0;
19302
+ if (isSmartCol && colTokens.length < 2) return void 0;
19303
+ if (isSmartDebt && debtTokens.length < 2) return void 0;
19111
19304
  const vaultId = Number(constants.vaultId ?? 0);
19305
+ const vaultType = Number(constants.vaultType ?? 0);
19112
19306
  const lender = `FLUID_${chainId}_${vaultId}`;
19113
- const collateralMeta = tokenList[collateralAddress];
19114
- const loanMeta = tokenList[loanAddress];
19115
- const colDecimals = Number(
19116
- constants.supplyDecimals ?? collateralMeta?.decimals ?? 18
19117
- );
19118
- const borrowDecimals = Number(
19119
- constants.borrowDecimals ?? loanMeta?.decimals ?? 18
19120
- );
19121
- const totalSupply = Number(
19122
- parseRawAmount(totals.totalSupplyVault?.toString(), colDecimals)
19307
+ const isSmartVault = isSmartCol || isSmartDebt;
19308
+ const simpleDecimals = (token, resolverValue) => {
19309
+ const listed = tokenList[token]?.decimals;
19310
+ if (listed !== void 0 && listed !== null) return Number(listed);
19311
+ if (resolverValue !== void 0 && resolverValue !== null)
19312
+ return Number(resolverValue);
19313
+ return isSmartVault ? void 0 : 18;
19314
+ };
19315
+ const colDecimals = simpleDecimals(colTokens[0], constants.supplyDecimals);
19316
+ const debtDecimals = simpleDecimals(debtTokens[0], constants.borrowDecimals);
19317
+ if (!isSmartCol && colDecimals === void 0 || !isSmartDebt && debtDecimals === void 0) {
19318
+ return void 0;
19319
+ }
19320
+ const resolveShares = (isSmart, sideContract, tokens, onChainPerShare, apiSide) => {
19321
+ if (!isSmart) return void 0;
19322
+ const dex = String(sideContract ?? "").toLowerCase();
19323
+ const decimalsFor = (token, fallback) => {
19324
+ const d = tokenList[token]?.decimals;
19325
+ if (d !== void 0 && d !== null) return Number(d);
19326
+ return fallback;
19327
+ };
19328
+ const onChain = dex ? dexState?.[dex] : void 0;
19329
+ const perShare = onChain ? onChainPerShare(onChain) : apiSide ? [apiSide.token0PerShare, apiSide.token1PerShare] : void 0;
19330
+ if (!perShare) return void 0;
19331
+ const d0 = decimalsFor(tokens[0], apiSide?.token0Decimals);
19332
+ const d1 = decimalsFor(tokens[1], apiSide?.token1Decimals);
19333
+ if (d0 === void 0 || d1 === void 0) return void 0;
19334
+ return { dex, perShare, decimals: [d0, d1] };
19335
+ };
19336
+ const colShares = resolveShares(
19337
+ isSmartCol,
19338
+ constants.supply,
19339
+ colTokens,
19340
+ (s) => [s.token0PerSupplyShare, s.token1PerSupplyShare],
19341
+ api?.supplyShares
19123
19342
  );
19124
- const totalBorrow = Number(
19125
- parseRawAmount(totals.totalBorrowVault?.toString(), borrowDecimals)
19343
+ const debtShares = resolveShares(
19344
+ isSmartDebt,
19345
+ constants.borrow,
19346
+ debtTokens,
19347
+ (s) => [s.token0PerBorrowShare, s.token1PerBorrowShare],
19348
+ api?.borrowShares
19126
19349
  );
19127
- const borrowable = Number(
19128
- parseRawAmount(limits?.borrowable?.toString(), borrowDecimals)
19350
+ if (isSmartCol && !colShares || isSmartDebt && !debtShares) {
19351
+ return void 0;
19352
+ }
19353
+ const supplyRate = scaleFluidRate(rates.supplyRateVault);
19354
+ const borrowRate = scaleFluidRate(rates.borrowRateVault);
19355
+ const supplyDexTrading = (api?.supplyDexTradingRate ?? 0) / FLUID_RATE_SCALE;
19356
+ const borrowDexTrading = (api?.borrowDexTradingRate ?? 0) / FLUID_RATE_SCALE;
19357
+ const colLegs = splitSide(
19358
+ colTokens,
19359
+ BigInt(totals.totalSupplyVault?.toString() ?? "0"),
19360
+ BigInt(limits?.withdrawable?.toString() ?? "0"),
19361
+ colDecimals ?? 18,
19362
+ colShares,
19363
+ (token) => (
19364
+ // Simple side: the vault's own supply rate is authoritative on-chain.
19365
+ // Smart side: that field is 0, so the rate is the token's own
19366
+ // Liquidity-layer supply rate plus the DEX trading yield the LP earns.
19367
+ isSmartCol ? (liquidityByToken[token]?.supplyRate ?? 0) + supplyDexTrading : supplyRate
19368
+ )
19129
19369
  );
19130
- const withdrawable = Number(
19131
- parseRawAmount(limits?.withdrawable?.toString(), colDecimals)
19370
+ const debtLegs = splitSide(
19371
+ debtTokens,
19372
+ BigInt(totals.totalBorrowVault?.toString() ?? "0"),
19373
+ BigInt(limits?.borrowable?.toString() ?? "0"),
19374
+ debtDecimals ?? 18,
19375
+ debtShares,
19376
+ (token) => isSmartDebt ? (liquidityByToken[token]?.borrowRate ?? 0) + SMART_DEBT_TRADING_SIGN * borrowDexTrading : borrowRate
19132
19377
  );
19378
+ if (!colLegs.length || !debtLegs.length) return void 0;
19133
19379
  const totalSupplyRaw = BigInt(totals.totalSupplyVault?.toString() ?? "0");
19134
19380
  const withdrawLimitRaw = BigInt(limits?.withdrawLimit?.toString() ?? "0");
19135
19381
  const lockupRatio = totalSupplyRaw > 0n ? Number(withdrawLimitRaw * 10000n / totalSupplyRaw) / 1e4 : 0;
19136
- const collateralPriceKey = toOracleKey(collateralMeta?.assetGroup) ?? toGenericPriceKey(collateralAddress, chainId);
19137
- const loanPriceKey = toOracleKey(loanMeta?.assetGroup) ?? toGenericPriceKey(loanAddress, chainId);
19138
- const collateralPrice = prices[collateralPriceKey] ?? 0;
19139
- const loanPrice = prices[loanPriceKey] ?? 0;
19140
19382
  const ltv = Number(configs.collateralFactor ?? 0) / BPS;
19141
19383
  const liquidationThreshold = Number(configs.liquidationThreshold ?? 0) / BPS;
19142
19384
  const liquidationPenalty = Number(configs.liquidationPenalty ?? 0) / BPS;
19143
- const supplyRate = scaleFluidRate(rates.supplyRateVault);
19144
- const borrowRate = scaleFluidRate(rates.borrowRateVault);
19145
- const collateralLiquidity = liquidityByToken[collateralAddress];
19146
- const loanLiquidity = liquidityByToken[loanAddress];
19385
+ const priceKeyFor = (token) => {
19386
+ const meta = tokenList[token];
19387
+ return toOracleKey(meta?.assetGroup) ?? toGenericPriceKey(token, chainId);
19388
+ };
19147
19389
  const irmTotals = (state, decimals) => state ? {
19148
19390
  irmTotalDeposits: Number(parseRawAmount(state.totalSupply, decimals)),
19149
19391
  irmTotalDebt: Number(parseRawAmount(state.totalBorrow, decimals))
19150
19392
  } : {};
19151
19393
  const data = {};
19152
- const collateralMarketUid = createMarketUid(
19153
- chainId,
19154
- lender,
19155
- collateralAddress
19156
- );
19157
- data[collateralMarketUid] = {
19158
- marketUid: collateralMarketUid,
19159
- name: "Collateral " + (collateralMeta?.symbol ?? ""),
19160
- poolId: collateralAddress,
19161
- underlying: collateralAddress,
19162
- asset: collateralMeta,
19163
- totalDeposits: totalSupply,
19164
- totalDebtStable: 0,
19165
- totalDebt: 0,
19166
- totalLiquidity: totalSupply,
19167
- borrowLiquidity: 0,
19168
- totalDepositsUSD: totalSupply * collateralPrice,
19169
- totalDebtStableUSD: 0,
19170
- totalDebtUSD: 0,
19171
- totalLiquidityUSD: totalSupply * collateralPrice,
19172
- borrowLiquidityUSD: 0,
19173
- // IRM x-coordinate: the collateral token's Liquidity-layer utilization —
19174
- // it drives the supply rate (borrowRate × utilization × (1 - fee)).
19175
- utilization: collateralLiquidity?.utilization ?? 0,
19176
- ...irmTotals(collateralLiquidity, colDecimals),
19177
- // Share of this vault's collateral currently locked below the LL
19178
- // withdrawal limit (withdrawLimit / totalSupplyVault).
19179
- lockupRatio,
19180
- depositRate: supplyRate,
19181
- // vault collateral earns the supply side rate
19182
- variableBorrowRate: 0,
19183
- stableBorrowRate: 0,
19184
- intrinsicYield: additionalYields?.intrinsicYields?.[collateralPriceKey] ?? 0,
19185
- rewards: [],
19186
- decimals: colDecimals,
19187
- config: {
19188
- "0": {
19189
- category: 0,
19190
- borrowCollateralFactor: ltv,
19191
- collateralFactor: liquidationThreshold,
19192
- borrowFactor: 1,
19193
- liquidationPenalty,
19194
- closeFactor: 1,
19195
- collateralDisabled: false,
19196
- debtDisabled: true
19197
- }
19198
- },
19199
- liquidationBonus: liquidationPenalty,
19200
- closeFactor: 1,
19201
- collateralActive: true,
19202
- borrowingEnabled: false,
19203
- depositsEnabled: true,
19204
- hasStable: false,
19205
- isActive: true,
19206
- isFrozen: false
19207
- };
19208
- const loanMarketUid = createMarketUid(chainId, lender, loanAddress);
19209
- data[loanMarketUid] = {
19210
- marketUid: loanMarketUid,
19211
- name: "Loan " + (loanMeta?.symbol ?? ""),
19212
- poolId: loanAddress,
19213
- underlying: loanAddress,
19214
- asset: loanMeta,
19215
- totalDeposits: 0,
19216
- totalDebtStable: 0,
19217
- totalDebt: totalBorrow,
19218
- totalLiquidity: borrowable,
19219
- borrowLiquidity: borrowable,
19220
- totalDepositsUSD: 0,
19221
- totalDebtStableUSD: 0,
19222
- totalDebtUSD: totalBorrow * loanPrice,
19223
- totalLiquidityUSD: borrowable * loanPrice,
19224
- borrowLiquidityUSD: borrowable * loanPrice,
19225
- // IRM x-coordinate: the loan token's Liquidity-layer utilization — the
19226
- // exact input the current borrow rate was computed from.
19227
- utilization: loanLiquidity?.utilization ?? 0,
19228
- ...irmTotals(loanLiquidity, borrowDecimals),
19229
- depositRate: 0,
19230
- variableBorrowRate: borrowRate,
19231
- stableBorrowRate: 0,
19232
- intrinsicYield: additionalYields?.intrinsicYields?.[loanPriceKey] ?? 0,
19233
- rewards: [],
19234
- decimals: borrowDecimals,
19235
- config: {
19236
- "0": {
19237
- category: 0,
19238
- borrowCollateralFactor: 0,
19239
- collateralFactor: 0,
19240
- borrowFactor: 1,
19241
- liquidationPenalty: 0,
19242
- closeFactor: 1,
19243
- collateralDisabled: true,
19244
- debtDisabled: false
19245
- }
19246
- },
19247
- liquidationBonus: 0,
19248
- closeFactor: 1,
19249
- collateralActive: false,
19250
- borrowingEnabled: true,
19251
- depositsEnabled: false,
19252
- hasStable: false,
19253
- isActive: true,
19254
- isFrozen: false
19394
+ const ensureRow = (leg) => {
19395
+ const marketUid = createMarketUid(chainId, lender, leg.token);
19396
+ if (data[marketUid]) return data[marketUid];
19397
+ const meta = tokenList[leg.token];
19398
+ const priceKey = priceKeyFor(leg.token);
19399
+ const liquidity = liquidityByToken[leg.token];
19400
+ const row = {
19401
+ marketUid,
19402
+ name: "",
19403
+ poolId: leg.token,
19404
+ underlying: leg.token,
19405
+ asset: meta,
19406
+ totalDeposits: 0,
19407
+ totalDebtStable: 0,
19408
+ totalDebt: 0,
19409
+ totalLiquidity: 0,
19410
+ borrowLiquidity: 0,
19411
+ totalDepositsUSD: 0,
19412
+ totalDebtStableUSD: 0,
19413
+ totalDebtUSD: 0,
19414
+ totalLiquidityUSD: 0,
19415
+ borrowLiquidityUSD: 0,
19416
+ // IRM x-coordinate: this token's Liquidity-layer utilization.
19417
+ utilization: liquidity?.utilization ?? 0,
19418
+ ...irmTotals(liquidity, leg.decimals),
19419
+ lockupRatio,
19420
+ depositRate: 0,
19421
+ variableBorrowRate: 0,
19422
+ stableBorrowRate: 0,
19423
+ intrinsicYield: additionalYields?.intrinsicYields?.[priceKey] ?? 0,
19424
+ rewards: [],
19425
+ decimals: leg.decimals,
19426
+ config: {
19427
+ "0": {
19428
+ category: 0,
19429
+ borrowCollateralFactor: 0,
19430
+ collateralFactor: 0,
19431
+ borrowFactor: 1,
19432
+ liquidationPenalty: 0,
19433
+ closeFactor: 1,
19434
+ collateralDisabled: true,
19435
+ debtDisabled: true
19436
+ }
19437
+ },
19438
+ liquidationBonus: 0,
19439
+ closeFactor: 1,
19440
+ collateralActive: false,
19441
+ borrowingEnabled: false,
19442
+ depositsEnabled: false,
19443
+ hasStable: false,
19444
+ isActive: true,
19445
+ isFrozen: false,
19446
+ /**
19447
+ * Smart-vault descriptor, read by the Fluid term adapter.
19448
+ *
19449
+ * Present ONLY on a T2/T3/T4 row, where this leg is one half of a
19450
+ * two-token DEX LP position rather than a plain deposit or debt. Without
19451
+ * it a smart market is described as an ordinary pool — the generic
19452
+ * builder cannot tell them apart.
19453
+ */
19454
+ fluid: isSmartVault ? {
19455
+ vaultType,
19456
+ isSmartCol,
19457
+ isSmartDebt,
19458
+ /** Both legs of the collateral LP, in token0/token1 order. */
19459
+ collateralPair: isSmartCol ? colTokens : void 0,
19460
+ /** Both legs of the debt LP, in token0/token1 order. */
19461
+ debtPair: isSmartDebt ? debtTokens : void 0,
19462
+ /** Percent APR the LP earns; supply ADDS it, debt NETS it off. */
19463
+ supplyDexTradingRate: supplyDexTrading,
19464
+ borrowDexTradingRate: borrowDexTrading
19465
+ } : void 0,
19466
+ // Price cached for the second pass; stripped before returning.
19467
+ __price: prices[priceKey] ?? 0
19468
+ };
19469
+ data[marketUid] = row;
19470
+ return row;
19255
19471
  };
19472
+ for (const leg of colLegs) {
19473
+ const row = ensureRow(leg);
19474
+ const price2 = row.__price;
19475
+ row.totalDeposits += leg.amount;
19476
+ row.totalLiquidity += leg.amount;
19477
+ row.totalDepositsUSD += leg.amount * price2;
19478
+ row.totalLiquidityUSD += leg.amount * price2;
19479
+ row.depositRate = leg.rate;
19480
+ row.collateralActive = true;
19481
+ row.depositsEnabled = true;
19482
+ row.liquidationBonus = liquidationPenalty;
19483
+ row.config["0"].borrowCollateralFactor = ltv;
19484
+ row.config["0"].collateralFactor = liquidationThreshold;
19485
+ row.config["0"].liquidationPenalty = liquidationPenalty;
19486
+ row.config["0"].collateralDisabled = false;
19487
+ row.name = "Collateral " + (row.asset?.symbol ?? "");
19488
+ }
19489
+ for (const leg of debtLegs) {
19490
+ const row = ensureRow(leg);
19491
+ const price2 = row.__price;
19492
+ row.totalDebt += leg.amount;
19493
+ row.totalLiquidity += leg.available;
19494
+ row.borrowLiquidity += leg.available;
19495
+ row.totalDebtUSD += leg.amount * price2;
19496
+ row.totalLiquidityUSD += leg.available * price2;
19497
+ row.borrowLiquidityUSD += leg.available * price2;
19498
+ row.variableBorrowRate = leg.rate;
19499
+ row.borrowingEnabled = true;
19500
+ row.config["0"].debtDisabled = false;
19501
+ if (!row.collateralActive) row.name = "Loan " + (row.asset?.symbol ?? "");
19502
+ }
19503
+ for (const row of Object.values(data)) delete row.__price;
19256
19504
  const llSupply = vault.liquidityUserSupplyData;
19257
19505
  const liquidityUserSupply = llSupply ? {
19258
- withdrawable,
19506
+ withdrawable: colLegs[0]?.available ?? 0,
19259
19507
  withdrawalLimit: llSupply.withdrawalLimit?.toString() ?? "0",
19260
19508
  baseWithdrawalLimit: llSupply.baseWithdrawalLimit?.toString() ?? "0",
19261
19509
  expandPercent: Number(llSupply.expandPercent ?? 0),
@@ -19271,6 +19519,14 @@ function parseVault(vault, chainId, prices, additionalYields, tokenList, liquidi
19271
19519
  borrowRate: state.borrowRate,
19272
19520
  supplyRate: state.supplyRate
19273
19521
  } : void 0;
19522
+ const sideDescriptor = (legs, shares) => ({
19523
+ /** Underlying legs in the vault's own token0/token1 order. */
19524
+ assets: legs.map((l) => ({ underlying: l.token, decimals: l.decimals })),
19525
+ /** Fluid DEX pool backing this side; `null` when the side is simple. */
19526
+ dex: shares?.dex ?? null,
19527
+ /** Token units per 1e18 LP shares, parallel to `assets`. `null` when simple. */
19528
+ perShare: shares ? [shares.perShare[0].toString(), shares.perShare[1].toString()] : null
19529
+ });
19274
19530
  return {
19275
19531
  lender,
19276
19532
  data,
@@ -19279,10 +19535,18 @@ function parseVault(vault, chainId, prices, additionalYields, tokenList, liquidi
19279
19535
  lender,
19280
19536
  vaultAddress,
19281
19537
  vaultId,
19282
- collateralAddress,
19283
- loanAddress,
19284
- collateralDecimals: colDecimals,
19285
- loanDecimals: borrowDecimals,
19538
+ /** Raw `TYPE()` — 10000/20000/30000/40000 for T1/T2/T3/T4. */
19539
+ vaultType,
19540
+ // Kept for backwards compatibility: the FIRST leg of each side. On a
19541
+ // smart side this is token0 only — read `collateral` / `loan` below
19542
+ // for the full picture, and never assume a single asset per side.
19543
+ collateralAddress: colTokens[0],
19544
+ loanAddress: debtTokens[0],
19545
+ collateralDecimals: colLegs[0]?.decimals ?? colDecimals ?? 18,
19546
+ loanDecimals: debtLegs[0]?.decimals ?? debtDecimals ?? 18,
19547
+ /** Full per-side descriptor incl. the DEX and its share conversion. */
19548
+ collateral: sideDescriptor(colLegs, colShares),
19549
+ loan: sideDescriptor(debtLegs, debtShares),
19286
19550
  oracle: configs.oracle,
19287
19551
  rebalancer: configs.rebalancer,
19288
19552
  liquidationThreshold,
@@ -19290,12 +19554,21 @@ function parseVault(vault, chainId, prices, additionalYields, tokenList, liquidi
19290
19554
  liquidationPenalty,
19291
19555
  oraclePriceOperate: configs.oraclePriceOperate?.toString(),
19292
19556
  oraclePriceLiquidate: configs.oraclePriceLiquidate?.toString(),
19293
- isSmartCol: !!vault.isSmartCol,
19294
- isSmartDebt: !!vault.isSmartDebt,
19557
+ isSmartCol,
19558
+ isSmartDebt,
19559
+ /** DEX trading yield, percent APR. Supply ADDS it, debt NETS it off. */
19560
+ supplyDexTradingRate: supplyDexTrading,
19561
+ borrowDexTradingRate: borrowDexTrading,
19295
19562
  liquidityUserSupply,
19296
19563
  liquidity: {
19297
- supplyToken: formatLiquidity(collateralLiquidity, colDecimals),
19298
- borrowToken: formatLiquidity(loanLiquidity, borrowDecimals)
19564
+ supplyToken: formatLiquidity(
19565
+ liquidityByToken[colTokens[0]],
19566
+ colLegs[0]?.decimals ?? colDecimals ?? 18
19567
+ ),
19568
+ borrowToken: formatLiquidity(
19569
+ liquidityByToken[debtTokens[0]],
19570
+ debtLegs[0]?.decimals ?? debtDecimals ?? 18
19571
+ )
19299
19572
  }
19300
19573
  }
19301
19574
  }
@@ -19929,11 +20202,13 @@ var getLenderPublicData = async (chainId, lenders, prices, additionalYields, mul
19929
20202
  }) => {
19930
20203
  let calls = [];
19931
20204
  const validLenders = [];
20205
+ const sliceStart = {};
19932
20206
  for (const lender of lenders) {
19933
20207
  const abi = getAbi(lender);
19934
20208
  const callData = buildLenderCall(chainId, lender);
19935
20209
  if (callData.some((c) => !c.address)) continue;
19936
20210
  const mappedCalls = callData.map((call) => ({ call, abi: call.abi ?? abi }));
20211
+ sliceStart[lender] = calls.length;
19937
20212
  calls.push(...mappedCalls);
19938
20213
  validLenders.push(lender);
19939
20214
  }
@@ -19944,8 +20219,31 @@ var getLenderPublicData = async (chainId, lenders, prices, additionalYields, mul
19944
20219
  abi: calls.map((call) => call.abi),
19945
20220
  batchSize: chainId === Chain.ETHEREUM_MAINNET ? 500 : void 0
19946
20221
  }),
19947
- tokenList()
20222
+ tokenList(),
20223
+ // Fluid SMART vaults (T2/T3/T4) need the DEX trading yield, which is
20224
+ // published nowhere on-chain. Cached + single-flighted; primed here
20225
+ // because the converters below are synchronous. If it fails, a smart row
20226
+ // still serves correct amounts and its liquidity-layer rate legs, just
20227
+ // without the trading leg. T1 is unaffected either way.
20228
+ validLenders.some(isFluid) ? fetchFluidApiData(chainId).catch(() => void 0) : Promise.resolve(void 0)
19948
20229
  ]);
20230
+ const fluidLender = validLenders.find(isFluid);
20231
+ if (fluidLender !== void 0) {
20232
+ try {
20233
+ const start = sliceStart[fluidLender] ?? 0;
20234
+ const vaults = rawResults?.[start];
20235
+ const referenced = /* @__PURE__ */ new Set();
20236
+ for (const v of vaults ?? []) {
20237
+ if (!v?.isSmartCol && !v?.isSmartDebt) continue;
20238
+ if (v?.isSmartCol && v?.constantVariables?.supply)
20239
+ referenced.add(String(v.constantVariables.supply).toLowerCase());
20240
+ if (v?.isSmartDebt && v?.constantVariables?.borrow)
20241
+ referenced.add(String(v.constantVariables.borrow).toLowerCase());
20242
+ }
20243
+ await fetchFluidDexState(chainId, multicallRetry, [...referenced]);
20244
+ } catch {
20245
+ }
20246
+ }
19949
20247
  const invalidLenders = [];
19950
20248
  let lenderData = {};
19951
20249
  let currentSlice = 0;
@@ -26474,7 +26772,7 @@ function bigintToLtv(v) {
26474
26772
  return Number.isFinite(n) ? n / 1e18 : 0;
26475
26773
  }
26476
26774
  }
26477
- var ZERO_ADDRESS4 = "0x0000000000000000000000000000000000000000";
26775
+ var ZERO_ADDRESS6 = "0x0000000000000000000000000000000000000000";
26478
26776
  function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additionalYields = {
26479
26777
  intrinsicYields: {},
26480
26778
  lenderRewards: {},
@@ -26577,8 +26875,8 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
26577
26875
  silo: self.silo.toLowerCase(),
26578
26876
  counterpartySilo: other.silo.toLowerCase(),
26579
26877
  siloConfig: registryEntry.siloConfig.toLowerCase(),
26580
- oracle: (api.solvencyOracleAddress || self.solvencyOracle || ZERO_ADDRESS4).toLowerCase(),
26581
- irm: (api.interestRateModelId || self.interestRateModel || ZERO_ADDRESS4).toLowerCase(),
26878
+ oracle: (api.solvencyOracleAddress || self.solvencyOracle || ZERO_ADDRESS6).toLowerCase(),
26879
+ irm: (api.interestRateModelId || self.interestRateModel || ZERO_ADDRESS6).toLowerCase(),
26582
26880
  shareTokens: {
26583
26881
  collateral: self.collateralShareToken,
26584
26882
  protected: self.protectedShareToken,
@@ -30881,11 +31179,11 @@ var getSiloV2UserDataConverter = (lender, chainId, account, metaMap) => {
30881
31179
  for (let s = 0; s < 2; s++) {
30882
31180
  const { self } = sides[s];
30883
31181
  const slot = s * SILO_V2_USER_CALLS_PER_SIDE;
30884
- const collateralShares = toBigInt6(data[slot]);
30885
- const protectedShares = toBigInt6(data[slot + 1]);
30886
- const collateralRate = toBigInt6(data[slot + 2]);
30887
- const protectedRate = toBigInt6(data[slot + 3]);
30888
- const repayRaw = toBigInt6(data[slot + 4]);
31182
+ const collateralShares = toBigInt7(data[slot]);
31183
+ const protectedShares = toBigInt7(data[slot + 1]);
31184
+ const collateralRate = toBigInt7(data[slot + 2]);
31185
+ const protectedRate = toBigInt7(data[slot + 3]);
31186
+ const repayRaw = toBigInt7(data[slot + 4]);
30889
31187
  const decimals = self.decimals;
30890
31188
  const oneUnit = BigInt(10) ** BigInt(decimals);
30891
31189
  const collateralAssets = oneUnit > 0n ? collateralShares * collateralRate / oneUnit : 0n;
@@ -30966,7 +31264,7 @@ var getSiloV2UserDataConverter = (lender, chainId, account, metaMap) => {
30966
31264
  SILO_V2_USER_CALLS_PER_PAIR
30967
31265
  ];
30968
31266
  };
30969
- function toBigInt6(v) {
31267
+ function toBigInt7(v) {
30970
31268
  if (v === void 0 || v === null || v === "0x") return 0n;
30971
31269
  if (typeof v === "bigint") return v;
30972
31270
  try {
@@ -30993,11 +31291,11 @@ var getSiloV3UserDataConverter = (lender, chainId, account, metaMap) => {
30993
31291
  for (let s = 0; s < 2; s++) {
30994
31292
  const { self } = sides[s];
30995
31293
  const slot = s * SILO_V3_USER_CALLS_PER_SIDE;
30996
- const collateralShares = toBigInt7(data[slot]);
30997
- const protectedShares = toBigInt7(data[slot + 1]);
30998
- const collateralRate = toBigInt7(data[slot + 2]);
30999
- const protectedRate = toBigInt7(data[slot + 3]);
31000
- const repayRaw = toBigInt7(data[slot + 4]);
31294
+ const collateralShares = toBigInt8(data[slot]);
31295
+ const protectedShares = toBigInt8(data[slot + 1]);
31296
+ const collateralRate = toBigInt8(data[slot + 2]);
31297
+ const protectedRate = toBigInt8(data[slot + 3]);
31298
+ const repayRaw = toBigInt8(data[slot + 4]);
31001
31299
  const decimals = self.decimals;
31002
31300
  const oneUnit = BigInt(10) ** BigInt(decimals);
31003
31301
  const collateralAssets = oneUnit > 0n ? collateralShares * collateralRate / oneUnit : 0n;
@@ -31076,7 +31374,7 @@ var getSiloV3UserDataConverter = (lender, chainId, account, metaMap) => {
31076
31374
  SILO_V3_USER_CALLS_PER_PAIR
31077
31375
  ];
31078
31376
  };
31079
- function toBigInt7(v) {
31377
+ function toBigInt8(v) {
31080
31378
  if (v === void 0 || v === null || v === "0x") return 0n;
31081
31379
  if (typeof v === "bigint") return v;
31082
31380
  try {
@@ -31087,7 +31385,7 @@ function toBigInt7(v) {
31087
31385
  }
31088
31386
  var FLUID_EEE_LOWER2 = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
31089
31387
  var normalizeUnderlying2 = (addr3) => addr3 === FLUID_EEE_LOWER2 ? zeroAddress : addr3;
31090
- function toBigInt8(v) {
31388
+ function toBigInt9(v) {
31091
31389
  if (v === void 0 || v === null || v === "0x") return 0n;
31092
31390
  if (typeof v === "bigint") return v;
31093
31391
  try {
@@ -31106,12 +31404,12 @@ var getFluidUserDataConverter = (lender, chainId, account, meta) => {
31106
31404
  const vaults = result[1];
31107
31405
  if (!Array.isArray(positions) || !Array.isArray(vaults) || positions.length === 0)
31108
31406
  return void 0;
31407
+ const dexState = getCachedFluidDexState(chainId);
31109
31408
  const perVault = /* @__PURE__ */ new Map();
31110
31409
  for (let i = 0; i < positions.length; i++) {
31111
31410
  const pos = positions[i];
31112
31411
  const vault = vaults[i];
31113
31412
  if (!vault?.constantVariables) continue;
31114
- if (vault.isSmartCol || vault.isSmartDebt) continue;
31115
31413
  if (pos.isLiquidated) continue;
31116
31414
  const vaultId = Number(vault.constantVariables.vaultId ?? 0);
31117
31415
  if (!perVault.has(vaultId)) perVault.set(vaultId, []);
@@ -31123,80 +31421,123 @@ var getFluidUserDataConverter = (lender, chainId, account, meta) => {
31123
31421
  const lenderKey = `${Lender.FLUID}_${chainId}_${vaultId}`;
31124
31422
  const metaMap = meta?.[lenderKey];
31125
31423
  if (!metaMap) continue;
31126
- const constants = nfts[0].vault.constantVariables;
31127
- const rawCol = (constants.supplyToken?.token0 ?? constants.supplyToken ?? "").toString().toLowerCase();
31128
- const rawLoan = (constants.borrowToken?.token0 ?? constants.borrowToken ?? "").toString().toLowerCase();
31129
- if (!rawCol || !rawLoan) continue;
31130
- const collateral = normalizeUnderlying2(rawCol);
31131
- const loan = normalizeUnderlying2(rawLoan);
31132
- const colMarketUid = createMarketUid(chainId, lenderKey, collateral);
31133
- const loanMarketUid = createMarketUid(chainId, lenderKey, loan);
31134
- const colMeta = metaMap[colMarketUid];
31135
- const loanMeta = metaMap[loanMarketUid];
31136
- const colDec = colMeta?.asset?.decimals ?? 18;
31137
- const loanDec = loanMeta?.asset?.decimals ?? 18;
31138
- const colDisplayPrice = colMeta ? getDisplayPrice(colMeta) : 0;
31139
- const colOraclePrice = colMeta ? getOraclePrice(colMeta) : 0;
31140
- const loanDisplayPrice = loanMeta ? getDisplayPrice(loanMeta) : 0;
31141
- const loanOraclePrice = loanMeta ? getOraclePrice(loanMeta) : 0;
31142
- const colPriceHist = colMeta?.price?.priceUsd24h ?? colDisplayPrice;
31143
- const loanPriceHist = loanMeta?.price?.priceUsd24h ?? loanDisplayPrice;
31424
+ const vaultData = nfts[0].vault;
31425
+ const constants = vaultData.constantVariables;
31426
+ const isSmartCol = !!vaultData.isSmartCol;
31427
+ const isSmartDebt = !!vaultData.isSmartDebt;
31428
+ const sideLegs = (side, isSmart, sideContract, perShareOf) => {
31429
+ const raw = side?.token0 !== void 0 ? side : { token0: side };
31430
+ const tokens = [
31431
+ normalizeUnderlying2((raw?.token0 ?? "").toString().toLowerCase())
31432
+ ];
31433
+ if (isSmart)
31434
+ tokens.push(
31435
+ normalizeUnderlying2((raw?.token1 ?? "").toString().toLowerCase())
31436
+ );
31437
+ if (!tokens[0]) return void 0;
31438
+ let perShare;
31439
+ if (isSmart) {
31440
+ const state = dexState?.[String(sideContract ?? "").toLowerCase()];
31441
+ if (!state) return void 0;
31442
+ perShare = perShareOf(state);
31443
+ }
31444
+ const legs = [];
31445
+ for (let i = 0; i < tokens.length; i++) {
31446
+ const token = tokens[i];
31447
+ const marketUid = createMarketUid(chainId, lenderKey, token);
31448
+ const m = metaMap[marketUid];
31449
+ if (!m) return void 0;
31450
+ legs.push({
31451
+ token,
31452
+ marketUid,
31453
+ decimals: m.asset?.decimals ?? 18,
31454
+ displayPrice: getDisplayPrice(m),
31455
+ oraclePrice: getOraclePrice(m),
31456
+ priceHist: m.price?.priceUsd24h ?? getDisplayPrice(m),
31457
+ // Simple side: the raw amount IS the token amount.
31458
+ // Smart side: it is a 1e18 LP share count, converted with the
31459
+ // DEX's per-share amounts (each already in ITS token's decimals).
31460
+ perShare: perShare?.[i]
31461
+ });
31462
+ }
31463
+ return legs;
31464
+ };
31465
+ const colLegs = sideLegs(
31466
+ constants.supplyToken,
31467
+ isSmartCol,
31468
+ constants.supply,
31469
+ (s) => [s.token0PerSupplyShare, s.token1PerSupplyShare]
31470
+ );
31471
+ const debtLegs = sideLegs(
31472
+ constants.borrowToken,
31473
+ isSmartDebt,
31474
+ constants.borrow,
31475
+ (s) => [s.token0PerBorrowShare, s.token1PerBorrowShare]
31476
+ );
31477
+ if (!colLegs || !debtLegs) continue;
31144
31478
  const lendingPositions = {};
31145
31479
  const modes = {};
31146
31480
  const histData = {};
31147
31481
  for (const { pos } of nfts) {
31148
31482
  const nftId = pos.nftId.toString();
31149
- const supplyRaw = toBigInt8(pos.supply);
31150
- const borrowRaw = toBigInt8(pos.borrow) + toBigInt8(pos.dustBorrow);
31483
+ const supplyRaw = toBigInt9(pos.supply);
31484
+ const borrowRaw = toBigInt9(pos.borrow) + toBigInt9(pos.dustBorrow);
31151
31485
  if (supplyRaw === 0n && borrowRaw === 0n) continue;
31152
- const depositsStr = parseRawAmount(
31153
- supplyRaw.toString(),
31154
- colDec
31155
- );
31156
- const debtStr = parseRawAmount(borrowRaw.toString(), loanDec);
31157
- const depositsNum = Number(depositsStr);
31158
- const debtNum = Number(debtStr);
31159
- const depositsUSD = depositsNum * colDisplayPrice;
31160
- const debtUSD = debtNum * loanDisplayPrice;
31161
- const depositsUSDOracle = depositsNum * colOraclePrice;
31162
- const debtUSDOracle = debtNum * loanOraclePrice;
31163
- histData[nftId] = {
31164
- totalDeposits24h: depositsNum * colPriceHist,
31165
- totalDebt24h: debtNum * loanPriceHist
31166
- };
31167
31486
  modes[nftId] = 0;
31168
31487
  const posData = {};
31169
- posData[colMarketUid] = {
31170
- marketUid: colMarketUid,
31171
- underlying: collateral,
31172
- deposits: depositsStr,
31173
- debt: "0",
31174
- debtStable: "0",
31175
- depositsUSD,
31176
- debtUSD: 0,
31177
- debtStableUSD: 0,
31178
- depositsUSDOracle,
31179
- debtUSDOracle: 0,
31180
- debtStableUSDOracle: 0,
31181
- stableBorrowRate: "0",
31182
- collateralEnabled: supplyRaw > 0n,
31183
- claimableRewards: 0
31488
+ let deposits24h = 0;
31489
+ let debt24h = 0;
31490
+ const entryFor = (leg) => {
31491
+ const existing = posData[leg.marketUid];
31492
+ if (existing) return existing;
31493
+ const created = {
31494
+ marketUid: leg.marketUid,
31495
+ underlying: leg.token,
31496
+ deposits: "0",
31497
+ debt: "0",
31498
+ debtStable: "0",
31499
+ depositsUSD: 0,
31500
+ debtUSD: 0,
31501
+ debtStableUSD: 0,
31502
+ depositsUSDOracle: 0,
31503
+ debtUSDOracle: 0,
31504
+ debtStableUSDOracle: 0,
31505
+ stableBorrowRate: "0",
31506
+ collateralEnabled: false,
31507
+ claimableRewards: 0
31508
+ };
31509
+ posData[leg.marketUid] = created;
31510
+ return created;
31184
31511
  };
31185
- posData[loanMarketUid] = {
31186
- marketUid: loanMarketUid,
31187
- underlying: loan,
31188
- deposits: "0",
31189
- debt: debtStr,
31190
- debtStable: "0",
31191
- depositsUSD: 0,
31192
- debtUSD,
31193
- debtStableUSD: 0,
31194
- depositsUSDOracle: 0,
31195
- debtUSDOracle,
31196
- debtStableUSDOracle: 0,
31197
- stableBorrowRate: "0",
31198
- collateralEnabled: false,
31199
- claimableRewards: 0
31512
+ const legRaw = (leg, raw) => leg.perShare === void 0 ? raw : raw * leg.perShare / 10n ** 18n;
31513
+ for (const leg of colLegs) {
31514
+ const amountStr = parseRawAmount(
31515
+ legRaw(leg, supplyRaw).toString(),
31516
+ leg.decimals
31517
+ );
31518
+ const amount3 = Number(amountStr);
31519
+ const e = entryFor(leg);
31520
+ e.deposits = amountStr;
31521
+ e.depositsUSD = amount3 * leg.displayPrice;
31522
+ e.depositsUSDOracle = amount3 * leg.oraclePrice;
31523
+ e.collateralEnabled = supplyRaw > 0n;
31524
+ deposits24h += amount3 * leg.priceHist;
31525
+ }
31526
+ for (const leg of debtLegs) {
31527
+ const amountStr = parseRawAmount(
31528
+ legRaw(leg, borrowRaw).toString(),
31529
+ leg.decimals
31530
+ );
31531
+ const amount3 = Number(amountStr);
31532
+ const e = entryFor(leg);
31533
+ e.debt = amountStr;
31534
+ e.debtUSD = amount3 * leg.displayPrice;
31535
+ e.debtUSDOracle = amount3 * leg.oraclePrice;
31536
+ debt24h += amount3 * leg.priceHist;
31537
+ }
31538
+ histData[nftId] = {
31539
+ totalDeposits24h: deposits24h,
31540
+ totalDebt24h: debt24h
31200
31541
  };
31201
31542
  lendingPositions[nftId] = posData;
31202
31543
  }
@@ -31220,7 +31561,7 @@ var getFluidUserDataConverter = (lender, chainId, account, meta) => {
31220
31561
  FLUID_USER_CALL_COUNT
31221
31562
  ];
31222
31563
  };
31223
- function toBigInt9(v) {
31564
+ function toBigInt10(v) {
31224
31565
  if (v === void 0 || v === null || v === "0x") return 0n;
31225
31566
  if (typeof v === "bigint") return v;
31226
31567
  try {
@@ -31304,7 +31645,7 @@ var getGearboxV3UserDataConverter = (_lender, chainId, account, meta) => {
31304
31645
  for (const ca of accounts) {
31305
31646
  const caAddress = (ca.creditAccount ?? ca.addr ?? "").toString().toLowerCase();
31306
31647
  if (!caAddress) continue;
31307
- const debtRaw = toBigInt9(ca.debt);
31648
+ const debtRaw = toBigInt10(ca.debt);
31308
31649
  const tokens = Array.isArray(ca.tokens) ? ca.tokens : Array.isArray(ca.balances) ? ca.balances : [];
31309
31650
  modes[caAddress] = 0;
31310
31651
  const posData = {};
@@ -31313,9 +31654,9 @@ var getGearboxV3UserDataConverter = (_lender, chainId, account, meta) => {
31313
31654
  const rawToken = (bal?.token ?? "").toString().toLowerCase();
31314
31655
  if (!rawToken) continue;
31315
31656
  const token = rawToken;
31316
- const balRaw = toBigInt9(bal.balance);
31657
+ const balRaw = toBigInt10(bal.balance);
31317
31658
  if (balRaw === 0n) continue;
31318
- const quotaRaw = toBigInt9(bal.quota);
31659
+ const quotaRaw = toBigInt10(bal.quota);
31319
31660
  const isQuoted = quotaRaw > 0n || !!bal?.isQuoted;
31320
31661
  const colMarketUid = createMarketUid(chainId, lenderKey, token);
31321
31662
  ensureMetaStub(metaMap, colMarketUid, token);
@@ -31490,7 +31831,7 @@ function normalizeUnderlying3(token) {
31490
31831
  const lower3 = token.toLowerCase();
31491
31832
  return Object.values(WETH_BY_CHAIN).includes(lower3) ? zeroAddress : lower3;
31492
31833
  }
31493
- function toBigInt10(v) {
31834
+ function toBigInt11(v) {
31494
31835
  if (v === void 0 || v === null || v === "0x") return 0n;
31495
31836
  if (typeof v === "bigint") return v;
31496
31837
  try {
@@ -31500,22 +31841,22 @@ function toBigInt10(v) {
31500
31841
  }
31501
31842
  }
31502
31843
  function readDebtUnits(positionResult) {
31503
- if (Array.isArray(positionResult)) return toBigInt10(positionResult[4]);
31844
+ if (Array.isArray(positionResult)) return toBigInt11(positionResult[4]);
31504
31845
  if (positionResult && typeof positionResult === "object")
31505
- return toBigInt10(positionResult.debt);
31846
+ return toBigInt11(positionResult.debt);
31506
31847
  return 0n;
31507
31848
  }
31508
31849
  function readUpdatedLender(updateResult) {
31509
31850
  if (Array.isArray(updateResult)) {
31510
31851
  return {
31511
- credit: toBigInt10(updateResult[0]),
31512
- pendingFee: toBigInt10(updateResult[1])
31852
+ credit: toBigInt11(updateResult[0]),
31853
+ pendingFee: toBigInt11(updateResult[1])
31513
31854
  };
31514
31855
  }
31515
31856
  if (updateResult && typeof updateResult === "object") {
31516
31857
  return {
31517
- credit: toBigInt10(updateResult.newCredit),
31518
- pendingFee: toBigInt10(updateResult.newPendingFee)
31858
+ credit: toBigInt11(updateResult.newCredit),
31859
+ pendingFee: toBigInt11(updateResult.newPendingFee)
31519
31860
  };
31520
31861
  }
31521
31862
  return { credit: 0n, pendingFee: 0n };
@@ -31586,7 +31927,7 @@ var getMidnightUserDataConverter = (_lender, chainId, account, meta) => {
31586
31927
  pendingFee: pendingFeeStr
31587
31928
  };
31588
31929
  market.collateralParams.forEach((c, i) => {
31589
- const collAmt = toBigInt10(collateralResults[i]);
31930
+ const collAmt = toBigInt11(collateralResults[i]);
31590
31931
  if (collAmt === 0n) return;
31591
31932
  anyBalance = true;
31592
31933
  const collAddr = c.token.toLowerCase();
@@ -31635,7 +31976,7 @@ var getMidnightUserDataConverter = (_lender, chainId, account, meta) => {
31635
31976
  ];
31636
31977
  };
31637
31978
  var WAD11 = 1000000000000000000n;
31638
- function toBigInt11(v) {
31979
+ function toBigInt12(v) {
31639
31980
  if (v === void 0 || v === null || v === "0x") return 0n;
31640
31981
  if (typeof v === "bigint") return v;
31641
31982
  try {
@@ -31672,11 +32013,11 @@ var getTermUserDataConverter = (_lender, chainId, account, meta) => {
31672
32013
  const loanDisplayPrice = loanMeta ? getDisplayPrice(loanMeta) : 0;
31673
32014
  const loanOraclePrice = loanMeta ? getOraclePrice(loanMeta) : 0;
31674
32015
  const loanPriceHist = loanMeta?.price?.priceUsd24h ?? loanDisplayPrice;
31675
- const debtUnits = toBigInt11(obligationResult);
32016
+ const debtUnits = toBigInt12(obligationResult);
31676
32017
  const debtStr = parseRawAmount(debtUnits.toString(), market.loanDecimals);
31677
32018
  const debtNum = Number(debtStr);
31678
- const repoBalance = toBigInt11(balanceResult);
31679
- const redemptionValue = toBigInt11(redemptionResult) || toBigInt11(market.redemptionValue) || WAD11;
32019
+ const repoBalance = toBigInt12(balanceResult);
32020
+ const redemptionValue = toBigInt12(redemptionResult) || toBigInt12(market.redemptionValue) || WAD11;
31680
32021
  const lentUnits = repoBalance * redemptionValue / WAD11;
31681
32022
  const depositsStr = parseRawAmount(lentUnits.toString(), market.loanDecimals);
31682
32023
  const depositsNum = Number(depositsStr);
@@ -31700,7 +32041,7 @@ var getTermUserDataConverter = (_lender, chainId, account, meta) => {
31700
32041
  claimableRewards: 0
31701
32042
  };
31702
32043
  market.collateralParams.forEach((c, i) => {
31703
- const collAmt = toBigInt11(collateralResults[i]);
32044
+ const collAmt = toBigInt12(collateralResults[i]);
31704
32045
  if (collAmt === 0n) return;
31705
32046
  anyBalance = true;
31706
32047
  const collAddr = c.token.toLowerCase();
@@ -33361,7 +33702,7 @@ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
33361
33702
  ];
33362
33703
  };
33363
33704
  var nowSec8 = () => Math.floor(Date.now() / 1e3);
33364
- function toBigInt12(v) {
33705
+ function toBigInt13(v) {
33365
33706
  if (v === void 0 || v === null || v === "0x") return 0n;
33366
33707
  if (typeof v === "bigint") return v;
33367
33708
  try {
@@ -33378,18 +33719,18 @@ function field11(res, name, index) {
33378
33719
  return void 0;
33379
33720
  }
33380
33721
  function parsePosition(res) {
33381
- const ftBalance = toBigInt12(field11(res, "ftBalance", 2));
33382
- const xtBalance = toBigInt12(field11(res, "xtBalance", 3));
33722
+ const ftBalance = toBigInt13(field11(res, "ftBalance", 2));
33723
+ const xtBalance = toBigInt13(field11(res, "xtBalance", 3));
33383
33724
  const rawGts = field11(res, "gtInfo", 4);
33384
33725
  const gts = [];
33385
33726
  if (Array.isArray(rawGts)) {
33386
33727
  for (const g of rawGts) {
33387
- const loanId = toBigInt12(field11(g, "loanId", 0));
33728
+ const loanId = toBigInt13(field11(g, "loanId", 0));
33388
33729
  if (loanId === 0n) continue;
33389
33730
  gts.push({
33390
33731
  loanId: loanId.toString(),
33391
- collateralAmt: toBigInt12(field11(g, "collateralAmt", 1)),
33392
- debtAmt: toBigInt12(field11(g, "debtAmt", 2))
33732
+ collateralAmt: toBigInt13(field11(g, "collateralAmt", 1)),
33733
+ debtAmt: toBigInt13(field11(g, "debtAmt", 2))
33393
33734
  });
33394
33735
  }
33395
33736
  }
@@ -38942,7 +39283,7 @@ async function fetchJsonWithProxyFallback(url, body, proxyConfig) {
38942
39283
  if (!proxyConfig) return void 0;
38943
39284
  return attemptFetchJson(url, body, proxyConfig);
38944
39285
  }
38945
- var inflight = /* @__PURE__ */ new Map();
39286
+ var inflight3 = /* @__PURE__ */ new Map();
38946
39287
  var resolved = /* @__PURE__ */ new Map();
38947
39288
  function cacheKey6(chainId, account) {
38948
39289
  return `${chainId}:${account.toLowerCase()}`;
@@ -38954,15 +39295,15 @@ async function dedupedFetch(chainId, account, loader) {
38954
39295
  if (cached && cached.expiresAt > now) {
38955
39296
  return cached.value;
38956
39297
  }
38957
- const existing = inflight.get(key3);
39298
+ const existing = inflight3.get(key3);
38958
39299
  if (existing) return existing;
38959
39300
  const promise = loader().then((value) => {
38960
39301
  resolved.set(key3, { value, expiresAt: Date.now() + CACHE_TTL_MS5 });
38961
39302
  return value;
38962
39303
  }).finally(() => {
38963
- inflight.delete(key3);
39304
+ inflight3.delete(key3);
38964
39305
  });
38965
- inflight.set(key3, promise);
39306
+ inflight3.set(key3, promise);
38966
39307
  return promise;
38967
39308
  }
38968
39309
  function hasMorphoUserSubgraph(chainId) {
@@ -47815,7 +48156,7 @@ var DLEND_POOLS = [
47815
48156
  pool: "0x6598DaD18Bda89A0E58A1F427c8CeBc0dE90F153"
47816
48157
  }
47817
48158
  ];
47818
- var ZERO_ADDRESS5 = "0x0000000000000000000000000000000000000000";
48159
+ var ZERO_ADDRESS7 = "0x0000000000000000000000000000000000000000";
47819
48160
  var SECONDS_PER_YEAR12 = 31536e3;
47820
48161
  var ABI = [
47821
48162
  {
@@ -47932,7 +48273,7 @@ var DTRINITY_SOURCE = {
47932
48273
  link: "https://docs.dtrinity.org/protocol-components/dlend",
47933
48274
  platform: "protocol"
47934
48275
  };
47935
- var isZero = (a) => !a || a.toLowerCase() === ZERO_ADDRESS5;
48276
+ var isZero = (a) => !a || a.toLowerCase() === ZERO_ADDRESS7;
47936
48277
  var scale = (raw, decimals) => Number(raw) / 10 ** decimals;
47937
48278
  function emptyReward2() {
47938
48279
  return {
@@ -50692,7 +51033,7 @@ var SiloOracleAbi = [
50692
51033
  type: "function"
50693
51034
  }
50694
51035
  ];
50695
- var ZERO_ADDRESS6 = "0x0000000000000000000000000000000000000000";
51036
+ var ZERO_ADDRESS8 = "0x0000000000000000000000000000000000000000";
50696
51037
  function lookupUSD(context, asset) {
50697
51038
  const lc = asset.toLowerCase();
50698
51039
  const groupKey = context.tokenList?.[lc]?.assetGroup ?? `${context.chainId}-${lc}`;
@@ -50704,7 +51045,7 @@ function getSiloV2Calls(chainId) {
50704
51045
  const tokensWithRealOracle = /* @__PURE__ */ new Set();
50705
51046
  for (const market of allMarkets) {
50706
51047
  for (const half of [market.silo0, market.silo1]) {
50707
- if (half.solvencyOracle && half.solvencyOracle !== ZERO_ADDRESS6) {
51048
+ if (half.solvencyOracle && half.solvencyOracle !== ZERO_ADDRESS8) {
50708
51049
  tokensWithRealOracle.add(half.token.toLowerCase());
50709
51050
  }
50710
51051
  }
@@ -50717,7 +51058,7 @@ function getSiloV2Calls(chainId) {
50717
51058
  const lenderKey = siloV2LenderKey(market.siloConfig);
50718
51059
  const halves = [market.silo0, market.silo1];
50719
51060
  const isStatic = halves.map(
50720
- (h) => !h.solvencyOracle || h.solvencyOracle === ZERO_ADDRESS6
51061
+ (h) => !h.solvencyOracle || h.solvencyOracle === ZERO_ADDRESS8
50721
51062
  );
50722
51063
  if (isStatic[0] && isStatic[1]) {
50723
51064
  const t0 = halves[0].token.toLowerCase();
@@ -50737,7 +51078,7 @@ function getSiloV2Calls(chainId) {
50737
51078
  decimals: half.decimals,
50738
51079
  silo: half.silo.toLowerCase(),
50739
51080
  lenderKey,
50740
- oracle: ZERO_ADDRESS6,
51081
+ oracle: ZERO_ADDRESS8,
50741
51082
  partnerToken: partnerLc,
50742
51083
  isStatic: true
50743
51084
  });
@@ -50861,7 +51202,7 @@ var SiloOracleAbi2 = [
50861
51202
  type: "function"
50862
51203
  }
50863
51204
  ];
50864
- var ZERO_ADDRESS7 = "0x0000000000000000000000000000000000000000";
51205
+ var ZERO_ADDRESS9 = "0x0000000000000000000000000000000000000000";
50865
51206
  function lookupUSD2(context, asset) {
50866
51207
  const lc = asset.toLowerCase();
50867
51208
  const groupKey = context.tokenList?.[lc]?.assetGroup ?? `${context.chainId}-${lc}`;
@@ -50873,7 +51214,7 @@ function getSiloV3Calls(chainId) {
50873
51214
  const tokensWithRealOracle = /* @__PURE__ */ new Set();
50874
51215
  for (const market of allMarkets) {
50875
51216
  for (const half of [market.silo0, market.silo1]) {
50876
- if (half.solvencyOracle && half.solvencyOracle !== ZERO_ADDRESS7) {
51217
+ if (half.solvencyOracle && half.solvencyOracle !== ZERO_ADDRESS9) {
50877
51218
  tokensWithRealOracle.add(half.token.toLowerCase());
50878
51219
  }
50879
51220
  }
@@ -50886,7 +51227,7 @@ function getSiloV3Calls(chainId) {
50886
51227
  const lenderKey = siloV3LenderKey(market.siloConfig);
50887
51228
  const halves = [market.silo0, market.silo1];
50888
51229
  const isStatic = halves.map(
50889
- (h) => !h.solvencyOracle || h.solvencyOracle === ZERO_ADDRESS7
51230
+ (h) => !h.solvencyOracle || h.solvencyOracle === ZERO_ADDRESS9
50890
51231
  );
50891
51232
  if (isStatic[0] && isStatic[1]) {
50892
51233
  const t0 = halves[0].token.toLowerCase();
@@ -50906,7 +51247,7 @@ function getSiloV3Calls(chainId) {
50906
51247
  decimals: half.decimals,
50907
51248
  silo: half.silo.toLowerCase(),
50908
51249
  lenderKey,
50909
- oracle: ZERO_ADDRESS7,
51250
+ oracle: ZERO_ADDRESS9,
50910
51251
  partnerToken: partnerLc,
50911
51252
  isStatic: true
50912
51253
  });
@@ -51285,7 +51626,7 @@ function lookupUSD3(context, asset) {
51285
51626
  return context.usdPrices[groupKey] ?? context.usdPrices[lc] ?? 0;
51286
51627
  }
51287
51628
  function parseSiloV2GraphQLResults(items, context) {
51288
- const ZERO_ADDRESS9 = "0x0000000000000000000000000000000000000000";
51629
+ const ZERO_ADDRESS11 = "0x0000000000000000000000000000000000000000";
51289
51630
  const out = [];
51290
51631
  const seen = /* @__PURE__ */ new Set();
51291
51632
  for (const item of items) {
@@ -51308,8 +51649,8 @@ function parseSiloV2GraphQLResults(items, context) {
51308
51649
  const partnerTokenLc = other.token.toLowerCase();
51309
51650
  const dedupKey = `${lenderKey}:${tokenLc}`;
51310
51651
  if (seen.has(dedupKey)) continue;
51311
- const oracleAddr = (side.solvencyOracleAddress ?? side.solvencyOracle?.id ?? self.solvencyOracle ?? ZERO_ADDRESS9).toLowerCase();
51312
- const isStatic = !oracleAddr || oracleAddr === ZERO_ADDRESS9;
51652
+ const oracleAddr = (side.solvencyOracleAddress ?? side.solvencyOracle?.id ?? self.solvencyOracle ?? ZERO_ADDRESS11).toLowerCase();
51653
+ const isStatic = !oracleAddr || oracleAddr === ZERO_ADDRESS11;
51313
51654
  const siloAddrLc = self.silo.toLowerCase();
51314
51655
  try {
51315
51656
  let priceUSD = 0;
@@ -51427,7 +51768,7 @@ function lookupUSD4(context, asset) {
51427
51768
  return context.usdPrices[groupKey] ?? context.usdPrices[lc] ?? 0;
51428
51769
  }
51429
51770
  function parseSiloV3GraphQLResults(items, context) {
51430
- const ZERO_ADDRESS9 = "0x0000000000000000000000000000000000000000";
51771
+ const ZERO_ADDRESS11 = "0x0000000000000000000000000000000000000000";
51431
51772
  const out = [];
51432
51773
  const seen = /* @__PURE__ */ new Set();
51433
51774
  for (const item of items) {
@@ -51450,8 +51791,8 @@ function parseSiloV3GraphQLResults(items, context) {
51450
51791
  const partnerTokenLc = other.token.toLowerCase();
51451
51792
  const dedupKey = `${lenderKey}:${tokenLc}`;
51452
51793
  if (seen.has(dedupKey)) continue;
51453
- const oracleAddr = (side.solvencyOracleAddress ?? side.solvencyOracle?.id ?? self.solvencyOracle ?? ZERO_ADDRESS9).toLowerCase();
51454
- const isStatic = !oracleAddr || oracleAddr === ZERO_ADDRESS9;
51794
+ const oracleAddr = (side.solvencyOracleAddress ?? side.solvencyOracle?.id ?? self.solvencyOracle ?? ZERO_ADDRESS11).toLowerCase();
51795
+ const isStatic = !oracleAddr || oracleAddr === ZERO_ADDRESS11;
51455
51796
  const siloAddrLc = self.silo.toLowerCase();
51456
51797
  try {
51457
51798
  let priceUSD = 0;
@@ -51573,7 +51914,7 @@ var AGGREGATOR_ABI = [...ChainlinkAggregatorAbi, ...DESCRIPTION_ABI];
51573
51914
  function isFailed(r) {
51574
51915
  return r === "0x" || r === void 0 || r === null;
51575
51916
  }
51576
- var ZERO_ADDRESS8 = "0x0000000000000000000000000000000000000000";
51917
+ var ZERO_ADDRESS10 = "0x0000000000000000000000000000000000000000";
51577
51918
  async function probeAaveFeedTimestamps(chainId, options = {}) {
51578
51919
  const { rpcOverrides, batchSize, retries = 2 } = options;
51579
51920
  const result = {};
@@ -51610,7 +51951,7 @@ async function probeAaveFeedTimestamps(chainId, options = {}) {
51610
51951
  const raw = sourceResults[i];
51611
51952
  if (isFailed(raw)) return;
51612
51953
  const source = String(raw).toLowerCase();
51613
- if (source === ZERO_ADDRESS8) return;
51954
+ if (source === ZERO_ADDRESS10) return;
51614
51955
  sourceOf.set(i, source);
51615
51956
  if (!sourceIndex.has(source)) {
51616
51957
  sourceIndex.set(source, uniqueSources.length);
@@ -56030,7 +56371,7 @@ var Multicall3BalanceAbi = [
56030
56371
  outputs: [{ type: "uint256" }]
56031
56372
  }
56032
56373
  ];
56033
- var toBigInt13 = (v) => {
56374
+ var toBigInt14 = (v) => {
56034
56375
  if (v === void 0 || v === null) return void 0;
56035
56376
  if (typeof v === "bigint") return v;
56036
56377
  if (typeof v === "number") return BigInt(v);
@@ -56054,12 +56395,12 @@ var readerBeetsStS = (entry) => ({
56054
56395
  ],
56055
56396
  abis: [TotalSupplyAbi, BeetsStSAbi, BeetsStSAbi],
56056
56397
  parse: ([supply, rate, pool]) => {
56057
- const totalSupply = toBigInt13(supply);
56058
- const exchangeRate = toBigInt13(rate);
56398
+ const totalSupply = toBigInt14(supply);
56399
+ const exchangeRate = toBigInt14(rate);
56059
56400
  if (totalSupply === void 0 || exchangeRate === void 0) {
56060
56401
  return void 0;
56061
56402
  }
56062
- const liquidity = toBigInt13(pool);
56403
+ const liquidity = toBigInt14(pool);
56063
56404
  return {
56064
56405
  totalAssets: totalSupply * exchangeRate / ONE_E189,
56065
56406
  totalSupply,
@@ -56100,12 +56441,12 @@ var readerBenqiSavax = (entry) => ({
56100
56441
  ],
56101
56442
  abis: [TotalSupplyAbi, BenqiSavaxAbi, BenqiSavaxAbi],
56102
56443
  parse: ([supply, rate, totalPooled]) => {
56103
- const totalSupply = toBigInt13(supply);
56104
- const exchangeRate = toBigInt13(rate);
56444
+ const totalSupply = toBigInt14(supply);
56445
+ const exchangeRate = toBigInt14(rate);
56105
56446
  if (totalSupply === void 0 || exchangeRate === void 0) {
56106
56447
  return void 0;
56107
56448
  }
56108
- const totalAssets = toBigInt13(totalPooled) ?? totalSupply * exchangeRate / ONE_E189;
56449
+ const totalAssets = toBigInt14(totalPooled) ?? totalSupply * exchangeRate / ONE_E189;
56109
56450
  return {
56110
56451
  totalAssets,
56111
56452
  totalSupply,
@@ -56119,7 +56460,7 @@ var readerBgtWrapper1to1 = (entry) => ({
56119
56460
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56120
56461
  abis: [TotalSupplyAbi],
56121
56462
  parse: ([supply]) => {
56122
- const totalSupply = toBigInt13(supply);
56463
+ const totalSupply = toBigInt14(supply);
56123
56464
  if (totalSupply === void 0) return void 0;
56124
56465
  return {
56125
56466
  totalAssets: totalSupply,
@@ -56148,8 +56489,8 @@ var readerDineroBeraEth = (entry) => ({
56148
56489
  ],
56149
56490
  abis: [TotalSupplyAbi, DineroBeraEthAbi],
56150
56491
  parse: ([supply, rate]) => {
56151
- const totalSupply = toBigInt13(supply);
56152
- const exchangeRate = toBigInt13(rate);
56492
+ const totalSupply = toBigInt14(supply);
56493
+ const exchangeRate = toBigInt14(rate);
56153
56494
  if (totalSupply === void 0 || exchangeRate === void 0) {
56154
56495
  return void 0;
56155
56496
  }
@@ -56170,9 +56511,9 @@ var readerErc4626 = (entry) => ({
56170
56511
  ],
56171
56512
  abis: [Erc4626ReadAbi, TotalSupplyAbi, Erc4626ReadAbi],
56172
56513
  parse: ([assets, supply, rate]) => {
56173
- const totalAssets = toBigInt13(assets);
56174
- const totalSupply = toBigInt13(supply);
56175
- const exchangeRate = toBigInt13(rate);
56514
+ const totalAssets = toBigInt14(assets);
56515
+ const totalSupply = toBigInt14(supply);
56516
+ const exchangeRate = toBigInt14(rate);
56176
56517
  if (totalAssets === void 0 || totalSupply === void 0 || exchangeRate === void 0) {
56177
56518
  return void 0;
56178
56519
  }
@@ -56187,9 +56528,9 @@ var readerErc4626PreviewRedeem = (entry) => ({
56187
56528
  ],
56188
56529
  abis: [Erc4626PreviewRedeemAbi, TotalSupplyAbi, Erc4626PreviewRedeemAbi],
56189
56530
  parse: ([assets, supply, rate]) => {
56190
- const totalAssets = toBigInt13(assets);
56191
- const totalSupply = toBigInt13(supply);
56192
- const exchangeRate = toBigInt13(rate);
56531
+ const totalAssets = toBigInt14(assets);
56532
+ const totalSupply = toBigInt14(supply);
56533
+ const exchangeRate = toBigInt14(rate);
56193
56534
  if (totalAssets === void 0 || totalSupply === void 0 || exchangeRate === void 0) {
56194
56535
  return void 0;
56195
56536
  }
@@ -56249,15 +56590,15 @@ var readerEtherFiWeEth = (entry) => {
56249
56590
  calls,
56250
56591
  abis,
56251
56592
  parse: (slice2) => {
56252
- const totalSupply = toBigInt13(slice2[0]);
56253
- const exchangeRate = toBigInt13(slice2[1]);
56593
+ const totalSupply = toBigInt14(slice2[0]);
56594
+ const exchangeRate = toBigInt14(slice2[1]);
56254
56595
  if (totalSupply === void 0 || exchangeRate === void 0) {
56255
56596
  return void 0;
56256
56597
  }
56257
56598
  let liquidity;
56258
56599
  if (lp) {
56259
- const lpBalance = toBigInt13(slice2[2]);
56260
- const locked = toBigInt13(slice2[3]);
56600
+ const lpBalance = toBigInt14(slice2[2]);
56601
+ const locked = toBigInt14(slice2[3]);
56261
56602
  if (lpBalance !== void 0 && locked !== void 0) {
56262
56603
  liquidity = lpBalance > locked ? lpBalance - locked : 0n;
56263
56604
  }
@@ -56291,7 +56632,7 @@ var readerHyperbeatBeHype = (entry) => {
56291
56632
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56292
56633
  abis: [TotalSupplyAbi],
56293
56634
  parse: ([supply]) => {
56294
- const totalSupply = toBigInt13(supply);
56635
+ const totalSupply = toBigInt14(supply);
56295
56636
  if (totalSupply === void 0) return void 0;
56296
56637
  return {
56297
56638
  totalAssets: totalSupply,
@@ -56308,8 +56649,8 @@ var readerHyperbeatBeHype = (entry) => {
56308
56649
  ],
56309
56650
  abis: [TotalSupplyAbi, HyperbeatStakingCoreAbi],
56310
56651
  parse: ([supply, rate]) => {
56311
- const totalSupply = toBigInt13(supply);
56312
- const exchangeRate = toBigInt13(rate);
56652
+ const totalSupply = toBigInt14(supply);
56653
+ const exchangeRate = toBigInt14(rate);
56313
56654
  if (totalSupply === void 0 || exchangeRate === void 0) {
56314
56655
  return void 0;
56315
56656
  }
@@ -56341,7 +56682,7 @@ var readerKelpRsEth = (entry) => {
56341
56682
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56342
56683
  abis: [TotalSupplyAbi],
56343
56684
  parse: ([supply]) => {
56344
- const totalSupply = toBigInt13(supply);
56685
+ const totalSupply = toBigInt14(supply);
56345
56686
  if (totalSupply === void 0) return void 0;
56346
56687
  return {
56347
56688
  totalAssets: totalSupply,
@@ -56358,8 +56699,8 @@ var readerKelpRsEth = (entry) => {
56358
56699
  ],
56359
56700
  abis: [TotalSupplyAbi, KelpLrtOracleAbi],
56360
56701
  parse: ([supply, rate]) => {
56361
- const totalSupply = toBigInt13(supply);
56362
- const exchangeRate = toBigInt13(rate);
56702
+ const totalSupply = toBigInt14(supply);
56703
+ const exchangeRate = toBigInt14(rate);
56363
56704
  if (totalSupply === void 0 || exchangeRate === void 0) {
56364
56705
  return void 0;
56365
56706
  }
@@ -56391,7 +56732,7 @@ var readerKinetiqKHype = (entry) => {
56391
56732
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56392
56733
  abis: [TotalSupplyAbi],
56393
56734
  parse: ([supply]) => {
56394
- const totalSupply = toBigInt13(supply);
56735
+ const totalSupply = toBigInt14(supply);
56395
56736
  if (totalSupply === void 0) return void 0;
56396
56737
  return {
56397
56738
  totalAssets: totalSupply,
@@ -56408,8 +56749,8 @@ var readerKinetiqKHype = (entry) => {
56408
56749
  ],
56409
56750
  abis: [TotalSupplyAbi, KinetiqStakingAccountantAbi],
56410
56751
  parse: ([supply, rate]) => {
56411
- const totalSupply = toBigInt13(supply);
56412
- const exchangeRate = toBigInt13(rate);
56752
+ const totalSupply = toBigInt14(supply);
56753
+ const exchangeRate = toBigInt14(rate);
56413
56754
  if (totalSupply === void 0 || exchangeRate === void 0) {
56414
56755
  return void 0;
56415
56756
  }
@@ -56449,12 +56790,12 @@ var readerLairStKaia = (entry) => ({
56449
56790
  ],
56450
56791
  abis: [TotalSupplyAbi, LairStKaiaAbi, LairStKaiaAbi],
56451
56792
  parse: ([supply, rate, totalStaking]) => {
56452
- const totalSupply = toBigInt13(supply);
56453
- const exchangeRate = toBigInt13(rate);
56793
+ const totalSupply = toBigInt14(supply);
56794
+ const exchangeRate = toBigInt14(rate);
56454
56795
  if (totalSupply === void 0 || exchangeRate === void 0) {
56455
56796
  return void 0;
56456
56797
  }
56457
- const totalAssets = toBigInt13(totalStaking) ?? totalSupply * exchangeRate / ONE_E189;
56798
+ const totalAssets = toBigInt14(totalStaking) ?? totalSupply * exchangeRate / ONE_E189;
56458
56799
  return {
56459
56800
  totalAssets,
56460
56801
  totalSupply,
@@ -56482,8 +56823,8 @@ var readerLidoWstEth = (entry) => ({
56482
56823
  ],
56483
56824
  abis: [TotalSupplyAbi, LidoWstEthAbi],
56484
56825
  parse: ([supply, rate]) => {
56485
- const totalSupply = toBigInt13(supply);
56486
- const exchangeRate = toBigInt13(rate);
56826
+ const totalSupply = toBigInt14(supply);
56827
+ const exchangeRate = toBigInt14(rate);
56487
56828
  if (totalSupply === void 0 || exchangeRate === void 0) {
56488
56829
  return void 0;
56489
56830
  }
@@ -56521,7 +56862,7 @@ var readerListaSlisBnb = (entry) => {
56521
56862
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56522
56863
  abis: [TotalSupplyAbi],
56523
56864
  parse: ([supply]) => {
56524
- const totalSupply = toBigInt13(supply);
56865
+ const totalSupply = toBigInt14(supply);
56525
56866
  if (totalSupply === void 0) return void 0;
56526
56867
  return {
56527
56868
  totalAssets: totalSupply,
@@ -56539,12 +56880,12 @@ var readerListaSlisBnb = (entry) => {
56539
56880
  ],
56540
56881
  abis: [TotalSupplyAbi, ListaStakeManagerReadAbi, ListaStakeManagerReadAbi],
56541
56882
  parse: ([supply, rate, pooled]) => {
56542
- const totalSupply = toBigInt13(supply);
56543
- const exchangeRate = toBigInt13(rate);
56883
+ const totalSupply = toBigInt14(supply);
56884
+ const exchangeRate = toBigInt14(rate);
56544
56885
  if (totalSupply === void 0 || exchangeRate === void 0) {
56545
56886
  return void 0;
56546
56887
  }
56547
- const pooledBnb = toBigInt13(pooled);
56888
+ const pooledBnb = toBigInt14(pooled);
56548
56889
  const totalAssets = pooledBnb ?? totalSupply * exchangeRate / ONE_E189;
56549
56890
  return { totalAssets, totalSupply, exchangeRate };
56550
56891
  }
@@ -56570,7 +56911,7 @@ var readerMantleMEth = (entry) => {
56570
56911
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56571
56912
  abis: [TotalSupplyAbi],
56572
56913
  parse: ([supply]) => {
56573
- const totalSupply = toBigInt13(supply);
56914
+ const totalSupply = toBigInt14(supply);
56574
56915
  if (totalSupply === void 0) return void 0;
56575
56916
  return {
56576
56917
  totalAssets: totalSupply,
@@ -56587,8 +56928,8 @@ var readerMantleMEth = (entry) => {
56587
56928
  ],
56588
56929
  abis: [TotalSupplyAbi, MantleStakingAbi],
56589
56930
  parse: ([supply, rate]) => {
56590
- const totalSupply = toBigInt13(supply);
56591
- const exchangeRate = toBigInt13(rate);
56931
+ const totalSupply = toBigInt14(supply);
56932
+ const exchangeRate = toBigInt14(rate);
56592
56933
  if (totalSupply === void 0 || exchangeRate === void 0) {
56593
56934
  return void 0;
56594
56935
  }
@@ -56609,7 +56950,7 @@ var readerOffChain = (entry) => {
56609
56950
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56610
56951
  abis: [TotalSupplyAbi],
56611
56952
  parse: ([supply]) => {
56612
- const totalSupply = toBigInt13(supply);
56953
+ const totalSupply = toBigInt14(supply);
56613
56954
  if (totalSupply === void 0) return void 0;
56614
56955
  return {
56615
56956
  totalAssets: rescaleDecimals(totalSupply, shareDec, underlyingDec),
@@ -56643,7 +56984,7 @@ var readerRenzoEzEth = (entry) => {
56643
56984
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56644
56985
  abis: [TotalSupplyAbi],
56645
56986
  parse: ([supply]) => {
56646
- const totalSupply = toBigInt13(supply);
56987
+ const totalSupply = toBigInt14(supply);
56647
56988
  if (totalSupply === void 0) return void 0;
56648
56989
  return {
56649
56990
  totalAssets: totalSupply,
@@ -56660,9 +57001,9 @@ var readerRenzoEzEth = (entry) => {
56660
57001
  ],
56661
57002
  abis: [TotalSupplyAbi, RenzoRestakeManagerAbi],
56662
57003
  parse: ([supply, tvls]) => {
56663
- const totalSupply = toBigInt13(supply);
57004
+ const totalSupply = toBigInt14(supply);
56664
57005
  if (totalSupply === void 0 || totalSupply === 0n) return void 0;
56665
- const totalTvl = Array.isArray(tvls) && tvls.length >= 3 ? toBigInt13(tvls[2]) : void 0;
57006
+ const totalTvl = Array.isArray(tvls) && tvls.length >= 3 ? toBigInt14(tvls[2]) : void 0;
56666
57007
  if (totalTvl === void 0) return void 0;
56667
57008
  return {
56668
57009
  totalAssets: totalTvl,
@@ -56716,12 +57057,12 @@ var readerRocketReth = (entry) => {
56716
57057
  calls,
56717
57058
  abis,
56718
57059
  parse: (slice2) => {
56719
- const totalSupply = toBigInt13(slice2[0]);
56720
- const exchangeRate = toBigInt13(slice2[1]);
57060
+ const totalSupply = toBigInt14(slice2[0]);
57061
+ const exchangeRate = toBigInt14(slice2[1]);
56721
57062
  if (totalSupply === void 0 || exchangeRate === void 0) {
56722
57063
  return void 0;
56723
57064
  }
56724
- const liquidity = depositPool ? toBigInt13(slice2[2]) : void 0;
57065
+ const liquidity = depositPool ? toBigInt14(slice2[2]) : void 0;
56725
57066
  return {
56726
57067
  totalAssets: totalSupply * exchangeRate / ONE_E189,
56727
57068
  totalSupply,
@@ -56760,7 +57101,7 @@ var readerStaderEthx = (entry) => {
56760
57101
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56761
57102
  abis: [TotalSupplyAbi],
56762
57103
  parse: ([supply]) => {
56763
- const totalSupply = toBigInt13(supply);
57104
+ const totalSupply = toBigInt14(supply);
56764
57105
  if (totalSupply === void 0) return void 0;
56765
57106
  return {
56766
57107
  totalAssets: totalSupply,
@@ -56777,8 +57118,8 @@ var readerStaderEthx = (entry) => {
56777
57118
  ],
56778
57119
  abis: [TotalSupplyAbi, StaderEthxAbi],
56779
57120
  parse: ([supply, rate]) => {
56780
- const totalSupply = toBigInt13(supply);
56781
- const exchangeRate = toBigInt13(rate);
57121
+ const totalSupply = toBigInt14(supply);
57122
+ const exchangeRate = toBigInt14(rate);
56782
57123
  if (totalSupply === void 0 || exchangeRate === void 0) {
56783
57124
  return void 0;
56784
57125
  }
@@ -56806,10 +57147,10 @@ var readerStaderMaticX = (entry) => {
56806
57147
  ],
56807
57148
  abis: [TotalSupplyAbi, StaderMaticXAbi],
56808
57149
  parse: ([supply, tup]) => {
56809
- const totalSupply = toBigInt13(supply);
57150
+ const totalSupply = toBigInt14(supply);
56810
57151
  if (!Array.isArray(tup) || tup.length < 3) return void 0;
56811
- const amountInMatic = toBigInt13(tup[0]);
56812
- const totalPooledMatic = toBigInt13(tup[2]);
57152
+ const amountInMatic = toBigInt14(tup[0]);
57153
+ const totalPooledMatic = toBigInt14(tup[2]);
56813
57154
  if (totalSupply === void 0 || amountInMatic === void 0) {
56814
57155
  return void 0;
56815
57156
  }
@@ -56842,7 +57183,7 @@ var readerStakeWiseOsEth = (entry) => {
56842
57183
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56843
57184
  abis: [TotalSupplyAbi],
56844
57185
  parse: ([supply]) => {
56845
- const totalSupply = toBigInt13(supply);
57186
+ const totalSupply = toBigInt14(supply);
56846
57187
  if (totalSupply === void 0) return void 0;
56847
57188
  return {
56848
57189
  totalAssets: totalSupply,
@@ -56859,8 +57200,8 @@ var readerStakeWiseOsEth = (entry) => {
56859
57200
  ],
56860
57201
  abis: [TotalSupplyAbi, StakeWiseOsTokenAbi],
56861
57202
  parse: ([supply, rate]) => {
56862
- const totalSupply = toBigInt13(supply);
56863
- const exchangeRate = toBigInt13(rate);
57203
+ const totalSupply = toBigInt14(supply);
57204
+ const exchangeRate = toBigInt14(rate);
56864
57205
  if (totalSupply === void 0 || exchangeRate === void 0) {
56865
57206
  return void 0;
56866
57207
  }
@@ -56892,7 +57233,7 @@ var readerStCelo = (entry) => {
56892
57233
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56893
57234
  abis: [TotalSupplyAbi],
56894
57235
  parse: ([supply]) => {
56895
- const totalSupply = toBigInt13(supply);
57236
+ const totalSupply = toBigInt14(supply);
56896
57237
  if (totalSupply === void 0) return void 0;
56897
57238
  return {
56898
57239
  totalAssets: totalSupply,
@@ -56909,8 +57250,8 @@ var readerStCelo = (entry) => {
56909
57250
  ],
56910
57251
  abis: [TotalSupplyAbi, StCeloManagerAbi],
56911
57252
  parse: ([supply, rate]) => {
56912
- const totalSupply = toBigInt13(supply);
56913
- const exchangeRate = toBigInt13(rate);
57253
+ const totalSupply = toBigInt14(supply);
57254
+ const exchangeRate = toBigInt14(rate);
56914
57255
  if (totalSupply === void 0 || exchangeRate === void 0) {
56915
57256
  return void 0;
56916
57257
  }
@@ -56942,8 +57283,8 @@ var readerSwellGetRate = (entry) => ({
56942
57283
  ],
56943
57284
  abis: [TotalSupplyAbi, SwellGetRateAbi],
56944
57285
  parse: ([supply, rate]) => {
56945
- const totalSupply = toBigInt13(supply);
56946
- const exchangeRate = toBigInt13(rate);
57286
+ const totalSupply = toBigInt14(supply);
57287
+ const exchangeRate = toBigInt14(rate);
56947
57288
  if (totalSupply === void 0 || exchangeRate === void 0) {
56948
57289
  return void 0;
56949
57290
  }
@@ -56974,7 +57315,7 @@ var readerValantisWstHype = (entry) => {
56974
57315
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
56975
57316
  abis: [TotalSupplyAbi],
56976
57317
  parse: ([supply]) => {
56977
- const totalSupply = toBigInt13(supply);
57318
+ const totalSupply = toBigInt14(supply);
56978
57319
  if (totalSupply === void 0) return void 0;
56979
57320
  return {
56980
57321
  totalAssets: totalSupply,
@@ -56991,8 +57332,8 @@ var readerValantisWstHype = (entry) => {
56991
57332
  ],
56992
57333
  abis: [TotalSupplyAbi, ValantisStHypeAbi],
56993
57334
  parse: ([supply, rate]) => {
56994
- const totalSupply = toBigInt13(supply);
56995
- const exchangeRate = toBigInt13(rate);
57335
+ const totalSupply = toBigInt14(supply);
57336
+ const exchangeRate = toBigInt14(rate);
56996
57337
  if (totalSupply === void 0 || exchangeRate === void 0) {
56997
57338
  return void 0;
56998
57339
  }
@@ -57026,7 +57367,7 @@ var readerVedaAccountant = (entry) => {
57026
57367
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
57027
57368
  abis: [TotalSupplyAbi],
57028
57369
  parse: ([supply]) => {
57029
- const totalSupply = toBigInt13(supply);
57370
+ const totalSupply = toBigInt14(supply);
57030
57371
  if (totalSupply === void 0) return void 0;
57031
57372
  return {
57032
57373
  totalAssets: rescaleDecimals(totalSupply, shareDec, underlyingDec),
@@ -57044,8 +57385,8 @@ var readerVedaAccountant = (entry) => {
57044
57385
  ],
57045
57386
  abis: [TotalSupplyAbi, VedaAccountantGetRateAbi],
57046
57387
  parse: ([supply, rate]) => {
57047
- const totalSupply = toBigInt13(supply);
57048
- const rawRate = toBigInt13(rate);
57388
+ const totalSupply = toBigInt14(supply);
57389
+ const rawRate = toBigInt14(rate);
57049
57390
  if (totalSupply === void 0 || rawRate === void 0) return void 0;
57050
57391
  const exchangeRate = rawRate * scale3;
57051
57392
  return {
@@ -57080,8 +57421,8 @@ var readerAnkrRatio = (entry) => ({
57080
57421
  ],
57081
57422
  abis: [TotalSupplyAbi, AnkrRatioAbi],
57082
57423
  parse: ([supply, ratio]) => {
57083
- const totalSupply = toBigInt13(supply);
57084
- const r = toBigInt13(ratio);
57424
+ const totalSupply = toBigInt14(supply);
57425
+ const r = toBigInt14(ratio);
57085
57426
  if (totalSupply === void 0 || r === void 0 || r === 0n) {
57086
57427
  return void 0;
57087
57428
  }
@@ -57112,8 +57453,8 @@ var readerBinanceWbeth = (entry) => ({
57112
57453
  ],
57113
57454
  abis: [TotalSupplyAbi, WbethExchangeRateAbi],
57114
57455
  parse: ([supply, rate]) => {
57115
- const totalSupply = toBigInt13(supply);
57116
- const exchangeRate = toBigInt13(rate);
57456
+ const totalSupply = toBigInt14(supply);
57457
+ const exchangeRate = toBigInt14(rate);
57117
57458
  if (totalSupply === void 0 || exchangeRate === void 0) {
57118
57459
  return void 0;
57119
57460
  }
@@ -57156,8 +57497,8 @@ var readerCoreEarnRate = (entry) => {
57156
57497
  ],
57157
57498
  abis: [CoreEarnRateAbi, TotalSupplyAbi],
57158
57499
  parse: ([rate, supply]) => {
57159
- const r = toBigInt13(rate);
57160
- const totalSupply = toBigInt13(supply);
57500
+ const r = toBigInt14(rate);
57501
+ const totalSupply = toBigInt14(supply);
57161
57502
  if (r === void 0 || r === 0n || totalSupply === void 0) {
57162
57503
  return void 0;
57163
57504
  }
@@ -57178,8 +57519,8 @@ var readerCoreStakedRatio = (entry) => {
57178
57519
  ],
57179
57520
  abis: [CoreTotalStakedAbi, TotalSupplyAbi],
57180
57521
  parse: ([staked, supply]) => {
57181
- const totalStaked = toBigInt13(staked);
57182
- const totalSupply = toBigInt13(supply);
57522
+ const totalStaked = toBigInt14(staked);
57523
+ const totalSupply = toBigInt14(supply);
57183
57524
  if (totalStaked === void 0 || totalSupply === void 0 || totalSupply === 0n) {
57184
57525
  return void 0;
57185
57526
  }
@@ -57218,8 +57559,8 @@ var readerKintsuSMon = (entry) => ({
57218
57559
  ],
57219
57560
  abis: [KintsuSMonAbi, KintsuSMonAbi],
57220
57561
  parse: ([pooled, shares]) => {
57221
- const totalAssets = toBigInt13(pooled);
57222
- const totalSupply = toBigInt13(shares);
57562
+ const totalAssets = toBigInt14(pooled);
57563
+ const totalSupply = toBigInt14(shares);
57223
57564
  if (totalAssets === void 0 || totalSupply === void 0) return void 0;
57224
57565
  const exchangeRate = totalSupply > 0n ? totalAssets * ONE_E189 / totalSupply : ONE_E189;
57225
57566
  return { totalAssets, totalSupply, exchangeRate };
@@ -57740,7 +58081,7 @@ var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList
57740
58081
  const validatorsByAddress = new Map(validatorEntries);
57741
58082
  const idleByAddress = /* @__PURE__ */ new Map();
57742
58083
  idleEntries.forEach((e, i) => {
57743
- const bal = toBigInt13(idleResults[i]);
58084
+ const bal = toBigInt14(idleResults[i]);
57744
58085
  if (bal !== void 0) idleByAddress.set(e.address.toLowerCase(), bal);
57745
58086
  });
57746
58087
  const rawResults = new Array(allCalls.length);
@@ -57870,7 +58211,7 @@ var BeetsStSWithdrawalAbi = [
57870
58211
  ];
57871
58212
 
57872
58213
  // src/vaults/lst/withdrawals/readers/shared.ts
57873
- var toBigInt14 = (v) => {
58214
+ var toBigInt15 = (v) => {
57874
58215
  if (v === void 0 || v === null) return void 0;
57875
58216
  if (typeof v === "bigint") return v;
57876
58217
  if (typeof v === "number") return BigInt(v);
@@ -57885,7 +58226,7 @@ var toBigInt14 = (v) => {
57885
58226
  return void 0;
57886
58227
  };
57887
58228
  var toNumber = (v) => {
57888
- const b = toBigInt14(v);
58229
+ const b = toBigInt15(v);
57889
58230
  if (b === void 0) return void 0;
57890
58231
  if (b > BigInt(Number.MAX_SAFE_INTEGER)) return void 0;
57891
58232
  return Number(b);
@@ -57922,7 +58263,7 @@ var readerBeets = {
57922
58263
  const out = [];
57923
58264
  for (let i = 0; i < reqs.length; i++) {
57924
58265
  const r = reqs[i];
57925
- const amount3 = toBigInt14(r.assetAmount);
58266
+ const amount3 = toBigInt15(r.assetAmount);
57926
58267
  const ts = toNumber(r.requestTimestamp);
57927
58268
  const isWithdrawn = Boolean(r.isWithdrawn);
57928
58269
  if (amount3 === void 0 || ts === void 0) continue;
@@ -58014,13 +58355,13 @@ var readerBeHype = {
58014
58355
  const q = stage2[i * 2];
58015
58356
  const canClaim = Boolean(stage2[i * 2 + 1]);
58016
58357
  if (!q) continue;
58017
- const hypeAmount = Array.isArray(q) ? toBigInt14(q[2]) : toBigInt14(q.hypeAmount);
58358
+ const hypeAmount = Array.isArray(q) ? toBigInt15(q[2]) : toBigInt15(q.hypeAmount);
58018
58359
  if (hypeAmount === void 0) continue;
58019
58360
  out.push({
58020
58361
  lst: entry.lst,
58021
58362
  brand: entry.brand,
58022
58363
  symbol: entry.symbol,
58023
- requestId: String(toBigInt14(ids[i]) ?? i),
58364
+ requestId: String(toBigInt15(ids[i]) ?? i),
58024
58365
  amountUnderlying: hypeAmount.toString(),
58025
58366
  status: canClaim ? "claimable" : "pending"
58026
58367
  });
@@ -58123,7 +58464,7 @@ var readerBenqi = {
58123
58464
  for (let i = 0; i < reqs.length; i++) {
58124
58465
  const r = reqs[i];
58125
58466
  const startedAt = toNumber(r.startedAt);
58126
- const shareAmount = toBigInt14(r.shareAmount);
58467
+ const shareAmount = toBigInt15(r.shareAmount);
58127
58468
  if (startedAt === void 0 || shareAmount === void 0) continue;
58128
58469
  const readyAt = startedAt + cooldown;
58129
58470
  const expiresAt = readyAt + claimWindow;
@@ -58212,8 +58553,8 @@ var readerBinanceWbeth2 = {
58212
58553
  for (let i = 0; i < reqs.length; i++) {
58213
58554
  const r = reqs[i];
58214
58555
  const triggerTime = toNumber(r.triggerTime);
58215
- const ethAmount = toBigInt14(r.ethAmount);
58216
- const wbethAmount = toBigInt14(r.wbethAmount);
58556
+ const ethAmount = toBigInt15(r.ethAmount);
58557
+ const wbethAmount = toBigInt15(r.wbethAmount);
58217
58558
  if (triggerTime === void 0 || ethAmount === void 0) continue;
58218
58559
  const readyAt = triggerTime + lockTime;
58219
58560
  const claimed = (toNumber(r.claimTime) ?? 0) > 0;
@@ -58276,8 +58617,8 @@ var readerBeraPaw = {
58276
58617
  }
58277
58618
  const pos = res[0];
58278
58619
  if (!pos) return [];
58279
- const queued = Array.isArray(pos) ? toBigInt14(pos[0]) : toBigInt14(pos.queued);
58280
- const available = Array.isArray(pos) ? toBigInt14(pos[1]) : toBigInt14(pos.available);
58620
+ const queued = Array.isArray(pos) ? toBigInt15(pos[0]) : toBigInt15(pos.queued);
58621
+ const available = Array.isArray(pos) ? toBigInt15(pos[1]) : toBigInt15(pos.available);
58281
58622
  const out = [];
58282
58623
  if (available !== void 0 && available > 0n) {
58283
58624
  out.push({
@@ -58359,7 +58700,7 @@ var readerIbera = {
58359
58700
  return [];
58360
58701
  }
58361
58702
  const length = toNumber(stage1[0]) ?? 0;
58362
- const frontier = toBigInt14(stage1[1]) ?? 0n;
58703
+ const frontier = toBigInt15(stage1[1]) ?? 0n;
58363
58704
  if (length === 0) return [];
58364
58705
  const start = length > MAX_SCAN ? length - MAX_SCAN : 0;
58365
58706
  const ids = Array.from({ length: length - start }, (_3, k) => start + k);
@@ -58383,7 +58724,7 @@ var readerIbera = {
58383
58724
  const r = stage2[k];
58384
58725
  if (!r) continue;
58385
58726
  const receiver = Array.isArray(r) ? r[2] : r.receiver;
58386
- const amount3 = Array.isArray(r) ? toBigInt14(r[3]) : toBigInt14(r.amount);
58727
+ const amount3 = Array.isArray(r) ? toBigInt15(r[3]) : toBigInt15(r.amount);
58387
58728
  if (typeof receiver !== "string" || receiver.toLowerCase() !== target || amount3 === void 0 || amount3 === 0n) {
58388
58729
  continue;
58389
58730
  }
@@ -58456,7 +58797,7 @@ var readerPrimeStaking = {
58456
58797
  return [];
58457
58798
  }
58458
58799
  const length = toNumber(stage1[0]) ?? 0;
58459
- const frontier = toBigInt14(stage1[1]) ?? 0n;
58800
+ const frontier = toBigInt15(stage1[1]) ?? 0n;
58460
58801
  if (length === 0) return [];
58461
58802
  const start = length > MAX_SCAN2 ? length - MAX_SCAN2 : 0;
58462
58803
  const ids = Array.from({ length: length - start }, (_3, k) => start + k);
@@ -58480,7 +58821,7 @@ var readerPrimeStaking = {
58480
58821
  const r = stage2[k];
58481
58822
  if (!r) continue;
58482
58823
  const receiver = Array.isArray(r) ? r[1] : r.receiver;
58483
- const assets = Array.isArray(r) ? toBigInt14(r[3]) : toBigInt14(r.assets);
58824
+ const assets = Array.isArray(r) ? toBigInt15(r[3]) : toBigInt15(r.assets);
58484
58825
  const processed = Array.isArray(r) ? r[4] : r.processed;
58485
58826
  if (typeof receiver !== "string" || receiver.toLowerCase() !== target || assets === void 0 || assets === 0n) {
58486
58827
  continue;
@@ -58551,8 +58892,8 @@ var readerErc7540 = {
58551
58892
  ],
58552
58893
  abi: [Erc7540Abi, Erc7540Abi]
58553
58894
  });
58554
- const pending = toBigInt14(stage1[0]) ?? 0n;
58555
- const claimable = toBigInt14(stage1[1]) ?? 0n;
58895
+ const pending = toBigInt15(stage1[0]) ?? 0n;
58896
+ const claimable = toBigInt15(stage1[1]) ?? 0n;
58556
58897
  const out = [];
58557
58898
  if (claimable > 0n) {
58558
58899
  const stage2 = await multicallRetry({
@@ -58566,7 +58907,7 @@ var readerErc7540 = {
58566
58907
  ],
58567
58908
  abi: [Erc7540Abi]
58568
58909
  });
58569
- const amount3 = toBigInt14(stage2[0]) ?? claimable;
58910
+ const amount3 = toBigInt15(stage2[0]) ?? claimable;
58570
58911
  out.push({
58571
58912
  lst: entry.lst,
58572
58913
  brand: entry.brand,
@@ -58623,11 +58964,11 @@ var readerEthenaCooldown = {
58623
58964
  let cooldownEnd;
58624
58965
  let amount3;
58625
58966
  if (Array.isArray(cell)) {
58626
- cooldownEnd = toBigInt14(cell[0]);
58627
- amount3 = toBigInt14(cell[1]);
58967
+ cooldownEnd = toBigInt15(cell[0]);
58968
+ amount3 = toBigInt15(cell[1]);
58628
58969
  } else if (cell && typeof cell === "object") {
58629
- cooldownEnd = toBigInt14(cell.cooldownEnd);
58630
- amount3 = toBigInt14(cell.underlyingAmount);
58970
+ cooldownEnd = toBigInt15(cell.cooldownEnd);
58971
+ amount3 = toBigInt15(cell.underlyingAmount);
58631
58972
  }
58632
58973
  if (!amount3 || amount3 === 0n) return [];
58633
58974
  const readyAt = Number(cooldownEnd ?? 0n);
@@ -58683,13 +59024,13 @@ var readerSusd3Cooldown = {
58683
59024
  let windowEnd;
58684
59025
  let shares;
58685
59026
  if (Array.isArray(cell)) {
58686
- cooldownEnd = toBigInt14(cell[0]);
58687
- windowEnd = toBigInt14(cell[1]);
58688
- shares = toBigInt14(cell[2]);
59027
+ cooldownEnd = toBigInt15(cell[0]);
59028
+ windowEnd = toBigInt15(cell[1]);
59029
+ shares = toBigInt15(cell[2]);
58689
59030
  } else if (cell && typeof cell === "object") {
58690
- cooldownEnd = toBigInt14(cell.cooldownEnd);
58691
- windowEnd = toBigInt14(cell.windowEnd);
58692
- shares = toBigInt14(cell.shares);
59031
+ cooldownEnd = toBigInt15(cell.cooldownEnd);
59032
+ windowEnd = toBigInt15(cell.windowEnd);
59033
+ shares = toBigInt15(cell.shares);
58693
59034
  }
58694
59035
  if (!shares || shares === 0n) return [];
58695
59036
  let amount3 = shares;
@@ -58701,7 +59042,7 @@ var readerSusd3Cooldown = {
58701
59042
  ],
58702
59043
  abi: [Susd3CooldownStatusAbi]
58703
59044
  });
58704
- amount3 = toBigInt14(stage2[0]) ?? shares;
59045
+ amount3 = toBigInt15(stage2[0]) ?? shares;
58705
59046
  } catch {
58706
59047
  }
58707
59048
  const readyAt = Number(cooldownEnd ?? 0n);
@@ -58775,12 +59116,12 @@ var readerStrataCooldown = {
58775
59116
  let claimable;
58776
59117
  let nextUnlockAt;
58777
59118
  if (Array.isArray(cell)) {
58778
- pending = toBigInt14(cell[0]);
58779
- claimable = toBigInt14(cell[1]);
59119
+ pending = toBigInt15(cell[0]);
59120
+ claimable = toBigInt15(cell[1]);
58780
59121
  nextUnlockAt = toNumber(cell[2]);
58781
59122
  } else if (cell && typeof cell === "object") {
58782
- pending = toBigInt14(cell.pending);
58783
- claimable = toBigInt14(cell.claimable);
59123
+ pending = toBigInt15(cell.pending);
59124
+ claimable = toBigInt15(cell.claimable);
58784
59125
  nextUnlockAt = toNumber(cell.nextUnlockAt);
58785
59126
  }
58786
59127
  const escrow = { withdrawQueue: contracts[i], claimToken: escrowToken };
@@ -58888,7 +59229,7 @@ var readerEtherFi = {
58888
59229
  calls: enumCalls,
58889
59230
  abi: enumCalls.map(() => EtherFiWithdrawRequestAbi)
58890
59231
  });
58891
- const ids = stage2.map(toBigInt14).filter((v) => v !== void 0);
59232
+ const ids = stage2.map(toBigInt15).filter((v) => v !== void 0);
58892
59233
  if (ids.length === 0) return [];
58893
59234
  const detailCalls = ids.flatMap((id) => [
58894
59235
  { address: entry.withdrawalContract, name: "getRequest", params: [id] },
@@ -58908,7 +59249,7 @@ var readerEtherFi = {
58908
59249
  const isValid = Boolean(stage3[i * 3 + 2]);
58909
59250
  if (!req) continue;
58910
59251
  if (!isValid) continue;
58911
- const amount3 = toBigInt14(req.amountOfEEth);
59252
+ const amount3 = toBigInt15(req.amountOfEEth);
58912
59253
  if (amount3 === void 0) continue;
58913
59254
  out.push({
58914
59255
  lst: entry.lst,
@@ -59003,7 +59344,7 @@ var readerKelp = {
59003
59344
  }
59004
59345
  ],
59005
59346
  abi: [KelpWithdrawalManagerAbi]
59006
- }).then((res) => toBigInt14(res[0]) ?? 0n)
59347
+ }).then((res) => toBigInt15(res[0]) ?? 0n)
59007
59348
  ]);
59008
59349
  lengths = storageReads;
59009
59350
  currentBlock = block;
@@ -59035,9 +59376,9 @@ var readerKelp = {
59035
59376
  for (let i = 0; i < detailCalls.length; i++) {
59036
59377
  const r = stage2[i];
59037
59378
  if (!r) continue;
59038
- const expected = Array.isArray(r) ? toBigInt14(r[1]) : toBigInt14(r.expectedAssetAmount);
59039
- const startBlock = Array.isArray(r) ? toBigInt14(r[2]) : toBigInt14(r.withdrawalStartBlock);
59040
- const nonce = Array.isArray(r) ? toBigInt14(r[3]) : toBigInt14(r.userNonce);
59379
+ const expected = Array.isArray(r) ? toBigInt15(r[1]) : toBigInt15(r.expectedAssetAmount);
59380
+ const startBlock = Array.isArray(r) ? toBigInt15(r[2]) : toBigInt15(r.withdrawalStartBlock);
59381
+ const nonce = Array.isArray(r) ? toBigInt15(r[3]) : toBigInt15(r.userNonce);
59041
59382
  if (expected === void 0 || startBlock === void 0) continue;
59042
59383
  const claimable = currentBlock >= startBlock + delayBlocks;
59043
59384
  out.push({
@@ -59114,7 +59455,7 @@ var readerLido = {
59114
59455
  abi: [LidoWithdrawalQueueAbi, LidoWithdrawalQueueAbi]
59115
59456
  });
59116
59457
  const ids = stage1[0];
59117
- const frontier = toBigInt14(stage1[1]) ?? 0n;
59458
+ const frontier = toBigInt15(stage1[1]) ?? 0n;
59118
59459
  if (!Array.isArray(ids) || ids.length === 0) return [];
59119
59460
  const stage2 = await multicallRetry({
59120
59461
  chain: chainId,
@@ -59131,10 +59472,10 @@ var readerLido = {
59131
59472
  if (!Array.isArray(statuses)) return [];
59132
59473
  const out = [];
59133
59474
  for (let i = 0; i < ids.length; i++) {
59134
- const id = toBigInt14(ids[i]);
59475
+ const id = toBigInt15(ids[i]);
59135
59476
  const s = statuses[i];
59136
59477
  if (id === void 0 || !s) continue;
59137
- const amountOfStETH = toBigInt14(s.amountOfStETH);
59478
+ const amountOfStETH = toBigInt15(s.amountOfStETH);
59138
59479
  const isFinalized = Boolean(s.isFinalized);
59139
59480
  const isClaimed = Boolean(s.isClaimed);
59140
59481
  if (amountOfStETH === void 0) continue;
@@ -59243,11 +59584,11 @@ var readerLista = {
59243
59584
  const status = stage2[i];
59244
59585
  if (!status) continue;
59245
59586
  const isClaimable = Array.isArray(status) ? Boolean(status[0]) : Boolean(status._isClaimable);
59246
- const bnbAmount = Array.isArray(status) ? toBigInt14(status[1]) : toBigInt14(status._amount);
59247
- const snbnbAmount = Array.isArray(req) ? toBigInt14(req[1]) : toBigInt14(req?.amountInSnBnb);
59587
+ const bnbAmount = Array.isArray(status) ? toBigInt15(status[1]) : toBigInt15(status._amount);
59588
+ const snbnbAmount = Array.isArray(req) ? toBigInt15(req[1]) : toBigInt15(req?.amountInSnBnb);
59248
59589
  const amount3 = bnbAmount ?? snbnbAmount;
59249
59590
  if (amount3 === void 0) continue;
59250
- const uuid = Array.isArray(req) ? toBigInt14(req[0]) : toBigInt14(req?.uuid);
59591
+ const uuid = Array.isArray(req) ? toBigInt15(req[0]) : toBigInt15(req?.uuid);
59251
59592
  out.push({
59252
59593
  lst: entry.lst,
59253
59594
  brand: entry.brand,
@@ -59332,7 +59673,7 @@ var readerRenzo = {
59332
59673
  for (let i = 0; i < count; i++) {
59333
59674
  const tup = stage2[i];
59334
59675
  if (!Array.isArray(tup) || tup.length < 5) continue;
59335
- const amountToRedeem = toBigInt14(tup[2]);
59676
+ const amountToRedeem = toBigInt15(tup[2]);
59336
59677
  const createdAt = toNumber(tup[4]);
59337
59678
  if (amountToRedeem === void 0 || createdAt === void 0) continue;
59338
59679
  const readyAt = createdAt + cooldown;
@@ -59405,9 +59746,9 @@ var readerStaderEthx2 = {
59405
59746
  ]
59406
59747
  });
59407
59748
  const ids = stage1[0];
59408
- const frontier = toBigInt14(stage1[1]) ?? 0n;
59749
+ const frontier = toBigInt15(stage1[1]) ?? 0n;
59409
59750
  if (!Array.isArray(ids) || ids.length === 0) return [];
59410
- const idBigInts = ids.map(toBigInt14).filter((v) => v !== void 0);
59751
+ const idBigInts = ids.map(toBigInt15).filter((v) => v !== void 0);
59411
59752
  const detailCalls = idBigInts.map((id) => ({
59412
59753
  address: entry.withdrawalContract,
59413
59754
  name: "userWithdrawRequests",
@@ -59423,8 +59764,8 @@ var readerStaderEthx2 = {
59423
59764
  const id = idBigInts[i];
59424
59765
  const tup = stage2[i];
59425
59766
  if (!Array.isArray(tup) || tup.length < 5) continue;
59426
- const ethExpected = toBigInt14(tup[2]) ?? 0n;
59427
- const ethFinalized = toBigInt14(tup[3]) ?? 0n;
59767
+ const ethExpected = toBigInt15(tup[2]) ?? 0n;
59768
+ const ethFinalized = toBigInt15(tup[3]) ?? 0n;
59428
59769
  const isFinalized = id < frontier && ethFinalized > 0n;
59429
59770
  const queuePosition = isFinalized ? 0 : Number(id - frontier);
59430
59771
  out.push({
@@ -59503,13 +59844,13 @@ var readerStaderMaticX2 = {
59503
59844
  });
59504
59845
  const arr = stage1[0];
59505
59846
  if (!Array.isArray(arr)) return [];
59506
- const currentEpoch = stakeManager ? toBigInt14(stage1[1]) ?? 0n : 0n;
59507
- const delay = stakeManager ? toBigInt14(stage1[2]) ?? 0n : 0n;
59847
+ const currentEpoch = stakeManager ? toBigInt15(stage1[1]) ?? 0n : 0n;
59848
+ const delay = stakeManager ? toBigInt15(stage1[2]) ?? 0n : 0n;
59508
59849
  const out = [];
59509
59850
  for (let i = 0; i < arr.length; i++) {
59510
59851
  const r = arr[i];
59511
- const amount3 = toBigInt14(r.amount) ?? 0n;
59512
- const requestEpoch = toBigInt14(r.requestEpoch);
59852
+ const amount3 = toBigInt15(r.amount) ?? 0n;
59853
+ const requestEpoch = toBigInt15(r.requestEpoch);
59513
59854
  if (requestEpoch === void 0) continue;
59514
59855
  const ready = stakeManager ? currentEpoch >= requestEpoch + delay : false;
59515
59856
  out.push({
@@ -59594,9 +59935,9 @@ var readerMantle = {
59594
59935
  if (typeof requester === "string" && requester.toLowerCase() !== lcUser) {
59595
59936
  continue;
59596
59937
  }
59597
- const ethRequested = Array.isArray(detail) ? toBigInt14(detail[3]) : toBigInt14(detail.ethRequested);
59938
+ const ethRequested = Array.isArray(detail) ? toBigInt15(detail[3]) : toBigInt15(detail.ethRequested);
59598
59939
  const isFinalized = Array.isArray(info) ? Boolean(info[0]) : Boolean(info.isFinalized);
59599
- const claimable = Array.isArray(info) ? toBigInt14(info[1]) : toBigInt14(info.claimableAmount);
59940
+ const claimable = Array.isArray(info) ? toBigInt15(info[1]) : toBigInt15(info.claimableAmount);
59600
59941
  if (ethRequested === void 0) continue;
59601
59942
  out.push({
59602
59943
  lst: entry.lst,
@@ -59675,8 +60016,8 @@ var readerPuffer = {
59675
60016
  calls,
59676
60017
  abi: calls.map(() => PufferWithdrawalManagerAbi)
59677
60018
  });
59678
- const finalizedBatch = toBigInt14(results[detailCalls.length]) ?? 0n;
59679
- const batchSize = toBigInt14(results[detailCalls.length + 1]) ?? 0n;
60019
+ const finalizedBatch = toBigInt15(results[detailCalls.length]) ?? 0n;
60020
+ const batchSize = toBigInt15(results[detailCalls.length + 1]) ?? 0n;
59680
60021
  const out = [];
59681
60022
  const lcUser = user.toLowerCase();
59682
60023
  for (let i = 0; i < ids.length; i++) {
@@ -59686,7 +60027,7 @@ var readerPuffer = {
59686
60027
  if (typeof recipient === "string" && recipient.toLowerCase() !== lcUser) {
59687
60028
  continue;
59688
60029
  }
59689
- const pufETHAmount = Array.isArray(d) ? toBigInt14(d[0]) : toBigInt14(d.pufETHAmount);
60030
+ const pufETHAmount = Array.isArray(d) ? toBigInt15(d[0]) : toBigInt15(d.pufETHAmount);
59690
60031
  if (pufETHAmount === void 0) continue;
59691
60032
  const batchIdx = batchSize > 0n ? ids[i] / batchSize : 0n;
59692
60033
  const claimable = batchIdx <= finalizedBatch;
@@ -59784,7 +60125,7 @@ var readerKinetiq = {
59784
60125
  for (let i = 0; i < count; i++) {
59785
60126
  const r = stage2[i];
59786
60127
  if (!r) continue;
59787
- const hypeAmount = Array.isArray(r) ? toBigInt14(r[0]) : toBigInt14(r.hypeAmount);
60128
+ const hypeAmount = Array.isArray(r) ? toBigInt15(r[0]) : toBigInt15(r.hypeAmount);
59788
60129
  const timestamp = Array.isArray(r) ? toNumber(r[4]) : toNumber(r.timestamp);
59789
60130
  if (hypeAmount === void 0 || hypeAmount === 0n || timestamp === void 0) {
59790
60131
  continue;
@@ -59912,7 +60253,7 @@ var readerStakeWise = {
59912
60253
  const claimedByIdx = /* @__PURE__ */ new Map();
59913
60254
  for (let i = 0; i < onChainChecks.length; i++) {
59914
60255
  const cell = checkResults[i];
59915
- const claimed = Array.isArray(cell) ? toBigInt14(cell[2]) : toBigInt14(cell?.claimedAssets);
60256
+ const claimed = Array.isArray(cell) ? toBigInt15(cell[2]) : toBigInt15(cell?.claimedAssets);
59916
60257
  if (claimed !== void 0 && claimed > 0n) {
59917
60258
  claimedByIdx.set(onChainChecks[i].idx, claimed);
59918
60259
  }
@@ -59920,7 +60261,7 @@ var readerStakeWise = {
59920
60261
  const out = [];
59921
60262
  for (let i = 0; i < requests.length; i++) {
59922
60263
  const r = requests[i];
59923
- const amount3 = toBigInt14(r.totalAssets) ?? 0n;
60264
+ const amount3 = toBigInt15(r.totalAssets) ?? 0n;
59924
60265
  const onChainClaimed = claimedByIdx.get(i);
59925
60266
  const claimable = onChainClaimed !== void 0 || r.isClaimable;
59926
60267
  out.push({
@@ -59977,7 +60318,7 @@ var readerStCelo2 = {
59977
60318
  const timestamps = cell[1] ?? [];
59978
60319
  const out = [];
59979
60320
  for (let i = 0; i < values.length; i++) {
59980
- const amount3 = toBigInt14(values[i]);
60321
+ const amount3 = toBigInt15(values[i]);
59981
60322
  const readyAt = toNumber(timestamps[i]);
59982
60323
  if (amount3 === void 0 || readyAt === void 0) continue;
59983
60324
  out.push({
@@ -60057,7 +60398,7 @@ var readerSwell = {
60057
60398
  abi: [SwellRswExitAbi, SwellRswExitAbi]
60058
60399
  });
60059
60400
  const count = toNumber(stage1[0]) ?? 0;
60060
- const lastProcessed = toBigInt14(stage1[1]) ?? 0n;
60401
+ const lastProcessed = toBigInt15(stage1[1]) ?? 0n;
60061
60402
  if (count === 0) return [];
60062
60403
  const enumCalls = Array.from({ length: count }, (_3, i) => ({
60063
60404
  address: entry.withdrawalContract,
@@ -60069,7 +60410,7 @@ var readerSwell = {
60069
60410
  calls: enumCalls,
60070
60411
  abi: enumCalls.map(() => SwellRswExitAbi)
60071
60412
  });
60072
- const ids = stage2.map(toBigInt14).filter((v) => v !== void 0);
60413
+ const ids = stage2.map(toBigInt15).filter((v) => v !== void 0);
60073
60414
  if (ids.length === 0) return [];
60074
60415
  const detailCalls = ids.map((id) => ({
60075
60416
  address: entry.withdrawalContract,
@@ -60086,7 +60427,7 @@ var readerSwell = {
60086
60427
  const id = ids[i];
60087
60428
  const r = stage3[i];
60088
60429
  if (!r) continue;
60089
- const amount3 = toBigInt14(r.amount);
60430
+ const amount3 = toBigInt15(r.amount);
60090
60431
  if (amount3 === void 0) continue;
60091
60432
  const claimable = id <= lastProcessed;
60092
60433
  out.push({
@@ -60160,14 +60501,14 @@ var readerValantis = {
60160
60501
  for (let i = 0; i < burns.length; i++) {
60161
60502
  const b = burns[i];
60162
60503
  if (!b) continue;
60163
- const amount3 = Array.isArray(b) ? toBigInt14(b[0]) : toBigInt14(b.amount);
60504
+ const amount3 = Array.isArray(b) ? toBigInt15(b[0]) : toBigInt15(b.amount);
60164
60505
  const completed = Array.isArray(b) ? Boolean(b[2]) : Boolean(b.completed);
60165
60506
  if (amount3 === void 0 || completed) continue;
60166
60507
  out.push({
60167
60508
  lst: entry.lst,
60168
60509
  brand: entry.brand,
60169
60510
  symbol: entry.symbol,
60170
- requestId: String(toBigInt14(ids[i]) ?? i),
60511
+ requestId: String(toBigInt15(ids[i]) ?? i),
60171
60512
  amountUnderlying: amount3.toString(),
60172
60513
  status: redeemable[i] ? "claimable" : "pending"
60173
60514
  });
@@ -60240,7 +60581,7 @@ var readerTruFin = {
60240
60581
  if (typeof recipient === "string" && recipient.toLowerCase() !== lcUser) {
60241
60582
  continue;
60242
60583
  }
60243
- const amount3 = Array.isArray(w) ? toBigInt14(w[1]) : toBigInt14(w.amount);
60584
+ const amount3 = Array.isArray(w) ? toBigInt15(w[1]) : toBigInt15(w.amount);
60244
60585
  if (amount3 === void 0 || amount3 === 0n) continue;
60245
60586
  out.push({
60246
60587
  lst: entry.lst,
@@ -60336,7 +60677,7 @@ var readerYieldNest = {
60336
60677
  calls: enumCalls,
60337
60678
  abi: enumCalls.map(() => YieldNestWithdrawalQueueAbi)
60338
60679
  });
60339
- const ids = stage2.map(toBigInt14).filter((v) => v !== void 0);
60680
+ const ids = stage2.map(toBigInt15).filter((v) => v !== void 0);
60340
60681
  if (ids.length === 0) return [];
60341
60682
  const detailCalls = ids.map((id) => ({
60342
60683
  address: entry.withdrawalContract,
@@ -60355,7 +60696,7 @@ var readerYieldNest = {
60355
60696
  const id = ids[i];
60356
60697
  const r = stage3[i];
60357
60698
  if (!r) continue;
60358
- const amount3 = toBigInt14(r.amount);
60699
+ const amount3 = toBigInt15(r.amount);
60359
60700
  const created = toNumber(r.creationTimestamp);
60360
60701
  const processed = Boolean(r.processed);
60361
60702
  if (amount3 === void 0 || created === void 0) continue;
@@ -61223,7 +61564,7 @@ var NavOracleReadAbi = [
61223
61564
 
61224
61565
  // src/vaults/savings/readers/shared.ts
61225
61566
  var ONE_E1811 = 10n ** 18n;
61226
- var toBigInt15 = (v) => {
61567
+ var toBigInt16 = (v) => {
61227
61568
  if (v === void 0 || v === null) return void 0;
61228
61569
  if (typeof v === "bigint") return v;
61229
61570
  if (typeof v === "number") return BigInt(v);
@@ -61254,9 +61595,9 @@ var readerErc46262 = (entry) => {
61254
61595
  ],
61255
61596
  abis: [Erc4626ReadAbi2, TotalSupplyAbi2, Erc4626ReadAbi2],
61256
61597
  parse: ([assets, supply, rate]) => {
61257
- const totalAssets = toBigInt15(assets);
61258
- const totalSupply = toBigInt15(supply);
61259
- const convertToAssetsRaw = toBigInt15(rate);
61598
+ const totalAssets = toBigInt16(assets);
61599
+ const totalSupply = toBigInt16(supply);
61600
+ const convertToAssetsRaw = toBigInt16(rate);
61260
61601
  if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
61261
61602
  return void 0;
61262
61603
  }
@@ -61442,13 +61783,13 @@ var readerErc4626Idle = (entry) => {
61442
61783
  ],
61443
61784
  abis: [Erc4626ReadAbi2, TotalSupplyAbi2, Erc4626ReadAbi2, BalanceOfAbi],
61444
61785
  parse: ([assets, supply, rate, inventoryBalance]) => {
61445
- const totalAssets = toBigInt15(assets);
61446
- const totalSupply = toBigInt15(supply);
61447
- const convertToAssetsRaw = toBigInt15(rate);
61786
+ const totalAssets = toBigInt16(assets);
61787
+ const totalSupply = toBigInt16(supply);
61788
+ const convertToAssetsRaw = toBigInt16(rate);
61448
61789
  if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
61449
61790
  return void 0;
61450
61791
  }
61451
- const capacity = toBigInt15(inventoryBalance);
61792
+ const capacity = toBigInt16(inventoryBalance);
61452
61793
  return {
61453
61794
  totalAssets,
61454
61795
  totalSupply,
@@ -61491,13 +61832,13 @@ var readerErc4626WithdrawLimit = (entry) => {
61491
61832
  AvailableWithdrawLimitAbi
61492
61833
  ],
61493
61834
  parse: ([assets, supply, rate, withdrawLimit]) => {
61494
- const totalAssets = toBigInt15(assets);
61495
- const totalSupply = toBigInt15(supply);
61496
- const convertToAssetsRaw = toBigInt15(rate);
61835
+ const totalAssets = toBigInt16(assets);
61836
+ const totalSupply = toBigInt16(supply);
61837
+ const convertToAssetsRaw = toBigInt16(rate);
61497
61838
  if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
61498
61839
  return void 0;
61499
61840
  }
61500
- const capacity = toBigInt15(withdrawLimit);
61841
+ const capacity = toBigInt16(withdrawLimit);
61501
61842
  return {
61502
61843
  totalAssets,
61503
61844
  totalSupply,
@@ -61520,9 +61861,9 @@ var readerFrankencoinSavings = (entry) => ({
61520
61861
  ],
61521
61862
  abis: [BalanceOfAbi, FrankencoinSavingsReadAbi],
61522
61863
  parse: ([balance, ratePPM]) => {
61523
- const deposits = toBigInt15(balance);
61864
+ const deposits = toBigInt16(balance);
61524
61865
  if (deposits === void 0) return void 0;
61525
- if (toBigInt15(ratePPM) === void 0) return void 0;
61866
+ if (toBigInt16(ratePPM) === void 0) return void 0;
61526
61867
  return {
61527
61868
  totalAssets: deposits,
61528
61869
  // No shares exist; the "supply" IS the deposited principal, and
@@ -61550,10 +61891,10 @@ var readerNavOracle = (entry) => {
61550
61891
  ],
61551
61892
  abis: [TotalSupplyAbi2, NavOracleReadAbi],
61552
61893
  parse: ([supply, round]) => {
61553
- const totalSupply = toBigInt15(supply);
61894
+ const totalSupply = toBigInt16(supply);
61554
61895
  if (totalSupply === void 0) return void 0;
61555
61896
  const raw = Array.isArray(round) ? round[1] : round?.answer;
61556
- const exchangeRate = toBigInt15(raw);
61897
+ const exchangeRate = toBigInt16(raw);
61557
61898
  if (exchangeRate === void 0 || exchangeRate <= 0n) return void 0;
61558
61899
  return {
61559
61900
  totalAssets: totalSupply * exchangeRate * underlyingUnit / (ONE_E1811 * shareUnit),
@@ -61595,14 +61936,14 @@ var readerNativeWnlp = (entry) => {
61595
61936
  NativeWithdrawQueueReadAbi
61596
61937
  ],
61597
61938
  parse: ([supply, rate, feeBips, instantEnabled, inventory, window]) => {
61598
- const totalSupply = toBigInt15(supply);
61599
- const exchangeRate = toBigInt15(rate);
61939
+ const totalSupply = toBigInt16(supply);
61940
+ const exchangeRate = toBigInt16(rate);
61600
61941
  if (totalSupply === void 0 || exchangeRate === void 0) {
61601
61942
  return void 0;
61602
61943
  }
61603
- const capacity = toBigInt15(inventory);
61604
- const windowSeconds = toBigInt15(window);
61605
- const bips = toBigInt15(feeBips);
61944
+ const capacity = toBigInt16(inventory);
61945
+ const windowSeconds = toBigInt16(window);
61946
+ const bips = toBigInt16(feeBips);
61606
61947
  return {
61607
61948
  totalAssets: totalSupply * exchangeRate / ONE_E1811,
61608
61949
  totalSupply,
@@ -61642,17 +61983,17 @@ var readerYieldBasisLt = (entry) => {
61642
61983
  YieldBasisAmmReadAbi
61643
61984
  ],
61644
61985
  parse: ([supply, pps, redeemPerShare, maxDebt, valueOracle]) => {
61645
- const totalSupply = toBigInt15(supply);
61646
- const fundamental = toBigInt15(pps);
61647
- const redeemRaw = toBigInt15(redeemPerShare);
61986
+ const totalSupply = toBigInt16(supply);
61987
+ const fundamental = toBigInt16(pps);
61988
+ const redeemRaw = toBigInt16(redeemPerShare);
61648
61989
  if (totalSupply === void 0 || fundamental === void 0 || redeemRaw === void 0) {
61649
61990
  return void 0;
61650
61991
  }
61651
61992
  if (totalSupply === 0n || redeemRaw === 0n) return void 0;
61652
61993
  const totalAssets = totalSupply * redeemRaw / ONE_SHARE;
61653
61994
  const exchangeRate = redeemRaw * ONE_E1811 / underlyingUnit;
61654
- const equity = Array.isArray(valueOracle) ? toBigInt15(valueOracle[1]) : toBigInt15(valueOracle?.value);
61655
- const cap = toBigInt15(maxDebt);
61995
+ const equity = Array.isArray(valueOracle) ? toBigInt16(valueOracle[1]) : toBigInt16(valueOracle?.value);
61996
+ const cap = toBigInt16(maxDebt);
61656
61997
  let depositCapacity;
61657
61998
  if (cap !== void 0 && equity !== void 0 && equity > 0n) {
61658
61999
  const headroom = cap / 2n - equity;
@@ -62173,7 +62514,7 @@ var resolveAaveEarnCuratorName = (chainId, owner) => {
62173
62514
 
62174
62515
  // src/vaults/aave-earn/fetchPublic.ts
62175
62516
  var BRAND2 = "Aave";
62176
- var toBigInt16 = (v) => {
62517
+ var toBigInt17 = (v) => {
62177
62518
  if (v === void 0 || v === null) return void 0;
62178
62519
  if (typeof v === "bigint") return v;
62179
62520
  if (typeof v === "number") return BigInt(v);
@@ -62233,15 +62574,15 @@ var fetchAaveEarnVaults = async (chainId, multicallRetry, prices = {}, tokenList
62233
62574
  const token = v.usedReserve.underlyingToken;
62234
62575
  const underlyingLc = token.address.toLowerCase();
62235
62576
  const assetDecimals = token.decimals;
62236
- const shareDecOnChain = toBigInt16(slice2[1]);
62577
+ const shareDecOnChain = toBigInt17(slice2[1]);
62237
62578
  const decimals = shareDecOnChain !== void 0 ? Number(shareDecOnChain) : assetDecimals;
62238
- const totalSupply = toBigInt16(slice2[2]);
62579
+ const totalSupply = toBigInt17(slice2[2]);
62239
62580
  if (totalSupply === void 0) continue;
62240
62581
  const shareUnit = 10n ** BigInt(decimals);
62241
62582
  const underlyingUnit = 10n ** BigInt(assetDecimals);
62242
- const convertToAssets = toBigInt16(slice2[3]) ?? 0n;
62583
+ const convertToAssets = toBigInt17(slice2[3]) ?? 0n;
62243
62584
  const convertToShares = convertToAssets > 0n ? shareUnit * underlyingUnit / convertToAssets : 0n;
62244
- const totalAssets = toBigInt16(slice2[0]) ?? totalSupply * convertToAssets / shareUnit;
62585
+ const totalAssets = toBigInt17(slice2[0]) ?? totalSupply * convertToAssets / shareUnit;
62245
62586
  const totalAssetsFormatted = Number(totalAssets) / 10 ** assetDecimals;
62246
62587
  const asset = tokenList[underlyingLc];
62247
62588
  const priceUsd = prices[underlyingLc] ?? (v.balance?.usdPerToken != null ? num7(v.balance.usdPerToken) : void 0);
@@ -64111,7 +64452,7 @@ async function getJson4(url, label) {
64111
64452
  }
64112
64453
  return response.json();
64113
64454
  }
64114
- function cache(slot, build, store) {
64455
+ function cache3(slot, build, store) {
64115
64456
  const now = Date.now();
64116
64457
  if (slot && now - slot.at < CACHE_TTL_MS6) return slot.promise;
64117
64458
  const promise = build();
@@ -64121,7 +64462,7 @@ function cache(slot, build, store) {
64121
64462
  return promise;
64122
64463
  }
64123
64464
  function fetchPendleApiMarkets() {
64124
- return cache(
64465
+ return cache3(
64125
64466
  marketsCache,
64126
64467
  async () => (await getJson4(PENDLE_MARKETS_URL, "markets"))?.markets ?? [],
64127
64468
  (c) => {
@@ -64131,7 +64472,7 @@ function fetchPendleApiMarkets() {
64131
64472
  }
64132
64473
  var assetKey = (chainId, address) => `${chainId}-${address.toLowerCase()}`;
64133
64474
  function fetchPendleApiAssets() {
64134
- return cache(
64475
+ return cache3(
64135
64476
  assetsCache,
64136
64477
  async () => {
64137
64478
  const json = await getJson4(PENDLE_ASSETS_URL, "assets");
@@ -68498,6 +68839,9 @@ var ROW_DESCRIPTOR_KEYS = [
68498
68839
  "resupply",
68499
68840
  "gearbox",
68500
68841
  "curvance",
68842
+ // Fluid: distinguishes a SMART (T2/T3/T4) vault, whose collateral and/or
68843
+ // debt is a two-token DEX LP position, from an ordinary T1 pool row.
68844
+ "fluid",
68501
68845
  "broker",
68502
68846
  "collateralProvider",
68503
68847
  "loanProvider",
@@ -69436,17 +69780,45 @@ var fluidAdapter = {
69436
69780
  id: "fluid",
69437
69781
  matches: isFluid,
69438
69782
  profileId: () => "pool.variable@v1",
69439
- build: (input) => ({
69440
- // Only claim the liquidity-layer basis when the layer totals are actually
69441
- // present. The origin does not select `irmTotal*` today, and asserting a
69442
- // basis we cannot verify is worse than reporting the plain market ratio —
69443
- // the validator rejects it for exactly that reason.
69444
- utilization: input.irmTotalDeposits != null && input.irmTotalDebt != null ? { basis: "liquidity-layer", lockupRatio: input.lockupRatio } : { lockupRatio: input.lockupRatio },
69445
- constraints: {
69446
- positionModel: "nft",
69447
- positionIdMeaning: "The Fluid vault position NFT id."
69448
- }
69449
- })
69783
+ build: (input) => {
69784
+ const smart = input.market?.fluid ?? {};
69785
+ const isSmartCol = !!smart.isSmartCol;
69786
+ const isSmartDebt = !!smart.isSmartDebt;
69787
+ const isSmart = isSmartCol || isSmartDebt;
69788
+ const pair = (p) => Array.isArray(p) ? p.join(" + ") : void 0;
69789
+ return {
69790
+ // Only claim the liquidity-layer basis when the layer totals are actually
69791
+ // present. The origin does not select `irmTotal*` today, and asserting a
69792
+ // basis we cannot verify is worse than reporting the plain market ratio —
69793
+ // the validator rejects it for exactly that reason.
69794
+ utilization: input.irmTotalDeposits != null && input.irmTotalDebt != null ? { basis: "liquidity-layer", lockupRatio: input.lockupRatio } : { lockupRatio: input.lockupRatio },
69795
+ constraints: {
69796
+ positionModel: "nft",
69797
+ positionIdMeaning: "The Fluid vault position NFT id.",
69798
+ ...isSmart ? {
69799
+ /**
69800
+ * A smart vault is NOT a plain pool, and the difference is what a
69801
+ * user is actually agreeing to:
69802
+ *
69803
+ * - the position is a two-token DEX LP share, so its value moves
69804
+ * with the pool's composition, not just with the two prices;
69805
+ * - the row's amount is this leg only — the other leg is a
69806
+ * sibling row of the same vault, and neither can be moved
69807
+ * alone;
69808
+ * - exiting means unwinding LP shares, which is bounded by
69809
+ * share-slippage parameters rather than a plain transfer.
69810
+ */
69811
+ notes: [
69812
+ isSmartCol ? `Collateral is a Fluid DEX LP position over ${pair(smart.collateralPair) ?? "two tokens"}; this row is one leg of it.` : void 0,
69813
+ isSmartDebt ? `Debt is a Fluid DEX LP position over ${pair(smart.debtPair) ?? "two tokens"}; this row is one leg of it.` : void 0,
69814
+ isSmartDebt ? "The borrow rate is NET of the trading yield the debt LP earns, so it can be negative." : void 0,
69815
+ isSmartCol ? "The supply rate INCLUDES the DEX trading yield on top of the liquidity-layer rate." : void 0,
69816
+ "Both legs of a side move together \u2014 a leg cannot be supplied, borrowed or withdrawn on its own."
69817
+ ].filter(Boolean)
69818
+ } : {}
69819
+ }
69820
+ };
69821
+ }
69450
69822
  };
69451
69823
  var gearboxAdapter = {
69452
69824
  id: "gearbox",