@1delta/margin-fetcher 5.0.138 → 5.0.140

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
@@ -6306,6 +6306,9 @@ var { uniq } = lodash;
6306
6306
  var ENABLED_COMPOUNDS = [
6307
6307
  Lender.VENUS,
6308
6308
  Lender.VENUS_ETH,
6309
+ // Venus Spoke pool (BNB) — supply-allowlisted stables, see pause.ts and
6310
+ // docs/lending/VENUS_SPOKE.md.
6311
+ Lender.VENUS_BSTOCK,
6309
6312
  Lender.MOONWELL,
6310
6313
  Lender.ENCLABS,
6311
6314
  Lender.ENCLABS_LST,
@@ -6948,8 +6951,8 @@ function scaledToDecimal(raw, decimals) {
6948
6951
  const neg = raw < 0n;
6949
6952
  const text = (neg ? -raw : raw).toString().padStart(decimals + 1, "0");
6950
6953
  const cut = text.length - decimals;
6951
- const frac2 = text.slice(cut).replace(/0+$/, "");
6952
- const out = frac2 ? `${text.slice(0, cut)}.${frac2}` : text.slice(0, cut);
6954
+ const frac3 = text.slice(cut).replace(/0+$/, "");
6955
+ const out = frac3 ? `${text.slice(0, cut)}.${frac3}` : text.slice(0, cut);
6953
6956
  return neg ? `-${out}` : out;
6954
6957
  }
6955
6958
  function toBigInt(v) {
@@ -11089,7 +11092,19 @@ function getMarketUidsFromMeta(meta) {
11089
11092
  }
11090
11093
 
11091
11094
  // src/lending/user-data/utils/createGeneralUserState.ts
11095
+ function assertFlatLendingPositions(lendingPositions) {
11096
+ if (!lendingPositions || typeof lendingPositions !== "object") return;
11097
+ for (const [key5, value] of Object.entries(lendingPositions)) {
11098
+ if (!value || typeof value !== "object" || "depositsUSD" in value) continue;
11099
+ const inner = Object.values(value);
11100
+ if (inner.length > 0 && inner.every((v) => v && typeof v === "object" && "marketUid" in v))
11101
+ throw new Error(
11102
+ `createBaseTypeUserState: lendingPositions['${key5}'] is a map of positions \u2014 the multi-account shape; pass lendingPositions[marketUid] or use createMultiAccountTypeUserState`
11103
+ );
11104
+ }
11105
+ }
11092
11106
  function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, totalDebt24h = 0, lender) {
11107
+ assertFlatLendingPositions(payload.lendingPositions);
11093
11108
  let assetKeys = getMarketUidsFromMeta(lenderData);
11094
11109
  const { chainId, account } = payload;
11095
11110
  const mode = String(payload.userEMode ?? 0);
@@ -11107,6 +11122,8 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
11107
11122
  let borrowDiscountedCollateral = 0;
11108
11123
  let borrowDiscountedCollateralAllActive = 0;
11109
11124
  let collateralAllActive = 0;
11125
+ let capacityDebt = 0;
11126
+ let hasCapacityWeights = false;
11110
11127
  let rewardsPerAsset = {};
11111
11128
  for (let i = 0; i < assetKeys.length; i++) {
11112
11129
  const marketUid = assetKeys[i];
@@ -11132,6 +11149,9 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
11132
11149
  debt += debtUSD;
11133
11150
  oracleDebt += debtStableUSDOracle;
11134
11151
  oracleDebt += debtUSDOracle;
11152
+ if (userConfigForAsset?.liquidationBorrowFactor != null)
11153
+ hasCapacityWeights = true;
11154
+ capacityDebt += (userConfigForAsset?.liquidationBorrowFactor != null ? userConfigForAsset.borrowFactor ?? 1 : 1) * (debtStableUSDOracle + debtUSDOracle);
11135
11155
  (rewards ?? []).forEach((rewardData) => {
11136
11156
  const key5 = rewardData.asset;
11137
11157
  rewardDepositAccrual += rewardData.depositRate * depositsUSD;
@@ -11158,6 +11178,14 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
11158
11178
  const effStableBorrowRate = Number.isFinite(posStableRate) && posStableRate > 0 ? posStableRate : stableBorrowRate;
11159
11179
  borrowInterest += debtStableUSD * effStableBorrowRate + debtUSD * variableBorrowRate;
11160
11180
  }
11181
+ const externalDebts = payload.externalDebts ?? [];
11182
+ const externalDebtUSD = externalDebts.reduce(
11183
+ (a, d) => a + (Number(d.debtUSD) || 0),
11184
+ 0
11185
+ );
11186
+ debt += externalDebtUSD;
11187
+ oracleDebt += externalDebtUSD;
11188
+ capacityDebt += externalDebtUSD;
11161
11189
  const nav = deposits - debt;
11162
11190
  const balanceData2 = {
11163
11191
  borrowDiscountedCollateral,
@@ -11188,7 +11216,7 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
11188
11216
  const userConfig = { selectedMode: mode, id: account, isWhitelisted };
11189
11217
  const creditLine = Math.max(
11190
11218
  0,
11191
- borrowDiscountedCollateral - balanceData2.adjustedDebt
11219
+ borrowDiscountedCollateral - (hasCapacityWeights ? capacityDebt : balanceData2.adjustedDebt)
11192
11220
  );
11193
11221
  for (let i = 0; i < assetKeys.length; i++) {
11194
11222
  const marketUid = assetKeys[i];
@@ -11257,6 +11285,7 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
11257
11285
  {
11258
11286
  health: balanceData2.debt === 0 ? null : balanceData2.adjustedDebt > 0 ? balanceData2.collateral / balanceData2.adjustedDebt : balanceData2.collateral / balanceData2.debt,
11259
11287
  borrowCapacityUSD: creditLine,
11288
+ ...externalDebts.length ? { externalDebts } : {},
11260
11289
  accountId: "0",
11261
11290
  balanceData: balanceData2,
11262
11291
  aprData: aprData2,
@@ -12196,9 +12225,10 @@ function createMultiAccountTypeUserState(payload, lenderData, histData, accountA
12196
12225
  accountId: posId,
12197
12226
  ...accountAddresses?.[posId] ? { accountAddress: accountAddresses[posId] } : {},
12198
12227
  health: balanceData2.debt === 0 ? null : balanceData2.adjustedDebt > 0 ? balanceData2.borrowDiscountedCollateral / balanceData2.adjustedDebt : balanceData2.collateral / balanceData2.debt,
12199
- ...hasLiquidationWeights ? {
12200
- liquidationHealth: balanceData2.debt === 0 ? null : balanceData2.collateral / liquidationAdjustedDebt
12201
- } : {},
12228
+ // against the LIQUIDATION thresholds — what the venue's own UI calls
12229
+ // health (Kamino, Euler, Fluid: LT ≠ LTV); `health` above is the
12230
+ // opening-side ratio and reads lower by exactly LTV / LT
12231
+ liquidationHealth: balanceData2.debt === 0 ? null : liquidationAdjustedDebt > 0 ? balanceData2.collateral / liquidationAdjustedDebt : balanceData2.collateral / balanceData2.debt,
12202
12232
  borrowCapacityUSD: creditLine,
12203
12233
  userConfig,
12204
12234
  // aggregated balance data
@@ -12633,15 +12663,15 @@ async function post(query3) {
12633
12663
  throw new Error(json.errors.map((e) => e?.message).join("; "));
12634
12664
  return json.data;
12635
12665
  }
12636
- async function pageAll(build9, field16, pageSize) {
12666
+ async function pageAll(build9, field17, pageSize) {
12637
12667
  const out = [];
12638
12668
  for (let page = 0; page < MAX_PAGES; page++) {
12639
- const items = (await post(build9(pageSize, page * pageSize)))?.[field16]?.items;
12640
- if (!Array.isArray(items)) throw new Error(`unexpected ${field16} shape`);
12669
+ const items = (await post(build9(pageSize, page * pageSize)))?.[field17]?.items;
12670
+ if (!Array.isArray(items)) throw new Error(`unexpected ${field17} shape`);
12641
12671
  out.push(...items);
12642
12672
  if (items.length < pageSize) return out;
12643
12673
  }
12644
- console.warn(`[morpho-vault-funded] ${field16}: hit MAX_PAGES, result truncated`);
12674
+ console.warn(`[morpho-vault-funded] ${field17}: hit MAX_PAGES, result truncated`);
12645
12675
  return out;
12646
12676
  }
12647
12677
  async function discover(chainId) {
@@ -13897,6 +13927,8 @@ var SHARED_LENS_ARBITRUM = {
13897
13927
  var COMPOUND_V2_LENS = {
13898
13928
  [Lender.VENUS]: VENUS_LENS,
13899
13929
  [Lender.VENUS_ETH]: VENUS_LENS,
13930
+ // The BNB Venus lens reads Spoke vTokens unchanged (verified 2026-10-26).
13931
+ [Lender.VENUS_BSTOCK]: VENUS_LENS,
13900
13932
  [Lender.MOONWELL]: MOONWELL_LENS,
13901
13933
  [Lender.ENCLABS]: ENCLABS_LENS,
13902
13934
  [Lender.ENCLABS_LST]: ENCLABS_LENS,
@@ -16053,6 +16085,17 @@ var ComptrollerAbi = [
16053
16085
  outputs: [{ internalType: "bool", name: "", type: "bool" }],
16054
16086
  stateMutability: "view",
16055
16087
  type: "function"
16088
+ },
16089
+ // Venus Spoke Comptroller (isolated-pools #559): a per-market supply
16090
+ // allowlist. When enabled, `mintAllowed` reverts for any supplier that is
16091
+ // not allowlisted — on the bStock-index pool that is everyone but the
16092
+ // Liquidity Hub — while the lens's `pausedActions` still reads MINT open.
16093
+ {
16094
+ inputs: [{ internalType: "address", name: "market", type: "address" }],
16095
+ name: "isSupplyAllowlistEnabled",
16096
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
16097
+ stateMutability: "view",
16098
+ type: "function"
16056
16099
  }
16057
16100
  ];
16058
16101
  var COMPTROLLER_PAUSE_READ_LENDERS = [
@@ -16083,6 +16126,10 @@ var COMPTROLLER_PAUSE_READ_LENDERS = [
16083
16126
  Lender.REACTOR_FUSION
16084
16127
  ];
16085
16128
  var usesComptrollerPauseReads = (lender) => COMPTROLLER_PAUSE_READ_LENDERS.includes(lender);
16129
+ var COMPTROLLER_SUPPLY_ALLOWLIST_LENDERS = [
16130
+ Lender.VENUS_BSTOCK
16131
+ ];
16132
+ var usesSupplyAllowlistReads = (lender) => COMPTROLLER_SUPPLY_ALLOWLIST_LENDERS.includes(lender);
16086
16133
  var parsePausedFlag = (raw) => typeof raw === "boolean" ? raw : void 0;
16087
16134
  var resolveMarketPause = (token, live) => {
16088
16135
  const mintPaused = live?.mintPaused ?? token?.mintPaused;
@@ -16090,6 +16137,334 @@ var resolveMarketPause = (token, live) => {
16090
16137
  if (mintPaused === void 0 && borrowPaused === void 0) return void 0;
16091
16138
  return { mintPaused, borrowPaused };
16092
16139
  };
16140
+ var applySupplyAllowlist = (pause, allowlistEnabled) => allowlistEnabled === true ? { ...pause, mintPaused: true } : pause;
16141
+
16142
+ // src/lending/public-data/compound-v2/convert/types.ts
16143
+ var PRICE_DECIMALS = 18;
16144
+ var RESERVE_MANTISSA_DECIMALS = 18;
16145
+ var resolveMarketPrice = (prices, asset, chainId) => {
16146
+ const group = asset?.assetGroup;
16147
+ if (group != null && prices[group] != null) return prices[group];
16148
+ const address = asset?.address?.toLowerCase();
16149
+ if (address != null) {
16150
+ const fallback = prices[`${chainId}-${address}`];
16151
+ if (fallback != null) return fallback;
16152
+ }
16153
+ return 0;
16154
+ };
16155
+
16156
+ // src/lending/public-data/compound-v2/venusEMode.ts
16157
+ var VENUS_EMODE_SETUPS = {
16158
+ [Chain.BNB_SMART_CHAIN_MAINNET]: {
16159
+ [Lender.VENUS]: {
16160
+ comptroller: "0xfD36E2c2a6789Db23113685031d7F16329158384",
16161
+ poolLens: "0xe797804c5d4410777c70EF8769c4eB9C39BEF662",
16162
+ // pinned (one multicall round, so no discovery); verified 2026-10-26
16163
+ // against the comptroller's own getters
16164
+ spotOracle: "0x6592b5DE802159F3E74B2486b091D11a8256ab8A",
16165
+ boundedOracle: "0xc79Cb7efEBd121DC4B39eA141C214606595D665A",
16166
+ vaiController: "0x004065D34C6b18cE4370ced1CeBDE94865DbFAFE"
16167
+ }
16168
+ }
16169
+ };
16170
+ var getVenusEModeSetup = (chainId, lender) => VENUS_EMODE_SETUPS[chainId]?.[lender];
16171
+ var VENUS_CORE_POOL_ID = 0;
16172
+ var POOL_MARKET_COMPONENTS = [
16173
+ { internalType: "bool", name: "isListed", type: "bool" },
16174
+ {
16175
+ internalType: "uint256",
16176
+ name: "collateralFactorMantissa",
16177
+ type: "uint256"
16178
+ },
16179
+ { internalType: "bool", name: "isVenus", type: "bool" },
16180
+ {
16181
+ internalType: "uint256",
16182
+ name: "liquidationThresholdMantissa",
16183
+ type: "uint256"
16184
+ },
16185
+ {
16186
+ internalType: "uint256",
16187
+ name: "liquidationIncentiveMantissa",
16188
+ type: "uint256"
16189
+ },
16190
+ { internalType: "uint96", name: "marketPoolId", type: "uint96" },
16191
+ { internalType: "bool", name: "isBorrowAllowed", type: "bool" }
16192
+ ];
16193
+ var VenusEModeAbi = [
16194
+ {
16195
+ // 7-tuple since the pool rollout; equals `poolMarkets(0, vToken)`.
16196
+ inputs: [{ internalType: "address", name: "vToken", type: "address" }],
16197
+ name: "markets",
16198
+ outputs: POOL_MARKET_COMPONENTS,
16199
+ stateMutability: "view",
16200
+ type: "function"
16201
+ },
16202
+ {
16203
+ inputs: [],
16204
+ name: "lastPoolId",
16205
+ outputs: [{ internalType: "uint96", name: "", type: "uint96" }],
16206
+ stateMutability: "view",
16207
+ type: "function"
16208
+ },
16209
+ {
16210
+ inputs: [{ internalType: "address", name: "account", type: "address" }],
16211
+ name: "userPoolId",
16212
+ outputs: [{ internalType: "uint96", name: "", type: "uint96" }],
16213
+ stateMutability: "view",
16214
+ type: "function"
16215
+ },
16216
+ {
16217
+ inputs: [{ internalType: "uint96", name: "poolId", type: "uint96" }],
16218
+ name: "pools",
16219
+ outputs: [
16220
+ { internalType: "string", name: "label", type: "string" },
16221
+ { internalType: "bool", name: "isActive", type: "bool" },
16222
+ { internalType: "bool", name: "allowCorePoolFallback", type: "bool" }
16223
+ ],
16224
+ stateMutability: "view",
16225
+ type: "function"
16226
+ },
16227
+ {
16228
+ inputs: [
16229
+ { internalType: "address", name: "account", type: "address" },
16230
+ { internalType: "uint96", name: "targetPoolId", type: "uint96" }
16231
+ ],
16232
+ name: "hasValidPoolBorrows",
16233
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
16234
+ stateMutability: "view",
16235
+ type: "function"
16236
+ },
16237
+ {
16238
+ inputs: [{ internalType: "address", name: "vToken", type: "address" }],
16239
+ name: "getBoundedPricesView",
16240
+ outputs: [
16241
+ { internalType: "uint256", name: "collateralPrice", type: "uint256" },
16242
+ { internalType: "uint256", name: "debtPrice", type: "uint256" }
16243
+ ],
16244
+ stateMutability: "view",
16245
+ type: "function"
16246
+ },
16247
+ {
16248
+ inputs: [{ internalType: "address", name: "vToken", type: "address" }],
16249
+ name: "getUnderlyingPrice",
16250
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
16251
+ stateMutability: "view",
16252
+ type: "function"
16253
+ },
16254
+ {
16255
+ inputs: [{ internalType: "address", name: "borrower", type: "address" }],
16256
+ name: "getVAIRepayAmount",
16257
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
16258
+ stateMutability: "view",
16259
+ type: "function"
16260
+ },
16261
+ {
16262
+ inputs: [
16263
+ { internalType: "address", name: "comptrollerAddress", type: "address" }
16264
+ ],
16265
+ name: "getAllPoolsData",
16266
+ outputs: [
16267
+ {
16268
+ components: [
16269
+ { internalType: "uint96", name: "poolId", type: "uint96" },
16270
+ { internalType: "string", name: "label", type: "string" },
16271
+ { internalType: "bool", name: "isActive", type: "bool" },
16272
+ {
16273
+ internalType: "bool",
16274
+ name: "allowCorePoolFallback",
16275
+ type: "bool"
16276
+ },
16277
+ {
16278
+ components: [
16279
+ { internalType: "uint96", name: "poolId", type: "uint96" },
16280
+ { internalType: "string", name: "poolLabel", type: "string" },
16281
+ { internalType: "address", name: "vToken", type: "address" },
16282
+ { internalType: "bool", name: "isListed", type: "bool" },
16283
+ {
16284
+ internalType: "uint256",
16285
+ name: "collateralFactor",
16286
+ type: "uint256"
16287
+ },
16288
+ { internalType: "bool", name: "isVenus", type: "bool" },
16289
+ {
16290
+ internalType: "uint256",
16291
+ name: "liquidationThreshold",
16292
+ type: "uint256"
16293
+ },
16294
+ {
16295
+ internalType: "uint256",
16296
+ name: "liquidationIncentive",
16297
+ type: "uint256"
16298
+ },
16299
+ { internalType: "bool", name: "isBorrowAllowed", type: "bool" }
16300
+ ],
16301
+ internalType: "struct VenusLens.MarketData[]",
16302
+ name: "markets",
16303
+ type: "tuple[]"
16304
+ }
16305
+ ],
16306
+ internalType: "struct VenusLens.PoolWithMarkets[]",
16307
+ name: "",
16308
+ type: "tuple[]"
16309
+ }
16310
+ ],
16311
+ stateMutability: "view",
16312
+ type: "function"
16313
+ }
16314
+ ];
16315
+ var frac = (v) => Number(parseRawAmount(String(v ?? 0), RESERVE_MANTISSA_DECIMALS));
16316
+ var field = (raw, name, index) => raw?.[name] !== void 0 ? raw[name] : raw?.[index];
16317
+ var parseVenusCoreMarket = (raw) => {
16318
+ if (isFailedCall(raw) || raw == null) return void 0;
16319
+ const cf = field(raw, "collateralFactorMantissa", 1);
16320
+ const lt = field(raw, "liquidationThresholdMantissa", 3);
16321
+ if (cf === void 0 || lt === void 0) return void 0;
16322
+ return {
16323
+ isListed: Boolean(field(raw, "isListed", 0)),
16324
+ collateralFactor: frac(cf),
16325
+ liquidationThreshold: frac(lt),
16326
+ liquidationIncentive: frac(field(raw, "liquidationIncentiveMantissa", 4)),
16327
+ isBorrowAllowed: Boolean(field(raw, "isBorrowAllowed", 6))
16328
+ };
16329
+ };
16330
+ var parseVenusPools = (allPoolsRaw, lastPoolIdRaw) => {
16331
+ if (isFailedCall(allPoolsRaw) || !Array.isArray(allPoolsRaw)) return void 0;
16332
+ if (isFailedCall(lastPoolIdRaw) || lastPoolIdRaw == null) return void 0;
16333
+ const lastPoolId = Number(lastPoolIdRaw);
16334
+ const pools = [];
16335
+ for (const p of allPoolsRaw) {
16336
+ const poolId = Number(field(p, "poolId", 0));
16337
+ if (poolId === VENUS_CORE_POOL_ID) continue;
16338
+ const markets = {};
16339
+ for (const m of field(p, "markets", 4) ?? []) {
16340
+ const vToken = String(field(m, "vToken", 2)).toLowerCase();
16341
+ markets[vToken] = {
16342
+ isListed: Boolean(field(m, "isListed", 3)),
16343
+ collateralFactor: frac(field(m, "collateralFactor", 4)),
16344
+ liquidationThreshold: frac(field(m, "liquidationThreshold", 6)),
16345
+ liquidationIncentive: frac(field(m, "liquidationIncentive", 7)),
16346
+ isBorrowAllowed: Boolean(field(m, "isBorrowAllowed", 8))
16347
+ };
16348
+ }
16349
+ pools.push({
16350
+ poolId,
16351
+ label: String(field(p, "label", 1) ?? ""),
16352
+ isActive: Boolean(field(p, "isActive", 2)),
16353
+ allowCorePoolFallback: Boolean(field(p, "allowCorePoolFallback", 3)),
16354
+ markets
16355
+ });
16356
+ }
16357
+ const ids = new Set(pools.map((p) => p.poolId));
16358
+ for (let i = 1; i <= lastPoolId; i++) if (!ids.has(i)) return void 0;
16359
+ return pools.sort((a, b) => a.poolId - b.poolId);
16360
+ };
16361
+ var venusPoolLabels = (pools) => {
16362
+ const count = /* @__PURE__ */ new Map();
16363
+ for (const p of pools) count.set(p.label, (count.get(p.label) ?? 0) + 1);
16364
+ const out = {};
16365
+ for (const p of pools)
16366
+ out[p.poolId] = !p.label || (count.get(p.label) ?? 0) > 1 ? `${p.label || "E-Mode"} #${p.poolId}` : p.label;
16367
+ return out;
16368
+ };
16369
+ var parseVenusPriceBounds = (boundedRaw, spotRaw) => {
16370
+ if (isFailedCall(boundedRaw) || isFailedCall(spotRaw)) return void 0;
16371
+ const spot = Number(spotRaw ?? 0);
16372
+ const coll = Number(field(boundedRaw, "collateralPrice", 0) ?? 0);
16373
+ const debt = Number(field(boundedRaw, "debtPrice", 1) ?? 0);
16374
+ if (!(spot > 0) || !(coll > 0) || !(debt > 0)) return void 0;
16375
+ return {
16376
+ collateral: Math.min(coll / spot, 1),
16377
+ debt: Math.max(debt / spot, 1)
16378
+ };
16379
+ };
16380
+ var entryFrom = (category, label, m, base, forceDebtDisabled) => ({
16381
+ label,
16382
+ category,
16383
+ // CF path prices at the bounded collateral price — folded into the weight,
16384
+ // since a row carries one (spot) price
16385
+ borrowCollateralFactor: m.collateralFactor * (base.bounds?.collateral ?? 1),
16386
+ collateralFactor: m.liquidationThreshold,
16387
+ // ... and at the bounded DEBT price: a borrow-capacity-only multiplier.
16388
+ // Liquidation weighs debt at spot, hence `liquidationBorrowFactor: 1`.
16389
+ borrowFactor: base.bounds?.debt ?? 1,
16390
+ liquidationBorrowFactor: 1,
16391
+ liquidationPenalty: Math.max(m.liquidationIncentive - 1, 0),
16392
+ closeFactor: base.closeFactor,
16393
+ // LT > 0 with CF 0 (TRX in its pool) still counts toward liquidation, so the
16394
+ // market is collateral; only a market weighted 0 on both is not.
16395
+ collateralDisabled: !base.listed || !m.isListed || m.collateralFactor === 0 && m.liquidationThreshold === 0,
16396
+ debtDisabled: forceDebtDisabled || !m.isListed || !m.isBorrowAllowed || base.borrowPaused
16397
+ });
16398
+ var buildVenusModeConfigs = (vToken, core, pools, base) => {
16399
+ const listed = core.isListed;
16400
+ const b = { ...base, listed };
16401
+ const out = {
16402
+ [VENUS_CORE_POOL_ID]: entryFrom(VENUS_CORE_POOL_ID, "Core", core, b, false)
16403
+ };
16404
+ if (!pools) return out;
16405
+ const labels = venusPoolLabels(pools);
16406
+ const key5 = vToken.toLowerCase();
16407
+ const zero2 = {
16408
+ isListed: true,
16409
+ collateralFactor: 0,
16410
+ liquidationThreshold: 0,
16411
+ liquidationIncentive: 1,
16412
+ isBorrowAllowed: false
16413
+ };
16414
+ for (const p of pools) {
16415
+ const label = labels[p.poolId];
16416
+ const member = p.markets[key5];
16417
+ let entry2;
16418
+ if (!p.isActive) entry2 = entryFrom(p.poolId, label, core, b, true);
16419
+ else if (member?.isListed)
16420
+ entry2 = entryFrom(p.poolId, label, member, b, false);
16421
+ else if (p.allowCorePoolFallback)
16422
+ entry2 = entryFrom(p.poolId, label, core, b, true);
16423
+ else
16424
+ entry2 = {
16425
+ ...entryFrom(p.poolId, label, zero2, b, true),
16426
+ collateralDisabled: true
16427
+ };
16428
+ out[p.poolId] = entry2;
16429
+ }
16430
+ return out;
16431
+ };
16432
+ var ISOLATED_THRESHOLD_LENDERS = [
16433
+ Lender.VENUS_ETH,
16434
+ Lender.VENUS_BSTOCK
16435
+ ];
16436
+ var usesIsolatedThresholdReads = (lender) => ISOLATED_THRESHOLD_LENDERS.includes(lender);
16437
+ var IsolatedComptrollerMarketsAbi = [
16438
+ {
16439
+ inputs: [{ internalType: "address", name: "vToken", type: "address" }],
16440
+ name: "markets",
16441
+ outputs: [
16442
+ { internalType: "bool", name: "isListed", type: "bool" },
16443
+ {
16444
+ internalType: "uint256",
16445
+ name: "collateralFactorMantissa",
16446
+ type: "uint256"
16447
+ },
16448
+ {
16449
+ internalType: "uint256",
16450
+ name: "liquidationThresholdMantissa",
16451
+ type: "uint256"
16452
+ }
16453
+ ],
16454
+ stateMutability: "view",
16455
+ type: "function"
16456
+ }
16457
+ ];
16458
+ var parseIsolatedThreshold = (raw) => {
16459
+ if (!Array.isArray(raw) || raw.length < 3) return void 0;
16460
+ try {
16461
+ const cf = BigInt(raw[1]);
16462
+ const lt = BigInt(raw[2]);
16463
+ return lt > 0n && lt >= cf ? lt : void 0;
16464
+ } catch {
16465
+ return void 0;
16466
+ }
16467
+ };
16093
16468
 
16094
16469
  // src/lending/public-data/compound-v2/publicCallBuild.ts
16095
16470
  var buildCompoundV2StyleLenderReserveCall = (chainId, lender) => {
@@ -16183,6 +16558,60 @@ var buildCompoundV2StyleLenderReserveCall = (chainId, lender) => {
16183
16558
  }
16184
16559
  }
16185
16560
  }
16561
+ if (usesSupplyAllowlistReads(lender)) {
16562
+ for (const tk of tokens) {
16563
+ calls.push({
16564
+ abi: ComptrollerAbi,
16565
+ address: stdComptroller,
16566
+ name: "isSupplyAllowlistEnabled",
16567
+ params: [tk.cToken]
16568
+ });
16569
+ }
16570
+ }
16571
+ const emode = getVenusEModeSetup(chainId, lender);
16572
+ if (emode) {
16573
+ for (const tk of tokens) {
16574
+ calls.push({
16575
+ abi: VenusEModeAbi,
16576
+ address: emode.comptroller,
16577
+ name: "markets",
16578
+ params: [tk.cToken]
16579
+ });
16580
+ }
16581
+ calls.push({
16582
+ abi: VenusEModeAbi,
16583
+ address: emode.comptroller,
16584
+ name: "lastPoolId",
16585
+ params: []
16586
+ });
16587
+ calls.push({
16588
+ abi: VenusEModeAbi,
16589
+ address: emode.poolLens,
16590
+ name: "getAllPoolsData",
16591
+ params: [emode.comptroller]
16592
+ });
16593
+ for (const [address, name] of [
16594
+ [emode.boundedOracle, "getBoundedPricesView"],
16595
+ [emode.spotOracle, "getUnderlyingPrice"]
16596
+ ])
16597
+ for (const tk of tokens)
16598
+ calls.push({
16599
+ abi: VenusEModeAbi,
16600
+ address,
16601
+ name,
16602
+ params: [tk.cToken]
16603
+ });
16604
+ }
16605
+ if (usesIsolatedThresholdReads(lender)) {
16606
+ for (const tk of tokens) {
16607
+ calls.push({
16608
+ abi: IsolatedComptrollerMarketsAbi,
16609
+ address: stdComptroller,
16610
+ name: "markets",
16611
+ params: [tk.cToken]
16612
+ });
16613
+ }
16614
+ }
16186
16615
  }
16187
16616
  return calls;
16188
16617
  };
@@ -16445,7 +16874,7 @@ function toAddress(value) {
16445
16874
  return value.toString();
16446
16875
  throw new Error(`Cannot convert value to address string: ${String(value)}`);
16447
16876
  }
16448
- function field(src, key5, index) {
16877
+ function field2(src, key5, index) {
16449
16878
  if (src == null) throw new Error("Source is null/undefined");
16450
16879
  if (key5 in src) return src[key5];
16451
16880
  if (Array.isArray(src)) return src[index];
@@ -16453,57 +16882,57 @@ function field(src, key5, index) {
16453
16882
  }
16454
16883
  function parseMarketIncentives(input) {
16455
16884
  return {
16456
- token: toAddress(field(input, "token", 0)),
16457
- supplyIncentivesPerSec: toBigInt2(field(input, "supplyIncentivesPerSec", 1)),
16458
- borrowIncentivesPerSec: toBigInt2(field(input, "borrowIncentivesPerSec", 2))
16885
+ token: toAddress(field2(input, "token", 0)),
16886
+ supplyIncentivesPerSec: toBigInt2(field2(input, "supplyIncentivesPerSec", 1)),
16887
+ borrowIncentivesPerSec: toBigInt2(field2(input, "borrowIncentivesPerSec", 2))
16459
16888
  };
16460
16889
  }
16461
16890
  function parseMoonwellMarket(input, token) {
16462
- const incentivesRaw = field(input, "incentives", 18) ?? [];
16891
+ const incentivesRaw = field2(input, "incentives", 18) ?? [];
16463
16892
  return {
16464
- market: toAddress(field(input, "market", 0)),
16893
+ market: toAddress(field2(input, "market", 0)),
16465
16894
  cTokenDecimals: 8,
16466
- isListed: toBool(field(input, "isListed", 1)),
16895
+ isListed: toBool(field2(input, "isListed", 1)),
16467
16896
  // borrowCap: toBigInt(field(input, 'borrowCap', 2)),
16468
16897
  // supplyCap: toBigInt(field(input, 'supplyCap', 3)),
16469
16898
  // mintPaused: toBool(field(input, 'mintPaused', 4)),
16470
16899
  // isBorrowAllowed: !toBool(field(input, 'borrowPaused', 5)),
16471
- collateralFactorMantissa: toBigInt2(field(input, "collateralFactor", 6)),
16472
- underlyingPrice: toBigInt2(field(input, "underlyingPrice", 7)),
16473
- totalSupply: toBigInt2(field(input, "totalSupply", 8)),
16474
- totalBorrows: toBigInt2(field(input, "totalBorrows", 9)),
16475
- totalReserves: toBigInt2(field(input, "totalReserves", 10)),
16476
- cash: toBigInt2(field(input, "cash", 11)),
16477
- exchangeRateCurrent: toBigInt2(field(input, "exchangeRate", 12)),
16478
- borrowIndex: toBigInt2(field(input, "borrowIndex", 13)),
16479
- reserveFactor: toBigInt2(field(input, "reserveFactor", 14)),
16900
+ collateralFactorMantissa: toBigInt2(field2(input, "collateralFactor", 6)),
16901
+ underlyingPrice: toBigInt2(field2(input, "underlyingPrice", 7)),
16902
+ totalSupply: toBigInt2(field2(input, "totalSupply", 8)),
16903
+ totalBorrows: toBigInt2(field2(input, "totalBorrows", 9)),
16904
+ totalReserves: toBigInt2(field2(input, "totalReserves", 10)),
16905
+ cash: toBigInt2(field2(input, "cash", 11)),
16906
+ exchangeRateCurrent: toBigInt2(field2(input, "exchangeRate", 12)),
16907
+ borrowIndex: toBigInt2(field2(input, "borrowIndex", 13)),
16908
+ reserveFactor: toBigInt2(field2(input, "reserveFactor", 14)),
16480
16909
  // borrowRate: toBigInt(field(input, 'borrowRate', 15)),
16481
16910
  // supplyRate: toBigInt(field(input, 'supplyRate', 16)),
16482
16911
  pausedActions: {
16483
- [0 /* MINT */]: toBool(field(input, "mintPaused", 4)),
16484
- [2 /* BORROW */]: toBool(field(input, "borrowPaused", 5))
16912
+ [0 /* MINT */]: toBool(field2(input, "mintPaused", 4)),
16913
+ [2 /* BORROW */]: toBool(field2(input, "borrowPaused", 5))
16485
16914
  },
16486
16915
  incentives: (incentivesRaw ?? []).map(parseMarketIncentives),
16487
16916
  depositRate: apyToApr(
16488
16917
  calculateRateForCompoundType(
16489
- toBigInt2(field(input, "supplyRate", 15)).toString() ?? "0",
16918
+ toBigInt2(field2(input, "supplyRate", 15)).toString() ?? "0",
16490
16919
  "1",
16491
16920
  1 /* SECOND */
16492
16921
  ) / 100
16493
16922
  ) * 100,
16494
16923
  variableBorrowRate: apyToApr(
16495
16924
  calculateRateForCompoundType(
16496
- toBigInt2(field(input, "borrowRate", 15)).toString() ?? "0",
16925
+ toBigInt2(field2(input, "borrowRate", 15)).toString() ?? "0",
16497
16926
  "1",
16498
16927
  1 /* SECOND */
16499
16928
  ) / 100
16500
16929
  ) * 100,
16501
16930
  isBorrowAllowed: true,
16502
16931
  borrowCap: Number(
16503
- formatUnits(toBigInt2(field(input, "borrowCap", 2)), token.decimals ?? 18)
16932
+ formatUnits(toBigInt2(field2(input, "borrowCap", 2)), token.decimals ?? 18)
16504
16933
  ),
16505
16934
  supplyCap: Number(
16506
- formatUnits(toBigInt2(field(input, "supplyCap", 2)), token.decimals ?? 18)
16935
+ formatUnits(toBigInt2(field2(input, "supplyCap", 2)), token.decimals ?? 18)
16507
16936
  )
16508
16937
  };
16509
16938
  }
@@ -16520,7 +16949,7 @@ function toBigInt3(value) {
16520
16949
  }
16521
16950
  throw new Error(`Cannot convert value to bigint: ${String(value)}`);
16522
16951
  }
16523
- function field2(src, key5, index) {
16952
+ function field3(src, key5, index) {
16524
16953
  if (src == null) throw new Error("Source is null/undefined");
16525
16954
  if (key5 in src) return src[key5];
16526
16955
  if (Array.isArray(src)) return src[index];
@@ -16541,21 +16970,21 @@ function toBool2(value) {
16541
16970
  }
16542
16971
  function parseTakaraMarketsInfo(input) {
16543
16972
  return {
16544
- tvl: toBigInt3(field2(input, "tvl", 0)),
16545
- ltv: toBigInt3(field2(input, "ltv", 1)),
16546
- exchangeRateCurrent: toBigInt3(field2(input, "exchangeRateCurrent", 2)),
16547
- reserveFactorMantissa: toBigInt3(field2(input, "reserveFactorMantissa", 3)),
16548
- totalSupply: toBigInt3(field2(input, "totalSupply", 4)),
16549
- isListed: toBool2(field2(input, "isListed", 5)),
16550
- totalBorrows: toBigInt3(field2(input, "totalBorrows", 6)),
16551
- supplyRatePerBlock: toBigInt3(field2(input, "supplyRatePerBlock", 7)),
16552
- borrowRatePerBlock: toBigInt3(field2(input, "borrowRatePerBlock", 8)),
16553
- blocksPerYear: toBigInt3(field2(input, "blocksPerYear", 9)),
16554
- timestampsPerYear: toBigInt3(field2(input, "timestampsPerYear", 10)),
16555
- token: String(field2(input, "token", 11)),
16556
- underlying: String(field2(input, "underlying", 12)),
16557
- symbol: String(field2(input, "symbol", 13)),
16558
- underlyingSymbol: String(field2(input, "underlyingSymbol", 14))
16973
+ tvl: toBigInt3(field3(input, "tvl", 0)),
16974
+ ltv: toBigInt3(field3(input, "ltv", 1)),
16975
+ exchangeRateCurrent: toBigInt3(field3(input, "exchangeRateCurrent", 2)),
16976
+ reserveFactorMantissa: toBigInt3(field3(input, "reserveFactorMantissa", 3)),
16977
+ totalSupply: toBigInt3(field3(input, "totalSupply", 4)),
16978
+ isListed: toBool2(field3(input, "isListed", 5)),
16979
+ totalBorrows: toBigInt3(field3(input, "totalBorrows", 6)),
16980
+ supplyRatePerBlock: toBigInt3(field3(input, "supplyRatePerBlock", 7)),
16981
+ borrowRatePerBlock: toBigInt3(field3(input, "borrowRatePerBlock", 8)),
16982
+ blocksPerYear: toBigInt3(field3(input, "blocksPerYear", 9)),
16983
+ timestampsPerYear: toBigInt3(field3(input, "timestampsPerYear", 10)),
16984
+ token: String(field3(input, "token", 11)),
16985
+ underlying: String(field3(input, "underlying", 12)),
16986
+ symbol: String(field3(input, "symbol", 13)),
16987
+ underlyingSymbol: String(field3(input, "underlyingSymbol", 14))
16559
16988
  };
16560
16989
  }
16561
16990
  function getTakaraRates(info) {
@@ -16585,7 +17014,7 @@ function toBool3(value) {
16585
17014
  if (typeof value === "number") return value !== 0;
16586
17015
  return Boolean(value);
16587
17016
  }
16588
- function field3(src, key5, index) {
17017
+ function field4(src, key5, index) {
16589
17018
  if (src == null) throw new Error("Source is null/undefined");
16590
17019
  if (key5 in src) return src[key5];
16591
17020
  if (Array.isArray(src)) return src[index];
@@ -16593,35 +17022,35 @@ function field3(src, key5, index) {
16593
17022
  }
16594
17023
  function parseTectonicMarketData(input) {
16595
17024
  return {
16596
- tokenAddress: String(field3(input, "tokenAddress", 0)),
16597
- label: String(field3(input, "label", 1)),
16598
- symbol: String(field3(input, "symbol", 2)),
16599
- decimal: Number(field3(input, "decimal", 3)),
16600
- ttokenAddress: String(field3(input, "ttokenAddress", 4)),
16601
- ttokenDecimal: Number(field3(input, "ttokenDecimal", 5)),
16602
- borrowCap: toBigInt4(field3(input, "borrowCap", 6)),
16603
- supplyCap: toBigInt4(field3(input, "supplyCap", 7)),
16604
- availableLiquidity: toBigInt4(field3(input, "availableLiquidity", 8)),
16605
- asCollateralEnabled: toBool3(field3(input, "asCollateralEnabled", 9)),
16606
- reserves: toBigInt4(field3(input, "reserves", 10)),
16607
- reserveFactor: toBigInt4(field3(input, "reserveFactor", 11)),
16608
- collateralFactor: toBigInt4(field3(input, "collateralFactor", 12)),
16609
- liquidationPenalty: toBigInt4(field3(input, "liquidationPenalty", 13)),
16610
- price: toBigInt4(field3(input, "price", 14)),
16611
- exchangeRate: toBigInt4(field3(input, "exchangeRate", 15)),
16612
- tTokenMinted: toBigInt4(field3(input, "tTokenMinted", 16)),
16613
- totalSupply: toBigInt4(field3(input, "totalSupply", 17)),
16614
- totalBorrow: toBigInt4(field3(input, "totalBorrow", 18)),
16615
- borrowRatePerBlock: toBigInt4(field3(input, "borrowRatePerBlock", 19)),
16616
- supplyRatePerBlock: toBigInt4(field3(input, "supplyRatePerBlock", 20)),
16617
- availableBorrow: toBigInt4(field3(input, "availableBorrow", 21)),
16618
- isBoosted: toBool3(field3(input, "isBoosted", 22)),
16619
- baseRatePerBlock: toBigInt4(field3(input, "baseRatePerBlock", 23)),
16620
- multiplierPerBlock: toBigInt4(field3(input, "multiplierPerBlock", 24)),
17025
+ tokenAddress: String(field4(input, "tokenAddress", 0)),
17026
+ label: String(field4(input, "label", 1)),
17027
+ symbol: String(field4(input, "symbol", 2)),
17028
+ decimal: Number(field4(input, "decimal", 3)),
17029
+ ttokenAddress: String(field4(input, "ttokenAddress", 4)),
17030
+ ttokenDecimal: Number(field4(input, "ttokenDecimal", 5)),
17031
+ borrowCap: toBigInt4(field4(input, "borrowCap", 6)),
17032
+ supplyCap: toBigInt4(field4(input, "supplyCap", 7)),
17033
+ availableLiquidity: toBigInt4(field4(input, "availableLiquidity", 8)),
17034
+ asCollateralEnabled: toBool3(field4(input, "asCollateralEnabled", 9)),
17035
+ reserves: toBigInt4(field4(input, "reserves", 10)),
17036
+ reserveFactor: toBigInt4(field4(input, "reserveFactor", 11)),
17037
+ collateralFactor: toBigInt4(field4(input, "collateralFactor", 12)),
17038
+ liquidationPenalty: toBigInt4(field4(input, "liquidationPenalty", 13)),
17039
+ price: toBigInt4(field4(input, "price", 14)),
17040
+ exchangeRate: toBigInt4(field4(input, "exchangeRate", 15)),
17041
+ tTokenMinted: toBigInt4(field4(input, "tTokenMinted", 16)),
17042
+ totalSupply: toBigInt4(field4(input, "totalSupply", 17)),
17043
+ totalBorrow: toBigInt4(field4(input, "totalBorrow", 18)),
17044
+ borrowRatePerBlock: toBigInt4(field4(input, "borrowRatePerBlock", 19)),
17045
+ supplyRatePerBlock: toBigInt4(field4(input, "supplyRatePerBlock", 20)),
17046
+ availableBorrow: toBigInt4(field4(input, "availableBorrow", 21)),
17047
+ isBoosted: toBool3(field4(input, "isBoosted", 22)),
17048
+ baseRatePerBlock: toBigInt4(field4(input, "baseRatePerBlock", 23)),
17049
+ multiplierPerBlock: toBigInt4(field4(input, "multiplierPerBlock", 24)),
16621
17050
  jumpMultiplierPerBlock: toBigInt4(
16622
- field3(input, "jumpMultiplierPerBlock", 25)
17051
+ field4(input, "jumpMultiplierPerBlock", 25)
16623
17052
  ),
16624
- kink: toBigInt4(field3(input, "kink", 26))
17053
+ kink: toBigInt4(field4(input, "kink", 26))
16625
17054
  };
16626
17055
  }
16627
17056
  function getTectonicRates(info, chainId, unitSeconds) {
@@ -16661,7 +17090,7 @@ function toBool4(value) {
16661
17090
  if (typeof value === "number") return value !== 0;
16662
17091
  return Boolean(value);
16663
17092
  }
16664
- function field4(src, key5, index) {
17093
+ function field5(src, key5, index) {
16665
17094
  if (src == null) throw new Error("Source is null/undefined");
16666
17095
  if (key5 in src) return src[key5];
16667
17096
  if (Array.isArray(src)) return src[index];
@@ -16669,26 +17098,26 @@ function field4(src, key5, index) {
16669
17098
  }
16670
17099
  function parseKineticMarketMetadata(input) {
16671
17100
  return {
16672
- market: String(field4(input, "market", 0)),
16673
- supplyRate: toBigInt5(field4(input, "supplyRate", 1)),
16674
- borrowRate: toBigInt5(field4(input, "borrowRate", 2)),
16675
- price: toBigInt5(field4(input, "price", 3)),
16676
- exchangeRate: toBigInt5(field4(input, "exchangeRate", 4)),
16677
- reserveFactor: toBigInt5(field4(input, "reserveFactor", 5)),
16678
- borrowCap: toBigInt5(field4(input, "borrowCap", 6)),
16679
- totalSupply: toBigInt5(field4(input, "totalSupply", 7)),
16680
- totalUnderlyingSupply: toBigInt5(field4(input, "totalUnderlyingSupply", 8)),
16681
- totalBorrows: toBigInt5(field4(input, "totalBorrows", 9)),
16682
- collateralFactor: toBigInt5(field4(input, "collateralFactor", 10)),
16683
- underlyingToken: String(field4(input, "underlyingToken", 11)),
17101
+ market: String(field5(input, "market", 0)),
17102
+ supplyRate: toBigInt5(field5(input, "supplyRate", 1)),
17103
+ borrowRate: toBigInt5(field5(input, "borrowRate", 2)),
17104
+ price: toBigInt5(field5(input, "price", 3)),
17105
+ exchangeRate: toBigInt5(field5(input, "exchangeRate", 4)),
17106
+ reserveFactor: toBigInt5(field5(input, "reserveFactor", 5)),
17107
+ borrowCap: toBigInt5(field5(input, "borrowCap", 6)),
17108
+ totalSupply: toBigInt5(field5(input, "totalSupply", 7)),
17109
+ totalUnderlyingSupply: toBigInt5(field5(input, "totalUnderlyingSupply", 8)),
17110
+ totalBorrows: toBigInt5(field5(input, "totalBorrows", 9)),
17111
+ collateralFactor: toBigInt5(field5(input, "collateralFactor", 10)),
17112
+ underlyingToken: String(field5(input, "underlyingToken", 11)),
16684
17113
  underlyingTokenDecimals: Number(
16685
- field4(input, "underlyingTokenDecimals", 12)
17114
+ field5(input, "underlyingTokenDecimals", 12)
16686
17115
  ),
16687
- cTokenDecimals: Number(field4(input, "cTokenDecimals", 13)),
16688
- totalReserves: toBigInt5(field4(input, "totalReserves", 16)),
16689
- cash: toBigInt5(field4(input, "cash", 17)),
16690
- mintPaused: toBool4(field4(input, "mintPaused", 18)),
16691
- borrowPaused: toBool4(field4(input, "borrowPaused", 19))
17116
+ cTokenDecimals: Number(field5(input, "cTokenDecimals", 13)),
17117
+ totalReserves: toBigInt5(field5(input, "totalReserves", 16)),
17118
+ cash: toBigInt5(field5(input, "cash", 17)),
17119
+ mintPaused: toBool4(field5(input, "mintPaused", 18)),
17120
+ borrowPaused: toBool4(field5(input, "borrowPaused", 19))
16692
17121
  };
16693
17122
  }
16694
17123
  function getKineticRates(info, chainId) {
@@ -16708,20 +17137,6 @@ function getKineticRates(info, chainId) {
16708
17137
  };
16709
17138
  }
16710
17139
 
16711
- // src/lending/public-data/compound-v2/convert/types.ts
16712
- var PRICE_DECIMALS = 18;
16713
- var RESERVE_MANTISSA_DECIMALS = 18;
16714
- var resolveMarketPrice = (prices, asset, chainId) => {
16715
- const group = asset?.assetGroup;
16716
- if (group != null && prices[group] != null) return prices[group];
16717
- const address = asset?.address?.toLowerCase();
16718
- if (address != null) {
16719
- const fallback = prices[`${chainId}-${address}`];
16720
- if (fallback != null) return fallback;
16721
- }
16722
- return 0;
16723
- };
16724
-
16725
17140
  // src/lending/public-data/compound-v2/convert/risk.ts
16726
17141
  var DEFAULT_CLOSE_FACTOR = 0.5;
16727
17142
  var DEFAULT_LIQUIDATION_PENALTY = 0.08;
@@ -16758,6 +17173,8 @@ function convertSingleEntry(opts) {
16758
17173
  currentEntry?.collateralFactorMantissa?.toString(),
16759
17174
  RESERVE_MANTISSA_DECIMALS
16760
17175
  );
17176
+ const ltMantissa = currentEntry?.liquidationThresholdMantissa;
17177
+ const liquidationThreshold = ltMantissa !== void 0 && BigInt(ltMantissa.toString()) > 0n ? parseRawAmount(ltMantissa.toString(), RESERVE_MANTISSA_DECIMALS) : borrowCollateralFactor;
16761
17178
  const perMarketIncentive = currentEntry?.liquidationIncentiveMantissa;
16762
17179
  let liquidationPenalty;
16763
17180
  if (perMarketIncentive !== void 0 && Number(perMarketIncentive) > 0) {
@@ -16795,7 +17212,13 @@ function convertSingleEntry(opts) {
16795
17212
  const allPaused = pausedActions[0 /* MINT */] && pausedActions[2 /* BORROW */] && pausedActions[1 /* REDEEM */] && pausedActions[3 /* REPAY */];
16796
17213
  const poolId = asset.address;
16797
17214
  const collateralActive = Boolean(currentEntry?.isListed);
16798
- const borrowingEnabled = Boolean(currentEntry?.isBorrowAllowed) && !pausedActions[2 /* BORROW */];
17215
+ const venusCore = opts.venusEMode?.core;
17216
+ const venusConfigs = venusCore ? buildVenusModeConfigs(cToken, venusCore, opts.venusEMode?.pools, {
17217
+ closeFactor: opts.closeFactor ?? DEFAULT_CLOSE_FACTOR,
17218
+ borrowPaused: Boolean(pausedActions[2 /* BORROW */]),
17219
+ bounds: opts.venusEMode?.bounds
17220
+ }) : void 0;
17221
+ const borrowingEnabled = venusConfigs ? Object.values(venusConfigs).some((c) => !c.debtDisabled) : Boolean(currentEntry?.isBorrowAllowed) && !pausedActions[2 /* BORROW */];
16799
17222
  const marketUid = createMarketUid(chainId, lender, cToken);
16800
17223
  const name = COMPOUND_V2_NAME_OVERRIDES[`${chainId}:${cToken.toLowerCase()}`] ?? lenderShortName(lender) + " " + (asset?.symbol ?? "");
16801
17224
  return {
@@ -16820,12 +17243,12 @@ function convertSingleEntry(opts) {
16820
17243
  totalDebtStableUSD: 0,
16821
17244
  utilization: computeUtilization(totalSupplyUnderlying, totalDebt),
16822
17245
  intrinsicYield: additionalYields?.intrinsicYields?.[asset.assetGroup] ?? 0,
16823
- config: {
17246
+ config: venusConfigs ? venusConfigs : {
16824
17247
  [LENDER_MODE_NO_MODE]: {
16825
17248
  category: LENDER_MODE_NO_MODE,
16826
17249
  // collateral factors
16827
17250
  borrowCollateralFactor: Number(borrowCollateralFactor),
16828
- collateralFactor: Number(borrowCollateralFactor),
17251
+ collateralFactor: Number(liquidationThreshold),
16829
17252
  borrowFactor: 1,
16830
17253
  liquidationPenalty,
16831
17254
  closeFactor,
@@ -17134,7 +17557,7 @@ function toBool5(value) {
17134
17557
  if (typeof value === "number") return value !== 0;
17135
17558
  return Boolean(value);
17136
17559
  }
17137
- function field5(src, key5, index) {
17560
+ function field6(src, key5, index) {
17138
17561
  if (src == null) throw new Error("Source is null/undefined");
17139
17562
  if (key5 in src) return src[key5];
17140
17563
  if (Array.isArray(src)) return src[index];
@@ -17142,55 +17565,55 @@ function field5(src, key5, index) {
17142
17565
  }
17143
17566
  function parseToken(raw) {
17144
17567
  return {
17145
- token: String(field5(raw, "token", 0)),
17146
- decimals: Number(field5(raw, "decimals", 1)),
17147
- symbol: String(field5(raw, "symbol", 2)),
17148
- name: String(field5(raw, "name", 3))
17568
+ token: String(field6(raw, "token", 0)),
17569
+ decimals: Number(field6(raw, "decimals", 1)),
17570
+ symbol: String(field6(raw, "symbol", 2)),
17571
+ name: String(field6(raw, "name", 3))
17149
17572
  };
17150
17573
  }
17151
17574
  function parseBenqiMarketMetadata(input) {
17152
17575
  return {
17153
- market: String(field5(input, "market", 0)),
17154
- supplyRate: toBigInt6(field5(input, "supplyRate", 1)),
17155
- borrowRate: toBigInt6(field5(input, "borrowRate", 2)),
17156
- price: toBigInt6(field5(input, "price", 3)),
17157
- exchangeRate: toBigInt6(field5(input, "exchangeRate", 4)),
17158
- reserveFactor: toBigInt6(field5(input, "reserveFactor", 5)),
17159
- borrowCap: toBigInt6(field5(input, "borrowCap", 6)),
17576
+ market: String(field6(input, "market", 0)),
17577
+ supplyRate: toBigInt6(field6(input, "supplyRate", 1)),
17578
+ borrowRate: toBigInt6(field6(input, "borrowRate", 2)),
17579
+ price: toBigInt6(field6(input, "price", 3)),
17580
+ exchangeRate: toBigInt6(field6(input, "exchangeRate", 4)),
17581
+ reserveFactor: toBigInt6(field6(input, "reserveFactor", 5)),
17582
+ borrowCap: toBigInt6(field6(input, "borrowCap", 6)),
17160
17583
  supplyCap: 0n,
17161
17584
  // regular BENQI has no supply cap
17162
- totalSupply: toBigInt6(field5(input, "totalSupply", 7)),
17163
- totalUnderlyingSupply: toBigInt6(field5(input, "totalUnderlyingSupply", 8)),
17164
- totalBorrows: toBigInt6(field5(input, "totalBorrows", 9)),
17165
- collateralFactor: toBigInt6(field5(input, "collateralFactor", 10)),
17166
- underlying: parseToken(field5(input, "underlying", 11)),
17167
- qiTokenDecimals: Number(field5(input, "qiTokenDecimals", 12)),
17168
- totalReserves: toBigInt6(field5(input, "totalReserves", 17)),
17169
- cash: toBigInt6(field5(input, "cash", 18)),
17170
- mintPaused: toBool5(field5(input, "mintPaused", 19)),
17171
- borrowPaused: toBool5(field5(input, "borrowPaused", 20))
17585
+ totalSupply: toBigInt6(field6(input, "totalSupply", 7)),
17586
+ totalUnderlyingSupply: toBigInt6(field6(input, "totalUnderlyingSupply", 8)),
17587
+ totalBorrows: toBigInt6(field6(input, "totalBorrows", 9)),
17588
+ collateralFactor: toBigInt6(field6(input, "collateralFactor", 10)),
17589
+ underlying: parseToken(field6(input, "underlying", 11)),
17590
+ qiTokenDecimals: Number(field6(input, "qiTokenDecimals", 12)),
17591
+ totalReserves: toBigInt6(field6(input, "totalReserves", 17)),
17592
+ cash: toBigInt6(field6(input, "cash", 18)),
17593
+ mintPaused: toBool5(field6(input, "mintPaused", 19)),
17594
+ borrowPaused: toBool5(field6(input, "borrowPaused", 20))
17172
17595
  };
17173
17596
  }
17174
17597
  function parseBenqiEcoMarketMetadata(input) {
17175
17598
  return {
17176
- market: String(field5(input, "market", 0)),
17177
- supplyRate: toBigInt6(field5(input, "supplyRate", 1)),
17178
- borrowRate: toBigInt6(field5(input, "borrowRate", 2)),
17179
- price: toBigInt6(field5(input, "price", 3)),
17180
- exchangeRate: toBigInt6(field5(input, "exchangeRate", 4)),
17181
- reserveFactor: toBigInt6(field5(input, "reserveFactor", 5)),
17182
- borrowCap: toBigInt6(field5(input, "borrowCap", 6)),
17183
- supplyCap: toBigInt6(field5(input, "supplyCap", 7)),
17184
- totalSupply: toBigInt6(field5(input, "totalSupply", 8)),
17185
- totalUnderlyingSupply: toBigInt6(field5(input, "totalUnderlyingSupply", 9)),
17186
- totalBorrows: toBigInt6(field5(input, "totalBorrows", 10)),
17187
- collateralFactor: toBigInt6(field5(input, "collateralFactor", 11)),
17188
- underlying: parseToken(field5(input, "underlying", 12)),
17189
- qiTokenDecimals: Number(field5(input, "qiTokenDecimals", 13)),
17190
- totalReserves: toBigInt6(field5(input, "totalReserves", 14)),
17191
- cash: toBigInt6(field5(input, "cash", 15)),
17192
- mintPaused: toBool5(field5(input, "mintPaused", 16)),
17193
- borrowPaused: toBool5(field5(input, "borrowPaused", 17))
17599
+ market: String(field6(input, "market", 0)),
17600
+ supplyRate: toBigInt6(field6(input, "supplyRate", 1)),
17601
+ borrowRate: toBigInt6(field6(input, "borrowRate", 2)),
17602
+ price: toBigInt6(field6(input, "price", 3)),
17603
+ exchangeRate: toBigInt6(field6(input, "exchangeRate", 4)),
17604
+ reserveFactor: toBigInt6(field6(input, "reserveFactor", 5)),
17605
+ borrowCap: toBigInt6(field6(input, "borrowCap", 6)),
17606
+ supplyCap: toBigInt6(field6(input, "supplyCap", 7)),
17607
+ totalSupply: toBigInt6(field6(input, "totalSupply", 8)),
17608
+ totalUnderlyingSupply: toBigInt6(field6(input, "totalUnderlyingSupply", 9)),
17609
+ totalBorrows: toBigInt6(field6(input, "totalBorrows", 10)),
17610
+ collateralFactor: toBigInt6(field6(input, "collateralFactor", 11)),
17611
+ underlying: parseToken(field6(input, "underlying", 12)),
17612
+ qiTokenDecimals: Number(field6(input, "qiTokenDecimals", 13)),
17613
+ totalReserves: toBigInt6(field6(input, "totalReserves", 14)),
17614
+ cash: toBigInt6(field6(input, "cash", 15)),
17615
+ mintPaused: toBool5(field6(input, "mintPaused", 16)),
17616
+ borrowPaused: toBool5(field6(input, "borrowPaused", 17))
17194
17617
  };
17195
17618
  }
17196
17619
  function getBenqiRates(info, chainId, unitSeconds) {
@@ -17636,7 +18059,13 @@ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tok
17636
18059
  const stdComptrollerCalls = stdComptroller ? 2 : 0;
17637
18060
  const pauseReads = Boolean(stdComptroller) && usesComptrollerPauseReads(lender);
17638
18061
  const pauseCalls = pauseReads ? tokenCount * 2 : 0;
17639
- const expectedNumberOfCalls = isSumer ? tokenCount + SUMER_GROUP_COUNT : tokenCount + stdComptrollerCalls + pauseCalls;
18062
+ const allowlistReads = Boolean(stdComptroller) && usesSupplyAllowlistReads(lender);
18063
+ const allowlistCalls = allowlistReads ? tokenCount : 0;
18064
+ const emodeReads = Boolean(stdComptroller) && Boolean(getVenusEModeSetup(chainId, lender));
18065
+ const emodeCalls = emodeReads ? 3 * tokenCount + 2 : 0;
18066
+ const thresholdReads = Boolean(stdComptroller) && usesIsolatedThresholdReads(lender);
18067
+ const thresholdCalls = thresholdReads ? tokenCount : 0;
18068
+ const expectedNumberOfCalls = isSumer ? tokenCount + SUMER_GROUP_COUNT : tokenCount + stdComptrollerCalls + pauseCalls + allowlistCalls + emodeCalls + thresholdCalls;
17640
18069
  const reader = getReader(lender, chainId, unitSeconds);
17641
18070
  return [
17642
18071
  (data) => {
@@ -17675,6 +18104,19 @@ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tok
17675
18104
  }
17676
18105
  const mintPausedBase = tokenCount + stdComptrollerCalls;
17677
18106
  const borrowPausedBase = mintPausedBase + tokenCount;
18107
+ const allowlistBase = mintPausedBase + pauseCalls;
18108
+ const emodeBase = allowlistBase + allowlistCalls;
18109
+ const thresholdBase = emodeBase + emodeCalls;
18110
+ const venusPools = emodeReads ? parseVenusPools(
18111
+ data[emodeBase + tokenCount + 1],
18112
+ data[emodeBase + tokenCount]
18113
+ ) : void 0;
18114
+ if (emodeReads && !venusPools) {
18115
+ console.warn(
18116
+ `[venus] e-mode pool inventory unavailable on chain ${chainId}; skipping ${lender} this tick`
18117
+ );
18118
+ return void 0;
18119
+ }
17678
18120
  for (let i = 0; i < tokenCount; i++) {
17679
18121
  const { underlying, cToken } = compoundV2Tokens2[i];
17680
18122
  if (!cToken || !underlying) continue;
@@ -17682,8 +18124,11 @@ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tok
17682
18124
  if (!asset) continue;
17683
18125
  const entryRaw = data[i];
17684
18126
  if (isFailedCall(entryRaw)) continue;
18127
+ const venusCore = emodeReads ? parseVenusCoreMarket(data[emodeBase + i]) : void 0;
18128
+ if (emodeReads && !venusCore) continue;
18129
+ const isolatedLt = thresholdReads ? parseIsolatedThreshold(data[thresholdBase + i]) : void 0;
17685
18130
  const entry2 = convertSingleEntry({
17686
- entryRaw,
18131
+ entryRaw: isolatedLt !== void 0 ? { ...entryRaw, liquidationThresholdMantissa: isolatedLt } : entryRaw,
17687
18132
  reader,
17688
18133
  asset,
17689
18134
  chainId,
@@ -17695,10 +18140,21 @@ var getCompoundV2DataConverter = (lender, chainId, prices, additionalYields, tok
17695
18140
  liquidationPenalty: globalLiquidationPenalty,
17696
18141
  // live guardian read first, then the static fallback published on
17697
18142
  // the token entry for forks that expose no getter at all
17698
- pause: pauseReads ? resolveMarketPause(compoundV2Tokens2[i], {
17699
- mintPaused: parsePausedFlag(data[mintPausedBase + i]),
17700
- borrowPaused: parsePausedFlag(data[borrowPausedBase + i])
17701
- }) : void 0
18143
+ pause: applySupplyAllowlist(
18144
+ pauseReads ? resolveMarketPause(compoundV2Tokens2[i], {
18145
+ mintPaused: parsePausedFlag(data[mintPausedBase + i]),
18146
+ borrowPaused: parsePausedFlag(data[borrowPausedBase + i])
18147
+ }) : void 0,
18148
+ allowlistReads ? parsePausedFlag(data[allowlistBase + i]) : void 0
18149
+ ),
18150
+ venusEMode: emodeReads ? {
18151
+ core: venusCore,
18152
+ pools: venusPools,
18153
+ bounds: parseVenusPriceBounds(
18154
+ data[emodeBase + tokenCount + 2 + i],
18155
+ data[emodeBase + 2 * tokenCount + 2 + i]
18156
+ )
18157
+ } : void 0
17702
18158
  });
17703
18159
  out.data[entry2.marketUid] = entry2;
17704
18160
  }
@@ -21487,6 +21943,10 @@ var getGearboxV3PublicDataConverter = (_lender, chainId, prices, additionalYield
21487
21943
  borrowed: 0n,
21488
21944
  available: 0n
21489
21945
  };
21946
+ const minDebtRaw = BigInt(facade.minDebt ?? 0);
21947
+ const maxDebtRaw = BigInt(facade.maxDebt ?? 0);
21948
+ const openable = maxDebtRaw > 0n && maxDebtRaw >= minDebtRaw && cmDebt.available > 0n && cmDebt.available >= minDebtRaw;
21949
+ if (!openable && cmDebt.borrowed === 0n) continue;
21490
21950
  const availableToBorrow = Number(
21491
21951
  parseRawAmount(cmDebt.available.toString(), underlyingDecimals)
21492
21952
  );
@@ -21543,7 +22003,10 @@ var getGearboxV3PublicDataConverter = (_lender, chainId, prices, additionalYield
21543
22003
  liquidationBonus: liquidationPenalty,
21544
22004
  closeFactor: 1,
21545
22005
  collateralActive: false,
21546
- borrowingEnabled: true,
22006
+ // False when the CM cannot be opened (liquidity below `minDebt`),
22007
+ // so the pair book and listings skip it while existing
22008
+ // positions still read.
22009
+ borrowingEnabled: openable,
21547
22010
  depositsEnabled: false,
21548
22011
  hasStable: false,
21549
22012
  isActive: true,
@@ -21630,6 +22093,19 @@ var getGearboxV3PublicDataConverter = (_lender, chainId, prices, additionalYield
21630
22093
  forbiddenTokenMask: facade.forbiddenTokensMask?.toString() ?? "0",
21631
22094
  isDegenMode: false
21632
22095
  // filtered above; kept for shape-compat
22096
+ },
22097
+ // The descriptor the term sheet reads (`market.gearbox`):
22098
+ // `minDebt` → `availability.minSize` + `exit.minDebt`, and
22099
+ // `openable` → `canOpen` / `blockedBy: 'no-liquidity'`.
22100
+ // Deliberately NOT under `params.market`: yield-tracer ingests
22101
+ // any `params.market` as a `morpho_markets` row, and this one
22102
+ // has no lender/oracle/irm — the NOT NULL insert would fail the
22103
+ // whole batch. `toTermSheetInput` reads `params.gearbox` too.
22104
+ gearbox: {
22105
+ minDebt: minDebtRaw.toString(),
22106
+ maxDebt: maxDebtRaw.toString(),
22107
+ availableToBorrow: cmDebt.available.toString(),
22108
+ openable
21633
22109
  }
21634
22110
  },
21635
22111
  chainId
@@ -21892,6 +22368,23 @@ var getLenderPublicData = async (chainId, lenders, prices, additionalYields, mul
21892
22368
  } catch {
21893
22369
  }
21894
22370
  }
22371
+ const gearboxLender = validLenders.find(isGearboxV3);
22372
+ if (gearboxLender !== void 0) {
22373
+ const start = sliceStart[gearboxLender];
22374
+ const results = rawResults;
22375
+ for (let attempt = 1; attempt <= 3 && !Array.isArray(results?.[start]); attempt++) {
22376
+ try {
22377
+ const [retried] = await multicallRetry({
22378
+ chain: chainId,
22379
+ calls: [calls[start].call],
22380
+ abi: [calls[start].abi],
22381
+ providerId: attempt
22382
+ });
22383
+ if (Array.isArray(retried)) results[start] = retried;
22384
+ } catch {
22385
+ }
22386
+ }
22387
+ }
21895
22388
  const invalidLenders = [];
21896
22389
  let lenderData = {};
21897
22390
  const rateUnitSeconds = /* @__PURE__ */ new Map();
@@ -28151,36 +28644,36 @@ var big7 = (v) => {
28151
28644
  };
28152
28645
  var isAddr = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{40}$/.test(v);
28153
28646
  var ZERO3 = "0x0000000000000000000000000000000000000000";
28154
- var field6 = (o, name, idx) => o == null ? void 0 : o[name] !== void 0 ? o[name] : o[idx];
28647
+ var field7 = (o, name, idx) => o == null ? void 0 : o[name] !== void 0 ? o[name] : o[idx];
28155
28648
  var num4 = (v) => {
28156
28649
  const b = big7(v);
28157
28650
  return b === null ? 0 : Number(b);
28158
28651
  };
28159
28652
  var parseDebtTerms = (o) => ({
28160
- ltv: num4(field6(o, "ltv", 0)),
28161
- redemptionThreshold: num4(field6(o, "redemptionThreshold", 1)),
28162
- liqThreshold: num4(field6(o, "liqThreshold", 2)),
28163
- liqFee: num4(field6(o, "liqFee", 3)),
28164
- borrowRate: num4(field6(o, "borrowRate", 4)),
28165
- daowry: num4(field6(o, "daowry", 5))
28653
+ ltv: num4(field7(o, "ltv", 0)),
28654
+ redemptionThreshold: num4(field7(o, "redemptionThreshold", 1)),
28655
+ liqThreshold: num4(field7(o, "liqThreshold", 2)),
28656
+ liqFee: num4(field7(o, "liqFee", 3)),
28657
+ borrowRate: num4(field7(o, "borrowRate", 4)),
28658
+ daowry: num4(field7(o, "daowry", 5))
28166
28659
  });
28167
28660
  var parseGenConfig = (o) => o == null ? null : {
28168
- perUserMaxVaults: num4(field6(o, "perUserMaxVaults", 0)),
28169
- perUserMaxAssetsPerVault: num4(field6(o, "perUserMaxAssetsPerVault", 1)),
28170
- canDeposit: Boolean(field6(o, "canDeposit", 3)),
28171
- canWithdraw: Boolean(field6(o, "canWithdraw", 4)),
28172
- canBorrow: Boolean(field6(o, "canBorrow", 5)),
28173
- canRepay: Boolean(field6(o, "canRepay", 6))
28661
+ perUserMaxVaults: num4(field7(o, "perUserMaxVaults", 0)),
28662
+ perUserMaxAssetsPerVault: num4(field7(o, "perUserMaxAssetsPerVault", 1)),
28663
+ canDeposit: Boolean(field7(o, "canDeposit", 3)),
28664
+ canWithdraw: Boolean(field7(o, "canWithdraw", 4)),
28665
+ canBorrow: Boolean(field7(o, "canBorrow", 5)),
28666
+ canRepay: Boolean(field7(o, "canRepay", 6))
28174
28667
  };
28175
28668
  var parseGenDebtConfig = (o) => o == null ? null : {
28176
- perUserDebtLimit: big7(field6(o, "perUserDebtLimit", 0)) ?? 0n,
28177
- globalDebtLimit: big7(field6(o, "globalDebtLimit", 1)) ?? 0n,
28178
- minDebtAmount: big7(field6(o, "minDebtAmount", 2)) ?? 0n,
28179
- numAllowedBorrowers: big7(field6(o, "numAllowedBorrowers", 3)) ?? 0n,
28180
- maxBorrowPerInterval: big7(field6(o, "maxBorrowPerInterval", 4)) ?? 0n,
28181
- numBlocksPerInterval: big7(field6(o, "numBlocksPerInterval", 5)) ?? 0n,
28182
- maxBorrowRate: num4(field6(o, "maxBorrowRate", 9)),
28183
- isDaowryEnabled: Boolean(field6(o, "isDaowryEnabled", 14))
28669
+ perUserDebtLimit: big7(field7(o, "perUserDebtLimit", 0)) ?? 0n,
28670
+ globalDebtLimit: big7(field7(o, "globalDebtLimit", 1)) ?? 0n,
28671
+ minDebtAmount: big7(field7(o, "minDebtAmount", 2)) ?? 0n,
28672
+ numAllowedBorrowers: big7(field7(o, "numAllowedBorrowers", 3)) ?? 0n,
28673
+ maxBorrowPerInterval: big7(field7(o, "maxBorrowPerInterval", 4)) ?? 0n,
28674
+ numBlocksPerInterval: big7(field7(o, "numBlocksPerInterval", 5)) ?? 0n,
28675
+ maxBorrowRate: num4(field7(o, "maxBorrowRate", 9)),
28676
+ isDaowryEnabled: Boolean(field7(o, "isDaowryEnabled", 14))
28184
28677
  };
28185
28678
  var empty = (lender) => ({
28186
28679
  lender,
@@ -28319,7 +28812,7 @@ async function fetchRipeMarkets(lender, chainId, multicallRetry = multicallRetry
28319
28812
  const o = i * PER_ASSET;
28320
28813
  const cfg = r4[o];
28321
28814
  if (cfg == null) return;
28322
- const ids = field6(cfg, "vaultIds", 0) ?? [];
28815
+ const ids = field7(cfg, "vaultIds", 0) ?? [];
28323
28816
  const vaultIds = ids.map(num4).filter((v) => v > 0);
28324
28817
  const vaults = vaultIds.map((v) => vaultById.get(v) ?? "");
28325
28818
  assets.push({
@@ -28329,14 +28822,14 @@ async function fetchRipeMarkets(lender, chainId, multicallRetry = multicallRetry
28329
28822
  vaultIds,
28330
28823
  vaults,
28331
28824
  totalDeposited: 0n,
28332
- perUserDepositLimit: big7(field6(cfg, "perUserDepositLimit", 3)) ?? 0n,
28333
- globalDepositLimit: big7(field6(cfg, "globalDepositLimit", 4)) ?? 0n,
28334
- minDepositBalance: big7(field6(cfg, "minDepositBalance", 5)) ?? 0n,
28335
- debtTerms: parseDebtTerms(field6(cfg, "debtTerms", 6)),
28336
- canDeposit: Boolean(field6(cfg, "canDeposit", 11)),
28337
- canWithdraw: Boolean(field6(cfg, "canWithdraw", 12)),
28338
- whitelist: String(field6(cfg, "whitelist", 19) ?? ZERO3).toLowerCase(),
28339
- isNft: Boolean(field6(cfg, "isNft", 20)),
28825
+ perUserDepositLimit: big7(field7(cfg, "perUserDepositLimit", 3)) ?? 0n,
28826
+ globalDepositLimit: big7(field7(cfg, "globalDepositLimit", 4)) ?? 0n,
28827
+ minDepositBalance: big7(field7(cfg, "minDepositBalance", 5)) ?? 0n,
28828
+ debtTerms: parseDebtTerms(field7(cfg, "debtTerms", 6)),
28829
+ canDeposit: Boolean(field7(cfg, "canDeposit", 11)),
28830
+ canWithdraw: Boolean(field7(cfg, "canWithdraw", 12)),
28831
+ whitelist: String(field7(cfg, "whitelist", 19) ?? ZERO3).toLowerCase(),
28832
+ isNft: Boolean(field7(cfg, "isNft", 20)),
28340
28833
  priceWad: big7(r4[o + 1]),
28341
28834
  dynamicBorrowRate: null
28342
28835
  });
@@ -29279,7 +29772,7 @@ function flexRateDistribution(index) {
29279
29772
  var SECONDS_PER_YEAR10 = 365 * 24 * 3600;
29280
29773
  var WAD10 = 1e18;
29281
29774
  var human3 = (raw, decimals) => Number(raw) / 10 ** decimals;
29282
- var frac = (raw, precision) => Number(raw) / Number(precision);
29775
+ var frac2 = (raw, precision) => Number(raw) / Number(precision);
29283
29776
  function currencyFor13(address, decimals, symbol, tokens) {
29284
29777
  const lower4 = address.toLowerCase();
29285
29778
  return tokens[lower4] ?? { address: lower4, symbol, name: symbol, decimals };
@@ -29319,10 +29812,10 @@ function convertFlexMarketsToResponse(raw, chainId, prices = {}, additionalYield
29319
29812
  const borrowPrice = priceOfAddr(borrow);
29320
29813
  const oracleRatio = m.collateralPriceWad != null ? Number(m.collateralPriceWad) / WAD10 : 0;
29321
29814
  const collPrice = priceOfAddr(coll) || (oracleRatio > 0 ? oracleRatio * borrowPrice : 0);
29322
- const mcr = frac(m.minimumCollateralRatio, m.precision);
29815
+ const mcr = frac2(m.minimumCollateralRatio, m.precision);
29323
29816
  const ltv = mcr > 0 ? 1 / mcr : 0;
29324
- const minFee = frac(m.minLiquidationFee, m.precision);
29325
- const maxFee = frac(m.maxLiquidationFee, m.precision);
29817
+ const minFee = frac2(m.minLiquidationFee, m.precision);
29818
+ const maxFee = frac2(m.maxLiquidationFee, m.precision);
29326
29819
  const totalCollateral = human3(m.collateralBalance, collDecimals);
29327
29820
  const totalDebt = human3(m.totalDebt, borrowDecimals);
29328
29821
  const lenderAssets = human3(m.lenderTotalAssets, borrowDecimals);
@@ -29332,8 +29825,8 @@ function convertFlexMarketsToResponse(raw, chainId, prices = {}, additionalYield
29332
29825
  const avgRate = flexAverageRate(m);
29333
29826
  const lendApr = flexLenderApr(m);
29334
29827
  const upfrontYears = Number(m.upfrontInterestPeriod) / SECONDS_PER_YEAR10;
29335
- const minRate = frac(m.minAnnualInterestRate, m.precision);
29336
- const maxRate = frac(m.maxAnnualInterestRate, m.precision);
29828
+ const minRate = frac2(m.minAnnualInterestRate, m.precision);
29829
+ const maxRate = frac2(m.maxAnnualInterestRate, m.precision);
29337
29830
  const minDebt = human3(m.minDebt, borrowDecimals);
29338
29831
  const queue = m.rateDistribution ? buildRateQueue({
29339
29832
  entries: m.rateDistribution.map((d) => ({
@@ -29483,8 +29976,8 @@ function convertFlexMarketsToResponse(raw, chainId, prices = {}, additionalYield
29483
29976
  precision: m.precision.toString(),
29484
29977
  /** Fractions (1.1 = 110 %). */
29485
29978
  minimumCollateralRatio: mcr,
29486
- safeCollateralRatio: frac(m.safeCollateralRatio, m.precision),
29487
- maxPenaltyCollateralRatio: frac(
29979
+ safeCollateralRatio: frac2(m.safeCollateralRatio, m.precision),
29980
+ maxPenaltyCollateralRatio: frac2(
29488
29981
  m.maxPenaltyCollateralRatio,
29489
29982
  m.precision
29490
29983
  ),
@@ -30967,7 +31460,7 @@ async function fetchDssMarkets(lender, chainId, multicallRetry = multicallRetryU
30967
31460
  if (typeof v === "number") return BigInt(v);
30968
31461
  return null;
30969
31462
  };
30970
- const field16 = (res, name, idx) => big32(res?.[name] ?? res?.[idx]);
31463
+ const field17 = (res, name, idx) => big32(res?.[name] ?? res?.[idx]);
30971
31464
  let cursor = 0;
30972
31465
  const out = markets.map((market, i) => {
30973
31466
  const base = cursor;
@@ -30977,13 +31470,13 @@ async function fetchDssMarkets(lender, chainId, multicallRetry = multicallRetryU
30977
31470
  const spotIlk = results[base + 2];
30978
31471
  return {
30979
31472
  market,
30980
- Art: field16(vatIlk, "Art", 0),
30981
- rate: field16(vatIlk, "rate", 1),
30982
- spot: field16(vatIlk, "spot", 2),
30983
- line: field16(vatIlk, "line", 3),
30984
- dust: field16(vatIlk, "dust", 4),
30985
- duty: field16(jugIlk, "duty", 0),
30986
- mat: field16(spotIlk, "mat", 1),
31473
+ Art: field17(vatIlk, "Art", 0),
31474
+ rate: field17(vatIlk, "rate", 1),
31475
+ spot: field17(vatIlk, "spot", 2),
31476
+ line: field17(vatIlk, "line", 3),
31477
+ dust: field17(vatIlk, "dust", 4),
31478
+ duty: field17(jugIlk, "duty", 0),
31479
+ mat: field17(spotIlk, "mat", 1),
30987
31480
  joinBalance: joinReadIndex[i] >= 0 ? big32(results[joinReadIndex[i]]) : null
30988
31481
  };
30989
31482
  });
@@ -33416,6 +33909,25 @@ var buildCompoundV3UserCall = (chainId, lender, account) => {
33416
33909
  };
33417
33910
 
33418
33911
  // src/lending/user-data/compound-v2/userCallBuild.ts
33912
+ var VENUS_EMODE_USER_CALLS = 2;
33913
+ var venusEModeUserCalls = (chainId, lender, account) => {
33914
+ const emode = getVenusEModeSetup(chainId, lender);
33915
+ if (!emode) return [];
33916
+ return [
33917
+ {
33918
+ address: emode.comptroller,
33919
+ name: "userPoolId",
33920
+ params: [account],
33921
+ abi: VenusEModeAbi
33922
+ },
33923
+ {
33924
+ address: emode.vaiController,
33925
+ name: "getVAIRepayAmount",
33926
+ params: [account],
33927
+ abi: VenusEModeAbi
33928
+ }
33929
+ ];
33930
+ };
33419
33931
  var COMPOUND_V2_LENS_WORDS = 3;
33420
33932
  var COMPOUND_V2_LENS_HEADER_BYTES = 1;
33421
33933
  var usesCompoundV2Lens = (chainId) => getPositionLensFor(chainId, LENS_FAMILY.COMPOUND_V2) !== void 0;
@@ -33439,7 +33951,8 @@ var buildCompoundV2UserCall = (chainId, lender, account) => {
33439
33951
  name: "getUserData",
33440
33952
  params: [[{ family: LENS_FAMILY.COMPOUND_V2, payload }], account],
33441
33953
  abi: PositionLensAbi
33442
- }
33954
+ },
33955
+ ...venusEModeUserCalls(chainId, lender, account)
33443
33956
  ];
33444
33957
  }
33445
33958
  let calls = tokens.flatMap((tk) => [
@@ -33467,6 +33980,7 @@ var buildCompoundV2UserCall = (chainId, lender, account) => {
33467
33980
  params: [account]
33468
33981
  }
33469
33982
  ];
33983
+ calls.push(...venusEModeUserCalls(chainId, lender, account));
33470
33984
  return calls;
33471
33985
  };
33472
33986
  var getCompoundV2UserDataConverter = (lender, chainId, account, metaMap) => {
@@ -33476,12 +33990,30 @@ var getCompoundV2UserDataConverter = (lender, chainId, account, metaMap) => {
33476
33990
  (a, b) => a.cToken.toLowerCase().localeCompare(b.cToken.toLowerCase())
33477
33991
  );
33478
33992
  const viaLens = usesCompoundV2Lens(chainId);
33479
- const expectedNumberOfCalls = viaLens ? 1 : tokens.length * 3 + 1;
33993
+ const emodeSetup = Boolean(getVenusEModeSetup(chainId, lender));
33994
+ const tailCalls = emodeSetup ? VENUS_EMODE_USER_CALLS : 0;
33995
+ const expectedNumberOfCalls = (viaLens ? 1 : tokens.length * 3 + 1) + tailCalls;
33480
33996
  return [
33481
- (data) => {
33482
- if (data.length !== expectedNumberOfCalls) {
33997
+ (rawData) => {
33998
+ if (rawData.length !== expectedNumberOfCalls) {
33483
33999
  return void 0;
33484
34000
  }
34001
+ let userEMode;
34002
+ let externalDebts;
34003
+ if (emodeSetup) {
34004
+ const poolRaw = rawData[rawData.length - 2];
34005
+ const vaiRaw = rawData[rawData.length - 1];
34006
+ if (isFailedCall(poolRaw) || poolRaw == null) return void 0;
34007
+ if (isFailedCall(vaiRaw) || vaiRaw == null) return void 0;
34008
+ userEMode = Number(poolRaw);
34009
+ if (!venusModeKnown(metaMap, String(userEMode))) return void 0;
34010
+ const vai = BigInt(vaiRaw.toString());
34011
+ if (vai > 0n) {
34012
+ const debt = parseRawAmount(vai.toString(), 18);
34013
+ externalDebts = [{ label: "VAI", debt, debtUSD: Number(debt) }];
34014
+ }
34015
+ }
34016
+ const data = emodeSetup ? rawData.slice(0, -tailCalls) : rawData;
33485
34017
  const lendingPositions = {};
33486
34018
  let totalDebt24h = 0;
33487
34019
  let totalDeposits24h = 0;
@@ -33540,7 +34072,9 @@ var getCompoundV2UserDataConverter = (lender, chainId, account, metaMap) => {
33540
34072
  chainId,
33541
34073
  account,
33542
34074
  lendingPositions,
33543
- rewards: []
34075
+ rewards: [],
34076
+ ...userEMode !== void 0 ? { userEMode } : {},
34077
+ ...externalDebts ? { externalDebts } : {}
33544
34078
  };
33545
34079
  const createState = isSumerType(lender) ? createSumerUserState : createBaseTypeUserState;
33546
34080
  const userData = createState(
@@ -33556,6 +34090,14 @@ var getCompoundV2UserDataConverter = (lender, chainId, account, metaMap) => {
33556
34090
  }
33557
34091
  }
33558
34092
  };
34093
+ function venusModeKnown(metaMap, mode) {
34094
+ if (mode === "0") return true;
34095
+ for (const m of Object.values(metaMap ?? {})) {
34096
+ const configs = m?.configs ?? m?.config;
34097
+ if (configs && configs[mode] !== void 0) return true;
34098
+ }
34099
+ return false;
34100
+ }
33559
34101
  function statesFromSlice(data, tokens, assetsIn) {
33560
34102
  const out = /* @__PURE__ */ new Map();
33561
34103
  for (let i = 0; i < tokens.length; i++) {
@@ -35726,7 +36268,7 @@ var big10 = (v) => {
35726
36268
  }
35727
36269
  return 0n;
35728
36270
  };
35729
- var field7 = (res, name, idx) => res?.[name] ?? res?.[idx];
36271
+ var field8 = (res, name, idx) => res?.[name] ?? res?.[idx];
35730
36272
  var buildDssUserCall = async (chainId, lender, account, opts) => {
35731
36273
  const cfg = dssConfigFor(lender, chainId);
35732
36274
  const markets = dssChainData(lender, chainId)?.markets ?? [];
@@ -35811,7 +36353,7 @@ var buildDssUserCall = async (chainId, lender, account, opts) => {
35811
36353
  if (curated.has(ilk)) {
35812
36354
  cdps.push({ cdpId: cursor.toString(), urn: String(urn), ilk });
35813
36355
  }
35814
- cursor = big10(field7(link, "next", 1));
36356
+ cursor = big10(field8(link, "next", 1));
35815
36357
  }
35816
36358
  }
35817
36359
  } catch {
@@ -38929,7 +39471,7 @@ var big11 = (v) => {
38929
39471
  }
38930
39472
  return 0n;
38931
39473
  };
38932
- var field8 = (res, name, idx) => big11(res?.[name] ?? res?.[idx]);
39474
+ var field9 = (res, name, idx) => big11(res?.[name] ?? res?.[idx]);
38933
39475
  var getLiquityUserDataConverter = (lender, chainId, account, meta, opts) => {
38934
39476
  const cfg = liquityConfigFor(lender, chainId);
38935
39477
  const branches = liquityBranchesByChain(lender, chainId);
@@ -38976,29 +39518,29 @@ var getLiquityUserDataConverter = (lender, chainId, account, meta, opts) => {
38976
39518
  const owner = typeof ownerRaw === "string" ? ownerRaw.toLowerCase() : void 0;
38977
39519
  if (owner !== accountLower) return;
38978
39520
  if (!troveData || troveData === "0x") return;
38979
- const entireDebt = field8(troveData, "entireDebt", 0);
38980
- const entireColl = field8(troveData, "entireColl", 1);
39521
+ const entireDebt = field9(troveData, "entireDebt", 0);
39522
+ const entireColl = field9(troveData, "entireColl", 1);
38981
39523
  if (entireDebt === 0n && entireColl === 0n) return;
38982
39524
  const troveInfo = {
38983
39525
  troveId: t.troveId,
38984
39526
  collIndex: branch.collIndex,
38985
- annualInterestRate: field8(
39527
+ annualInterestRate: field9(
38986
39528
  troveData,
38987
39529
  "annualInterestRate",
38988
39530
  6
38989
39531
  ).toString(),
38990
39532
  lastInterestRateAdjTime: Number(
38991
- field8(troveData, "lastInterestRateAdjTime", 9)
39533
+ field9(troveData, "lastInterestRateAdjTime", 9)
38992
39534
  ),
38993
39535
  zombie: t.zombie,
38994
- redistCollGain: field8(troveData, "redistCollGain", 3).toString(),
38995
- redistBoldDebtGain: field8(
39536
+ redistCollGain: field9(troveData, "redistCollGain", 3).toString(),
39537
+ redistBoldDebtGain: field9(
38996
39538
  troveData,
38997
39539
  "redistBoldDebtGain",
38998
39540
  2
38999
39541
  ).toString(),
39000
- accruedInterest: field8(troveData, "accruedInterest", 4).toString(),
39001
- accruedBatchManagementFee: field8(
39542
+ accruedInterest: field9(troveData, "accruedInterest", 4).toString(),
39543
+ accruedBatchManagementFee: field9(
39002
39544
  troveData,
39003
39545
  "accruedBatchManagementFee",
39004
39546
  8
@@ -39141,7 +39683,7 @@ var big12 = (v) => {
39141
39683
  }
39142
39684
  return 0n;
39143
39685
  };
39144
- var field9 = (res, name, idx) => big12(res?.[name] ?? res?.[idx]);
39686
+ var field10 = (res, name, idx) => big12(res?.[name] ?? res?.[idx]);
39145
39687
  var getRiverUserDataConverter = (lender, chainId, account, meta) => {
39146
39688
  const cfg = riverConfigFor(lender, chainId);
39147
39689
  const markets = riverChainData(lender, chainId)?.markets ?? [];
@@ -39182,8 +39724,8 @@ var getRiverUserDataConverter = (lender, chainId, account, meta) => {
39182
39724
  const lendingPositions = {};
39183
39725
  const modes = {};
39184
39726
  const hist = {};
39185
- const debt = field9(entire, "debt", 0);
39186
- const coll = field9(entire, "coll", 1);
39727
+ const debt = field10(entire, "debt", 0);
39728
+ const coll = field10(entire, "coll", 1);
39187
39729
  if (status === 1 && (debt > 0n || coll > 0n)) {
39188
39730
  const riverInfo = {
39189
39731
  index: market.index,
@@ -39519,7 +40061,7 @@ var big15 = (v) => {
39519
40061
  }
39520
40062
  return 0n;
39521
40063
  };
39522
- var field10 = (o, name, idx) => o == null ? void 0 : o[name] !== void 0 ? o[name] : o[idx];
40064
+ var field11 = (o, name, idx) => o == null ? void 0 : o[name] !== void 0 ? o[name] : o[idx];
39523
40065
  var getRipeUserDataConverter = (lender, chainId, account, meta, opts) => {
39524
40066
  const cfg = ripeConfigFor(lender, chainId);
39525
40067
  const discovery = getCachedRipeDiscovery(chainId, lender, account, opts);
@@ -39533,19 +40075,19 @@ var getRipeUserDataConverter = (lender, chainId, account, meta, opts) => {
39533
40075
  const debtNowRaw = data[1];
39534
40076
  if (isFailedCall(userDebtRaw) || isFailedCall(debtNowRaw))
39535
40077
  return void 0;
39536
- const terms = field10(userDebtRaw, "debtTerms", 2);
39537
- const stored = big15(field10(userDebtRaw, "amount", 0));
40078
+ const terms = field11(userDebtRaw, "debtTerms", 2);
40079
+ const stored = big15(field11(userDebtRaw, "amount", 0));
39538
40080
  const debtNow = big15(debtNowRaw);
39539
40081
  const debt = debtNow > stored ? debtNow : stored;
39540
40082
  const info = {
39541
40083
  debt: debt.toString(),
39542
- principal: big15(field10(userDebtRaw, "principal", 1)).toString(),
39543
- borrowRate: Number(big15(field10(terms, "borrowRate", 4))) / 100,
39544
- ltv: Number(big15(field10(terms, "ltv", 0))) / 1e4,
39545
- redemptionThreshold: Number(big15(field10(terms, "redemptionThreshold", 1))) / 1e4,
39546
- liquidationThreshold: Number(big15(field10(terms, "liqThreshold", 2))) / 1e4,
39547
- liquidationFee: Number(big15(field10(terms, "liqFee", 3))) / 1e4,
39548
- inLiquidation: Boolean(field10(userDebtRaw, "inLiquidation", 4))
40084
+ principal: big15(field11(userDebtRaw, "principal", 1)).toString(),
40085
+ borrowRate: Number(big15(field11(terms, "borrowRate", 4))) / 100,
40086
+ ltv: Number(big15(field11(terms, "ltv", 0))) / 1e4,
40087
+ redemptionThreshold: Number(big15(field11(terms, "redemptionThreshold", 1))) / 1e4,
40088
+ liquidationThreshold: Number(big15(field11(terms, "liqThreshold", 2))) / 1e4,
40089
+ liquidationFee: Number(big15(field11(terms, "liqFee", 3))) / 1e4,
40090
+ inLiquidation: Boolean(field11(userDebtRaw, "inLiquidation", 4))
39549
40091
  };
39550
40092
  const held = /* @__PURE__ */ new Map();
39551
40093
  let cursor = RIPE_ACCOUNT_READS;
@@ -39553,8 +40095,8 @@ var getRipeUserDataConverter = (lender, chainId, account, meta, opts) => {
39553
40095
  for (let i = 0; i < v.assetSlots; i++) {
39554
40096
  const r = data[cursor++];
39555
40097
  if (isFailedCall(r) || r == null) continue;
39556
- const asset = String(field10(r, "asset", 0) ?? "").toLowerCase();
39557
- const amount5 = big15(field10(r, "amount", 1));
40098
+ const asset = String(field11(r, "asset", 0) ?? "").toLowerCase();
40099
+ const amount5 = big15(field11(r, "amount", 1));
39558
40100
  if (!/^0x[0-9a-f]{40}$/.test(asset) || amount5 === 0n) continue;
39559
40101
  held.set(asset, (held.get(asset) ?? 0n) + amount5);
39560
40102
  }
@@ -39796,7 +40338,7 @@ var big17 = (v) => {
39796
40338
  }
39797
40339
  return void 0;
39798
40340
  };
39799
- var field11 = (res, name, idx) => res?.[name] ?? (Array.isArray(res) ? res[idx] : res?.[idx]);
40341
+ var field12 = (res, name, idx) => res?.[name] ?? (Array.isArray(res) ? res[idx] : res?.[idx]);
39800
40342
  var getFlexUserDataConverter = (_lender, chainId, account, meta, opts) => {
39801
40343
  const discovery = getCachedFlexDiscovery(chainId, account, opts);
39802
40344
  const markets = discovery?.markets ?? [];
@@ -39817,22 +40359,22 @@ var getFlexUserDataConverter = (_lender, chainId, account, meta, opts) => {
39817
40359
  const base = markets.length + i * FLEX_CALLS_PER_TROVE;
39818
40360
  const tr = data[base];
39819
40361
  if (tr == null || isFailedCall(tr)) return;
39820
- const owner = String(field11(tr, "owner", 6) ?? "").toLowerCase();
39821
- const status = big17(field11(tr, "status", 7)) ?? 0n;
40362
+ const owner = String(field12(tr, "owner", 6) ?? "").toLowerCase();
40363
+ const status = big17(field12(tr, "status", 7)) ?? 0n;
39822
40364
  if (owner !== who) return;
39823
40365
  if ((status & (FLEX_TROVE_STATUS.ACTIVE | FLEX_TROVE_STATUS.ZOMBIE)) === 0n)
39824
40366
  return;
39825
- const collateral = big17(field11(tr, "collateral", 1));
39826
- const storedDebt = big17(field11(tr, "debt", 0));
40367
+ const collateral = big17(field12(tr, "collateral", 1));
40368
+ const storedDebt = big17(field12(tr, "debt", 0));
39827
40369
  const accrued = isFailedCall(data[base + 1]) ? void 0 : big17(data[base + 1]);
39828
40370
  const debt = accrued ?? storedDebt;
39829
40371
  if (collateral === void 0 || debt === void 0) return;
39830
- const rateRaw = big17(field11(tr, "annual_interest_rate", 2)) ?? 0n;
40372
+ const rateRaw = big17(field12(tr, "annual_interest_rate", 2)) ?? 0n;
39831
40373
  const lastIncrease = Number(
39832
- big17(field11(tr, "last_debt_increase_time", 4)) ?? 0n
40374
+ big17(field12(tr, "last_debt_increase_time", 4)) ?? 0n
39833
40375
  );
39834
40376
  const lastRateAdj = Number(
39835
- big17(field11(tr, "last_interest_rate_adj_time", 5)) ?? 0n
40377
+ big17(field12(tr, "last_interest_rate_adj_time", 5)) ?? 0n
39836
40378
  );
39837
40379
  const m = t.market;
39838
40380
  const lenderKey = flexLenderKey(chainId, m.troveManager);
@@ -40868,7 +41410,7 @@ var big24 = (v) => {
40868
41410
  }
40869
41411
  return 0n;
40870
41412
  };
40871
- var field12 = (res, name, idx) => big24(res?.[name] ?? res?.[idx]);
41413
+ var field13 = (res, name, idx) => big24(res?.[name] ?? res?.[idx]);
40872
41414
  var getDssUserDataConverter = (lender, chainId, account, meta, opts) => {
40873
41415
  const cfg = dssConfigFor(lender, chainId);
40874
41416
  const markets = dssChainData(lender, chainId)?.markets ?? [];
@@ -40887,14 +41429,14 @@ var getDssUserDataConverter = (lender, chainId, account, meta, opts) => {
40887
41429
  const rateByIlk = /* @__PURE__ */ new Map();
40888
41430
  ilks.forEach((ilk, i) => {
40889
41431
  const res = data[cdps.length * DSS_CALLS_PER_CDP + i];
40890
- if (!isFailedCall(res)) rateByIlk.set(ilk, field12(res, "rate", 1));
41432
+ if (!isFailedCall(res)) rateByIlk.set(ilk, field13(res, "rate", 1));
40891
41433
  });
40892
41434
  const perMarket = /* @__PURE__ */ new Map();
40893
41435
  cdps.forEach((cdp, i) => {
40894
41436
  const res = data[i * DSS_CALLS_PER_CDP];
40895
41437
  if (isFailedCall(res)) return;
40896
- const ink = field12(res, "ink", 0);
40897
- const art = field12(res, "art", 1);
41438
+ const ink = field13(res, "ink", 0);
41439
+ const art = field13(res, "art", 1);
40898
41440
  const rate = rateByIlk.get(cdp.ilk) ?? RAY7;
40899
41441
  const debt = art * rate / RAY7;
40900
41442
  if (ink === 0n && debt === 0n) return;
@@ -41126,7 +41668,7 @@ var big26 = (v) => {
41126
41668
  }
41127
41669
  return 0n;
41128
41670
  };
41129
- var field13 = (res, name, idx) => res?.[name] ?? res?.[idx];
41671
+ var field14 = (res, name, idx) => res?.[name] ?? res?.[idx];
41130
41672
  var getTellerUserDataConverter = (_lender, chainId, account, meta, opts) => {
41131
41673
  const discovery = getCachedTellerBids(chainId, account, opts);
41132
41674
  const kept = discovery?.bids ?? [];
@@ -41161,17 +41703,17 @@ var getTellerUserDataConverter = (_lender, chainId, account, meta, opts) => {
41161
41703
  const collDisplay = collMeta ? getDisplayPrice(collMeta) : 0;
41162
41704
  const collOracle = collMeta ? getOraclePrice(collMeta) : 0;
41163
41705
  const collHist = collMeta?.price?.priceUsd24h ?? collDisplay;
41164
- const owedPrincipal = big26(field13(owed, "principal", 0));
41165
- const owedInterest = big26(field13(owed, "interest", 1));
41706
+ const owedPrincipal = big26(field14(owed, "principal", 0));
41707
+ const owedInterest = big26(field14(owed, "interest", 1));
41166
41708
  const owedTotal = owedPrincipal + owedInterest;
41167
41709
  if (owedTotal === 0n && collAmount === 0n) return;
41168
- const loanDetails = field13(bidRes, "loanDetails", 5);
41169
- const terms = field13(bidRes, "terms", 6);
41710
+ const loanDetails = field14(bidRes, "loanDetails", 5);
41711
+ const terms = field14(bidRes, "terms", 6);
41170
41712
  const acceptedTs = Number(
41171
- big26(field13(loanDetails, "acceptedTimestamp", 4))
41713
+ big26(field14(loanDetails, "acceptedTimestamp", 4))
41172
41714
  );
41173
- const loanDuration = Number(big26(field13(loanDetails, "loanDuration", 6)));
41174
- const aprBps = Number(big26(field13(terms, "APR", 2)));
41715
+ const loanDuration = Number(big26(field14(loanDetails, "loanDuration", 6)));
41716
+ const aprBps = Number(big26(field14(terms, "APR", 2)));
41175
41717
  const maturity = acceptedTs > 0 ? acceptedTs + loanDuration : void 0;
41176
41718
  const isMatured = defaulted || maturity !== void 0 && maturity < now;
41177
41719
  const collStr = parseRawAmount(collAmount.toString(), collDecimals);
@@ -41269,7 +41811,7 @@ function toBigInt13(v) {
41269
41811
  return 0n;
41270
41812
  }
41271
41813
  }
41272
- function field14(res, name, index) {
41814
+ function field15(res, name, index) {
41273
41815
  if (res && typeof res === "object" && !Array.isArray(res) && name in res) {
41274
41816
  return res[name];
41275
41817
  }
@@ -41277,18 +41819,18 @@ function field14(res, name, index) {
41277
41819
  return void 0;
41278
41820
  }
41279
41821
  function parsePosition(res) {
41280
- const ftBalance = toBigInt13(field14(res, "ftBalance", 2));
41281
- const xtBalance = toBigInt13(field14(res, "xtBalance", 3));
41282
- const rawGts = field14(res, "gtInfo", 4);
41822
+ const ftBalance = toBigInt13(field15(res, "ftBalance", 2));
41823
+ const xtBalance = toBigInt13(field15(res, "xtBalance", 3));
41824
+ const rawGts = field15(res, "gtInfo", 4);
41283
41825
  const gts = [];
41284
41826
  if (Array.isArray(rawGts)) {
41285
41827
  for (const g of rawGts) {
41286
- const loanId = toBigInt13(field14(g, "loanId", 0));
41828
+ const loanId = toBigInt13(field15(g, "loanId", 0));
41287
41829
  if (loanId === 0n) continue;
41288
41830
  gts.push({
41289
41831
  loanId: loanId.toString(),
41290
- collateralAmt: toBigInt13(field14(g, "collateralAmt", 1)),
41291
- debtAmt: toBigInt13(field14(g, "debtAmt", 2))
41832
+ collateralAmt: toBigInt13(field15(g, "collateralAmt", 1)),
41833
+ debtAmt: toBigInt13(field15(g, "debtAmt", 2))
41292
41834
  });
41293
41835
  }
41294
41836
  }
@@ -41467,21 +42009,21 @@ function checkSubAccount(entry2) {
41467
42009
  const accountId = entry2?.accountId ?? "0";
41468
42010
  const balance = entry2?.balanceData;
41469
42011
  const apr = entry2?.aprData;
41470
- for (const field16 of BALANCE_FIELDS) {
41471
- if (isBadNumber(balance?.[field16]))
42012
+ for (const field17 of BALANCE_FIELDS) {
42013
+ if (isBadNumber(balance?.[field17]))
41472
42014
  violations.push({
41473
42015
  accountId,
41474
42016
  code: "non-finite",
41475
- detail: `balanceData.${field16} = ${balance[field16]}`,
42017
+ detail: `balanceData.${field17} = ${balance[field17]}`,
41476
42018
  requiresFailedReads: false
41477
42019
  });
41478
42020
  }
41479
- for (const field16 of APR_FIELDS) {
41480
- if (isBadNumber(apr?.[field16]))
42021
+ for (const field17 of APR_FIELDS) {
42022
+ if (isBadNumber(apr?.[field17]))
41481
42023
  violations.push({
41482
42024
  accountId,
41483
42025
  code: "non-finite",
41484
- detail: `aprData.${field16} = ${apr[field16]}`,
42026
+ detail: `aprData.${field17} = ${apr[field17]}`,
41485
42027
  requiresFailedReads: false
41486
42028
  });
41487
42029
  }
@@ -47082,8 +47624,8 @@ function calculateOverallNetApr(totalDepositsUSD, totalDebtUSD, avgDepositApr, a
47082
47624
  return (totalDepositsUSD * avgDepositApr - totalDebtUSD * avgBorrowApr) / Math.abs(totalNetWorth) * (totalNetWorth > 0 ? 1 : -1);
47083
47625
  }
47084
47626
  function calculateWeightedAprs(items) {
47085
- const wa = (field16, weightField) => calculateWeightedAverage(
47086
- items.filter((i) => i[weightField] !== 0).map((i) => ({ value: i[field16], weight: Math.abs(i[weightField]) }))
47627
+ const wa = (field17, weightField) => calculateWeightedAverage(
47628
+ items.filter((i) => i[weightField] !== 0).map((i) => ({ value: i[field17], weight: Math.abs(i[weightField]) }))
47087
47629
  );
47088
47630
  return {
47089
47631
  apr: wa("apr", "nav"),
@@ -48994,8 +49536,8 @@ var lombardLbtcFetcher = {
48994
49536
  const res = await fetch(LBTC_APY_URL, {
48995
49537
  headers: { accept: "application/json" }
48996
49538
  }).then((r) => r.json());
48997
- const frac2 = Number(res?.lbtc_estimated_apy);
48998
- return { LBTC: Number.isFinite(frac2) ? frac2 * 100 : 0 };
49539
+ const frac3 = Number(res?.lbtc_estimated_apy);
49540
+ return { LBTC: Number.isFinite(frac3) ? frac3 * 100 : 0 };
48999
49541
  }
49000
49542
  };
49001
49543
  var LOMBARD_VAULT_APY_URL = "https://mainnet.prod.lombard.finance/api/v1/analytics/vault/apy/history";
@@ -49007,8 +49549,8 @@ var createLombardVaultFetcher = (wrapper, key5) => ({
49007
49549
  headers: { accept: "application/json" }
49008
49550
  }).then((r) => r.json());
49009
49551
  const latest = Array.isArray(res?.snapshots) ? res.snapshots[0] : void 0;
49010
- const frac2 = Number(latest?.total_apy);
49011
- return { [key5]: Number.isFinite(frac2) ? frac2 * 100 : 0 };
49552
+ const frac3 = Number(latest?.total_apy);
49553
+ return { [key5]: Number.isFinite(frac3) ? frac3 * 100 : 0 };
49012
49554
  }
49013
49555
  });
49014
49556
  var lombardLbtcvFetcher = createLombardVaultFetcher(
@@ -51860,6 +52402,7 @@ var rwaFundsFetcher = {
51860
52402
  // src/yields/intrinsic/fetchers/inverse.ts
51861
52403
  var DOLA_STAKING_URL = "https://www.inverse.finance/api/dola-staking";
51862
52404
  var JDOLA_STAKING_URL = "https://www.inverse.finance/api/junior/jdola-staking";
52405
+ var INV_STAKING_URL = "https://www.inverse.finance/api/inv-staking";
51863
52406
  var SDOLA_KEY = "SDOLA";
51864
52407
  var SDOLA_GROUP_KEY = "sDOLA::SDOLA";
51865
52408
  var fetchJson3 = async (url) => {
@@ -51890,6 +52433,35 @@ var sdolaFetcher = {
51890
52433
  return { [SDOLA_KEY]: apr, [SDOLA_GROUP_KEY]: apr };
51891
52434
  }
51892
52435
  };
52436
+ var JRDOLA_KEY = "JRDOLA";
52437
+ var JRDOLA_GROUP_KEYS = [
52438
+ "Junior DOLA::JRDOLA",
52439
+ "Junior DOLA::JRDOLA::1::0"
52440
+ ];
52441
+ var jrdolaFetcher = {
52442
+ label: "JRDOLA",
52443
+ fetch: async () => {
52444
+ const d = await fetchJson3(JDOLA_STAKING_URL);
52445
+ const apy = Number(d?.apy ?? d?.calculatedApy);
52446
+ if (!Number.isFinite(apy) || apy < 0) throw new Error("jrDOLA apy missing");
52447
+ const apr = apyToAprPercent(apy);
52448
+ const out = { [JRDOLA_KEY]: apr };
52449
+ for (const k of JRDOLA_GROUP_KEYS) out[k] = apr;
52450
+ return out;
52451
+ }
52452
+ };
52453
+ var SINV_KEY = "SINV";
52454
+ var SINV_GROUP_KEY = "Staked INV::SINV";
52455
+ var sinvFetcher = {
52456
+ label: "SINV",
52457
+ fetch: async () => {
52458
+ const d = await fetchJson3(INV_STAKING_URL);
52459
+ const apy = Number(d?.apy ?? d?.auctionApy);
52460
+ if (!Number.isFinite(apy) || apy < 0) throw new Error("sINV apy missing");
52461
+ const apr = apyToAprPercent(apy);
52462
+ return { [SINV_KEY]: apr, [SINV_GROUP_KEY]: apr };
52463
+ }
52464
+ };
51893
52465
 
51894
52466
  // src/yields/intrinsic/fetchers/reProtocol.ts
51895
52467
  var REUSD_KEY = "RE::reUSD";
@@ -54587,8 +55159,8 @@ var fetchBitfiApiApr = async () => {
54587
55159
  const res = await fetch(BITFI_APR_URL, {
54588
55160
  headers: { accept: "application/json" }
54589
55161
  }).then((r) => r.json());
54590
- const frac2 = Number(res?.data?.["7e"]?.apr);
54591
- const apr = frac2 * 100;
55162
+ const frac3 = Number(res?.data?.["7e"]?.apr);
55163
+ const apr = frac3 * 100;
54592
55164
  return plausible(apr) && apr > 0 ? apr : void 0;
54593
55165
  } catch {
54594
55166
  return void 0;
@@ -55305,20 +55877,17 @@ var hubBase = {
55305
55877
  underlyingDecimals: 18,
55306
55878
  isRebasing: false,
55307
55879
  isMintable: true,
55308
- withdrawalMode: "instant-capped",
55309
- // Asserted, not assumed — every leg is collateral-backed with an on-chain
55310
- // liquidation threshold, incl. the FRV one whose docs read like unsecured
55311
- // credit. See the note above for the live ratios and the two qualifications
55312
- // that live in the descriptions instead.
55313
- solvency: "overcollateralized"
55880
+ withdrawalMode: "instant-capped"
55314
55881
  // No `yieldFetcher`: the rate is the groups' TVL-weighted `spotAPYBps()`,
55315
55882
  // which the reader computes from the same block's `totalAssets()` reads.
55316
55883
  // There is nothing off-chain to fall back to — the Hub publishes no APY
55317
55884
  // view by design, `api.venus.io` has no Hub route, and DefiLlama carries
55318
55885
  // only `venus-core-pool` / `venus-flux` pools.
55319
55886
  };
55320
- var EXIT_PROSE = "Exits are same-transaction and free, but capped at the liquid legs: anything sitting in a Fixed-Rate Vault is locked until it matures, typically a 30-day term.";
55321
- var BACKING_PROSE = "Every leg is overcollateralised, though not all of it is Venus: Flux lends through third-party Fluid, and a Fixed-Rate Vault is one institutional borrower posting custodial or real-world-asset collateral rather than a pool.";
55887
+ var EXIT_PROSE = "Exits are same-transaction and free, but capped at the liquid legs: a Fixed-Rate Vault is locked until it matures (typically a 30-day term), a Centrifuge fund leg until the Hub's redemption request settles, and the Spoke leg only returns what its borrowers have not drawn.";
55888
+ var SPOKE_PROSE = "Part of the Hub funds the Venus bStock-index Spoke pool, which lends only against tokenized equities (QQQB, SPYB) priced by a single oracle feed per asset.";
55889
+ var BACKING_PROSE_COLLATERAL = "Every lending leg is overcollateralised, though not all of it is Venus or a pool: a Fixed-Rate Vault is one institutional borrower posting custodial or real-world-asset collateral.";
55890
+ var BACKING_PROSE_FUNDS = "Part of the Hub holds Janus Henderson fund shares through Centrifuge \u2014 JTRSY (US Treasury bills) and JAAA (AAA-rated CLOs, i.e. credit) \u2014 valued at the fund's published NAV rather than secured by on-chain collateral; the lending legs are overcollateralised.";
55322
55891
  var VENUS_HUB_ENTRIES = {
55323
55892
  [Chain.BNB_SMART_CHAIN_MAINNET]: [
55324
55893
  {
@@ -55326,12 +55895,17 @@ var VENUS_HUB_ENTRIES = {
55326
55895
  address: "0x18afdacf30f8671021dec4b78297e39d2fe87226",
55327
55896
  underlying: "0x55d398326f99059ff775485246999027b3197955",
55328
55897
  symbol: "vhUSDT",
55329
- description: `Venus's USDT Liquidity Hub cascades one deposit across Venus Core lending, Fluid and Venus Fixed-Rate Vaults; the share price is the blend. ${EXIT_PROSE} ${BACKING_PROSE}`,
55898
+ solvency: "nav-attested",
55899
+ description: `Venus's USDT Liquidity Hub cascades one deposit across Venus Core lending, the Venus Spoke pool, Janus Henderson funds via Centrifuge, Venus Fixed-Rate Vaults and Fluid; the share price is the blend. ${EXIT_PROSE} ${SPOKE_PROSE} ${BACKING_PROSE_FUNDS}`,
55330
55900
  venusHub: {
55331
55901
  yieldGroups: [
55332
55902
  "0xc9e6ced9589363f8dc5695be2c79ab4ddaecc94b",
55333
55903
  "0xe3df38e12e37ed80e1b3ccf2bdf84f9e1527ce14",
55334
- "0x621ef38ce0c4e7060ff0bf3d609e3d46ec144be7"
55904
+ "0x621ef38ce0c4e7060ff0bf3d609e3d46ec144be7",
55905
+ // Centrifuge JTRSY + JAAA (VIP-669)
55906
+ "0xda5affeb43719f517676e031a727071c7d400983",
55907
+ // Spoke → vUSDT_bStockIndex (VIP-670)
55908
+ "0x3cc1ede91419dc7ec199a06704ec8ecab665a684"
55335
55909
  ],
55336
55910
  core: {
55337
55911
  yieldGroup: "0xc9e6ced9589363f8dc5695be2c79ab4ddaecc94b",
@@ -55347,12 +55921,17 @@ var VENUS_HUB_ENTRIES = {
55347
55921
  address: "0x9d2d9592cf8dfbf59107faab703d08494be14617",
55348
55922
  underlying: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
55349
55923
  symbol: "vhUSDC",
55350
- description: `Venus's USDC Liquidity Hub cascades one deposit across Venus Core lending, Fluid and Venus Fixed-Rate Vaults; the share price is the blend. ${EXIT_PROSE} ${BACKING_PROSE}`,
55924
+ solvency: "nav-attested",
55925
+ description: `Venus's USDC Liquidity Hub cascades one deposit across Venus Core lending, the Venus Spoke pool, Janus Henderson funds via Centrifuge, Venus Fixed-Rate Vaults and Fluid; the share price is the blend. ${EXIT_PROSE} ${SPOKE_PROSE} ${BACKING_PROSE_FUNDS}`,
55351
55926
  venusHub: {
55352
55927
  yieldGroups: [
55353
55928
  "0x299d9be7cefff91c68f13f267d525cfc18e965ef",
55354
55929
  "0xa65bb4b20542268b64cf08871a98d75342afe927",
55355
- "0x438388847ee16850ab4f5b82dc7954c0d043b716"
55930
+ "0x438388847ee16850ab4f5b82dc7954c0d043b716",
55931
+ // Centrifuge JTRSY + JAAA (VIP-669)
55932
+ "0x84baecf7ac76039f731a0780eb59a03b2c7b593c",
55933
+ // Spoke → vUSDC_bStockIndex (VIP-670)
55934
+ "0x4cd4ab2f88e39d3f3e481bb2555ecdf00266f717"
55356
55935
  ],
55357
55936
  core: {
55358
55937
  yieldGroup: "0x299d9be7cefff91c68f13f267d525cfc18e965ef",
@@ -55368,12 +55947,15 @@ var VENUS_HUB_ENTRIES = {
55368
55947
  address: "0x0e5aa174d4f31b757a237eb1999de151596788b0",
55369
55948
  underlying: "0xce24439f2d9c6a2289f741120fe202248b666666",
55370
55949
  symbol: "vhU",
55371
- description: `Venus's Liquidity Hub for U (United Stables) cascades one deposit across Venus Core lending, Fluid and Venus Fixed-Rate Vaults; the share price is the blend. ${EXIT_PROSE} ${BACKING_PROSE}`,
55950
+ solvency: "overcollateralized",
55951
+ description: `Venus's Liquidity Hub for U (United Stables) cascades one deposit across Venus Core lending, the Venus Spoke pool, Venus Fixed-Rate Vaults and Fluid; the share price is the blend. ${EXIT_PROSE} ${SPOKE_PROSE} ${BACKING_PROSE_COLLATERAL}`,
55372
55952
  venusHub: {
55373
55953
  yieldGroups: [
55374
55954
  "0x8a680f77a5367fa7cd33a02f51896cb1d55159c3",
55375
55955
  "0xe31b8851c3fa9b3dd39a04a2ed9493869a410616",
55376
- "0x30908eddb9e94add7ac9944a0adda66d80b89143"
55956
+ "0x30908eddb9e94add7ac9944a0adda66d80b89143",
55957
+ // Spoke → vU_bStockIndex (VIP-670)
55958
+ "0xca3f9afd7c4c1022e4a37a12671ef57b8a7bfc51"
55377
55959
  ],
55378
55960
  core: {
55379
55961
  yieldGroup: "0x8a680f77a5367fa7cd33a02f51896cb1d55159c3",
@@ -57140,6 +57722,39 @@ var FIRM_ENTRIES = {
57140
57722
  withdrawalMode: "instant",
57141
57723
  yieldFetcher: firmCollateralFetcher,
57142
57724
  yieldKey: STYCRV_KEY
57725
+ },
57726
+ {
57727
+ reader: "inverse-jrdola",
57728
+ address: "0x6f80a22a57c7f0257094ea8d426af3f747defbc7",
57729
+ underlying: "0xb45ad160634c528cc3d2926d9807104fa3157305",
57730
+ // sDOLA
57731
+ symbol: "jrDOLA",
57732
+ brand: "Inverse",
57733
+ solvency: "tranched-junior",
57734
+ description: "jrDOLA is the junior, first-loss tranche of Inverse's DOLA savings: it holds sDOLA, which can be taken to cover FiRM bad debt before sDOLA holders are touched \u2014 its predecessor lost 99.8% that way in April 2026. It earns DBR sold for sDOLA; the rate shown is that leg, in sDOLA, on top of sDOLA's own rate. Exit is a queue: request it (0.05% fee), wait 1\u201310 days, then complete within a 48-hour window, paid in sDOLA. Miss the window and you queue and pay again.",
57735
+ decimals: 18,
57736
+ isRebasing: false,
57737
+ isMintable: true,
57738
+ withdrawalMode: "request-based",
57739
+ withdrawalCooldownSeconds: 86400,
57740
+ withdrawQueue: "0x8554d8a6bcc5b6d6eb7bea2189e6a8f8d24c7e45",
57741
+ yieldFetcher: jrdolaFetcher,
57742
+ yieldKey: JRDOLA_GROUP_KEYS[0]
57743
+ },
57744
+ {
57745
+ reader: "inverse-sinv",
57746
+ address: "0x08d23468a467d2bb86fae0e32f247a26c7e2e994",
57747
+ underlying: "0x41d5d79431a913c4ae7d69a668ecdfe5ff9dfb68",
57748
+ // INV
57749
+ symbol: "sINV",
57750
+ brand: "Inverse",
57751
+ description: "sINV stakes INV, Inverse Finance's governance token, in FiRM's INV market, where staked INV earns DBR. The vault sells that DBR for more INV in an on-chain auction and adds it to the share price over the following week, so the rate shown is earned in INV and the position's dollar value moves with INV's price. Deposits are capped by a guardian-set limit; withdrawals are instant, with no fee or cooldown.",
57752
+ decimals: 18,
57753
+ isRebasing: false,
57754
+ isMintable: true,
57755
+ withdrawalMode: "instant",
57756
+ yieldFetcher: sinvFetcher,
57757
+ yieldKey: SINV_GROUP_KEY
57143
57758
  }
57144
57759
  ]
57145
57760
  };
@@ -59632,9 +60247,8 @@ var SINGLE_CHAIN_ENTRIES = {
59632
60247
  // auction, no rehypothecation. Instant permissionless exit
59633
60248
  // (maxDeposit = uint.max verified 2026-08; ~6.9M DOLA TVL).
59634
60249
  // Ethereum-only; Inverse propagates the rate cross-chain via
59635
- // CCIP, so bridged deployments may appear later. The jDOLA
59636
- // junior tranche (48h exit window + fee, ~$28k) is deliberately
59637
- // not registered.
60250
+ // CCIP, so bridged deployments may appear later. The jrDOLA
60251
+ // junior tranche and sINV are in `registryFirm.ts`.
59638
60252
  address: "0xb45ad160634c528cc3d2926d9807104fa3157305",
59639
60253
  underlying: "0x865377367054516e17014ccded1e7d814edc9ce4",
59640
60254
  // DOLA
@@ -68424,7 +69038,7 @@ var big28 = (v) => {
68424
69038
  return 0n;
68425
69039
  }
68426
69040
  };
68427
- var field15 = (res, name, idx) => {
69041
+ var field16 = (res, name, idx) => {
68428
69042
  const v = res?.[name];
68429
69043
  if (typeof v === "bigint" || typeof v === "number" || typeof v === "string") {
68430
69044
  return big28(v);
@@ -68435,7 +69049,7 @@ function parseDssResults(data, meta, context) {
68435
69049
  const { chainId } = context;
68436
69050
  const key5 = dssLenderKey(meta.lender, chainId, meta.ilk);
68437
69051
  const entries = [];
68438
- const spot = field15(data?.[0], "spot", 2);
69052
+ const spot = field16(data?.[0], "spot", 2);
68439
69053
  const mat = big28(meta.mat);
68440
69054
  if (spot > 0n && mat > 0n) {
68441
69055
  const collUSD = Number(spot) / RAY10 * (Number(mat) / RAY10);
@@ -72910,10 +73524,10 @@ function createAssetArrayPerChain() {
72910
73524
  return assetsPerChain;
72911
73525
  }
72912
73526
  var RELEVANT_LENDING_ASSETS = () => createAssetArrayPerChain();
72913
- function createSimpleArrayPerChain(fork, field16 = void 0) {
73527
+ function createSimpleArrayPerChain(fork, field17 = void 0) {
72914
73528
  let pools = {};
72915
73529
  Object.entries(fork ?? {}).forEach(([b2, data]) => {
72916
- Object.entries(field16 ? data[field16] : data).forEach(
73530
+ Object.entries(field17 ? data[field17] : data).forEach(
72917
73531
  ([chainId, address]) => {
72918
73532
  if (!pools[chainId]) pools[chainId] = [];
72919
73533
  pools[chainId] = uniq2([...pools[chainId], { address, pool: b2 }]);
@@ -75645,9 +76259,9 @@ query EvkByAssets($assets: [Bytes!]!) {
75645
76259
  `;
75646
76260
  var ZERO8 = 0n;
75647
76261
  var RAY_TO_PERCENT3 = 1e25;
75648
- function readAddress2(field16) {
75649
- if (!field16) return void 0;
75650
- return field16.toLowerCase();
76262
+ function readAddress2(field17) {
76263
+ if (!field17) return void 0;
76264
+ return field17.toLowerCase();
75651
76265
  }
75652
76266
  function parseVaultFee(v) {
75653
76267
  if (v.performanceFee == null) return 0;
@@ -82503,86 +83117,6 @@ var NavOracleReadAbi = [
82503
83117
  }
82504
83118
  ];
82505
83119
 
82506
- // src/vaults/savings/readers/shared.ts
82507
- var ONE_E1823 = 10n ** 18n;
82508
- var toBigInt16 = (v) => {
82509
- if (v === void 0 || v === null) return void 0;
82510
- if (typeof v === "bigint") return v;
82511
- if (typeof v === "number") return BigInt(v);
82512
- if (typeof v === "string") {
82513
- if (v === "" || v === "0x" || v === "0X") return void 0;
82514
- try {
82515
- return BigInt(v);
82516
- } catch {
82517
- return void 0;
82518
- }
82519
- }
82520
- return void 0;
82521
- };
82522
-
82523
- // src/vaults/savings/readers/erc4626.ts
82524
- var readerErc46262 = (entry2) => {
82525
- const shareUnit = 10n ** BigInt(entry2.decimals);
82526
- const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
82527
- return {
82528
- calls: [
82529
- { address: entry2.address, name: "totalAssets", params: [] },
82530
- { address: entry2.address, name: "totalSupply", params: [] },
82531
- {
82532
- address: entry2.address,
82533
- name: "convertToAssets",
82534
- params: [shareUnit]
82535
- }
82536
- ],
82537
- abis: [Erc4626ReadAbi2, TotalSupplyAbi2, Erc4626ReadAbi2],
82538
- parse: ([assets, supply, rate]) => {
82539
- const totalAssets = toBigInt16(assets);
82540
- const totalSupply = toBigInt16(supply);
82541
- const convertToAssetsRaw = toBigInt16(rate);
82542
- if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
82543
- return void 0;
82544
- }
82545
- return {
82546
- totalAssets,
82547
- totalSupply,
82548
- exchangeRate: convertToAssetsRaw * ONE_E1823 / underlyingUnit
82549
- };
82550
- }
82551
- };
82552
- };
82553
-
82554
- // src/vaults/savings/readers/erc4626Cooldown.ts
82555
- var readerErc4626Cooldown = (entry2) => {
82556
- const shareUnit = 10n ** BigInt(entry2.decimals);
82557
- const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
82558
- const cooldownGetter = entry2.cooldownGetter ?? "cooldownDuration";
82559
- const cooldownAbi = cooldownGetter === "lockupPeriod" ? LockupPeriodAbi : CooldownDurationAbi;
82560
- return {
82561
- calls: [
82562
- { address: entry2.address, name: "totalAssets", params: [] },
82563
- { address: entry2.address, name: "totalSupply", params: [] },
82564
- { address: entry2.address, name: "convertToAssets", params: [shareUnit] },
82565
- { address: entry2.address, name: cooldownGetter, params: [] }
82566
- ],
82567
- abis: [Erc4626ReadAbi2, TotalSupplyAbi2, Erc4626ReadAbi2, cooldownAbi],
82568
- parse: ([assets, supply, rate, cooldown]) => {
82569
- const totalAssets = toBigInt16(assets);
82570
- const totalSupply = toBigInt16(supply);
82571
- const convertToAssetsRaw = toBigInt16(rate);
82572
- if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
82573
- return void 0;
82574
- }
82575
- const cooldownSecs = toBigInt16(cooldown);
82576
- return {
82577
- totalAssets,
82578
- totalSupply,
82579
- exchangeRate: convertToAssetsRaw * ONE_E1823 / underlyingUnit,
82580
- withdrawalCooldownSeconds: cooldownSecs === void 0 ? void 0 : Number(cooldownSecs)
82581
- };
82582
- }
82583
- };
82584
- };
82585
-
82586
83120
  // src/vaults/savings/abis/native.ts
82587
83121
  var NativeWnlpReadAbi = [
82588
83122
  {
@@ -83522,6 +84056,222 @@ var EmberPauseStatusAbi = [
83522
84056
  }
83523
84057
  ];
83524
84058
 
84059
+ // src/vaults/savings/abis/inverse.ts
84060
+ var uintView = (name) => [
84061
+ {
84062
+ name,
84063
+ type: "function",
84064
+ stateMutability: "view",
84065
+ inputs: [],
84066
+ outputs: [{ type: "uint256" }]
84067
+ }
84068
+ ];
84069
+ var InverseWithdrawFeeBpsAbi = uintView("withdrawFeeBps");
84070
+ var InverseWithdrawalsPausedUntilAbi = uintView(
84071
+ "withdrawalsPausedUntil"
84072
+ );
84073
+ var InverseMinDelayAbi = uintView("minDelay");
84074
+ var InverseMaxDelayAbi = uintView("maxDelay");
84075
+ var InverseMaxDelayThresholdBpsAbi = uintView("maxDelayThresholdBps");
84076
+ var InverseDepositLimitAbi = uintView("depositLimit");
84077
+
84078
+ // src/vaults/savings/readers/shared.ts
84079
+ var ONE_E1823 = 10n ** 18n;
84080
+ var toBigInt16 = (v) => {
84081
+ if (v === void 0 || v === null) return void 0;
84082
+ if (typeof v === "bigint") return v;
84083
+ if (typeof v === "number") return BigInt(v);
84084
+ if (typeof v === "string") {
84085
+ if (v === "" || v === "0x" || v === "0X") return void 0;
84086
+ try {
84087
+ return BigInt(v);
84088
+ } catch {
84089
+ return void 0;
84090
+ }
84091
+ }
84092
+ return void 0;
84093
+ };
84094
+
84095
+ // src/vaults/savings/readers/inverseStaking.ts
84096
+ var JRDOLA_DELAY_MODEL = "0x75fda12cb3341cccd41b77c2515f0da716119b07";
84097
+ var MIN_WITHDRAW_DELAY = 86400;
84098
+ var MAX_WITHDRAW_DELAY = 60 * 86400;
84099
+ var jrDolaWithdrawDelay = (p) => {
84100
+ const threshold = p.totalSupply * p.thresholdBps / 10000n;
84101
+ const raw = threshold === 0n || p.withdrawing >= threshold ? p.maxDelay : (p.minDelay * (threshold - p.withdrawing) + p.maxDelay * p.withdrawing) / threshold;
84102
+ const n = Number(raw);
84103
+ return Math.min(Math.max(n, MIN_WITHDRAW_DELAY), MAX_WITHDRAW_DELAY);
84104
+ };
84105
+ var readerInverseJrDola = (entry2) => {
84106
+ const shareUnit = 10n ** BigInt(entry2.decimals);
84107
+ const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
84108
+ const escrow = entry2.withdrawQueue;
84109
+ if (!escrow)
84110
+ throw new Error(`jrDOLA entry ${entry2.address} needs withdrawQueue`);
84111
+ return {
84112
+ calls: [
84113
+ { address: entry2.address, name: "totalAssets", params: [] },
84114
+ { address: entry2.address, name: "totalSupply", params: [] },
84115
+ { address: entry2.address, name: "convertToAssets", params: [shareUnit] },
84116
+ { address: entry2.address, name: "balanceOf", params: [escrow] },
84117
+ { address: escrow, name: "withdrawFeeBps", params: [] },
84118
+ { address: escrow, name: "withdrawalsPausedUntil", params: [] },
84119
+ { address: JRDOLA_DELAY_MODEL, name: "minDelay", params: [] },
84120
+ { address: JRDOLA_DELAY_MODEL, name: "maxDelay", params: [] },
84121
+ { address: JRDOLA_DELAY_MODEL, name: "maxDelayThresholdBps", params: [] }
84122
+ ],
84123
+ abis: [
84124
+ Erc4626ReadAbi2,
84125
+ TotalSupplyAbi2,
84126
+ Erc4626ReadAbi2,
84127
+ BalanceOfAbi,
84128
+ InverseWithdrawFeeBpsAbi,
84129
+ InverseWithdrawalsPausedUntilAbi,
84130
+ InverseMinDelayAbi,
84131
+ InverseMaxDelayAbi,
84132
+ InverseMaxDelayThresholdBpsAbi
84133
+ ],
84134
+ parse: ([
84135
+ assets,
84136
+ supply,
84137
+ rate,
84138
+ queued,
84139
+ fee,
84140
+ pausedUntil,
84141
+ minDelay,
84142
+ maxDelay,
84143
+ thresholdBps
84144
+ ]) => {
84145
+ const totalAssets = toBigInt16(assets);
84146
+ const totalSupply = toBigInt16(supply);
84147
+ const convertToAssetsRaw = toBigInt16(rate);
84148
+ if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
84149
+ return void 0;
84150
+ }
84151
+ const feeBps = toBigInt16(fee);
84152
+ const paused = toBigInt16(pausedUntil);
84153
+ const withdrawing = toBigInt16(queued);
84154
+ const lo = toBigInt16(minDelay);
84155
+ const hi = toBigInt16(maxDelay);
84156
+ const bps = toBigInt16(thresholdBps);
84157
+ const delay = withdrawing !== void 0 && lo !== void 0 && hi !== void 0 && bps !== void 0 ? jrDolaWithdrawDelay({
84158
+ totalSupply,
84159
+ withdrawing,
84160
+ minDelay: lo,
84161
+ maxDelay: hi,
84162
+ thresholdBps: bps
84163
+ }) : void 0;
84164
+ return {
84165
+ totalAssets,
84166
+ totalSupply,
84167
+ exchangeRate: convertToAssetsRaw * ONE_E1823 / underlyingUnit,
84168
+ withdrawQueue: escrow.toLowerCase(),
84169
+ ...feeBps !== void 0 ? { withdrawFeeBps: Number(feeBps) } : {},
84170
+ ...delay !== void 0 ? { withdrawalCooldownSeconds: delay } : {},
84171
+ ...paused !== void 0 ? { exitPaused: Number(paused) > Math.floor(Date.now() / 1e3) } : {}
84172
+ };
84173
+ }
84174
+ };
84175
+ };
84176
+ var readerInverseSinv = (entry2) => {
84177
+ const shareUnit = 10n ** BigInt(entry2.decimals);
84178
+ const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
84179
+ return {
84180
+ calls: [
84181
+ { address: entry2.address, name: "totalAssets", params: [] },
84182
+ { address: entry2.address, name: "totalSupply", params: [] },
84183
+ { address: entry2.address, name: "convertToAssets", params: [shareUnit] },
84184
+ { address: entry2.address, name: "depositLimit", params: [] }
84185
+ ],
84186
+ abis: [
84187
+ Erc4626ReadAbi2,
84188
+ TotalSupplyAbi2,
84189
+ Erc4626ReadAbi2,
84190
+ InverseDepositLimitAbi
84191
+ ],
84192
+ parse: ([assets, supply, rate, limit]) => {
84193
+ const totalAssets = toBigInt16(assets);
84194
+ const totalSupply = toBigInt16(supply);
84195
+ const convertToAssetsRaw = toBigInt16(rate);
84196
+ if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
84197
+ return void 0;
84198
+ }
84199
+ const depositLimit = toBigInt16(limit);
84200
+ return {
84201
+ totalAssets,
84202
+ totalSupply,
84203
+ exchangeRate: convertToAssetsRaw * ONE_E1823 / underlyingUnit,
84204
+ ...depositLimit !== void 0 ? {
84205
+ depositCapacity: depositLimit > totalAssets ? depositLimit - totalAssets : 0n
84206
+ } : {}
84207
+ };
84208
+ }
84209
+ };
84210
+ };
84211
+
84212
+ // src/vaults/savings/readers/erc4626.ts
84213
+ var readerErc46262 = (entry2) => {
84214
+ const shareUnit = 10n ** BigInt(entry2.decimals);
84215
+ const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
84216
+ return {
84217
+ calls: [
84218
+ { address: entry2.address, name: "totalAssets", params: [] },
84219
+ { address: entry2.address, name: "totalSupply", params: [] },
84220
+ {
84221
+ address: entry2.address,
84222
+ name: "convertToAssets",
84223
+ params: [shareUnit]
84224
+ }
84225
+ ],
84226
+ abis: [Erc4626ReadAbi2, TotalSupplyAbi2, Erc4626ReadAbi2],
84227
+ parse: ([assets, supply, rate]) => {
84228
+ const totalAssets = toBigInt16(assets);
84229
+ const totalSupply = toBigInt16(supply);
84230
+ const convertToAssetsRaw = toBigInt16(rate);
84231
+ if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
84232
+ return void 0;
84233
+ }
84234
+ return {
84235
+ totalAssets,
84236
+ totalSupply,
84237
+ exchangeRate: convertToAssetsRaw * ONE_E1823 / underlyingUnit
84238
+ };
84239
+ }
84240
+ };
84241
+ };
84242
+
84243
+ // src/vaults/savings/readers/erc4626Cooldown.ts
84244
+ var readerErc4626Cooldown = (entry2) => {
84245
+ const shareUnit = 10n ** BigInt(entry2.decimals);
84246
+ const underlyingUnit = 10n ** BigInt(entry2.underlyingDecimals ?? entry2.decimals);
84247
+ const cooldownGetter = entry2.cooldownGetter ?? "cooldownDuration";
84248
+ const cooldownAbi = cooldownGetter === "lockupPeriod" ? LockupPeriodAbi : CooldownDurationAbi;
84249
+ return {
84250
+ calls: [
84251
+ { address: entry2.address, name: "totalAssets", params: [] },
84252
+ { address: entry2.address, name: "totalSupply", params: [] },
84253
+ { address: entry2.address, name: "convertToAssets", params: [shareUnit] },
84254
+ { address: entry2.address, name: cooldownGetter, params: [] }
84255
+ ],
84256
+ abis: [Erc4626ReadAbi2, TotalSupplyAbi2, Erc4626ReadAbi2, cooldownAbi],
84257
+ parse: ([assets, supply, rate, cooldown]) => {
84258
+ const totalAssets = toBigInt16(assets);
84259
+ const totalSupply = toBigInt16(supply);
84260
+ const convertToAssetsRaw = toBigInt16(rate);
84261
+ if (totalAssets === void 0 || totalSupply === void 0 || convertToAssetsRaw === void 0) {
84262
+ return void 0;
84263
+ }
84264
+ const cooldownSecs = toBigInt16(cooldown);
84265
+ return {
84266
+ totalAssets,
84267
+ totalSupply,
84268
+ exchangeRate: convertToAssetsRaw * ONE_E1823 / underlyingUnit,
84269
+ withdrawalCooldownSeconds: cooldownSecs === void 0 ? void 0 : Number(cooldownSecs)
84270
+ };
84271
+ }
84272
+ };
84273
+ };
84274
+
83525
84275
  // src/vaults/savings/readers/erc4626Idle.ts
83526
84276
  var readerErc4626Idle = (entry2) => {
83527
84277
  const shareUnit = 10n ** BigInt(entry2.decimals);
@@ -85585,6 +86335,10 @@ var buildReader2 = (entry2) => {
85585
86335
  return readerAccountableVault(entry2);
85586
86336
  case "morpho-vault-v2":
85587
86337
  return readerMorphoVaultV2(entry2);
86338
+ case "inverse-jrdola":
86339
+ return readerInverseJrDola(entry2);
86340
+ case "inverse-sinv":
86341
+ return readerInverseSinv(entry2);
85588
86342
  case "erc4626-cooldown":
85589
86343
  return readerErc4626Cooldown(entry2);
85590
86344
  case "erc4626-idle":
@@ -85853,7 +86607,9 @@ var fetchSavingsVaults = async (chainId, multicallRetry, prices = {}, tokenList
85853
86607
  entry2.reader === "ember-vault" || // sBOLD and the Alchemix MYTs (Morpho Vault V2) are conforming 4626 on
85854
86608
  // both legs; their readers exist for the exit cap (SP BOLD / the
85855
86609
  // liquidity adapter) and sBOLD's collateral gate.
85856
- entry2.reader === "sbold" || entry2.reader === "morpho-vault-v2",
86610
+ entry2.reader === "sbold" || entry2.reader === "morpho-vault-v2" || // Inverse sINV is 4626 on every leg; jrDOLA is 4626 on views and
86611
+ // deposit, its exit is the WithdrawalEscrow the savings kind builds.
86612
+ entry2.reader === "inverse-sinv" || entry2.reader === "inverse-jrdola",
85857
86613
  isRebasing: entry2.isRebasing,
85858
86614
  isMintable: entry2.isMintable,
85859
86615
  mintContract: entry2.mintContract?.toLowerCase() ?? addressLc,
@@ -90446,6 +91202,27 @@ var TERM_PROFILES = [
90446
91202
  ]
90447
91203
  }
90448
91204
  }),
91205
+ P({
91206
+ id: "venus.spoke@v1",
91207
+ name: "Venus Spoke pool (Hub-funded, tokenized-equity collateral)",
91208
+ family: "pool",
91209
+ supply: {
91210
+ description: "A Venus isolated pool split in two. The borrowable stablecoins are supplied ONLY by the Venus Liquidity Hub; the collateral side takes tokenized US equity funds (bStocks QQQB, SPYB), which earn nothing here and cannot be borrowed.",
91211
+ implications: [
91212
+ "You cannot deposit the stablecoins directly \u2014 exposure to this pool\u2019s lending side comes only through a Venus Liquidity Hub.",
91213
+ "Collateral is a tokenized ETF priced by a single oracle feed per asset; a stale or wrong feed affects every position at once.",
91214
+ "Withdrawals of collateral are limited by your own health, not by pool liquidity."
91215
+ ]
91216
+ },
91217
+ borrow: {
91218
+ description: "Borrow USDT, USDC or U against tokenized QQQ or SPY at a utilization-driven rate. The debt accrues continuously and can be repaid at any time; liquidation is triggered at the liquidation threshold on the spot price.",
91219
+ implications: [
91220
+ "Borrowing power is computed on a deviation-bounded price \u2014 collateral at the low end of its recent range, debt at the high end \u2014 so after a sharp move you can borrow less than the spot price implies.",
91221
+ "Liquidation uses the spot price, so the gap between borrowing power and the liquidation point narrows after a move rather than widening.",
91222
+ "The pool\u2019s lendable cash is whatever the Liquidity Hubs choose to route into it, capped per market."
91223
+ ]
91224
+ }
91225
+ }),
90449
91226
  P({
90450
91227
  id: "llamalend.soft@v1",
90451
91228
  name: "Curve LlamaLend market",
@@ -93097,8 +93874,8 @@ function formatRaw(raw, decimals) {
93097
93874
  if (decimals <= 0) return Number(value);
93098
93875
  const base = 10n ** BigInt(decimals);
93099
93876
  const whole = value / base;
93100
- const frac2 = value % base;
93101
- const n = Number(whole) + Number(frac2) / Number(base);
93877
+ const frac3 = value % base;
93878
+ const n = Number(whole) + Number(frac3) / Number(base);
93102
93879
  return Number.isFinite(n) ? n : void 0;
93103
93880
  }
93104
93881
 
@@ -94089,8 +94866,9 @@ function computeEModeSwitchHealth(positions, lenderMeta, currentCollateral, curr
94089
94866
  const totalDebtUSD = (pos.debtUSDOracle ?? pos.debtUSD) + (pos.debtStableUSDOracle ?? pos.debtStableUSD);
94090
94867
  if (totalDebtUSD > 0) {
94091
94868
  const hasTargetConfig = Boolean(configs[targetMode]);
94092
- const oldFactor = configs[currentMode]?.borrowFactor ?? 1;
94093
- const newFactor = hasTargetConfig ? configs[targetMode]?.borrowFactor ?? 1 : 1e10;
94869
+ const liqWeight = (c) => c?.liquidationBorrowFactor ?? c?.borrowFactor ?? 1;
94870
+ const oldFactor = liqWeight(configs[currentMode]);
94871
+ const newFactor = hasTargetConfig ? liqWeight(configs[targetMode]) : 1e10;
94094
94872
  debtNew += totalDebtUSD * (newFactor - oldFactor);
94095
94873
  }
94096
94874
  }
@@ -94108,22 +94886,39 @@ function getSupportedAssets(lenderMeta, targetMode) {
94108
94886
  }
94109
94887
  return { collateral, borrow };
94110
94888
  }
94889
+ function computeEModeSwitchBorrowHeadroom(positions, lenderMeta, targetMode, externalDebtUSD = 0) {
94890
+ let capacity = 0;
94891
+ let debt = externalDebtUSD;
94892
+ for (let i = 0; i < positions.length; i++) {
94893
+ const pos = positions[i];
94894
+ const cfg = lenderMeta[pos.marketUid]?.configs?.[targetMode];
94895
+ const depositsOracle = pos.depositsUSDOracle ?? pos.depositsUSD;
94896
+ if (pos.collateralEnabled && depositsOracle > 0 && cfg && !cfg.collateralDisabled)
94897
+ capacity += depositsOracle * (cfg.borrowCollateralFactor ?? 0);
94898
+ debt += ((pos.debtUSDOracle ?? pos.debtUSD) + (pos.debtStableUSDOracle ?? pos.debtStableUSD)) * (cfg?.borrowFactor ?? 1);
94899
+ }
94900
+ return capacity - debt;
94901
+ }
94111
94902
  function isCollateralBlockedInMode(config) {
94112
94903
  if (!config) return true;
94113
94904
  if (config.collateralDisabled) return true;
94114
94905
  if ((config.borrowCollateralFactor ?? 0) === 0) return true;
94115
94906
  return false;
94116
94907
  }
94117
- function canSwitchToEMode(positions, lenderMeta, targetMode, healthFactor) {
94118
- if (healthFactor !== null && healthFactor <= 1) {
94119
- return { canSwitch: false, blockReason: "health_factor", blockingAssets: [] };
94908
+ function canSwitchToEMode(positions, lenderMeta, targetMode, healthFactor, rule = "aave", externalDebts = []) {
94909
+ if (rule === "aave" && healthFactor !== null && healthFactor <= 1) {
94910
+ return {
94911
+ canSwitch: false,
94912
+ blockReason: "health_factor",
94913
+ blockingAssets: []
94914
+ };
94120
94915
  }
94121
94916
  const collateralBlocking = [];
94122
94917
  const debtBlocking = [];
94123
94918
  for (let i = 0; i < positions.length; i++) {
94124
94919
  const pos = positions[i];
94125
94920
  const config = lenderMeta[pos.marketUid]?.configs?.[targetMode];
94126
- if (pos.collateralEnabled && pos.depositsUSD > 0) {
94921
+ if (rule === "aave" && pos.collateralEnabled && pos.depositsUSD > 0) {
94127
94922
  if (isCollateralBlockedInMode(config)) {
94128
94923
  collateralBlocking.push(pos.marketUid);
94129
94924
  }
@@ -94135,6 +94930,28 @@ function canSwitchToEMode(positions, lenderMeta, targetMode, healthFactor) {
94135
94930
  }
94136
94931
  }
94137
94932
  }
94933
+ if (rule === "borrow-capacity") {
94934
+ const externalBlocking = targetMode !== "0" ? externalDebts.map((d) => d.label) : [];
94935
+ if (debtBlocking.length > 0 || externalBlocking.length > 0)
94936
+ return {
94937
+ canSwitch: false,
94938
+ blockReason: "debt_not_supported",
94939
+ blockingAssets: [...debtBlocking, ...externalBlocking]
94940
+ };
94941
+ const externalDebtUSD = externalDebts.reduce((a, d) => a + d.debtUSD, 0);
94942
+ if (computeEModeSwitchBorrowHeadroom(
94943
+ positions,
94944
+ lenderMeta,
94945
+ targetMode,
94946
+ externalDebtUSD
94947
+ ) < 0)
94948
+ return {
94949
+ canSwitch: false,
94950
+ blockReason: "borrow_capacity",
94951
+ blockingAssets: []
94952
+ };
94953
+ return { canSwitch: true };
94954
+ }
94138
94955
  if (collateralBlocking.length > 0) {
94139
94956
  return {
94140
94957
  canSwitch: false,
@@ -94151,7 +94968,7 @@ function canSwitchToEMode(positions, lenderMeta, targetMode, healthFactor) {
94151
94968
  }
94152
94969
  return { canSwitch: true };
94153
94970
  }
94154
- function computeEModeAnalysis(subAccount, lenderMeta, eModes) {
94971
+ function computeEModeAnalysis(subAccount, lenderMeta, eModes, rule = "aave") {
94155
94972
  const { positions, balanceData: balanceData2, userConfig } = subAccount;
94156
94973
  const currentMode = userConfig.selectedMode;
94157
94974
  return Object.values(eModes).map((eMode) => {
@@ -94169,7 +94986,9 @@ function computeEModeAnalysis(subAccount, lenderMeta, eModes) {
94169
94986
  positions,
94170
94987
  lenderMeta,
94171
94988
  targetMode,
94172
- healthFactor
94989
+ healthFactor,
94990
+ rule,
94991
+ subAccount.externalDebts ?? []
94173
94992
  );
94174
94993
  return {
94175
94994
  modeId: eMode.category,
@@ -94715,7 +95534,9 @@ function resolveMarketDescriptors(row, ctxMarket) {
94715
95534
  const fromParams = pick2(row, "params.market");
94716
95535
  const rowLevel = {};
94717
95536
  for (const k of ROW_DESCRIPTOR_KEYS) {
95537
+ const underParams = row.params?.[k];
94718
95538
  if (row[k] != null) rowLevel[k] = row[k];
95539
+ else if (underParams != null && k !== "fee") rowLevel[k] = underParams;
94719
95540
  }
94720
95541
  const merged = { ...ctxMarket ?? {}, ...fromParams ?? {}, ...rowLevel };
94721
95542
  return Object.keys(merged).length > 0 ? merged : void 0;
@@ -96193,13 +97014,21 @@ var gearboxAdapter = {
96193
97014
  id: "gearbox",
96194
97015
  matches: isGearboxV3,
96195
97016
  profileId: () => "pool.variable@v1",
96196
- build: () => ({
96197
- utilization: { basis: "pool" },
96198
- constraints: {
96199
- positionModel: "sub-account",
96200
- positionIdMeaning: "The credit-account address opened for this user."
96201
- }
96202
- })
97017
+ build: (input) => {
97018
+ const g = input.market?.gearbox;
97019
+ return {
97020
+ utilization: { basis: "pool" },
97021
+ ...g?.openable === false ? {
97022
+ borrow: {
97023
+ availability: { canOpen: false, blockedBy: "no-liquidity" }
97024
+ }
97025
+ } : {},
97026
+ constraints: {
97027
+ positionModel: "sub-account",
97028
+ positionIdMeaning: "The credit-account address opened for this user."
97029
+ }
97030
+ };
97031
+ }
96203
97032
  };
96204
97033
  var llamaLendAdapter = {
96205
97034
  id: "llamalend",
@@ -96743,6 +97572,20 @@ var fraxlendAdapter = {
96743
97572
  }
96744
97573
  })
96745
97574
  };
97575
+ var venusSpokeAdapter = {
97576
+ id: "venus-spoke",
97577
+ matches: (lender) => lender === Lender.VENUS_BSTOCK,
97578
+ profileId: () => "venus.spoke@v1",
97579
+ build: (input) => input.depositsEnabled === false ? {
97580
+ supply: {
97581
+ availability: {
97582
+ canOpen: false,
97583
+ blockedBy: "not-whitelisted",
97584
+ gating: "allowlist-contract"
97585
+ }
97586
+ }
97587
+ } : {}
97588
+ };
96746
97589
  var MORPHO_BLUE_MAX_FEE_PERCENT = 25;
96747
97590
  function feePercent(raw) {
96748
97591
  if (raw == null) return void 0;
@@ -97924,6 +98767,7 @@ var TERM_ADAPTERS = [
97924
98767
  flexAdapter,
97925
98768
  twyneAdapter,
97926
98769
  fraxlendAdapter,
98770
+ venusSpokeAdapter,
97927
98771
  morphoBlueAdapter,
97928
98772
  aaveV4Adapter,
97929
98773
  // Solana families — predicates match `<FAMILY>` / `<FAMILY>_<base58>` on an
@@ -99545,7 +100389,9 @@ function earnPositionFromLenderEntry(entry2) {
99545
100389
  ...sub.accountAddress ? { accountAddress: sub.accountAddress } : {},
99546
100390
  ...sub.label ? { label: sub.label } : {},
99547
100391
  ...sub.unsupported ? { unsupported: sub.unsupported } : {},
99548
- health: sub.health ?? null,
100392
+ // the LIQUIDATION-side figure where the state carries one: a
100393
+ // multi-account `health` is on the opening factors (LTV, not LT)
100394
+ health: sub.liquidationHealth ?? sub.health ?? null,
99549
100395
  suppliedUsd: suppliedUsd2,
99550
100396
  borrowedUsd: borrowedUsd2,
99551
100397
  netUsd: suppliedUsd2 - borrowedUsd2,
@@ -100387,6 +101233,6 @@ function quoteBorosHedgeLeg(p) {
100387
101233
  };
100388
101234
  }
100389
101235
 
100390
- export { ALCHEMIX_BLOCK_SECONDS, ApiBookSource, BOROS_API_BASE, BOROS_GOVERNANCE, BOROS_MIN_CASH_USD, BOROS_PROFILE_ID, BorosApiError, DEFAULT_CONSENSUS_DEMOTION, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, DEFAULT_TERM_ORDER_STORE, DOLOMITE_ISO_ID_PREFIX, EARN_DESCRIPTIONS, EARN_LABELS, EARN_RATE_SOURCE_BY_PROVIDER, EMPTY_BALANCE, EXACTLY_LENDER_KEY, EXPONENT_MATURED_REASON, FIXED_YIELD_EARN_VENUE_PREFIXES, FLYING_TULIP_LENDER_KEY, FRACTION_RATE_PROVIDERS, FUNDING_EXPOSURE_PROFILES, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, HYPERCORE_VAULT_REGISTRY, IDLE_MARKET_ID, INTERFACE_IDS, LAGOON_API_URL, LAGOON_CHAIN_IDS, MORPHO_LENS, MULTICALL_FAILURE, MaxParamThresholds, NON_EVM_VAULT_PROVIDERS, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL2 as PENDLE_MARKETS_URL, PREFIX_LENDERS, RATE_QUEUE_MAX_LEVELS, RATE_QUEUE_STEP, RIPE_LENDER_KEY, SDK_FRACTION_RATE_PROVIDERS, SPECTRA_NETWORKS, SPECTRA_RATE_MAX_PERCENT, SPECTRA_RATE_MIN_PERCENT, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, SVM_EARN_MINT_BUILDERS, SVM_EARN_VAULT_BUILDERS, SVM_VAULT_PROVIDERS, TELLER_CALLS_PER_BID, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_MARKETS_PER_CALL, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, USER_REWARD_SOURCES, USER_SET_RATE_PICKS, VAULT_PROVIDERS, VAULT_PROVIDER_PROFILE, VAULT_PROVIDER_TRAITS, VAULT_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VOLATILE_VAULT_OVERRIDES, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, alchemixLenderKey, alchemixMytRate, alchemixRedemptionPace, appendSnapshot, applyEarnSanity, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, blockNumberFromTag, borosApi, borosInitialMargin, borosMaintenanceMargin, borosRateMoveToLiquidation, borosSideTerms, borosTakerFee, borrowDescription, borrowFindings, borrowHeadline, buildBorosTermSheet, buildExposures2 as buildExposures, buildFluidFTokensCall, buildLendingPositionUid, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildQueriesFromMeta, buildRateQueue, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, clearSpectraMarketsCache, collateralSymbolsByVenue, collectFeedObservations, computeBorrowDelta2 as computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta2 as computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta2 as computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta2 as computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertAlchemixMarketsToResponse, convertBorosCandle, convertBorosMarket, convertCoolerMarketsToResponse, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFlexMarketsToResponse, convertFlyingTulipMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRipeMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMultiAccountTypeUserState, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, debtAheadOf, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, deriveSwapTags, detectInterfaceKinds, dexResolverFor, disambiguateEarnNames, disambiguateOrderBookNames, discoverFlexTroves, dolomiteVaultAddress, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnPositionFromLenderEntry, earnPositionFromVaultBalance, earnPositionTotals, earnRateAtMaturity, earnRowSubtitle, earnUidFromMarketUid, earnVaultTerms, earnVenueKind, emitterCoverage, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, enumerateEmitters, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchAaveIncentivesUserRewards, fetchAlchemixMarkets, fetchBorosAccount, fetchBorosCollaterals, fetchBorosMarket, fetchBorosMarketById, fetchBorosMarkets, fetchBorosOrderBook, fetchBorosRateHistory, fetchCoolerMarkets, fetchDolomiteAccountNumbers, fetchDolomiteSubAccounts, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFlexMarkets, fetchFluidDexState, fetchFluidFTokens, fetchFlyingTulipMarkets, fetchFlyingTulipUserRewards, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLenderRewards, fetchLenderRewardsByMarketUid, fetchLiquityMarkets, fetchListaMarketEmissions, fetchListaUserRewards, fetchListaVaultEmissions, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMerklUserRewards, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRipeMarkets, fetchRiverMarkets, fetchSiloVaults, fetchSpectraApiMarkets, fetchSpectraPtMarkets, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTermStoreOrders, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchUserRewards, fetchUsualRewardsClaimData, fetchYearnApiVaults, fetchYearnVaults, fillableRemaining, filterActiveLenders, filterLenderMeta, filterLendersByProtocol, finalizeInfo, findingsFor, flexAverageRate, flexLenderApr, flexLenderKey, flexMarketIndex, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fundingExposureOf, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedFluidDexState, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMidnightChainBooks, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getResolvedDolomiteSubAccounts, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasSpectraMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, injectLenderInfoIntoEntries, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isFixedYieldEarnRow, isIlliquid, isLenderVenueKey, isLendingPosition, isLiveMarket as isLivePendleMarket, isLiveSpectraMarket, isMaturedTerm, isOrderBookCollateralLeg, isOrderBookLendRow, isPrincipalTokenSymbol, isRollingBookLendRow, isSecondaryMarketOnly, isStablecoinSymbol, isSyntheticQuoteUnit, isUnearnableEarnRate, isUnrealizableEarnRate, isVaultPosition, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, lenderLiquidityPressure, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, listaEmissionRewardFetcher, listaLoginMessage, llamaLendKeyParts, llamaLendLenderKey, marketKeysOf, meetsLiquidityFloor, mergeDeep, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, organizeUserQueries, parseBalanceFetcherResult, parseDolomiteSubAccountId, parseEarnUid, parseLenderKey, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseCurveFee as parseSpectraCurveFee, parsePtRate as parseSpectraPtRate, parseTermMaxLtv, parseTokenBalanceResult, pct, pegPressure, assetKey as pendleAssetKey, pickPool as pickSpectraPool, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, protocolConsensus, protocolOf, pruneFeedStats, quoteBorosHedgeLeg, rankBorosHedgeMarkets, rankFindings, ratePercent, readUserPositions, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, repairImpossibleTvl, resolveAdapter, resolveDerivation, resolveDolomiteRowIdentity, resolveEarnIdentity, resolveMerklOpportunityMarkets, resolveModeConfig, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, sanePercent as saneSpectraPercent, savingsAddresses, savingsBalanceKind, secondaryMarketVault, selectAssetGroupPrices, selectUsualRewardEntry, setMysticApiKey, shortDate, spectraAddress, spectraNetwork, spectraPoolsUrl, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampEarnSubtitles, stampOrderBookLendRow, stampRollingBookLendRow, stampVaultClassification, stampVaultTermSheets, stripLeadingBrand, subAccountsOf, supplyDescription, supplyFindings, supplyHeadline, svmEarnBuildability, svmEarnBuilderKey, swapRoutedProvidersArePriceConsistent, swapSideDescription, swapSideHeadline, swapSideImplications, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termApiBaseUrl, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, termOfferRateToAprPct, termOrderStoreBaseUrl, tickToAprNumber, tickToPrice, toDigest, toDolomiteSubAccountId, toTermFillNow, toTermSheetInput, toVaultTermInput, trancheFromCounterparty, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultSharesToAssets, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand, venueBrandKey, walkBorosBook, withMaturityLabel, withTrancheLabel };
101236
+ export { ALCHEMIX_BLOCK_SECONDS, ApiBookSource, BOROS_API_BASE, BOROS_GOVERNANCE, BOROS_MIN_CASH_USD, BOROS_PROFILE_ID, BorosApiError, DEFAULT_CONSENSUS_DEMOTION, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, DEFAULT_TERM_ORDER_STORE, DOLOMITE_ISO_ID_PREFIX, EARN_DESCRIPTIONS, EARN_LABELS, EARN_RATE_SOURCE_BY_PROVIDER, EMPTY_BALANCE, EXACTLY_LENDER_KEY, EXPONENT_MATURED_REASON, FIXED_YIELD_EARN_VENUE_PREFIXES, FLYING_TULIP_LENDER_KEY, FRACTION_RATE_PROVIDERS, FUNDING_EXPOSURE_PROFILES, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, HYPERCORE_VAULT_REGISTRY, IDLE_MARKET_ID, INTERFACE_IDS, LAGOON_API_URL, LAGOON_CHAIN_IDS, MORPHO_LENS, MULTICALL_FAILURE, MaxParamThresholds, NON_EVM_VAULT_PROVIDERS, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL2 as PENDLE_MARKETS_URL, PREFIX_LENDERS, RATE_QUEUE_MAX_LEVELS, RATE_QUEUE_STEP, RIPE_LENDER_KEY, SDK_FRACTION_RATE_PROVIDERS, SPECTRA_NETWORKS, SPECTRA_RATE_MAX_PERCENT, SPECTRA_RATE_MIN_PERCENT, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, SVM_EARN_MINT_BUILDERS, SVM_EARN_VAULT_BUILDERS, SVM_VAULT_PROVIDERS, TELLER_CALLS_PER_BID, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_MARKETS_PER_CALL, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, USER_REWARD_SOURCES, USER_SET_RATE_PICKS, VAULT_PROVIDERS, VAULT_PROVIDER_PROFILE, VAULT_PROVIDER_TRAITS, VAULT_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VENUS_CORE_POOL_ID, VOLATILE_VAULT_OVERRIDES, VenusEModeAbi, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, alchemixLenderKey, alchemixMytRate, alchemixRedemptionPace, appendSnapshot, applyEarnSanity, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, blockNumberFromTag, borosApi, borosInitialMargin, borosMaintenanceMargin, borosRateMoveToLiquidation, borosSideTerms, borosTakerFee, borrowDescription, borrowFindings, borrowHeadline, buildBorosTermSheet, buildExposures2 as buildExposures, buildFluidFTokensCall, buildLendingPositionUid, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildQueriesFromMeta, buildRateQueue, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, clearSpectraMarketsCache, collateralSymbolsByVenue, collectFeedObservations, computeBorrowDelta2 as computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta2 as computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta2 as computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta2 as computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertAlchemixMarketsToResponse, convertBorosCandle, convertBorosMarket, convertCoolerMarketsToResponse, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFlexMarketsToResponse, convertFlyingTulipMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRipeMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMultiAccountTypeUserState, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, debtAheadOf, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, deriveSwapTags, detectInterfaceKinds, dexResolverFor, disambiguateEarnNames, disambiguateOrderBookNames, discoverFlexTroves, dolomiteVaultAddress, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnPositionFromLenderEntry, earnPositionFromVaultBalance, earnPositionTotals, earnRateAtMaturity, earnRowSubtitle, earnUidFromMarketUid, earnVaultTerms, earnVenueKind, emitterCoverage, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, enumerateEmitters, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchAaveIncentivesUserRewards, fetchAlchemixMarkets, fetchBorosAccount, fetchBorosCollaterals, fetchBorosMarket, fetchBorosMarketById, fetchBorosMarkets, fetchBorosOrderBook, fetchBorosRateHistory, fetchCoolerMarkets, fetchDolomiteAccountNumbers, fetchDolomiteSubAccounts, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFlexMarkets, fetchFluidDexState, fetchFluidFTokens, fetchFlyingTulipMarkets, fetchFlyingTulipUserRewards, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLenderRewards, fetchLenderRewardsByMarketUid, fetchLiquityMarkets, fetchListaMarketEmissions, fetchListaUserRewards, fetchListaVaultEmissions, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMerklUserRewards, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRipeMarkets, fetchRiverMarkets, fetchSiloVaults, fetchSpectraApiMarkets, fetchSpectraPtMarkets, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTermStoreOrders, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchUserRewards, fetchUsualRewardsClaimData, fetchYearnApiVaults, fetchYearnVaults, fillableRemaining, filterActiveLenders, filterLenderMeta, filterLendersByProtocol, finalizeInfo, findingsFor, flexAverageRate, flexLenderApr, flexLenderKey, flexMarketIndex, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fundingExposureOf, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedFluidDexState, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMidnightChainBooks, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getResolvedDolomiteSubAccounts, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, getVenusEModeSetup, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasSpectraMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, injectLenderInfoIntoEntries, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isFixedYieldEarnRow, isIlliquid, isLenderVenueKey, isLendingPosition, isLiveMarket as isLivePendleMarket, isLiveSpectraMarket, isMaturedTerm, isOrderBookCollateralLeg, isOrderBookLendRow, isPrincipalTokenSymbol, isRollingBookLendRow, isSecondaryMarketOnly, isStablecoinSymbol, isSyntheticQuoteUnit, isUnearnableEarnRate, isUnrealizableEarnRate, isVaultPosition, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, lenderLiquidityPressure, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, listaEmissionRewardFetcher, listaLoginMessage, llamaLendKeyParts, llamaLendLenderKey, marketKeysOf, meetsLiquidityFloor, mergeDeep, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, organizeUserQueries, parseBalanceFetcherResult, parseDolomiteSubAccountId, parseEarnUid, parseLenderKey, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseCurveFee as parseSpectraCurveFee, parsePtRate as parseSpectraPtRate, parseTermMaxLtv, parseTokenBalanceResult, pct, pegPressure, assetKey as pendleAssetKey, pickPool as pickSpectraPool, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, protocolConsensus, protocolOf, pruneFeedStats, quoteBorosHedgeLeg, rankBorosHedgeMarkets, rankFindings, ratePercent, readUserPositions, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, repairImpossibleTvl, resolveAdapter, resolveDerivation, resolveDolomiteRowIdentity, resolveEarnIdentity, resolveMerklOpportunityMarkets, resolveModeConfig, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, sanePercent as saneSpectraPercent, savingsAddresses, savingsBalanceKind, secondaryMarketVault, selectAssetGroupPrices, selectUsualRewardEntry, setMysticApiKey, shortDate, spectraAddress, spectraNetwork, spectraPoolsUrl, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampEarnSubtitles, stampOrderBookLendRow, stampRollingBookLendRow, stampVaultClassification, stampVaultTermSheets, stripLeadingBrand, subAccountsOf, supplyDescription, supplyFindings, supplyHeadline, svmEarnBuildability, svmEarnBuilderKey, swapRoutedProvidersArePriceConsistent, swapSideDescription, swapSideHeadline, swapSideImplications, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termApiBaseUrl, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, termOfferRateToAprPct, termOrderStoreBaseUrl, tickToAprNumber, tickToPrice, toDigest, toDolomiteSubAccountId, toTermFillNow, toTermSheetInput, toVaultTermInput, trancheFromCounterparty, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultSharesToAssets, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand, venueBrandKey, walkBorosBook, withMaturityLabel, withTrancheLabel };
100391
101237
  //# sourceMappingURL=index.js.map
100392
101238
  //# sourceMappingURL=index.js.map