@1delta/margin-fetcher 0.0.332 → 0.0.334

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.
Files changed (46) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +810 -57
  4. package/dist/index.js.map +1 -1
  5. package/dist/lending/public-data/exactly/convertPublic.d.ts.map +1 -1
  6. package/dist/lending/public-data/fetchLenderAll.d.ts.map +1 -1
  7. package/dist/lending/public-data/fetchLenderExt.d.ts.map +1 -1
  8. package/dist/lending/public-data/liquity/convertPublic.d.ts.map +1 -1
  9. package/dist/lending/public-data/midnight/convertPublic.d.ts.map +1 -1
  10. package/dist/lending/public-data/river/convertPublic.d.ts.map +1 -1
  11. package/dist/lending/public-data/river/fetchPublic.d.ts.map +1 -1
  12. package/dist/lending/public-data/river/types.d.ts +2 -0
  13. package/dist/lending/public-data/river/types.d.ts.map +1 -1
  14. package/dist/lending/public-data/teller/convertPublic.d.ts +32 -0
  15. package/dist/lending/public-data/teller/convertPublic.d.ts.map +1 -0
  16. package/dist/lending/public-data/teller/fetchPublic.d.ts +16 -0
  17. package/dist/lending/public-data/teller/fetchPublic.d.ts.map +1 -0
  18. package/dist/lending/public-data/teller/index.d.ts +5 -0
  19. package/dist/lending/public-data/teller/index.d.ts.map +1 -0
  20. package/dist/lending/public-data/teller/math.d.ts +18 -0
  21. package/dist/lending/public-data/teller/math.d.ts.map +1 -0
  22. package/dist/lending/public-data/teller/types.d.ts +33 -0
  23. package/dist/lending/public-data/teller/types.d.ts.map +1 -0
  24. package/dist/lending/public-data/term/convertPublic.d.ts.map +1 -1
  25. package/dist/lending/user-data/abis.d.ts.map +1 -1
  26. package/dist/lending/user-data/fetch-balances/parse.d.ts.map +1 -1
  27. package/dist/lending/user-data/fetch-balances/prepare.d.ts.map +1 -1
  28. package/dist/lending/user-data/teller/index.d.ts +3 -0
  29. package/dist/lending/user-data/teller/index.d.ts.map +1 -0
  30. package/dist/lending/user-data/teller/userCallBuild.d.ts +31 -0
  31. package/dist/lending/user-data/teller/userCallBuild.d.ts.map +1 -0
  32. package/dist/lending/user-data/teller/userCallParse.d.ts +22 -0
  33. package/dist/lending/user-data/teller/userCallParse.d.ts.map +1 -0
  34. package/dist/prices/oracle-prices/fetchOraclePrices.d.ts +2 -2
  35. package/dist/prices/oracle-prices/fetchOraclePrices.d.ts.map +1 -1
  36. package/dist/prices/oracle-prices/fetchers/index.d.ts +1 -0
  37. package/dist/prices/oracle-prices/fetchers/index.d.ts.map +1 -1
  38. package/dist/prices/oracle-prices/fetchers/teller.d.ts +413 -0
  39. package/dist/prices/oracle-prices/fetchers/teller.d.ts.map +1 -0
  40. package/dist/types/lender/morpho-types.d.ts +21 -0
  41. package/dist/types/lender/morpho-types.d.ts.map +1 -1
  42. package/dist/types/lenderTypes.d.ts +1 -1
  43. package/dist/types/lenderTypes.d.ts.map +1 -1
  44. package/dist/utils/index.d.ts +1 -1
  45. package/dist/utils/index.d.ts.map +1 -1
  46. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, encodeFunctionData, formatUnits, isAddress, getAddress, decodeFunctionResult, decodeAbiParameters, AbiEncodingLengthMismatchError, concatHex, pad, InvalidAddressError, stringToHex, boolToHex, integerRegex, numberToHex, bytesRegex, BytesSizeMismatchError, arrayRegex, UnsupportedPackedAbiType } from './chunk-Z3MGRQJR.js';
2
2
  import './chunk-BYTNVMX7.js';
3
3
  import './chunk-PR4QN5HX.js';
4
- import { Lender, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isFluid, isGearboxV3, isMidnight, isTerm, isExactly, isLiquityFamily, isRiver, isYLDR, isCompoundV3Type, isLista, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
4
+ import { Lender, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isEulerType, isAaveV4Type, isInit, isMorphoType, isCompoundV2Type, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isAaveV2Type, isAaveV32Type, isAaveV3Type, isFluid, isGearboxV3, isMidnight, isTerm, isExactly, isLiquityFamily, isRiver, isTeller, isYLDR, isCompoundV3Type, isLista, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
5
5
  export { isAaveType, isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isCompoundV3Type, isInit, isMorphoType, isMultiMarket, isYLDR } from '@1delta/lender-registry';
6
- import { fetchTokenLists, fetchTokenList, aavePools, compoundV3Pools, initConfig, morphoPools, compoundV2Pools, eulerVaults, siloMarkets, siloV2LenderKey, siloMarketsV3, siloV3LenderKey, aaveV4Spokes, aaveV4SpokeLenderKey, fluidResolvers, gearboxResolvers, dolomiteConfigs, midnightConfig, termConfig, termMarketsByChain, exactlyConfig, liquityLendersByChain, riverLendersByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, aaveTokens, morphoTypeVaults, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, parseAaveV4SpokeLenderKey, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOracles, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles } from '@1delta/data-sdk';
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, tellerConfigByChain, tellerPoolsByChain, aaveReserves, compoundV3Reserves, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, morphoTypeMarkets, resolveMidnightApiBase, resolveTermApiBase, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, aaveTokens, morphoTypeVaults, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, gearboxV3LenderKey, midnightMarketsByChain, parseAaveV4SpokeLenderKey, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOracles, aaveOraclesConfig, compoundV2Oracles, compoundV2TokenArray, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles } from '@1delta/data-sdk';
7
7
  import lodash from 'lodash';
8
8
  import { getEvmClient, multicallRetryUniversal, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
9
- import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, GearboxCreditAccountCompressorV310Abi, TermPriceConsumerAbi } from '@1delta/abis';
9
+ import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, MetaMorphoAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, LenderCommitmentGroupAbi, TellerMarketRegistryAbi, TellerV2Abi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, GearboxCreditAccountCompressorV310Abi, TermPriceConsumerAbi } 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';
@@ -7516,6 +7516,9 @@ var getLendersForChain = (c) => {
7516
7516
  for (const l of riverLendersByChain(c)) {
7517
7517
  lenders.push(l);
7518
7518
  }
7519
+ if (tellerConfigByChain(c)?.tellerV2 && tellerPoolsByChain(c).length > 0) {
7520
+ lenders.push(Lender.TELLER);
7521
+ }
7519
7522
  return lenders.filter((l) => !isExcludedLender(l));
7520
7523
  };
7521
7524
  var filterLendersByProtocol = (allLenders, protocolList) => {
@@ -7531,7 +7534,7 @@ var filterLendersByProtocol = (allLenders, protocolList) => {
7531
7534
  (b) => protocolList.includes(b)
7532
7535
  );
7533
7536
  return allLenders.filter(
7534
- (lender) => protocolList.includes(lender) || hasMorpho && lender?.startsWith("MORPHO_BLUE") || hasMoolah && lender?.startsWith("LISTA_DAO") || hasFluid && lender?.startsWith("FLUID") || hasGearboxV3 && lender?.startsWith("GEARBOX_V3") || hasDolomite && lender?.startsWith("DOLOMITE") || liquityBases.some((b) => lender?.startsWith(b)) || protocolList.includes(Lender.RIVER) && lender?.startsWith("RIVER")
7537
+ (lender) => protocolList.includes(lender) || hasMorpho && lender?.startsWith("MORPHO_BLUE") || hasMoolah && lender?.startsWith("LISTA_DAO") || hasFluid && lender?.startsWith("FLUID") || hasGearboxV3 && lender?.startsWith("GEARBOX_V3") || hasDolomite && lender?.startsWith("DOLOMITE") || liquityBases.some((b) => lender?.startsWith(b)) || protocolList.includes(Lender.RIVER) && lender?.startsWith("RIVER") || protocolList.includes(Lender.TELLER) && lender?.startsWith("TELLER")
7535
7538
  );
7536
7539
  };
7537
7540
  var getAavesForChain = () => {
@@ -11165,8 +11168,8 @@ async function fetchListaBrokerUserData(chainId, account, marketKeys, nowSecs =
11165
11168
  const brokers = await resolveListaBrokers(chainId, marketKeys, getClient);
11166
11169
  const ids = Object.keys(brokers);
11167
11170
  const out = {};
11168
- const cacheKey3 = `${chainId}:${account.toLowerCase()}`;
11169
- BROKER_USER_CACHE[cacheKey3] = out;
11171
+ const cacheKey4 = `${chainId}:${account.toLowerCase()}`;
11172
+ BROKER_USER_CACHE[cacheKey4] = out;
11170
11173
  if (ids.length === 0) return out;
11171
11174
  try {
11172
11175
  const client = getClient(chainId);
@@ -21049,7 +21052,7 @@ function createMidnightBookSource(chainId, fetchImpl = fetch) {
21049
21052
  var MIDNIGHT_BOOK_LEVELS = 20;
21050
21053
  var LKG_TTL_SEC = 30 * 60;
21051
21054
  var lastGood = /* @__PURE__ */ new Map();
21052
- async function fetchTopAndBookWithFallback(source, chainId, marketId, nowSec5) {
21055
+ async function fetchTopAndBookWithFallback(source, chainId, marketId, nowSec7) {
21053
21056
  const key = `${chainId}:${marketId}`;
21054
21057
  let fresh = null;
21055
21058
  if (source.getTopAndBook) {
@@ -21059,11 +21062,11 @@ async function fetchTopAndBookWithFallback(source, chainId, marketId, nowSec5) {
21059
21062
  if (top) fresh = { top, book: { bids: [], asks: [] } };
21060
21063
  }
21061
21064
  if (fresh) {
21062
- lastGood.set(key, { top: fresh.top, book: fresh.book, at: nowSec5 });
21065
+ lastGood.set(key, { top: fresh.top, book: fresh.book, at: nowSec7 });
21063
21066
  return { top: fresh.top, book: fresh.book };
21064
21067
  }
21065
21068
  const cached = lastGood.get(key);
21066
- if (cached && nowSec5 - cached.at <= LKG_TTL_SEC) {
21069
+ if (cached && nowSec7 - cached.at <= LKG_TTL_SEC) {
21067
21070
  return { top: cached.top, book: cached.book };
21068
21071
  }
21069
21072
  return { top: null, book: null };
@@ -21071,17 +21074,17 @@ async function fetchTopAndBookWithFallback(source, chainId, marketId, nowSec5) {
21071
21074
  async function fetchMidnightMarkets(chainId, source = createMidnightBookSource(chainId)) {
21072
21075
  const markets = midnightMarketsByChain(chainId);
21073
21076
  if (markets.length === 0) return [];
21074
- const nowSec5 = Math.floor(Date.now() / 1e3);
21077
+ const nowSec7 = Math.floor(Date.now() / 1e3);
21075
21078
  return Promise.all(
21076
21079
  markets.map(async (config) => {
21077
- if (Number(config.maturity) <= nowSec5) {
21080
+ if (Number(config.maturity) <= nowSec7) {
21078
21081
  return { config, top: null, book: null };
21079
21082
  }
21080
21083
  const { top, book } = await fetchTopAndBookWithFallback(
21081
21084
  source,
21082
21085
  chainId,
21083
21086
  config.marketId,
21084
- nowSec5
21087
+ nowSec7
21085
21088
  );
21086
21089
  return { config, top, book };
21087
21090
  })
@@ -21260,6 +21263,7 @@ function convertMidnightMarketsToResponse(raw, chainId, prices = {}, _additional
21260
21263
  utilization: 0,
21261
21264
  depositRate: supplyAprPct,
21262
21265
  variableBorrowRate: borrowAprPct,
21266
+ rateModel: "fixedTerm",
21263
21267
  // Midnight is fixed-rate: expose the fixed borrow APR on stableBorrowRate
21264
21268
  // too, so fixed-rate consumers pick it up like a term product.
21265
21269
  stableBorrowRate: borrowAprPct,
@@ -21617,7 +21621,7 @@ function createTermBookSource(chainId, fetchImpl = fetch) {
21617
21621
  var TERM_BOOK_LEVELS = 20;
21618
21622
  var LKG_TTL_SEC2 = 30 * 60;
21619
21623
  var lastGood2 = /* @__PURE__ */ new Map();
21620
- async function fetchTopAndBookWithFallback2(source, chainId, config, nowSec5) {
21624
+ async function fetchTopAndBookWithFallback2(source, chainId, config, nowSec7) {
21621
21625
  const key = `${chainId}:${config.termRepoId}`;
21622
21626
  let fresh = null;
21623
21627
  if (source.getTopAndBook) {
@@ -21627,11 +21631,11 @@ async function fetchTopAndBookWithFallback2(source, chainId, config, nowSec5) {
21627
21631
  if (top) fresh = { top, book: { bids: [], asks: [] } };
21628
21632
  }
21629
21633
  if (fresh) {
21630
- lastGood2.set(key, { top: fresh.top, book: fresh.book, at: nowSec5 });
21634
+ lastGood2.set(key, { top: fresh.top, book: fresh.book, at: nowSec7 });
21631
21635
  return { top: fresh.top, book: fresh.book };
21632
21636
  }
21633
21637
  const cached = lastGood2.get(key);
21634
- if (cached && nowSec5 - cached.at <= LKG_TTL_SEC2) {
21638
+ if (cached && nowSec7 - cached.at <= LKG_TTL_SEC2) {
21635
21639
  return { top: cached.top, book: cached.book };
21636
21640
  }
21637
21641
  return { top: null, book: null };
@@ -21639,17 +21643,17 @@ async function fetchTopAndBookWithFallback2(source, chainId, config, nowSec5) {
21639
21643
  async function fetchTermMarkets(chainId, source = createTermBookSource(chainId)) {
21640
21644
  const markets = termMarketsByChain(chainId);
21641
21645
  if (markets.length === 0) return [];
21642
- const nowSec5 = Math.floor(Date.now() / 1e3);
21646
+ const nowSec7 = Math.floor(Date.now() / 1e3);
21643
21647
  return Promise.all(
21644
21648
  markets.map(async (config) => {
21645
- if (Number(config.maturity) <= nowSec5) {
21649
+ if (Number(config.maturity) <= nowSec7) {
21646
21650
  return { config, top: null, book: null };
21647
21651
  }
21648
21652
  const { top, book } = await fetchTopAndBookWithFallback2(
21649
21653
  source,
21650
21654
  chainId,
21651
21655
  config,
21652
- nowSec5
21656
+ nowSec7
21653
21657
  );
21654
21658
  return { config, top, book };
21655
21659
  })
@@ -21689,7 +21693,11 @@ function currencyFor2(address, decimals, tokens) {
21689
21693
  const lower = address.toLowerCase();
21690
21694
  return tokens[lower] ?? { address: lower, symbol: "", name: "", decimals };
21691
21695
  }
21692
- function convertTermMarketsToResponse(raw, chainId, prices = {}, _additionalYields = { intrinsicYields: {}, lenderRewards: {}, loaded: true }, tokens = {}) {
21696
+ function convertTermMarketsToResponse(raw, chainId, prices = {}, _additionalYields = {
21697
+ intrinsicYields: {},
21698
+ lenderRewards: {},
21699
+ loaded: true
21700
+ }, tokens = {}) {
21693
21701
  const out = {};
21694
21702
  const now = nowSec2();
21695
21703
  for (const { config, top, book } of raw) {
@@ -21735,6 +21743,7 @@ function convertTermMarketsToResponse(raw, chainId, prices = {}, _additionalYiel
21735
21743
  utilization: 0,
21736
21744
  depositRate: supplyAprPct,
21737
21745
  variableBorrowRate: borrowAprPct,
21746
+ rateModel: "fixedTerm",
21738
21747
  // Term is fixed-rate: mirror the fixed borrow APR on stableBorrowRate too.
21739
21748
  stableBorrowRate: borrowAprPct,
21740
21749
  intrinsicYield: 0,
@@ -21994,6 +22003,7 @@ function convertExactlyMarketsToResponse(raw, chainId, prices = {}, _additionalY
21994
22003
  m.floatingAssets
21995
22004
  ),
21996
22005
  variableBorrowRate: exactlyWadRateToPercent(m.floatingBorrowRate),
22006
+ rateModel: "fixedTerm",
21997
22007
  // Fixed-rate lender convention (Term/Lista): best fixed borrow APR on the
21998
22008
  // stable slot; the full per-maturity menu is params.market.terms.
21999
22009
  stableBorrowRate: bestFixedBorrowApr,
@@ -22296,6 +22306,11 @@ function convertLiquityMarketsToResponse(raw, chainId, prices = {}, _additionalY
22296
22306
  depositRate: spApr * 100,
22297
22307
  variableBorrowRate: avgRate * 100,
22298
22308
  stableBorrowRate: 0,
22309
+ // Borrower picks the per-trove rate; the one-off upfront fee is the
22310
+ // branch avg rate applied over the upfront period (7d vanilla), as a
22311
+ // percent of the borrowed amount.
22312
+ rateModel: "userSet",
22313
+ originationFee: avgRate * (Number(cfg.upfrontInterestPeriodSeconds ?? 604800) / 31536e3) * 100,
22299
22314
  intrinsicYield: 0,
22300
22315
  rewards: void 0,
22301
22316
  decimals: stableDecimals,
@@ -22378,7 +22393,7 @@ function convertLiquityMarketsToResponse(raw, chainId, prices = {}, _additionalY
22378
22393
  }
22379
22394
  return out;
22380
22395
  }
22381
- var READS_PER_TM = 5;
22396
+ var READS_PER_TM = 6;
22382
22397
  var RIVER_PUBLIC_READ_ABI = [
22383
22398
  ...RiverTroveManagerAbi,
22384
22399
  ...RiverStabilityPoolAbi
@@ -22401,6 +22416,7 @@ async function fetchRiverMarkets(lender, chainId) {
22401
22416
  name: "getBorrowingRateWithDecay",
22402
22417
  params: []
22403
22418
  },
22419
+ { address: m.troveManager, name: "interestRate", params: [] },
22404
22420
  { address: m.troveManager, name: "fetchPrice", params: [] },
22405
22421
  { address: m.troveManager, name: "getTroveOwnersCount", params: [] }
22406
22422
  ])
@@ -22429,8 +22445,9 @@ async function fetchRiverMarkets(lender, chainId) {
22429
22445
  entireDebt: val(base),
22430
22446
  entireColl: val(base + 1),
22431
22447
  mintFeeRate: val(base + 2),
22432
- price: val(base + 3),
22433
- troveCount: val(base + 4)
22448
+ interestRate: val(base + 3),
22449
+ price: val(base + 4),
22450
+ troveCount: val(base + 5)
22434
22451
  };
22435
22452
  });
22436
22453
  return { lender, config, chainData, spDeposits: val(0), markets: out };
@@ -22563,8 +22580,18 @@ function convertRiverMarketsToResponse(raw, chainId, prices = {}, _additionalYie
22563
22580
  // No interest yield while the protocol rate is 0% — SP earns
22564
22581
  // liquidation gains + OSHI emissions only (not modeled here).
22565
22582
  depositRate: 0,
22566
- variableBorrowRate: market.interestRate ? Number(market.interestRate) : 0,
22583
+ // Ongoing annual borrow rate as a PERCENT (WAD → %). Live on-chain
22584
+ // `interestRate()` preferred, metadata snapshot as fallback. River
22585
+ // (Satoshi, Prisma lineage) runs at 0% everywhere today — the real
22586
+ // borrow cost is the one-off decaying MINT FEE, surfaced separately as
22587
+ // `params.market.river.mintFeeRate` (it is not an APR, so it never
22588
+ // belongs in this field).
22589
+ variableBorrowRate: Number(m.interestRate ?? market.interestRate ?? 0) / WAD7 * 100,
22567
22590
  stableBorrowRate: 0,
22591
+ // River (Satoshi) has NO ongoing interest — the borrow cost is the
22592
+ // one-off decaying mint fee (`getBorrowingRateWithDecay`, WAD → percent).
22593
+ rateModel: "zeroInterest",
22594
+ originationFee: m.mintFeeRate !== null ? Number(m.mintFeeRate) / WAD7 * 100 : void 0,
22568
22595
  intrinsicYield: 0,
22569
22596
  rewards: void 0,
22570
22597
  decimals: debtDecimals,
@@ -22613,7 +22640,8 @@ function convertRiverMarketsToResponse(raw, chainId, prices = {}, _additionalYie
22613
22640
  mintFeeCap: market.maxBorrowingFee,
22614
22641
  /** Current decayed one-off mint-fee rate (WAD string). */
22615
22642
  mintFeeRate: m.mintFeeRate !== null ? m.mintFeeRate.toString() : void 0,
22616
- interestRate: market.interestRate,
22643
+ /** Ongoing annual interest rate (WAD string) — live on-chain, metadata fallback. */
22644
+ interestRate: m.interestRate !== null ? m.interestRate.toString() : market.interestRate,
22617
22645
  maxSystemDebt: market.maxSystemDebt,
22618
22646
  paused: !!market.paused,
22619
22647
  sunsetting: !!market.sunsetting,
@@ -22633,6 +22661,367 @@ function convertRiverMarketsToResponse(raw, chainId, prices = {}, _additionalYie
22633
22661
  }
22634
22662
  return out;
22635
22663
  }
22664
+ var READS_PER_POOL = 6;
22665
+ var READS_PER_MARKET = 2;
22666
+ async function fetchTellerMarkets(chainId) {
22667
+ const pools = tellerPoolsByChain(chainId);
22668
+ if (pools.length === 0) return { chainId, pools: [] };
22669
+ const marketRegistry = tellerConfigByChain(chainId)?.marketRegistry;
22670
+ const calls = pools.flatMap((p) => {
22671
+ const onePrincipal = 10n ** BigInt(p.principalDecimals);
22672
+ return [
22673
+ { address: p.pool, name: "getPrincipalAmountAvailableToBorrow", params: [] },
22674
+ { address: p.pool, name: "totalPrincipalTokensCommitted", params: [] },
22675
+ { address: p.pool, name: "getMinInterestRate", params: [0n] },
22676
+ {
22677
+ address: p.pool,
22678
+ name: "calculateCollateralRequiredToBorrowPrincipal",
22679
+ params: [onePrincipal]
22680
+ },
22681
+ { address: p.pool, name: "getMaxLoanDuration", params: [] },
22682
+ { address: p.pool, name: "getMarketId", params: [] }
22683
+ ];
22684
+ });
22685
+ let results = [];
22686
+ try {
22687
+ results = await multicallRetryUniversal({
22688
+ chain: chainId,
22689
+ calls,
22690
+ abi: LenderCommitmentGroupAbi,
22691
+ allowFailure: true
22692
+ });
22693
+ } catch {
22694
+ return { chainId, pools: [] };
22695
+ }
22696
+ const big4 = (i) => {
22697
+ const r = results[i];
22698
+ if (typeof r === "bigint") return r;
22699
+ if (typeof r === "number") return BigInt(r);
22700
+ if (typeof r === "string" && r !== "0x") {
22701
+ try {
22702
+ return BigInt(r);
22703
+ } catch {
22704
+ return null;
22705
+ }
22706
+ }
22707
+ return null;
22708
+ };
22709
+ const num6 = (i) => {
22710
+ const b = big4(i);
22711
+ return b === null ? null : Number(b);
22712
+ };
22713
+ const pool0 = pools.map((config, i) => {
22714
+ const base = i * READS_PER_POOL;
22715
+ return {
22716
+ config,
22717
+ available: big4(base),
22718
+ committed: big4(base + 1),
22719
+ minRateBps: num6(base + 2),
22720
+ collateralPerPrincipal: big4(base + 3),
22721
+ maxLoanDuration: num6(base + 4),
22722
+ marketId: big4(base + 5)
22723
+ };
22724
+ });
22725
+ const attByMarket = /* @__PURE__ */ new Map();
22726
+ if (marketRegistry) {
22727
+ const uniqueMarkets = [
22728
+ ...new Set(
22729
+ pool0.map((p) => p.marketId != null ? p.marketId.toString() : null).filter((m) => m != null)
22730
+ )
22731
+ ];
22732
+ if (uniqueMarkets.length > 0) {
22733
+ const mCalls = uniqueMarkets.flatMap((m) => [
22734
+ {
22735
+ address: marketRegistry,
22736
+ name: "getMarketAttestationRequirements",
22737
+ params: [BigInt(m)]
22738
+ },
22739
+ { address: marketRegistry, name: "isMarketOpen", params: [BigInt(m)] }
22740
+ ]);
22741
+ try {
22742
+ const mRes = await multicallRetryUniversal({
22743
+ chain: chainId,
22744
+ calls: mCalls,
22745
+ abi: TellerMarketRegistryAbi,
22746
+ allowFailure: true
22747
+ });
22748
+ uniqueMarkets.forEach((m, i) => {
22749
+ const att = mRes[i * READS_PER_MARKET];
22750
+ const open = mRes[i * READS_PER_MARKET + 1];
22751
+ const borrowerRequired = (att?.borrowerAttestationRequired ?? att?.[1]) === true;
22752
+ attByMarket.set(m, {
22753
+ requiresBorrowerAttestation: borrowerRequired,
22754
+ marketOpen: open === false ? false : true
22755
+ });
22756
+ });
22757
+ } catch {
22758
+ }
22759
+ }
22760
+ }
22761
+ const out = pool0.map((p) => {
22762
+ const att = p.marketId != null ? attByMarket.get(p.marketId.toString()) : void 0;
22763
+ return {
22764
+ ...p,
22765
+ requiresBorrowerAttestation: att?.requiresBorrowerAttestation,
22766
+ marketOpen: att?.marketOpen
22767
+ };
22768
+ });
22769
+ return { chainId, pools: out };
22770
+ }
22771
+
22772
+ // src/lending/public-data/teller/math.ts
22773
+ function tellerBpsToPercent(bps) {
22774
+ if (!bps) return 0;
22775
+ return bps / 100;
22776
+ }
22777
+ function tellerToHuman(raw, decimals) {
22778
+ if (!raw) return 0;
22779
+ return Number(raw) / 10 ** decimals;
22780
+ }
22781
+ function tellerImpliedLtv(collateralPerPrincipal, collateralDecimals, principalPrice, collateralPrice) {
22782
+ if (!collateralPerPrincipal || principalPrice <= 0 || collateralPrice <= 0) return 0;
22783
+ const collHuman = Number(collateralPerPrincipal) / 10 ** collateralDecimals;
22784
+ const collateralValue = collHuman * collateralPrice;
22785
+ if (collateralValue <= 0) return 0;
22786
+ const ltv = principalPrice / collateralValue;
22787
+ return ltv > 0 && ltv < 1 ? ltv : ltv >= 1 ? 1 : 0;
22788
+ }
22789
+
22790
+ // src/lending/public-data/teller/convertPublic.ts
22791
+ function tellerLenderKey(pool) {
22792
+ const body = pool.startsWith("0x") ? pool.slice(2) : pool;
22793
+ return "TELLER_" + body.toUpperCase();
22794
+ }
22795
+ function tellerPoolFromLenderKey(lender) {
22796
+ if (!lender.startsWith("TELLER_")) return void 0;
22797
+ const body = lender.slice("TELLER_".length);
22798
+ return body.length === 40 ? "0x" + body.toLowerCase() : void 0;
22799
+ }
22800
+ function currencyFor6(address, decimals, symbol, tokens) {
22801
+ const lower = address.toLowerCase();
22802
+ return tokens[lower] ?? { address: lower, symbol, name: symbol, decimals };
22803
+ }
22804
+ function priceFor(address, chainId, tokens, prices) {
22805
+ const lower = address.toLowerCase();
22806
+ const token = tokens[lower];
22807
+ const key = toOracleKey(token?.assetGroup) || toGenericPriceKey(lower, chainId);
22808
+ return prices[key] ?? 0;
22809
+ }
22810
+ function convertTellerMarketsToResponse(raw, chainId, prices = {}, _additionalYields = {
22811
+ intrinsicYields: {},
22812
+ lenderRewards: {},
22813
+ loaded: true
22814
+ }, tokens = {}) {
22815
+ const out = {};
22816
+ const proto = tellerConfigByChain(chainId);
22817
+ for (const p of raw?.pools ?? []) {
22818
+ const cfg = p.config;
22819
+ const lenderKey = tellerLenderKey(cfg.pool);
22820
+ const principalAddr = cfg.principal.toLowerCase();
22821
+ const collateralAddr = cfg.collateral.toLowerCase();
22822
+ const principalPrice = priceFor(principalAddr, chainId, tokens, prices);
22823
+ const collateralPrice = priceFor(collateralAddr, chainId, tokens, prices);
22824
+ const borrowLiquidity = tellerToHuman(p.available, cfg.principalDecimals);
22825
+ const totalDeposits = tellerToHuman(p.committed, cfg.principalDecimals);
22826
+ const totalDebt = Math.max(0, totalDeposits - borrowLiquidity);
22827
+ const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : 0;
22828
+ const borrowApr = tellerBpsToPercent(p.minRateBps);
22829
+ const depositApr = utilization * borrowApr;
22830
+ const ltv = tellerImpliedLtv(
22831
+ p.collateralPerPrincipal,
22832
+ cfg.collateralDecimals,
22833
+ principalPrice,
22834
+ collateralPrice
22835
+ );
22836
+ const durationSecs = p.maxLoanDuration ?? cfg.maxLoanDuration ?? 0;
22837
+ const terms = [
22838
+ {
22839
+ // Rolling duration → use the max duration as the (stable) term id.
22840
+ termId: durationSecs,
22841
+ durationSecs,
22842
+ durationDays: durationSecs / 86400,
22843
+ apr: borrowApr,
22844
+ depositApr,
22845
+ available: borrowLiquidity
22846
+ }
22847
+ ];
22848
+ const entry = { data: {} };
22849
+ const loanUid = createMarketUid(chainId, lenderKey, principalAddr);
22850
+ entry.data[loanUid] = {
22851
+ marketUid: loanUid,
22852
+ name: cfg.principalSymbol,
22853
+ poolId: cfg.pool.toLowerCase(),
22854
+ underlying: principalAddr,
22855
+ asset: currencyFor6(
22856
+ principalAddr,
22857
+ cfg.principalDecimals,
22858
+ cfg.principalSymbol,
22859
+ tokens
22860
+ ),
22861
+ totalDeposits,
22862
+ totalDebtStable: totalDebt,
22863
+ totalDebt: 0,
22864
+ totalLiquidity: borrowLiquidity,
22865
+ borrowLiquidity,
22866
+ totalLiquidityUSD: borrowLiquidity * principalPrice,
22867
+ borrowLiquidityUSD: borrowLiquidity * principalPrice,
22868
+ totalDepositsUSD: totalDeposits * principalPrice,
22869
+ totalDebtStableUSD: totalDebt * principalPrice,
22870
+ totalDebtUSD: 0,
22871
+ utilization,
22872
+ depositRate: depositApr,
22873
+ // Teller has NO floating leg — the fixed borrow APR sits on the stable slot
22874
+ // (fixed-rate convention: Exactly/Term/Lista), variable stays 0.
22875
+ variableBorrowRate: 0,
22876
+ stableBorrowRate: borrowApr,
22877
+ rateModel: "fixedTerm",
22878
+ intrinsicYield: 0,
22879
+ rewards: void 0,
22880
+ decimals: cfg.principalDecimals,
22881
+ config: {
22882
+ 0: {
22883
+ category: 0,
22884
+ // Principal token is the borrow asset, not collateral in this pool.
22885
+ borrowCollateralFactor: 0,
22886
+ collateralFactor: 0,
22887
+ borrowFactor: 1,
22888
+ liquidationPenalty: 0,
22889
+ closeFactor: 1,
22890
+ collateralDisabled: true,
22891
+ debtDisabled: false
22892
+ }
22893
+ },
22894
+ closeFactor: 1,
22895
+ collateralActive: false,
22896
+ // Open markets with live liquidity are borrowable; attestation-gated
22897
+ // markets stay borrowable here (flagged in the descriptor) — the per-user
22898
+ // gate runs at borrow time.
22899
+ borrowingEnabled: borrowLiquidity > 0 && p.marketOpen !== false,
22900
+ depositsEnabled: true,
22901
+ hasStable: false,
22902
+ variableBorrowDisabled: true,
22903
+ isActive: p.marketOpen !== false,
22904
+ isFrozen: p.marketOpen === false
22905
+ };
22906
+ const collUid = createMarketUid(chainId, lenderKey, collateralAddr);
22907
+ entry.data[collUid] = {
22908
+ marketUid: collUid,
22909
+ name: "Collateral " + cfg.collateralSymbol,
22910
+ poolId: cfg.pool.toLowerCase(),
22911
+ underlying: collateralAddr,
22912
+ asset: currencyFor6(
22913
+ collateralAddr,
22914
+ cfg.collateralDecimals,
22915
+ cfg.collateralSymbol,
22916
+ tokens
22917
+ ),
22918
+ totalDeposits: 0,
22919
+ totalDebtStable: 0,
22920
+ totalDebt: 0,
22921
+ totalLiquidity: 0,
22922
+ borrowLiquidity: 0,
22923
+ totalLiquidityUSD: 0,
22924
+ borrowLiquidityUSD: 0,
22925
+ totalDepositsUSD: 0,
22926
+ totalDebtStableUSD: 0,
22927
+ totalDebtUSD: 0,
22928
+ utilization: 0,
22929
+ depositRate: 0,
22930
+ variableBorrowRate: 0,
22931
+ stableBorrowRate: 0,
22932
+ intrinsicYield: 0,
22933
+ rewards: void 0,
22934
+ decimals: cfg.collateralDecimals,
22935
+ config: {
22936
+ 0: {
22937
+ category: 0,
22938
+ borrowCollateralFactor: ltv,
22939
+ collateralFactor: ltv,
22940
+ borrowFactor: 1,
22941
+ // Time-based liquidation → no price-based penalty parameter.
22942
+ liquidationPenalty: 0,
22943
+ closeFactor: 1,
22944
+ collateralDisabled: false,
22945
+ debtDisabled: true
22946
+ }
22947
+ },
22948
+ closeFactor: 1,
22949
+ collateralActive: true,
22950
+ borrowingEnabled: false,
22951
+ depositsEnabled: true,
22952
+ hasStable: false,
22953
+ isActive: true,
22954
+ isFrozen: false
22955
+ };
22956
+ const implications = [
22957
+ "Fixed-term, fixed-APR loan: the rate is locked at borrow time for a duration you choose (up to the pool max).",
22958
+ "TIME-based liquidation only \u2014 collateral is seized if a payment is missed past the market window. There is NO price-based liquidation and NO margin call.",
22959
+ "Closing is a FULL repayment: it repays principal + interest and releases ALL collateral in one tx (no partial collateral withdrawal; a partial repay keeps the collateral escrowed)."
22960
+ ];
22961
+ if (p.requiresBorrowerAttestation)
22962
+ implications.push(
22963
+ "This market requires borrower ATTESTATION \u2014 the borrower must be whitelisted by the market owner before borrowing."
22964
+ );
22965
+ if (p.marketOpen === false)
22966
+ implications.push("This market is currently CLOSED (not borrowable).");
22967
+ entry.params = {
22968
+ market: {
22969
+ lender: lenderKey,
22970
+ name: cfg.name ?? `Teller ${cfg.principalSymbol} / ${cfg.collateralSymbol}`,
22971
+ loanDecimals: cfg.principalDecimals,
22972
+ collateralDecimals: cfg.collateralDecimals,
22973
+ // Pool address doubles as the market id (it IS the lender-key body).
22974
+ id: cfg.pool.toLowerCase(),
22975
+ lltv: ltv.toString(),
22976
+ oracle: zeroAddress,
22977
+ irm: zeroAddress,
22978
+ collateralAddress: collateralAddr,
22979
+ loanAddress: principalAddr,
22980
+ terms,
22981
+ // Canonical cross-protocol fixed-term descriptor. Teller: rolling
22982
+ // duration (≤ maxLoanDuration), pool-fronted fixed APR, early repay =
22983
+ // NONE (full early repay is pro-rata, penalty-free), overdue handling is
22984
+ // time-based default/seizure (no late-penalty APR).
22985
+ fixedTerm: {
22986
+ model: "teller",
22987
+ maturity: void 0,
22988
+ fees: {},
22989
+ earlyRepay: { kind: "none" },
22990
+ provider: { kind: "pool", address: cfg.pool.toLowerCase() }
22991
+ },
22992
+ // --- Teller descriptor (addresses + config the calldata/worker
22993
+ // resolvers consume; mirrors river's `river` / exactly's extras) ---
22994
+ teller: {
22995
+ pool: cfg.pool.toLowerCase(),
22996
+ // On-chain marketId is authoritative; fall back to the config seed.
22997
+ marketId: p.marketId != null ? p.marketId.toString() : cfg.marketId,
22998
+ maxLoanDuration: durationSecs,
22999
+ // Permissioning: some markets only let PRE-ATTESTED borrowers open
23000
+ // loans (the borrow builder enforces per-user; this flags it for the
23001
+ // UI/allocator). `marketOpen` = MarketRegistry.isMarketOpen.
23002
+ requiresBorrowerAttestation: p.requiresBorrowerAttestation,
23003
+ marketOpen: p.marketOpen,
23004
+ /** Human-readable caveats for the UI to surface (see above). */
23005
+ implications,
23006
+ minInterestRateBps: p.minRateBps ?? void 0,
23007
+ interestRateLowerBound: cfg.interestRateLowerBound ?? void 0,
23008
+ interestRateUpperBound: cfg.interestRateUpperBound ?? void 0,
23009
+ principalAvailable: p.available !== null ? p.available.toString() : void 0,
23010
+ collateralPerPrincipal: p.collateralPerPrincipal !== null ? p.collateralPerPrincipal.toString() : void 0,
23011
+ addresses: {
23012
+ tellerV2: proto?.tellerV2,
23013
+ collateralManager: proto?.collateralManager,
23014
+ smartCommitmentForwarder: proto?.smartCommitmentForwarder,
23015
+ marketRegistry: proto?.marketRegistry
23016
+ }
23017
+ }
23018
+ }
23019
+ };
23020
+ entry.chainId = chainId;
23021
+ out[lenderKey] = entry;
23022
+ }
23023
+ return out;
23024
+ }
22636
23025
 
22637
23026
  // src/lending/public-data/silo-v2/fetchPublic.ts
22638
23027
  var BASE_URL2 = "https://api-v3.silo.finance";
@@ -23240,6 +23629,7 @@ async function getLenderDataFromApi(lender, chainId, prices, additionalYields, i
23240
23629
  if (isExactly(lender)) return await fetchExactlyMarkets(chainId);
23241
23630
  if (isLiquityFamily(lender)) return await fetchLiquityMarkets(lender, chainId);
23242
23631
  if (isRiver(lender)) return await fetchRiverMarkets(lender, chainId);
23632
+ if (isTeller(lender)) return await fetchTellerMarkets(chainId);
23243
23633
  return {};
23244
23634
  }
23245
23635
  function convertLenderDataFromApi(lender, chainId, data, prices, additionalYields, list = {}) {
@@ -23285,6 +23675,14 @@ function convertLenderDataFromApi(lender, chainId, data, prices, additionalYield
23285
23675
  additionalYields,
23286
23676
  list
23287
23677
  );
23678
+ if (isTeller(lender))
23679
+ return convertTellerMarketsToResponse(
23680
+ data,
23681
+ chainId,
23682
+ prices,
23683
+ additionalYields,
23684
+ list
23685
+ );
23288
23686
  return {};
23289
23687
  }
23290
23688
  var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYields, tokenList = async () => {
@@ -23473,6 +23871,7 @@ function lenderApiOnly(lender, chainId) {
23473
23871
  if (isExactly(lender)) return true;
23474
23872
  if (isLiquityFamily(lender)) return true;
23475
23873
  if (isRiver(lender)) return true;
23874
+ if (isTeller(lender)) return true;
23476
23875
  return false;
23477
23876
  }
23478
23877
  function lenderApiWithOnChainFallback(lender, chainId) {
@@ -24381,6 +24780,103 @@ var buildRiverUserCall = (chainId, lender, account) => {
24381
24780
  });
24382
24781
  return calls;
24383
24782
  };
24783
+ var TELLER_CALLS_PER_BID = 4;
24784
+ var CACHE_TTL_MS2 = 5 * 6e4;
24785
+ var discoveryCache2 = /* @__PURE__ */ new Map();
24786
+ var cacheKey2 = (chainId, account) => `${chainId}:${account.toLowerCase()}`;
24787
+ var getCachedTellerBids = (chainId, account) => {
24788
+ const hit = discoveryCache2.get(cacheKey2(chainId, account));
24789
+ if (!hit || Date.now() - hit.at > CACHE_TTL_MS2) return void 0;
24790
+ return hit;
24791
+ };
24792
+ var nowSec4 = () => Math.floor(Date.now() / 1e3);
24793
+ var toBigints = (arr) => {
24794
+ if (!Array.isArray(arr)) return [];
24795
+ const out = [];
24796
+ for (const x of arr) {
24797
+ try {
24798
+ out.push(BigInt(x).toString());
24799
+ } catch {
24800
+ }
24801
+ }
24802
+ return out;
24803
+ };
24804
+ var buildTellerUserCall = async (chainId, _lender, account) => {
24805
+ const proto = tellerConfigByChain(chainId);
24806
+ const pools = tellerPoolsByChain(chainId);
24807
+ if (!proto?.tellerV2 || !proto?.collateralManager || pools.length === 0) {
24808
+ return [];
24809
+ }
24810
+ let ids = [];
24811
+ try {
24812
+ const res = await multicallRetryUniversal({
24813
+ chain: chainId,
24814
+ calls: [
24815
+ {
24816
+ address: proto.tellerV2,
24817
+ name: "getBorrowerActiveLoanIds",
24818
+ params: [account]
24819
+ }
24820
+ ],
24821
+ abi: TellerV2Abi,
24822
+ allowFailure: true
24823
+ });
24824
+ ids = toBigints(res?.[0]);
24825
+ } catch {
24826
+ return [];
24827
+ }
24828
+ if (ids.length === 0) {
24829
+ discoveryCache2.set(cacheKey2(chainId, account), { bids: [], at: Date.now() });
24830
+ return [];
24831
+ }
24832
+ const poolByAddr = /* @__PURE__ */ new Map();
24833
+ for (const p of pools) poolByAddr.set(p.pool.toLowerCase(), p);
24834
+ let lenders = [];
24835
+ try {
24836
+ lenders = await multicallRetryUniversal({
24837
+ chain: chainId,
24838
+ calls: ids.map((id) => ({
24839
+ address: proto.tellerV2,
24840
+ name: "getLoanLender",
24841
+ params: [id]
24842
+ })),
24843
+ abi: TellerV2Abi,
24844
+ allowFailure: true
24845
+ });
24846
+ } catch {
24847
+ return [];
24848
+ }
24849
+ const kept = [];
24850
+ ids.forEach((id, i) => {
24851
+ const r = lenders[i];
24852
+ const lenderAddr = typeof r === "string" ? r.toLowerCase() : "";
24853
+ const pool = poolByAddr.get(lenderAddr);
24854
+ if (pool) kept.push({ bidId: id, pool });
24855
+ });
24856
+ discoveryCache2.set(cacheKey2(chainId, account), { bids: kept, at: Date.now() });
24857
+ if (kept.length === 0) return [];
24858
+ const ts = nowSec4();
24859
+ const calls = [];
24860
+ for (const b of kept) {
24861
+ calls.push({ address: proto.tellerV2, name: "bids", params: [b.bidId] });
24862
+ calls.push({
24863
+ address: proto.tellerV2,
24864
+ name: "calculateAmountOwed",
24865
+ params: [b.bidId, ts]
24866
+ });
24867
+ calls.push({
24868
+ address: proto.collateralManager,
24869
+ name: "getCollateralAmount",
24870
+ params: [b.bidId, b.pool.collateral]
24871
+ });
24872
+ calls.push({
24873
+ address: proto.tellerV2,
24874
+ name: "isLoanDefaulted",
24875
+ params: [b.bidId]
24876
+ });
24877
+ }
24878
+ return calls;
24879
+ };
24384
24880
 
24385
24881
  // src/lending/user-data/fetch-balances/prepare.ts
24386
24882
  async function buildUserCall(chainId, lender, account, params, getClient) {
@@ -24402,6 +24898,7 @@ async function buildUserCall(chainId, lender, account, params, getClient) {
24402
24898
  if (isLiquityFamily(lender))
24403
24899
  return buildLiquityUserCall(chainId, lender, account);
24404
24900
  if (isRiver(lender)) return buildRiverUserCall(chainId, lender, account);
24901
+ if (isTeller(lender)) return buildTellerUserCall(chainId, lender, account);
24405
24902
  if (isCompoundV3Type(lender))
24406
24903
  return buildCompoundV3UserCall(chainId, lender, account);
24407
24904
  if (isEulerType(lender))
@@ -24428,10 +24925,11 @@ function organizeUserQueries(queries) {
24428
24925
  const exactly = queries.filter((q) => isExactly(q.lender));
24429
24926
  const liquity = queries.filter((q) => isLiquityFamily(q.lender));
24430
24927
  const river = queries.filter((q) => isRiver(q.lender));
24431
- if (morphos.length === 0 && gearbox.length === 0 && midnight.length === 0 && term.length === 0 && exactly.length === 0 && liquity.length === 0 && river.length === 0)
24928
+ const teller = queries.filter((q) => isTeller(q.lender));
24929
+ if (morphos.length === 0 && gearbox.length === 0 && midnight.length === 0 && term.length === 0 && exactly.length === 0 && liquity.length === 0 && river.length === 0 && teller.length === 0)
24432
24930
  return queries;
24433
24931
  const others = queries.filter(
24434
- (q) => !isMorphoType(q.lender) && !isGearboxV3(q.lender) && !isMidnight(q.lender) && !isTerm(q.lender) && !isExactly(q.lender) && !isLiquityFamily(q.lender) && !isRiver(q.lender)
24932
+ (q) => !isMorphoType(q.lender) && !isGearboxV3(q.lender) && !isMidnight(q.lender) && !isTerm(q.lender) && !isExactly(q.lender) && !isLiquityFamily(q.lender) && !isRiver(q.lender) && !isTeller(q.lender)
24435
24933
  );
24436
24934
  const morphoBlue = morphos.filter((q) => q.lender.startsWith("MORPHO_BLUE"));
24437
24935
  const moolah = morphos.filter((q) => q.lender.startsWith("LISTA_DAO"));
@@ -24492,6 +24990,14 @@ function organizeUserQueries(queries) {
24492
24990
  assets: void 0
24493
24991
  });
24494
24992
  }
24993
+ if (teller.length > 0) {
24994
+ result.push({
24995
+ lender: Lender.TELLER,
24996
+ account: teller[0].account,
24997
+ params: teller.map((p) => p.lender),
24998
+ assets: void 0
24999
+ });
25000
+ }
24495
25001
  if (liquity.length > 0) {
24496
25002
  for (const base of LIQUITY_FAMILY_LENDERS) {
24497
25003
  const members = liquity.filter((q) => q.lender.startsWith(base));
@@ -26943,7 +27449,7 @@ var getTermUserDataConverter = (_lender, chainId, account, meta) => {
26943
27449
  totalCalls
26944
27450
  ];
26945
27451
  };
26946
- var nowSec4 = () => Math.floor(Date.now() / 1e3);
27452
+ var nowSec5 = () => Math.floor(Date.now() / 1e3);
26947
27453
  function sumPreview(positions) {
26948
27454
  return positions.reduce((acc, p) => acc + p.previewValue, 0n);
26949
27455
  }
@@ -26965,7 +27471,7 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
26965
27471
  const res = data[0];
26966
27472
  if (!res || res === "0x" || !Array.isArray(res)) return void 0;
26967
27473
  const markets = res;
26968
- const now = nowSec4();
27474
+ const now = nowSec5();
26969
27475
  const out = {};
26970
27476
  for (const m of markets) {
26971
27477
  const lenderKey = exactlyLenderKey(m.market);
@@ -27450,6 +27956,148 @@ var getRiverUserDataConverter = (lender, chainId, account, meta) => {
27450
27956
  ];
27451
27957
  };
27452
27958
 
27959
+ // src/lending/user-data/teller/userCallParse.ts
27960
+ var nowSec6 = () => Math.floor(Date.now() / 1e3);
27961
+ var big3 = (v) => {
27962
+ try {
27963
+ if (typeof v === "bigint") return v;
27964
+ if (typeof v === "number" || typeof v === "string") return BigInt(v);
27965
+ } catch {
27966
+ }
27967
+ return 0n;
27968
+ };
27969
+ var field8 = (res, name, idx) => res?.[name] ?? res?.[idx];
27970
+ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
27971
+ const discovery = getCachedTellerBids(chainId, account);
27972
+ const kept = discovery?.bids ?? [];
27973
+ const expected = kept.length * TELLER_CALLS_PER_BID;
27974
+ return [
27975
+ (data) => {
27976
+ if (expected === 0 || !data || data.length < expected) return void 0;
27977
+ const now = nowSec6();
27978
+ const perPool = {};
27979
+ kept.forEach((b, i) => {
27980
+ const base = i * TELLER_CALLS_PER_BID;
27981
+ const bidRes = data[base];
27982
+ const owed = data[base + 1];
27983
+ const collAmount = big3(data[base + 2]);
27984
+ const defaulted = !!data[base + 3];
27985
+ if (!bidRes) return;
27986
+ const pool = b.pool;
27987
+ const lenderKey = tellerLenderKey(pool.pool);
27988
+ const metaMap = meta?.[lenderKey];
27989
+ if (!metaMap) return;
27990
+ const principalAddr = pool.principal.toLowerCase();
27991
+ const collAddr = pool.collateral.toLowerCase();
27992
+ const loanUid = createMarketUid(chainId, lenderKey, principalAddr);
27993
+ const collUid = createMarketUid(chainId, lenderKey, collAddr);
27994
+ const loanMeta = metaMap[loanUid];
27995
+ const collMeta = metaMap[collUid];
27996
+ const principalDecimals = loanMeta?.asset?.decimals ?? pool.principalDecimals;
27997
+ const collDecimals = collMeta?.asset?.decimals ?? pool.collateralDecimals;
27998
+ const loanDisplay = loanMeta ? getDisplayPrice(loanMeta) : 0;
27999
+ const loanOracle = loanMeta ? getOraclePrice(loanMeta) : 0;
28000
+ const loanHist = loanMeta?.price?.priceUsd24h ?? loanDisplay;
28001
+ const collDisplay = collMeta ? getDisplayPrice(collMeta) : 0;
28002
+ const collOracle = collMeta ? getOraclePrice(collMeta) : 0;
28003
+ const collHist = collMeta?.price?.priceUsd24h ?? collDisplay;
28004
+ const owedPrincipal = big3(field8(owed, "principal", 0));
28005
+ const owedInterest = big3(field8(owed, "interest", 1));
28006
+ const owedTotal = owedPrincipal + owedInterest;
28007
+ if (owedTotal === 0n && collAmount === 0n) return;
28008
+ const loanDetails = field8(bidRes, "loanDetails", 5);
28009
+ const terms = field8(bidRes, "terms", 6);
28010
+ const acceptedTs = Number(big3(field8(loanDetails, "acceptedTimestamp", 4)));
28011
+ const loanDuration = Number(big3(field8(loanDetails, "loanDuration", 6)));
28012
+ const aprBps = Number(big3(field8(terms, "APR", 2)));
28013
+ const maturity = acceptedTs > 0 ? acceptedTs + loanDuration : void 0;
28014
+ const isMatured = defaulted || maturity !== void 0 && maturity < now;
28015
+ const collStr = parseRawAmount(collAmount.toString(), collDecimals);
28016
+ const collNum = Number(collStr);
28017
+ const debtStr = parseRawAmount(owedTotal.toString(), principalDecimals);
28018
+ const debtNum = Number(debtStr);
28019
+ const interestStr = parseRawAmount(
28020
+ owedInterest.toString(),
28021
+ principalDecimals
28022
+ );
28023
+ const bucket = perPool[lenderKey] ??= {
28024
+ positions: {},
28025
+ modes: {},
28026
+ hist: {},
28027
+ metaMap
28028
+ };
28029
+ bucket.positions[b.bidId] = {
28030
+ [collUid]: {
28031
+ marketUid: collUid,
28032
+ underlying: collAddr,
28033
+ deposits: collStr,
28034
+ debt: "0",
28035
+ debtStable: "0",
28036
+ depositsUSD: collNum * collDisplay,
28037
+ debtUSD: 0,
28038
+ debtStableUSD: 0,
28039
+ depositsUSDOracle: collNum * collOracle,
28040
+ debtUSDOracle: 0,
28041
+ debtStableUSDOracle: 0,
28042
+ stableBorrowRate: "0",
28043
+ collateralEnabled: true,
28044
+ claimableRewards: 0
28045
+ },
28046
+ [loanUid]: {
28047
+ marketUid: loanUid,
28048
+ underlying: principalAddr,
28049
+ deposits: "0",
28050
+ debt: "0",
28051
+ // Fixed-term debt → stable slot (Exactly/Lista convention).
28052
+ debtStable: debtStr,
28053
+ depositsUSD: 0,
28054
+ debtUSD: 0,
28055
+ debtStableUSD: debtNum * loanDisplay,
28056
+ depositsUSDOracle: 0,
28057
+ debtUSDOracle: 0,
28058
+ debtStableUSDOracle: debtNum * loanOracle,
28059
+ stableBorrowRate: String(aprBps / 100),
28060
+ collateralEnabled: false,
28061
+ claimableRewards: 0,
28062
+ // Fixed-term loan detail — `loanId = bidId` is the repayLoanFull target.
28063
+ term: {
28064
+ loanId: b.bidId,
28065
+ isDynamic: false,
28066
+ debt: debtStr,
28067
+ apr: aprBps / 100,
28068
+ maturity,
28069
+ accruedInterest: interestStr,
28070
+ isMatured
28071
+ }
28072
+ }
28073
+ };
28074
+ bucket.modes[b.bidId] = 0;
28075
+ bucket.hist[b.bidId] = {
28076
+ totalDeposits24h: collNum * collHist,
28077
+ totalDebt24h: debtNum * loanHist
28078
+ };
28079
+ });
28080
+ const out = {};
28081
+ for (const [lenderKey, bucket] of Object.entries(perPool)) {
28082
+ if (Object.keys(bucket.positions).length === 0) continue;
28083
+ const userData = createMultiAccountTypeUserState(
28084
+ {
28085
+ chainId,
28086
+ account,
28087
+ lendingPositions: bucket.positions,
28088
+ modes: bucket.modes
28089
+ },
28090
+ bucket.metaMap,
28091
+ bucket.hist
28092
+ );
28093
+ if (userData && userData.data.length > 0) out[lenderKey] = userData;
28094
+ }
28095
+ return Object.keys(out).length > 0 ? out : void 0;
28096
+ },
28097
+ expected
28098
+ ];
28099
+ };
28100
+
27453
28101
  // src/lending/user-data/fetch-balances/parse.ts
27454
28102
  function getUserDataConverter(lender, chainId, account, params, meta) {
27455
28103
  if (isAaveV4Type(lender))
@@ -27480,6 +28128,8 @@ function getUserDataConverter(lender, chainId, account, params, meta) {
27480
28128
  return getLiquityUserDataConverter(lender, chainId, account, meta);
27481
28129
  if (isRiver(lender))
27482
28130
  return getRiverUserDataConverter(lender, chainId, account, meta);
28131
+ if (isTeller(lender))
28132
+ return getTellerUserDataConverter(lender, chainId, account, meta);
27483
28133
  if (isCompoundV3Type(lender))
27484
28134
  return getCompoundV3UserDataConverter(
27485
28135
  lender,
@@ -32251,6 +32901,8 @@ var getAbi2 = (lender) => {
32251
32901
  ];
32252
32902
  if (isRiver(lender))
32253
32903
  return [...RiverTroveManagerAbi, ...RiverStabilityPoolAbi];
32904
+ if (isTeller(lender))
32905
+ return [...TellerV2Abi, ...TellerCollateralManagerAbi];
32254
32906
  if (isInit(lender)) return InitLensAbi;
32255
32907
  if (isEulerType(lender)) return accountLensAbi;
32256
32908
  if (isCompoundV2Type(lender))
@@ -32804,7 +33456,7 @@ var MORPHO_API_CHAIN_IDS = {
32804
33456
  [Chain.UNICHAIN]: 130
32805
33457
  };
32806
33458
  var FETCH_TIMEOUT_MS = 3e3;
32807
- var CACHE_TTL_MS2 = 2e3;
33459
+ var CACHE_TTL_MS3 = 2e3;
32808
33460
  var buildSubgraphQuery = (account) => `
32809
33461
  {
32810
33462
  account(id: "${account.toLowerCase()}") {
@@ -32859,11 +33511,11 @@ async function fetchJsonWithProxyFallback(url, body, proxyConfig) {
32859
33511
  }
32860
33512
  var inflight = /* @__PURE__ */ new Map();
32861
33513
  var resolved = /* @__PURE__ */ new Map();
32862
- function cacheKey2(chainId, account) {
33514
+ function cacheKey3(chainId, account) {
32863
33515
  return `${chainId}:${account.toLowerCase()}`;
32864
33516
  }
32865
33517
  async function dedupedFetch(chainId, account, loader) {
32866
- const key = cacheKey2(chainId, account);
33518
+ const key = cacheKey3(chainId, account);
32867
33519
  const now = Date.now();
32868
33520
  const cached = resolved.get(key);
32869
33521
  if (cached && cached.expiresAt > now) {
@@ -32872,7 +33524,7 @@ async function dedupedFetch(chainId, account, loader) {
32872
33524
  const existing = inflight.get(key);
32873
33525
  if (existing) return existing;
32874
33526
  const promise = loader().then((value) => {
32875
- resolved.set(key, { value, expiresAt: Date.now() + CACHE_TTL_MS2 });
33527
+ resolved.set(key, { value, expiresAt: Date.now() + CACHE_TTL_MS3 });
32876
33528
  return value;
32877
33529
  }).finally(() => {
32878
33530
  inflight.delete(key);
@@ -33004,8 +33656,8 @@ function calculateOverallNetApr(totalDepositsUSD, totalDebtUSD, avgDepositApr, a
33004
33656
  return (totalDepositsUSD * avgDepositApr - totalDebtUSD * avgBorrowApr) / Math.abs(totalNetWorth) * (totalNetWorth > 0 ? 1 : -1);
33005
33657
  }
33006
33658
  function calculateWeightedAprs(items) {
33007
- const wa = (field8, weightField) => calculateWeightedAverage(
33008
- items.filter((i) => i[weightField] !== 0).map((i) => ({ value: i[field8], weight: Math.abs(i[weightField]) }))
33659
+ const wa = (field9, weightField) => calculateWeightedAverage(
33660
+ items.filter((i) => i[weightField] !== 0).map((i) => ({ value: i[field9], weight: Math.abs(i[weightField]) }))
33009
33661
  );
33010
33662
  return {
33011
33663
  apr: wa("apr", "nav"),
@@ -34744,8 +35396,8 @@ var TIMEOUT_MS = 8e3;
34744
35396
  var slisBnbFetcher = {
34745
35397
  label: "SLISBNB",
34746
35398
  fetch: async () => {
34747
- const nowSec5 = Math.floor(Date.now() / 1e3);
34748
- const url = `${HISTORY_URL}?name=slisBNBRate&cycle=1&startTime=${nowSec5 - LOOKBACK_SECONDS}&endTime=${nowSec5}`;
35399
+ const nowSec7 = Math.floor(Date.now() / 1e3);
35400
+ const url = `${HISTORY_URL}?name=slisBNBRate&cycle=1&startTime=${nowSec7 - LOOKBACK_SECONDS}&endTime=${nowSec7}`;
34749
35401
  const controller = new AbortController();
34750
35402
  const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
34751
35403
  try {
@@ -39025,6 +39677,84 @@ var riverFetcher = {
39025
39677
  parse: parseRiverResults,
39026
39678
  getAbi: getRiverAbi
39027
39679
  };
39680
+ function getTellerCalls(chainId) {
39681
+ const pools = tellerPoolsByChain(chainId);
39682
+ if (pools.length === 0) return [];
39683
+ const results = [];
39684
+ for (const p of pools) {
39685
+ if (!p.pool || !p.principal || !p.collateral) continue;
39686
+ const onePrincipal = 10n ** BigInt(p.principalDecimals);
39687
+ const calls = [
39688
+ {
39689
+ address: p.pool,
39690
+ name: "calculateCollateralTokensAmountEquivalentToPrincipalTokens",
39691
+ params: [onePrincipal]
39692
+ }
39693
+ ];
39694
+ results.push({
39695
+ calls,
39696
+ meta: {
39697
+ pool: p.pool.toLowerCase(),
39698
+ principal: p.principal.toLowerCase(),
39699
+ principalDecimals: p.principalDecimals,
39700
+ collateral: p.collateral.toLowerCase(),
39701
+ collateralDecimals: p.collateralDecimals
39702
+ },
39703
+ lender: tellerLenderKey(p.pool)
39704
+ });
39705
+ }
39706
+ return results;
39707
+ }
39708
+ function parseTellerResults(data, meta, context) {
39709
+ const { chainId, usdPrices, tokenList } = context;
39710
+ const entries = [];
39711
+ const principal = meta.principal;
39712
+ const collateral = meta.collateral;
39713
+ const lenderKey = tellerLenderKey(meta.pool);
39714
+ const principalOracleKey = tokenList?.[principal]?.assetGroup ?? `${chainId}-${principal}`;
39715
+ const principalUSD = usdPrices[principalOracleKey] ?? usdPrices[principal];
39716
+ if (!principalUSD) return entries;
39717
+ entries.push({
39718
+ asset: principal,
39719
+ price: 1,
39720
+ priceUSD: principalUSD,
39721
+ marketUid: createMarketUid(chainId, lenderKey, principal),
39722
+ targetLender: lenderKey,
39723
+ description: "Teller principal asset",
39724
+ staticBase: true,
39725
+ baseAsset: principal
39726
+ });
39727
+ const rawCollateral = data?.[0];
39728
+ if (rawCollateral == null || rawCollateral === "0x") return entries;
39729
+ let equivalent;
39730
+ try {
39731
+ equivalent = BigInt(rawCollateral);
39732
+ } catch {
39733
+ return entries;
39734
+ }
39735
+ if (equivalent <= 0n) return entries;
39736
+ const collateralDecimals = meta.collateralDecimals ?? tokenList?.[collateral]?.decimals ?? 18;
39737
+ const priceCollateralInPrincipal = 10 ** collateralDecimals / Number(equivalent);
39738
+ if (!(priceCollateralInPrincipal > 0)) return entries;
39739
+ entries.push({
39740
+ asset: collateral,
39741
+ price: priceCollateralInPrincipal,
39742
+ // raw: collateral price in principal terms
39743
+ priceUSD: priceCollateralInPrincipal * principalUSD,
39744
+ marketUid: createMarketUid(chainId, lenderKey, collateral),
39745
+ targetLender: lenderKey,
39746
+ baseAsset: principal
39747
+ });
39748
+ return entries;
39749
+ }
39750
+ function getTellerAbi() {
39751
+ return LenderCommitmentGroupAbi;
39752
+ }
39753
+ var tellerFetcher = {
39754
+ getCalls: getTellerCalls,
39755
+ parse: parseTellerResults,
39756
+ getAbi: getTellerAbi
39757
+ };
39028
39758
  var CompoundV2OracleAbi = [
39029
39759
  {
39030
39760
  inputs: [{ internalType: "address", name: "cToken", type: "address" }],
@@ -40640,6 +41370,11 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40640
41370
  () => riverFetcher.getCalls(chainId),
40641
41371
  getCallsErrors
40642
41372
  ) : [];
41373
+ const tellerResults = isActive("teller") ? safeGetCalls(
41374
+ "teller",
41375
+ () => tellerFetcher.getCalls(chainId),
41376
+ getCallsErrors
41377
+ ) : [];
40643
41378
  const siloV2Results = isActive("silov2") ? safeGetCalls(
40644
41379
  "siloV2",
40645
41380
  () => siloV2Fetcher.getCalls(chainId),
@@ -40737,6 +41472,12 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40737
41472
  riverFetcher.parse,
40738
41473
  getRiverAbi()
40739
41474
  );
41475
+ const tellerGroup = buildGroup(
41476
+ "teller",
41477
+ tellerResults,
41478
+ tellerFetcher.parse,
41479
+ getTellerAbi()
41480
+ );
40740
41481
  const siloV2Group = buildGroup(
40741
41482
  "siloV2",
40742
41483
  siloV2Results,
@@ -40780,6 +41521,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40780
41521
  termGroup,
40781
41522
  liquityGroup,
40782
41523
  riverGroup,
41524
+ tellerGroup,
40783
41525
  siloV2Group,
40784
41526
  siloV3Group,
40785
41527
  fluidGroup,
@@ -40820,6 +41562,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40820
41562
  termData,
40821
41563
  liquityData,
40822
41564
  riverData,
41565
+ tellerData,
40823
41566
  morphoGqlEntries,
40824
41567
  siloV2GqlEntries,
40825
41568
  siloV3GqlEntries
@@ -40936,6 +41679,14 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40936
41679
  allowFailure,
40937
41680
  rpcOverrides
40938
41681
  ),
41682
+ executeGroup(
41683
+ tellerGroup,
41684
+ chainId,
41685
+ chainBatchSize,
41686
+ retries,
41687
+ allowFailure,
41688
+ rpcOverrides
41689
+ ),
40939
41690
  morphoGqlPromise,
40940
41691
  siloV2GqlPromise,
40941
41692
  siloV3GqlPromise
@@ -40987,6 +41738,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40987
41738
  { group: gearboxV3Group, data: gearboxV3Data },
40988
41739
  { group: dolomiteGroup, data: dolomiteData },
40989
41740
  { group: midnightGroup, data: midnightData },
41741
+ { group: tellerGroup, data: tellerData },
40990
41742
  ...siloV2GqlEntries != null ? [] : [{ group: siloV2Group, data: siloV2Data }],
40991
41743
  ...siloV3GqlEntries != null ? [] : [{ group: siloV3Group, data: siloV3Data }],
40992
41744
  // In hybrid mode the on-chain multicall ran too — surface its errors.
@@ -41185,6 +41937,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
41185
41937
  parseTrackers(morphoGroup, morphoData.results, false);
41186
41938
  }
41187
41939
  parseTrackers(midnightGroup, midnightData.results, false);
41940
+ parseTrackers(tellerGroup, tellerData.results, false);
41188
41941
  const totalFailedCalls = trackerDiags.reduce(
41189
41942
  (sum, d) => sum + d.failedCalls,
41190
41943
  0
@@ -41350,10 +42103,10 @@ function createAssetArrayPerChain() {
41350
42103
  return assetsPerChain;
41351
42104
  }
41352
42105
  var RELEVANT_LENDING_ASSETS = () => createAssetArrayPerChain();
41353
- function createSimpleArrayPerChain(fork, field8 = void 0) {
42106
+ function createSimpleArrayPerChain(fork, field9 = void 0) {
41354
42107
  let pools = {};
41355
42108
  Object.entries(fork ?? {}).forEach(([b2, data]) => {
41356
- Object.entries(field8 ? data[field8] : data).forEach(
42109
+ Object.entries(field9 ? data[field9] : data).forEach(
41357
42110
  ([chainId, address]) => {
41358
42111
  if (!pools[chainId]) pools[chainId] = [];
41359
42112
  pools[chainId] = uniq2([...pools[chainId], { address, pool: b2 }]);
@@ -43562,9 +44315,9 @@ query EvkByAssets($assets: [Bytes!]!) {
43562
44315
  `;
43563
44316
  var ZERO = 0n;
43564
44317
  var RAY_TO_PERCENT3 = 1e25;
43565
- function readAddress2(field8) {
43566
- if (!field8) return void 0;
43567
- return field8.toLowerCase();
44318
+ function readAddress2(field9) {
44319
+ if (!field9) return void 0;
44320
+ return field9.toLowerCase();
43568
44321
  }
43569
44322
  function parseVaultFee(v) {
43570
44323
  if (v.performanceFee == null) return 0;
@@ -50584,23 +51337,23 @@ var priceGmMarkets = async (chainId, multicallRetry, markets, prices) => {
50584
51337
  const indexMax = price(prices, m.indexToken)?.max;
50585
51338
  if (Array.isArray(dsRes) && longMax != null && shortMax != null) {
50586
51339
  const base = i * SLOTS;
50587
- const big3 = (j) => typeof dsRes[base + j] === "bigint" ? dsRes[base + j] : 0n;
51340
+ const big4 = (j) => typeof dsRes[base + j] === "bigint" ? dsRes[base + j] : 0n;
50588
51341
  const cap = computeDepositCapacityUsd(
50589
- [info?.longTokenAmount, longMax, big3(0), big3(2)],
50590
- [info?.shortTokenAmount, shortMax, big3(1), big3(3)]
51342
+ [info?.longTokenAmount, longMax, big4(0), big4(2)],
51343
+ [info?.shortTokenAmount, shortMax, big4(1), big4(3)]
50591
51344
  );
50592
51345
  if (cap != null) value.depositCapacityUsd = cap;
50593
51346
  if (indexMax != null) {
50594
51347
  const divisor = m.longToken.toLowerCase() === m.shortToken.toLowerCase() ? 2n : 1n;
50595
- const reservedUsdLong = (big3(4) + big3(5)) / divisor * indexMax;
50596
- const reservedUsdShort = (big3(6) + big3(7)) / divisor;
51348
+ const reservedUsdLong = (big4(4) + big4(5)) / divisor * indexMax;
51349
+ const reservedUsdShort = (big4(6) + big4(7)) / divisor;
50597
51350
  const liq = computeLiquidityUsd(
50598
51351
  info?.longTokenUsd,
50599
51352
  info?.shortTokenUsd,
50600
51353
  reservedUsdLong,
50601
51354
  reservedUsdShort,
50602
- big3(8),
50603
- big3(9)
51355
+ big4(8),
51356
+ big4(9)
50604
51357
  );
50605
51358
  if (liq != null)
50606
51359
  value.liquidityUsd = Math.max(0, Math.min(liq, value.tvlUsd));
@@ -50799,21 +51552,21 @@ var fetchGmxExecutionFees = async (chainId, multicallRetry, gasPriceWei) => {
50799
51552
  } catch {
50800
51553
  return void 0;
50801
51554
  }
50802
- const big3 = (i) => typeof res[i] === "bigint" ? res[i] : 0n;
50803
- const base = big3(0);
50804
- const mult = big3(1);
51555
+ const big4 = (i) => typeof res[i] === "bigint" ? res[i] : 0n;
51556
+ const base = big4(0);
51557
+ const mult = big4(1);
50805
51558
  if (base === 0n && mult === 0n) return void 0;
50806
51559
  const PRECISION = 10n ** 30n;
50807
51560
  const adjusted = (opGas) => base + opGas * mult / PRECISION;
50808
51561
  const fee = (opGas) => (adjusted(opGas) * gasPriceWei).toString();
50809
- const glvExtra = big3(6) * GLV_NOMINAL_MARKET_COUNT;
51562
+ const glvExtra = big4(6) * GLV_NOMINAL_MARKET_COUNT;
50810
51563
  return {
50811
51564
  chainId,
50812
51565
  gasPriceWei: gasPriceWei.toString(),
50813
- deposit: fee(big3(2)),
50814
- withdrawal: fee(big3(3)),
50815
- glvDeposit: fee(big3(4) + glvExtra),
50816
- glvWithdrawal: fee(big3(5) + glvExtra)
51566
+ deposit: fee(big4(2)),
51567
+ withdrawal: fee(big4(3)),
51568
+ glvDeposit: fee(big4(4) + glvExtra),
51569
+ glvWithdrawal: fee(big4(5) + glvExtra)
50817
51570
  };
50818
51571
  };
50819
51572
 
@@ -52019,6 +52772,6 @@ async function fetchTokenBalances(chainId, account, tokens, options = {}) {
52019
52772
  return parseTokenBalanceResult(rawResult, prepared.query);
52020
52773
  }
52021
52774
 
52022
- export { ApiBookSource, DEFAULT_MIDNIGHT_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, 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, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyVault, 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, convertExactlyMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertRiverMarketsToResponse, convertTermMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, detectInterfaceKinds, encodeBalanceFetcherCalldata, exactlyLenderKey, exactlyMarketFromLenderKey, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, fetchDolomiteAccountNumbers, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendlePrices, fetchRiverMarkets, fetchSiloVaults, fetchTermMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedLiquityTroves, 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, isStablecoinSymbol, isYearnV3, keysFromMaps, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseMergedResult, parseMulticallRpcResponses, parseRawRpcBatchResponses, parseRawRpcResponses, parseTokenBalanceResult, positivePart2 as positivePart, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, readVaultSharePrices, resolveStCeloDepositGroup, riverKeyParts, riverLenderKey, selectAssetGroupPrices, stampVaultClassification, termLenderKey, tickToAprNumber, tickToPrice, unflattenLenderData };
52775
+ export { ApiBookSource, DEFAULT_MIDNIGHT_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, 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, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyVault, 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, convertExactlyMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, detectInterfaceKinds, encodeBalanceFetcherCalldata, exactlyLenderKey, exactlyMarketFromLenderKey, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, fetchDolomiteAccountNumbers, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendlePrices, fetchRiverMarkets, fetchSiloVaults, fetchTellerMarkets, fetchTermMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedLiquityTroves, getCachedTellerBids, 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, isStablecoinSymbol, isYearnV3, keysFromMaps, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseMergedResult, parseMulticallRpcResponses, parseRawRpcBatchResponses, parseRawRpcResponses, parseTokenBalanceResult, positivePart2 as positivePart, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, readVaultSharePrices, resolveStCeloDepositGroup, riverKeyParts, riverLenderKey, selectAssetGroupPrices, stampVaultClassification, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termLenderKey, tickToAprNumber, tickToPrice, unflattenLenderData };
52023
52776
  //# sourceMappingURL=index.js.map
52024
52777
  //# sourceMappingURL=index.js.map