@1delta/margin-fetcher 0.0.410 → 0.0.411

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
@@ -6,7 +6,7 @@ export { isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, is
6
6
  import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, usddLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, usddConfigFor, usddChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, aaveTokens, morphoTypeVaults, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, parseAaveV4SpokeLenderKey, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles } from '@1delta/data-sdk';
7
7
  import lodash from 'lodash';
8
8
  import { multicallRetryUniversal, getEvmClient, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
9
- import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, Erc20Abi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, InverseEscrowAbi, GearboxCreditAccountCompressorV310Abi, UsddCdpManagerAbi, UsddProxyRegistryAbi, TermPriceConsumerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
9
+ import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, Erc20Abi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, GearboxCreditAccountCompressorV310Abi, UsddCdpManagerAbi, UsddProxyRegistryAbi, TermPriceConsumerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
10
10
  export { MorphoLensAbi } from '@1delta/abis';
11
11
  import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, InitMarginAddresses, getLstAcceptedInputs } from '@1delta/calldata-sdk';
12
12
  import { proxyNativeFetch } from '@1delta/proxy-fetch';
@@ -22127,15 +22127,7 @@ function exactlyPairLtv(collateralAdjustFactor, borrowAdjustFactor) {
22127
22127
 
22128
22128
  // src/lending/public-data/exactly/convertPublic.ts
22129
22129
  var nowSec3 = () => Math.floor(Date.now() / 1e3);
22130
- function exactlyLenderKey(market) {
22131
- const body = market.startsWith("0x") ? market.slice(2) : market;
22132
- return "EXACTLY_" + body.toUpperCase();
22133
- }
22134
- function exactlyMarketFromLenderKey(lender) {
22135
- if (!lender.startsWith("EXACTLY_")) return void 0;
22136
- const body = lender.slice("EXACTLY_".length);
22137
- return body.length === 40 ? "0x" + body.toLowerCase() : void 0;
22138
- }
22130
+ var EXACTLY_LENDER_KEY = "EXACTLY";
22139
22131
  function toHuman(raw, decimals) {
22140
22132
  return Number(raw) / 10 ** decimals;
22141
22133
  }
@@ -22151,9 +22143,12 @@ function convertExactlyMarketsToResponse(raw, chainId, prices = {}, _additionalY
22151
22143
  const out = {};
22152
22144
  const now = nowSec3();
22153
22145
  const markets = raw?.markets ?? [];
22146
+ if (markets.length === 0) return out;
22154
22147
  const liqBonus = raw?.liquidationIncentive ? Number(raw.liquidationIncentive.liquidator) / 1e18 : 0;
22148
+ const lenderKey = EXACTLY_LENDER_KEY;
22149
+ const entry = { data: {} };
22150
+ const penaltyAprs = [];
22155
22151
  for (const m of markets) {
22156
- const lenderKey = exactlyLenderKey(m.market);
22157
22152
  const assetAddr = m.asset.toLowerCase();
22158
22153
  const decimals = m.decimals;
22159
22154
  const asset = tokens[assetAddr];
@@ -22185,9 +22180,10 @@ function convertExactlyMarketsToResponse(raw, chainId, prices = {}, _additionalY
22185
22180
  const totalDebt = toHuman(m.totalFloatingBorrowAssets, decimals) + fixedBorrowed;
22186
22181
  const borrowLiquidity = toHuman(m.floatingAvailableAssets, decimals);
22187
22182
  const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : 0;
22188
- const selfLtv = exactlyPairLtv(m.adjustFactor, m.adjustFactor);
22183
+ const adjustFactor = Number(m.adjustFactor) / 1e18;
22184
+ const borrowFactor = adjustFactor > 0 ? 1 / adjustFactor : 1;
22189
22185
  const penaltyApr = exactlyPenaltyRateToAprPercent(m.penaltyRate);
22190
- const entry = { data: {} };
22186
+ penaltyAprs.push(penaltyApr);
22191
22187
  const loanUid = createMarketUid(chainId, lenderKey, assetAddr);
22192
22188
  entry.data[loanUid] = {
22193
22189
  marketUid: loanUid,
@@ -22215,17 +22211,28 @@ function convertExactlyMarketsToResponse(raw, chainId, prices = {}, _additionalY
22215
22211
  variableBorrowRate: exactlyWadRateToPercent(m.floatingBorrowRate),
22216
22212
  rateModel: "fixedTerm",
22217
22213
  // Fixed-rate lender convention (Term/Lista): best fixed borrow APR on the
22218
- // stable slot; the full per-maturity menu is params.market.terms.
22214
+ // stable slot; the full per-maturity menu is this entry's `terms`.
22219
22215
  stableBorrowRate: bestFixedBorrowApr,
22216
+ // PER-ASSET fixed-term menu + descriptor. Cross-margin means one lender
22217
+ // key spans every asset, and each asset has its OWN fixed pools — so
22218
+ // these cannot live on `params.market` (which assumes one borrowable
22219
+ // asset per key, true for every isolated fixed-term lender but not here).
22220
+ terms: terms.length > 0 ? terms : void 0,
22221
+ fixedTerm: {
22222
+ model: "exactly",
22223
+ fees: { latePenaltyApr: penaltyApr },
22224
+ earlyRepay: { kind: "discount" },
22225
+ provider: { kind: "pool", address: m.market.toLowerCase() }
22226
+ },
22220
22227
  intrinsicYield: 0,
22221
22228
  rewards: void 0,
22222
22229
  decimals,
22223
22230
  config: {
22224
22231
  0: {
22225
22232
  category: 0,
22226
- borrowCollateralFactor: selfLtv,
22227
- collateralFactor: selfLtv,
22228
- borrowFactor: 1,
22233
+ borrowCollateralFactor: adjustFactor,
22234
+ collateralFactor: adjustFactor,
22235
+ borrowFactor,
22229
22236
  liquidationPenalty: liqBonus,
22230
22237
  closeFactor: 1,
22231
22238
  collateralDisabled: false,
@@ -22240,93 +22247,50 @@ function convertExactlyMarketsToResponse(raw, chainId, prices = {}, _additionalY
22240
22247
  // Exactly DOES have a variable (floating) borrow side.
22241
22248
  variableBorrowDisabled: false,
22242
22249
  isActive: true,
22243
- isFrozen: false
22244
- };
22245
- for (const c of markets) {
22246
- if (c.market.toLowerCase() === m.market.toLowerCase()) continue;
22247
- const collAddr = c.asset.toLowerCase();
22248
- const ltv = exactlyPairLtv(c.adjustFactor, m.adjustFactor);
22249
- const collUid = createMarketUid(chainId, lenderKey, collAddr);
22250
- entry.data[collUid] = {
22251
- marketUid: collUid,
22252
- name: "Collateral " + c.assetSymbol,
22253
- poolId: c.market.toLowerCase(),
22254
- underlying: collAddr,
22255
- asset: currencyFor3(collAddr, c.decimals, c.assetSymbol, tokens),
22256
- totalDeposits: 0,
22257
- totalDebtStable: 0,
22258
- totalDebt: 0,
22259
- totalLiquidity: 0,
22260
- borrowLiquidity: 0,
22261
- totalLiquidityUSD: 0,
22262
- borrowLiquidityUSD: 0,
22263
- totalDepositsUSD: 0,
22264
- totalDebtStableUSD: 0,
22265
- totalDebtUSD: 0,
22266
- utilization: 0,
22267
- depositRate: 0,
22268
- variableBorrowRate: 0,
22269
- stableBorrowRate: 0,
22270
- intrinsicYield: 0,
22271
- rewards: void 0,
22272
- decimals: c.decimals,
22273
- config: {
22274
- 0: {
22275
- category: 0,
22276
- borrowCollateralFactor: ltv,
22277
- collateralFactor: ltv,
22278
- borrowFactor: 1,
22279
- liquidationPenalty: liqBonus,
22280
- closeFactor: 1,
22281
- collateralDisabled: false,
22282
- debtDisabled: true
22283
- }
22284
- },
22285
- closeFactor: 1,
22286
- collateralActive: true,
22287
- borrowingEnabled: false,
22288
- depositsEnabled: true,
22289
- hasStable: false,
22290
- isActive: true,
22291
- isFrozen: false
22292
- };
22293
- }
22294
- entry.params = {
22295
- market: {
22296
- lender: lenderKey,
22297
- name: "Exactly " + m.assetSymbol,
22298
- loanDecimals: decimals,
22299
- collateralDecimals: decimals,
22300
- // Market address doubles as the market id (it IS the lender-key body).
22301
- id: m.market.toLowerCase(),
22302
- // Self-pair adjust factor (WAD string); pairwise LTVs live on the
22303
- // per-collateral entries above.
22304
- lltv: m.adjustFactor.toString(),
22305
- oracle: zeroAddress,
22306
- irm: zeroAddress,
22307
- collateralAddress: assetAddr,
22308
- loanAddress: assetAddr,
22309
- terms: terms.length > 0 ? terms : void 0,
22310
- // Canonical cross-protocol fixed-term descriptor. Exactly: MENU of
22311
- // calendar maturities (terms[], termId = maturity), pool-fronted
22312
- // utilization-curve rates, early repay = DISCOUNT (unassigned-earnings
22313
- // rebate via previewRepayAtMaturity), late repay = per-second penalty.
22314
- fixedTerm: {
22315
- model: "exactly",
22316
- fees: { latePenaltyApr: penaltyApr },
22317
- earlyRepay: { kind: "discount" },
22318
- provider: { kind: "pool", address: m.market.toLowerCase() }
22319
- },
22320
- // Exactly-specific extras (consumed by calldata / worker-api resolvers)
22250
+ isFrozen: false,
22251
+ // Per-asset Exactly extras. `poolId` above already carries the Market
22252
+ // address (the write target resolve it from the ASSET now, via
22253
+ // `exactlyMarketByAsset`, never from the lender key).
22254
+ exactly: {
22255
+ market: m.market.toLowerCase(),
22321
22256
  penaltyRate: m.penaltyRate.toString(),
22322
22257
  adjustFactor: m.adjustFactor.toString(),
22323
22258
  maxFuturePools: m.maxFuturePools,
22324
22259
  usdPrice: m.usdPrice.toString()
22325
22260
  }
22326
22261
  };
22327
- entry.chainId = chainId;
22328
- out[lenderKey] = entry;
22329
22262
  }
22263
+ const uniformPenaltyApr = penaltyAprs.length > 0 && penaltyAprs.every((p) => p === penaltyAprs[0]) ? penaltyAprs[0] : void 0;
22264
+ entry.params = {
22265
+ market: {
22266
+ lender: lenderKey,
22267
+ name: "Exactly",
22268
+ // The per-chain Auditor — the shared cross-margin risk module every
22269
+ // Market reports to (Compound V2's Comptroller seam).
22270
+ id: (exactlyConfig()?.[chainId]?.auditor ?? zeroAddress).toLowerCase(),
22271
+ // No market-level LLTV: risk is per-asset (collateralFactor/borrowFactor
22272
+ // on each entry) and effective pair LTV is their product.
22273
+ lltv: "0",
22274
+ oracle: zeroAddress,
22275
+ irm: zeroAddress,
22276
+ collateralAddress: zeroAddress,
22277
+ loanAddress: zeroAddress,
22278
+ // `terms` is deliberately ABSENT at market level — each asset has its own
22279
+ // fixed pools, so the menu is on `data[*].terms`. A market-level
22280
+ // descriptor is still emitted so consumers that only probe
22281
+ // `params.market.fixedTerm` still recognise Exactly as fixed-term; its
22282
+ // `provider.address` is omitted (no single Market) and the late-penalty
22283
+ // rate is carried only when every asset agrees (it does today).
22284
+ fixedTerm: {
22285
+ model: "exactly",
22286
+ fees: uniformPenaltyApr !== void 0 ? { latePenaltyApr: uniformPenaltyApr } : {},
22287
+ earlyRepay: { kind: "discount" },
22288
+ provider: { kind: "pool" }
22289
+ }
22290
+ }
22291
+ };
22292
+ entry.chainId = chainId;
22293
+ out[lenderKey] = entry;
22330
22294
  return out;
22331
22295
  }
22332
22296
  var READS_PER_BRANCH = 8;
@@ -29417,7 +29381,7 @@ function toDetail(positions, kind, now, penaltyRate, penaltyApr) {
29417
29381
  };
29418
29382
  });
29419
29383
  }
29420
- var getExactlyUserDataConverter = (_lender, chainId, account, meta, requestedLenders) => {
29384
+ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
29421
29385
  const expected = exactlyConfig()?.[chainId]?.previewer ? 1 : 0;
29422
29386
  return [
29423
29387
  (data) => {
@@ -29426,69 +29390,32 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta, requestedLen
29426
29390
  if (!res || res === "0x" || !Array.isArray(res)) return void 0;
29427
29391
  const markets = res;
29428
29392
  const now = nowSec6();
29429
- const enteredCollateral = markets.filter(
29430
- (c) => c.isCollateral && c.floatingDepositAssets + sumPreview(c.fixedDepositPositions) > 0n
29431
- );
29432
- const collateralRow = (c, lenderKey, metaMap) => {
29433
- const cDeposit = c.floatingDepositAssets + sumPreview(c.fixedDepositPositions);
29434
- const collAddr = c.asset.toLowerCase();
29435
- const collUid = createMarketUid(chainId, lenderKey, collAddr);
29436
- const collMeta = metaMap[collUid];
29437
- const collDec = collMeta?.asset?.decimals ?? c.decimals;
29438
- const collDisplayPrice = collMeta ? getDisplayPrice(collMeta) : 0;
29439
- const collOraclePrice = collMeta ? getOraclePrice(collMeta) : 0;
29440
- const collPriceHist = collMeta?.price?.priceUsd24h ?? collDisplayPrice;
29441
- const collStr = parseRawAmount(cDeposit.toString(), collDec);
29442
- const collNum = Number(collStr);
29443
- return {
29444
- uid: collUid,
29445
- usd24h: collNum * collPriceHist,
29446
- row: {
29447
- marketUid: collUid,
29448
- underlying: collAddr,
29449
- deposits: collStr,
29450
- debt: "0",
29451
- debtStable: "0",
29452
- depositsUSD: collNum * collDisplayPrice,
29453
- debtUSD: 0,
29454
- debtStableUSD: 0,
29455
- depositsUSDOracle: collNum * collOraclePrice,
29456
- debtUSDOracle: 0,
29457
- debtStableUSDOracle: 0,
29458
- stableBorrowRate: "0",
29459
- collateralEnabled: true,
29460
- claimableRewards: 0,
29461
- // The SAME deposit reports as the own-asset row under its own
29462
- // market key — cross-key aggregation must skip flagged rows.
29463
- crossCollateral: true
29464
- }
29465
- };
29466
- };
29467
- const out = {};
29393
+ const lenderKey = EXACTLY_LENDER_KEY;
29394
+ const metaMap = meta?.[lenderKey];
29395
+ if (!metaMap) return void 0;
29396
+ const posData = {};
29397
+ let depositsUSD24h = 0;
29398
+ let debtUSD24h = 0;
29468
29399
  for (const m of markets) {
29469
- const lenderKey = exactlyLenderKey(m.market);
29470
- const metaMap = meta?.[lenderKey];
29471
- if (!metaMap) continue;
29472
29400
  const assetAddr = m.asset.toLowerCase();
29473
29401
  const loanUid = createMarketUid(chainId, lenderKey, assetAddr);
29474
29402
  const loanMeta = metaMap[loanUid];
29475
29403
  const decimals = loanMeta?.asset?.decimals ?? m.decimals;
29476
- const loanDisplayPrice = loanMeta ? getDisplayPrice(loanMeta) : 0;
29477
- const loanOraclePrice = loanMeta ? getOraclePrice(loanMeta) : 0;
29478
- const loanPriceHist = loanMeta?.price?.priceUsd24h ?? loanDisplayPrice;
29404
+ const displayPrice = loanMeta ? getDisplayPrice(loanMeta) : 0;
29405
+ const oraclePrice = loanMeta ? getOraclePrice(loanMeta) : 0;
29406
+ const priceHist = loanMeta?.price?.priceUsd24h ?? displayPrice;
29479
29407
  const fixedDebtUnits = sumPreview(m.fixedBorrowPositions);
29480
29408
  const depositUnits = m.floatingDepositAssets + sumPreview(m.fixedDepositPositions);
29481
29409
  const debtUnits = m.floatingBorrowAssets + fixedDebtUnits;
29482
29410
  if (depositUnits === 0n && debtUnits === 0n) continue;
29483
29411
  const depositsStr = parseRawAmount(depositUnits.toString(), decimals);
29484
29412
  const depositsNum = Number(depositsStr);
29485
- const debtStr = parseRawAmount(debtUnits.toString(), decimals);
29486
- const debtNum = Number(debtStr);
29487
29413
  const floatingDebtStr = parseRawAmount(
29488
29414
  m.floatingBorrowAssets.toString(),
29489
29415
  decimals
29490
29416
  );
29491
29417
  const fixedDebtStr = parseRawAmount(fixedDebtUnits.toString(), decimals);
29418
+ const debtNum = Number(floatingDebtStr) + Number(fixedDebtStr);
29492
29419
  const penaltyApr = exactlyPenaltyRateToAprPercent(m.penaltyRate);
29493
29420
  const fixedPositions = [
29494
29421
  ...toDetail(
@@ -29506,21 +29433,23 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta, requestedLen
29506
29433
  penaltyApr
29507
29434
  )
29508
29435
  ];
29509
- const posData = {};
29510
- let depositsUSD24h = depositsNum * loanPriceHist;
29436
+ depositsUSD24h += depositsNum * priceHist;
29437
+ debtUSD24h += debtNum * priceHist;
29511
29438
  posData[loanUid] = {
29512
29439
  marketUid: loanUid,
29513
29440
  underlying: assetAddr,
29514
29441
  deposits: depositsStr,
29515
29442
  debt: floatingDebtStr,
29516
29443
  debtStable: fixedDebtStr,
29517
- depositsUSD: depositsNum * loanDisplayPrice,
29518
- debtUSD: Number(floatingDebtStr) * loanDisplayPrice,
29519
- debtStableUSD: Number(fixedDebtStr) * loanDisplayPrice,
29520
- depositsUSDOracle: depositsNum * loanOraclePrice,
29521
- debtUSDOracle: Number(floatingDebtStr) * loanOraclePrice,
29522
- debtStableUSDOracle: Number(fixedDebtStr) * loanOraclePrice,
29444
+ depositsUSD: depositsNum * displayPrice,
29445
+ debtUSD: Number(floatingDebtStr) * displayPrice,
29446
+ debtStableUSD: Number(fixedDebtStr) * displayPrice,
29447
+ depositsUSDOracle: depositsNum * oraclePrice,
29448
+ debtUSDOracle: Number(floatingDebtStr) * oraclePrice,
29449
+ debtStableUSDOracle: Number(fixedDebtStr) * oraclePrice,
29523
29450
  stableBorrowRate: "0",
29451
+ // The Auditor's per-asset `enterMarket` flag: only entered deposits
29452
+ // back debt. A deposit with this false is inert collateral-wise.
29524
29453
  collateralEnabled: m.isCollateral,
29525
29454
  claimableRewards: 0,
29526
29455
  // Per-maturity fixed-position detail (survives to the output — the
@@ -29544,10 +29473,10 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta, requestedLen
29544
29473
  debtStable: trancheStr,
29545
29474
  depositsUSD: 0,
29546
29475
  debtUSD: 0,
29547
- debtStableUSD: Number(trancheStr) * loanDisplayPrice,
29476
+ debtStableUSD: Number(trancheStr) * displayPrice,
29548
29477
  depositsUSDOracle: 0,
29549
29478
  debtUSDOracle: 0,
29550
- debtStableUSDOracle: Number(trancheStr) * loanOraclePrice,
29479
+ debtStableUSDOracle: Number(trancheStr) * oraclePrice,
29551
29480
  collateralEnabled: false,
29552
29481
  claimableRewards: 0,
29553
29482
  term: {
@@ -29578,59 +29507,25 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta, requestedLen
29578
29507
  }
29579
29508
  };
29580
29509
  }
29581
- for (const c of enteredCollateral) {
29582
- if (c.market.toLowerCase() === m.market.toLowerCase()) continue;
29583
- const { uid, usd24h, row } = collateralRow(c, lenderKey, metaMap);
29584
- posData[uid] = row;
29585
- depositsUSD24h += usd24h;
29586
- }
29587
- const userData = createMultiAccountTypeUserState(
29588
- {
29589
- chainId,
29590
- account,
29591
- lendingPositions: { "0": posData },
29592
- modes: { "0": 0 }
29593
- },
29594
- metaMap,
29595
- {
29596
- "0": {
29597
- totalDeposits24h: depositsUSD24h,
29598
- totalDebt24h: debtNum * loanPriceHist
29599
- }
29600
- }
29601
- );
29602
- if (userData && userData.data.length > 0) out[lenderKey] = userData;
29603
29510
  }
29604
- if (enteredCollateral.length > 0 && requestedLenders?.length) {
29605
- for (const req of new Set(
29606
- requestedLenders.map((l) => l?.toUpperCase())
29607
- )) {
29608
- if (!req?.startsWith("EXACTLY_") || out[req]) continue;
29609
- const metaMap = meta?.[req];
29610
- if (!metaMap) continue;
29611
- const posData = {};
29612
- let depositsUSD24h = 0;
29613
- for (const c of enteredCollateral) {
29614
- if (exactlyLenderKey(c.market) === req) continue;
29615
- const { uid, usd24h, row } = collateralRow(c, req, metaMap);
29616
- posData[uid] = row;
29617
- depositsUSD24h += usd24h;
29511
+ if (Object.keys(posData).length === 0) return void 0;
29512
+ const userData = createMultiAccountTypeUserState(
29513
+ {
29514
+ chainId,
29515
+ account,
29516
+ lendingPositions: { "0": posData },
29517
+ modes: { "0": 0 }
29518
+ },
29519
+ metaMap,
29520
+ {
29521
+ "0": {
29522
+ totalDeposits24h: depositsUSD24h,
29523
+ totalDebt24h: debtUSD24h
29618
29524
  }
29619
- if (Object.keys(posData).length === 0) continue;
29620
- const userData = createMultiAccountTypeUserState(
29621
- {
29622
- chainId,
29623
- account,
29624
- lendingPositions: { "0": posData },
29625
- modes: { "0": 0 }
29626
- },
29627
- metaMap,
29628
- { "0": { totalDeposits24h: depositsUSD24h, totalDebt24h: 0 } }
29629
- );
29630
- if (userData && userData.data.length > 0) out[req] = userData;
29631
29525
  }
29632
- }
29633
- return Object.keys(out).length > 0 ? out : void 0;
29526
+ );
29527
+ if (!userData || userData.data.length === 0) return void 0;
29528
+ return { [lenderKey]: userData };
29634
29529
  },
29635
29530
  expected
29636
29531
  ];
@@ -30561,7 +30456,7 @@ function getUserDataConverter(lender, chainId, account, params, meta) {
30561
30456
  if (isTerm(lender))
30562
30457
  return getTermUserDataConverter(lender, chainId, account, meta);
30563
30458
  if (isExactly(lender))
30564
- return getExactlyUserDataConverter(lender, chainId, account, meta, params);
30459
+ return getExactlyUserDataConverter(lender, chainId, account, meta);
30565
30460
  if (isLiquityFamily(lender))
30566
30461
  return getLiquityUserDataConverter(lender, chainId, account, meta);
30567
30462
  if (isRiver(lender))
@@ -35171,6 +35066,7 @@ var getAbi2 = (lender) => {
35171
35066
  return [...RiverTroveManagerAbi, ...RiverStabilityPoolAbi];
35172
35067
  if (isTeller(lender))
35173
35068
  return [...TellerV2Abi, ...TellerCollateralManagerAbi];
35069
+ if (isTermMax(lender)) return [...TermMaxViewerAbi];
35174
35070
  if (isInverse(lender))
35175
35071
  return [...InverseMarketAbi, ...InverseEscrowAbi, ...InverseDbrAbi];
35176
35072
  if (isUsdd(lender)) return [...UsddVatAbi];
@@ -44608,14 +44504,15 @@ function parseExactlyResults(data, _meta, context) {
44608
44504
  if (tracked.size > 0 && !tracked.has(market.toLowerCase())) continue;
44609
44505
  const priceUSD = Number(usdPrice) / 1e18;
44610
44506
  if (!(priceUSD > 0)) continue;
44611
- const lenderKey = exactlyLenderKey(market);
44612
44507
  entries.push({
44613
44508
  asset,
44614
44509
  // Direct USD price — no oracle-unit denomination, so raw == USD.
44615
44510
  price: priceUSD,
44616
44511
  priceUSD,
44617
- marketUid: createMarketUid(chainId, lenderKey, asset),
44618
- targetLender: lenderKey,
44512
+ // ONE Exactly key per chain (cross-margin); the asset segment of the
44513
+ // marketUid is what distinguishes the per-asset rows.
44514
+ marketUid: createMarketUid(chainId, EXACTLY_LENDER_KEY, asset),
44515
+ targetLender: EXACTLY_LENDER_KEY,
44619
44516
  description: "Exactly market oracle (USD)"
44620
44517
  });
44621
44518
  }
@@ -59563,6 +59460,6 @@ async function fetchTokenBalances(chainId, account, tokens, options = {}) {
59563
59460
  return parseTokenBalanceResult(rawResult, prepared.query);
59564
59461
  }
59565
59462
 
59566
- export { ApiBookSource, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, EMPTY_BALANCE, 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, MaxParamThresholds, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, TELLER_CALLS_PER_BID, TERMMAX_CALLS_PER_ACCOUNT, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, VAULT_SHARE_PRICE_PROBE, VOLATILE_VAULT_OVERRIDES, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyPositionDelta, attachPricesToFlashLiquidity, buildFluidFTokensCall, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, 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, convertExactlyMarketsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, detectInterfaceKinds, encodeBalanceFetcherCalldata, exactlyLenderKey, exactlyMarketFromLenderKey, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendlePrices, fetchRiverMarkets, fetchSiloVaults, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, 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, getMorphoTypeMarketConverter, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getVaultPublicDataAll, getVaultWithdrawalRequests, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasUpshiftVaults, hasYearnVaults, inverseKeyParts, inverseLenderKey, isStablecoinSymbol, isYearnV3, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseMergedResult, parseMulticallRpcResponses, parseRawRpcBatchResponses, parseRawRpcResponses, parseTermMaxLtv, parseTokenBalanceResult, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveDerivation, resolveStCeloDepositGroup, riverKeyParts, riverLenderKey, selectAssetGroupPrices, stampVaultClassification, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, 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, tickToAprNumber, tickToPrice, unflattenLenderData, updateFeedStats, usddIlkBytes32, usddKeyParts, usddLenderKey };
59463
+ export { ApiBookSource, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, EMPTY_BALANCE, EXACTLY_LENDER_KEY, 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, MaxParamThresholds, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, TELLER_CALLS_PER_BID, TERMMAX_CALLS_PER_ACCOUNT, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TermMaxApiSource, TermSubgraphSource, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, VAULT_SHARE_PRICE_PROBE, VOLATILE_VAULT_OVERRIDES, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyPositionDelta, attachPricesToFlashLiquidity, buildFluidFTokensCall, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, 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, convertExactlyMarketsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, detectInterfaceKinds, encodeBalanceFetcherCalldata, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendlePrices, fetchRiverMarkets, fetchSiloVaults, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, 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, getMorphoTypeMarketConverter, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getVaultPublicDataAll, getVaultWithdrawalRequests, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasUpshiftVaults, hasYearnVaults, inverseKeyParts, inverseLenderKey, isStablecoinSymbol, isYearnV3, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, multicall3Abi2 as multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseMergedResult, parseMulticallRpcResponses, parseRawRpcBatchResponses, parseRawRpcResponses, parseTermMaxLtv, parseTokenBalanceResult, positivePart2 as positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveDerivation, resolveStCeloDepositGroup, riverKeyParts, riverLenderKey, selectAssetGroupPrices, stampVaultClassification, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, 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, tickToAprNumber, tickToPrice, unflattenLenderData, updateFeedStats, usddIlkBytes32, usddKeyParts, usddLenderKey };
59567
59464
  //# sourceMappingURL=index.js.map
59568
59465
  //# sourceMappingURL=index.js.map