@1delta/margin-fetcher 0.0.333 → 0.0.335

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 (37) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +821 -55
  4. package/dist/index.js.map +1 -1
  5. package/dist/lending/public-data/fetchLenderAll.d.ts.map +1 -1
  6. package/dist/lending/public-data/fetchLenderExt.d.ts.map +1 -1
  7. package/dist/lending/public-data/midnight/convertPublic.d.ts.map +1 -1
  8. package/dist/lending/public-data/teller/convertPublic.d.ts +32 -0
  9. package/dist/lending/public-data/teller/convertPublic.d.ts.map +1 -0
  10. package/dist/lending/public-data/teller/fetchPublic.d.ts +16 -0
  11. package/dist/lending/public-data/teller/fetchPublic.d.ts.map +1 -0
  12. package/dist/lending/public-data/teller/index.d.ts +5 -0
  13. package/dist/lending/public-data/teller/index.d.ts.map +1 -0
  14. package/dist/lending/public-data/teller/math.d.ts +18 -0
  15. package/dist/lending/public-data/teller/math.d.ts.map +1 -0
  16. package/dist/lending/public-data/teller/types.d.ts +37 -0
  17. package/dist/lending/public-data/teller/types.d.ts.map +1 -0
  18. package/dist/lending/user-data/abis.d.ts.map +1 -1
  19. package/dist/lending/user-data/fetch-balances/parse.d.ts.map +1 -1
  20. package/dist/lending/user-data/fetch-balances/prepare.d.ts.map +1 -1
  21. package/dist/lending/user-data/teller/index.d.ts +3 -0
  22. package/dist/lending/user-data/teller/index.d.ts.map +1 -0
  23. package/dist/lending/user-data/teller/userCallBuild.d.ts +31 -0
  24. package/dist/lending/user-data/teller/userCallBuild.d.ts.map +1 -0
  25. package/dist/lending/user-data/teller/userCallParse.d.ts +22 -0
  26. package/dist/lending/user-data/teller/userCallParse.d.ts.map +1 -0
  27. package/dist/prices/oracle-prices/fetchOraclePrices.d.ts +2 -2
  28. package/dist/prices/oracle-prices/fetchOraclePrices.d.ts.map +1 -1
  29. package/dist/prices/oracle-prices/fetchers/index.d.ts +1 -0
  30. package/dist/prices/oracle-prices/fetchers/index.d.ts.map +1 -1
  31. package/dist/prices/oracle-prices/fetchers/teller.d.ts +413 -0
  32. package/dist/prices/oracle-prices/fetchers/teller.d.ts.map +1 -0
  33. package/dist/types/lenderTypes.d.ts +1 -1
  34. package/dist/types/lenderTypes.d.ts.map +1 -1
  35. package/dist/utils/index.d.ts +1 -1
  36. package/dist/utils/index.d.ts.map +1 -1
  37. package/package.json +8 -8
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
  })
@@ -21297,20 +21300,25 @@ function convertMidnightMarketsToResponse(raw, chainId, prices = {}, _additional
21297
21300
  const cursor = toBigIntOr0(c.liquidationCursor);
21298
21301
  const liquidationPenalty = cursor > 0n ? midnightLiquidationPenaltyNumber(toBigIntOr0(c.lltv), cursor) : liquidationPenaltyFromLltv(ltv);
21299
21302
  const collUid = createMarketUid(chainId, m, collAddr);
21303
+ const collAsset = tokens[collAddr];
21304
+ const collKey = toOracleKey(collAsset?.assetGroup) || toGenericPriceKey(collAddr, chainId);
21305
+ const collPrice = prices[collKey] ?? 0;
21306
+ const collCapacityUSD = ltv > 0 ? borrowLiquidity * loanPrice / ltv : borrowLiquidity * loanPrice;
21307
+ const collCapacity = collPrice > 0 ? collCapacityUSD / collPrice : 0;
21300
21308
  entry.data[collUid] = {
21301
21309
  marketUid: collUid,
21302
21310
  name: "Collateral " + (tokens[collAddr]?.symbol ?? ""),
21303
21311
  poolId: collAddr,
21304
21312
  underlying: collAddr,
21305
21313
  asset: currencyFor(collAddr, c.decimals, tokens),
21306
- totalDeposits: 0,
21314
+ totalDeposits: collCapacity,
21307
21315
  totalDebtStable: 0,
21308
21316
  totalDebt: 0,
21309
- totalLiquidity: 0,
21317
+ totalLiquidity: collCapacity,
21310
21318
  borrowLiquidity: 0,
21311
- totalLiquidityUSD: 0,
21319
+ totalLiquidityUSD: collCapacityUSD,
21312
21320
  borrowLiquidityUSD: 0,
21313
- totalDepositsUSD: 0,
21321
+ totalDepositsUSD: collCapacityUSD,
21314
21322
  totalDebtStableUSD: 0,
21315
21323
  totalDebtUSD: 0,
21316
21324
  utilization: 0,
@@ -21618,7 +21626,7 @@ function createTermBookSource(chainId, fetchImpl = fetch) {
21618
21626
  var TERM_BOOK_LEVELS = 20;
21619
21627
  var LKG_TTL_SEC2 = 30 * 60;
21620
21628
  var lastGood2 = /* @__PURE__ */ new Map();
21621
- async function fetchTopAndBookWithFallback2(source, chainId, config, nowSec5) {
21629
+ async function fetchTopAndBookWithFallback2(source, chainId, config, nowSec7) {
21622
21630
  const key = `${chainId}:${config.termRepoId}`;
21623
21631
  let fresh = null;
21624
21632
  if (source.getTopAndBook) {
@@ -21628,11 +21636,11 @@ async function fetchTopAndBookWithFallback2(source, chainId, config, nowSec5) {
21628
21636
  if (top) fresh = { top, book: { bids: [], asks: [] } };
21629
21637
  }
21630
21638
  if (fresh) {
21631
- lastGood2.set(key, { top: fresh.top, book: fresh.book, at: nowSec5 });
21639
+ lastGood2.set(key, { top: fresh.top, book: fresh.book, at: nowSec7 });
21632
21640
  return { top: fresh.top, book: fresh.book };
21633
21641
  }
21634
21642
  const cached = lastGood2.get(key);
21635
- if (cached && nowSec5 - cached.at <= LKG_TTL_SEC2) {
21643
+ if (cached && nowSec7 - cached.at <= LKG_TTL_SEC2) {
21636
21644
  return { top: cached.top, book: cached.book };
21637
21645
  }
21638
21646
  return { top: null, book: null };
@@ -21640,17 +21648,17 @@ async function fetchTopAndBookWithFallback2(source, chainId, config, nowSec5) {
21640
21648
  async function fetchTermMarkets(chainId, source = createTermBookSource(chainId)) {
21641
21649
  const markets = termMarketsByChain(chainId);
21642
21650
  if (markets.length === 0) return [];
21643
- const nowSec5 = Math.floor(Date.now() / 1e3);
21651
+ const nowSec7 = Math.floor(Date.now() / 1e3);
21644
21652
  return Promise.all(
21645
21653
  markets.map(async (config) => {
21646
- if (Number(config.maturity) <= nowSec5) {
21654
+ if (Number(config.maturity) <= nowSec7) {
21647
21655
  return { config, top: null, book: null };
21648
21656
  }
21649
21657
  const { top, book } = await fetchTopAndBookWithFallback2(
21650
21658
  source,
21651
21659
  chainId,
21652
21660
  config,
21653
- nowSec5
21661
+ nowSec7
21654
21662
  );
21655
21663
  return { config, top, book };
21656
21664
  })
@@ -22658,6 +22666,376 @@ function convertRiverMarketsToResponse(raw, chainId, prices = {}, _additionalYie
22658
22666
  }
22659
22667
  return out;
22660
22668
  }
22669
+ var READS_PER_POOL = 7;
22670
+ var READS_PER_MARKET = 2;
22671
+ async function fetchTellerMarkets(chainId) {
22672
+ const pools = tellerPoolsByChain(chainId);
22673
+ if (pools.length === 0) return { chainId, pools: [] };
22674
+ const marketRegistry = tellerConfigByChain(chainId)?.marketRegistry;
22675
+ const calls = pools.flatMap((p) => {
22676
+ const onePrincipal = 10n ** BigInt(p.principalDecimals);
22677
+ return [
22678
+ { address: p.pool, name: "getPrincipalAmountAvailableToBorrow", params: [] },
22679
+ { address: p.pool, name: "totalPrincipalTokensCommitted", params: [] },
22680
+ { address: p.pool, name: "getMinInterestRate", params: [0n] },
22681
+ {
22682
+ address: p.pool,
22683
+ name: "calculateCollateralRequiredToBorrowPrincipal",
22684
+ params: [onePrincipal]
22685
+ },
22686
+ { address: p.pool, name: "getMaxLoanDuration", params: [] },
22687
+ { address: p.pool, name: "getMarketId", params: [] },
22688
+ // ERC-4626 CURRENT principal TVL (V2/V3). `totalPrincipalTokensCommitted`
22689
+ // is a CUMULATIVE lifetime counter, NOT the current balance — using it
22690
+ // overstates deposits by orders of magnitude. `totalAssets` reverts on V1
22691
+ // Smart pools (→ null), where we fall back to the committed counter.
22692
+ { address: p.pool, name: "totalAssets", params: [] }
22693
+ ];
22694
+ });
22695
+ let results = [];
22696
+ try {
22697
+ results = await multicallRetryUniversal({
22698
+ chain: chainId,
22699
+ calls,
22700
+ abi: LenderCommitmentGroupAbi,
22701
+ allowFailure: true
22702
+ });
22703
+ } catch {
22704
+ return { chainId, pools: [] };
22705
+ }
22706
+ const big4 = (i) => {
22707
+ const r = results[i];
22708
+ if (typeof r === "bigint") return r;
22709
+ if (typeof r === "number") return BigInt(r);
22710
+ if (typeof r === "string" && r !== "0x") {
22711
+ try {
22712
+ return BigInt(r);
22713
+ } catch {
22714
+ return null;
22715
+ }
22716
+ }
22717
+ return null;
22718
+ };
22719
+ const num6 = (i) => {
22720
+ const b = big4(i);
22721
+ return b === null ? null : Number(b);
22722
+ };
22723
+ const pool0 = pools.map((config, i) => {
22724
+ const base = i * READS_PER_POOL;
22725
+ return {
22726
+ config,
22727
+ available: big4(base),
22728
+ committed: big4(base + 1),
22729
+ minRateBps: num6(base + 2),
22730
+ collateralPerPrincipal: big4(base + 3),
22731
+ maxLoanDuration: num6(base + 4),
22732
+ marketId: big4(base + 5),
22733
+ totalAssets: big4(base + 6)
22734
+ };
22735
+ });
22736
+ const attByMarket = /* @__PURE__ */ new Map();
22737
+ if (marketRegistry) {
22738
+ const uniqueMarkets = [
22739
+ ...new Set(
22740
+ pool0.map((p) => p.marketId != null ? p.marketId.toString() : null).filter((m) => m != null)
22741
+ )
22742
+ ];
22743
+ if (uniqueMarkets.length > 0) {
22744
+ const mCalls = uniqueMarkets.flatMap((m) => [
22745
+ {
22746
+ address: marketRegistry,
22747
+ name: "getMarketAttestationRequirements",
22748
+ params: [BigInt(m)]
22749
+ },
22750
+ { address: marketRegistry, name: "isMarketOpen", params: [BigInt(m)] }
22751
+ ]);
22752
+ try {
22753
+ const mRes = await multicallRetryUniversal({
22754
+ chain: chainId,
22755
+ calls: mCalls,
22756
+ abi: TellerMarketRegistryAbi,
22757
+ allowFailure: true
22758
+ });
22759
+ uniqueMarkets.forEach((m, i) => {
22760
+ const att = mRes[i * READS_PER_MARKET];
22761
+ const open = mRes[i * READS_PER_MARKET + 1];
22762
+ const borrowerRequired = (att?.borrowerAttestationRequired ?? att?.[1]) === true;
22763
+ attByMarket.set(m, {
22764
+ requiresBorrowerAttestation: borrowerRequired,
22765
+ marketOpen: open === false ? false : true
22766
+ });
22767
+ });
22768
+ } catch {
22769
+ }
22770
+ }
22771
+ }
22772
+ const out = pool0.map((p) => {
22773
+ const att = p.marketId != null ? attByMarket.get(p.marketId.toString()) : void 0;
22774
+ return {
22775
+ ...p,
22776
+ requiresBorrowerAttestation: att?.requiresBorrowerAttestation,
22777
+ marketOpen: att?.marketOpen
22778
+ };
22779
+ });
22780
+ return { chainId, pools: out };
22781
+ }
22782
+
22783
+ // src/lending/public-data/teller/math.ts
22784
+ function tellerBpsToPercent(bps) {
22785
+ if (!bps) return 0;
22786
+ return bps / 100;
22787
+ }
22788
+ function tellerToHuman(raw, decimals) {
22789
+ if (!raw) return 0;
22790
+ return Number(raw) / 10 ** decimals;
22791
+ }
22792
+ function tellerImpliedLtv(collateralPerPrincipal, collateralDecimals, principalPrice, collateralPrice) {
22793
+ if (!collateralPerPrincipal || principalPrice <= 0 || collateralPrice <= 0) return 0;
22794
+ const collHuman = Number(collateralPerPrincipal) / 10 ** collateralDecimals;
22795
+ const collateralValue = collHuman * collateralPrice;
22796
+ if (collateralValue <= 0) return 0;
22797
+ const ltv = principalPrice / collateralValue;
22798
+ return ltv > 0 && ltv < 1 ? ltv : ltv >= 1 ? 1 : 0;
22799
+ }
22800
+
22801
+ // src/lending/public-data/teller/convertPublic.ts
22802
+ function tellerLenderKey(pool) {
22803
+ const body = pool.startsWith("0x") ? pool.slice(2) : pool;
22804
+ return "TELLER_" + body.toUpperCase();
22805
+ }
22806
+ function tellerPoolFromLenderKey(lender) {
22807
+ if (!lender.startsWith("TELLER_")) return void 0;
22808
+ const body = lender.slice("TELLER_".length);
22809
+ return body.length === 40 ? "0x" + body.toLowerCase() : void 0;
22810
+ }
22811
+ function currencyFor6(address, decimals, symbol, tokens) {
22812
+ const lower = address.toLowerCase();
22813
+ return tokens[lower] ?? { address: lower, symbol, name: symbol, decimals };
22814
+ }
22815
+ function priceFor(address, chainId, tokens, prices) {
22816
+ const lower = address.toLowerCase();
22817
+ const token = tokens[lower];
22818
+ const key = toOracleKey(token?.assetGroup) || toGenericPriceKey(lower, chainId);
22819
+ return prices[key] ?? 0;
22820
+ }
22821
+ function convertTellerMarketsToResponse(raw, chainId, prices = {}, _additionalYields = {
22822
+ intrinsicYields: {},
22823
+ lenderRewards: {},
22824
+ loaded: true
22825
+ }, tokens = {}) {
22826
+ const out = {};
22827
+ const proto = tellerConfigByChain(chainId);
22828
+ for (const p of raw?.pools ?? []) {
22829
+ const cfg = p.config;
22830
+ const lenderKey = tellerLenderKey(cfg.pool);
22831
+ const principalAddr = cfg.principal.toLowerCase();
22832
+ const collateralAddr = cfg.collateral.toLowerCase();
22833
+ const principalPrice = priceFor(principalAddr, chainId, tokens, prices);
22834
+ const collateralPrice = priceFor(collateralAddr, chainId, tokens, prices);
22835
+ const borrowLiquidity = tellerToHuman(p.available, cfg.principalDecimals);
22836
+ const totalDeposits = tellerToHuman(
22837
+ p.totalAssets ?? p.committed,
22838
+ cfg.principalDecimals
22839
+ );
22840
+ const totalDebt = Math.max(0, totalDeposits - borrowLiquidity);
22841
+ const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : 0;
22842
+ const borrowApr = tellerBpsToPercent(p.minRateBps);
22843
+ const depositApr = utilization * borrowApr;
22844
+ const ltv = tellerImpliedLtv(
22845
+ p.collateralPerPrincipal,
22846
+ cfg.collateralDecimals,
22847
+ principalPrice,
22848
+ collateralPrice
22849
+ );
22850
+ const durationSecs = p.maxLoanDuration ?? cfg.maxLoanDuration ?? 0;
22851
+ const terms = [
22852
+ {
22853
+ // Rolling duration → use the max duration as the (stable) term id.
22854
+ termId: durationSecs,
22855
+ durationSecs,
22856
+ durationDays: durationSecs / 86400,
22857
+ apr: borrowApr,
22858
+ depositApr,
22859
+ available: borrowLiquidity
22860
+ }
22861
+ ];
22862
+ const entry = { data: {} };
22863
+ const loanUid = createMarketUid(chainId, lenderKey, principalAddr);
22864
+ entry.data[loanUid] = {
22865
+ marketUid: loanUid,
22866
+ name: cfg.principalSymbol,
22867
+ poolId: cfg.pool.toLowerCase(),
22868
+ underlying: principalAddr,
22869
+ asset: currencyFor6(
22870
+ principalAddr,
22871
+ cfg.principalDecimals,
22872
+ cfg.principalSymbol,
22873
+ tokens
22874
+ ),
22875
+ totalDeposits,
22876
+ totalDebtStable: totalDebt,
22877
+ totalDebt: 0,
22878
+ totalLiquidity: borrowLiquidity,
22879
+ borrowLiquidity,
22880
+ totalLiquidityUSD: borrowLiquidity * principalPrice,
22881
+ borrowLiquidityUSD: borrowLiquidity * principalPrice,
22882
+ totalDepositsUSD: totalDeposits * principalPrice,
22883
+ totalDebtStableUSD: totalDebt * principalPrice,
22884
+ totalDebtUSD: 0,
22885
+ utilization,
22886
+ depositRate: depositApr,
22887
+ // Teller has NO floating leg — the fixed borrow APR sits on the stable slot
22888
+ // (fixed-rate convention: Exactly/Term/Lista), variable stays 0.
22889
+ variableBorrowRate: 0,
22890
+ stableBorrowRate: borrowApr,
22891
+ rateModel: "fixedTerm",
22892
+ intrinsicYield: 0,
22893
+ rewards: void 0,
22894
+ decimals: cfg.principalDecimals,
22895
+ config: {
22896
+ 0: {
22897
+ category: 0,
22898
+ // Principal token is the borrow asset, not collateral in this pool.
22899
+ borrowCollateralFactor: 0,
22900
+ collateralFactor: 0,
22901
+ borrowFactor: 1,
22902
+ liquidationPenalty: 0,
22903
+ closeFactor: 1,
22904
+ collateralDisabled: true,
22905
+ debtDisabled: false
22906
+ }
22907
+ },
22908
+ closeFactor: 1,
22909
+ collateralActive: false,
22910
+ // Open markets with live liquidity are borrowable; attestation-gated
22911
+ // markets stay borrowable here (flagged in the descriptor) — the per-user
22912
+ // gate runs at borrow time.
22913
+ borrowingEnabled: borrowLiquidity > 0 && p.marketOpen !== false,
22914
+ depositsEnabled: true,
22915
+ hasStable: false,
22916
+ variableBorrowDisabled: true,
22917
+ isActive: p.marketOpen !== false,
22918
+ isFrozen: p.marketOpen === false
22919
+ };
22920
+ const collUid = createMarketUid(chainId, lenderKey, collateralAddr);
22921
+ entry.data[collUid] = {
22922
+ marketUid: collUid,
22923
+ name: "Collateral " + cfg.collateralSymbol,
22924
+ poolId: cfg.pool.toLowerCase(),
22925
+ underlying: collateralAddr,
22926
+ asset: currencyFor6(
22927
+ collateralAddr,
22928
+ cfg.collateralDecimals,
22929
+ cfg.collateralSymbol,
22930
+ tokens
22931
+ ),
22932
+ totalDeposits: 0,
22933
+ totalDebtStable: 0,
22934
+ totalDebt: 0,
22935
+ totalLiquidity: 0,
22936
+ borrowLiquidity: 0,
22937
+ totalLiquidityUSD: 0,
22938
+ borrowLiquidityUSD: 0,
22939
+ totalDepositsUSD: 0,
22940
+ totalDebtStableUSD: 0,
22941
+ totalDebtUSD: 0,
22942
+ utilization: 0,
22943
+ depositRate: 0,
22944
+ variableBorrowRate: 0,
22945
+ stableBorrowRate: 0,
22946
+ intrinsicYield: 0,
22947
+ rewards: void 0,
22948
+ decimals: cfg.collateralDecimals,
22949
+ config: {
22950
+ 0: {
22951
+ category: 0,
22952
+ borrowCollateralFactor: ltv,
22953
+ collateralFactor: ltv,
22954
+ borrowFactor: 1,
22955
+ // Time-based liquidation → no price-based penalty parameter.
22956
+ liquidationPenalty: 0,
22957
+ closeFactor: 1,
22958
+ collateralDisabled: false,
22959
+ debtDisabled: true
22960
+ }
22961
+ },
22962
+ closeFactor: 1,
22963
+ collateralActive: true,
22964
+ borrowingEnabled: false,
22965
+ depositsEnabled: true,
22966
+ hasStable: false,
22967
+ isActive: true,
22968
+ isFrozen: false
22969
+ };
22970
+ const implications = [
22971
+ "Fixed-term, fixed-APR loan: the rate is locked at borrow time for a duration you choose (up to the pool max).",
22972
+ "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.",
22973
+ "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)."
22974
+ ];
22975
+ if (p.requiresBorrowerAttestation)
22976
+ implications.push(
22977
+ "This market requires borrower ATTESTATION \u2014 the borrower must be whitelisted by the market owner before borrowing."
22978
+ );
22979
+ if (p.marketOpen === false)
22980
+ implications.push("This market is currently CLOSED (not borrowable).");
22981
+ entry.params = {
22982
+ market: {
22983
+ lender: lenderKey,
22984
+ name: cfg.name ?? `Teller ${cfg.principalSymbol} / ${cfg.collateralSymbol}`,
22985
+ loanDecimals: cfg.principalDecimals,
22986
+ collateralDecimals: cfg.collateralDecimals,
22987
+ // Pool address doubles as the market id (it IS the lender-key body).
22988
+ id: cfg.pool.toLowerCase(),
22989
+ lltv: ltv.toString(),
22990
+ oracle: zeroAddress,
22991
+ irm: zeroAddress,
22992
+ collateralAddress: collateralAddr,
22993
+ loanAddress: principalAddr,
22994
+ terms,
22995
+ // Canonical cross-protocol fixed-term descriptor. Teller: rolling
22996
+ // duration (≤ maxLoanDuration), pool-fronted fixed APR, early repay =
22997
+ // NONE (full early repay is pro-rata, penalty-free), overdue handling is
22998
+ // time-based default/seizure (no late-penalty APR).
22999
+ fixedTerm: {
23000
+ model: "teller",
23001
+ maturity: void 0,
23002
+ fees: {},
23003
+ earlyRepay: { kind: "none" },
23004
+ provider: { kind: "pool", address: cfg.pool.toLowerCase() }
23005
+ },
23006
+ // --- Teller descriptor (addresses + config the calldata/worker
23007
+ // resolvers consume; mirrors river's `river` / exactly's extras) ---
23008
+ teller: {
23009
+ pool: cfg.pool.toLowerCase(),
23010
+ // On-chain marketId is authoritative; fall back to the config seed.
23011
+ marketId: p.marketId != null ? p.marketId.toString() : cfg.marketId,
23012
+ maxLoanDuration: durationSecs,
23013
+ // Permissioning: some markets only let PRE-ATTESTED borrowers open
23014
+ // loans (the borrow builder enforces per-user; this flags it for the
23015
+ // UI/allocator). `marketOpen` = MarketRegistry.isMarketOpen.
23016
+ requiresBorrowerAttestation: p.requiresBorrowerAttestation,
23017
+ marketOpen: p.marketOpen,
23018
+ /** Human-readable caveats for the UI to surface (see above). */
23019
+ implications,
23020
+ minInterestRateBps: p.minRateBps ?? void 0,
23021
+ interestRateLowerBound: cfg.interestRateLowerBound ?? void 0,
23022
+ interestRateUpperBound: cfg.interestRateUpperBound ?? void 0,
23023
+ principalAvailable: p.available !== null ? p.available.toString() : void 0,
23024
+ collateralPerPrincipal: p.collateralPerPrincipal !== null ? p.collateralPerPrincipal.toString() : void 0,
23025
+ addresses: {
23026
+ tellerV2: proto?.tellerV2,
23027
+ collateralManager: proto?.collateralManager,
23028
+ smartCommitmentForwarder: proto?.smartCommitmentForwarder,
23029
+ marketRegistry: proto?.marketRegistry
23030
+ }
23031
+ }
23032
+ }
23033
+ };
23034
+ entry.chainId = chainId;
23035
+ out[lenderKey] = entry;
23036
+ }
23037
+ return out;
23038
+ }
22661
23039
 
22662
23040
  // src/lending/public-data/silo-v2/fetchPublic.ts
22663
23041
  var BASE_URL2 = "https://api-v3.silo.finance";
@@ -23265,6 +23643,7 @@ async function getLenderDataFromApi(lender, chainId, prices, additionalYields, i
23265
23643
  if (isExactly(lender)) return await fetchExactlyMarkets(chainId);
23266
23644
  if (isLiquityFamily(lender)) return await fetchLiquityMarkets(lender, chainId);
23267
23645
  if (isRiver(lender)) return await fetchRiverMarkets(lender, chainId);
23646
+ if (isTeller(lender)) return await fetchTellerMarkets(chainId);
23268
23647
  return {};
23269
23648
  }
23270
23649
  function convertLenderDataFromApi(lender, chainId, data, prices, additionalYields, list = {}) {
@@ -23310,6 +23689,14 @@ function convertLenderDataFromApi(lender, chainId, data, prices, additionalYield
23310
23689
  additionalYields,
23311
23690
  list
23312
23691
  );
23692
+ if (isTeller(lender))
23693
+ return convertTellerMarketsToResponse(
23694
+ data,
23695
+ chainId,
23696
+ prices,
23697
+ additionalYields,
23698
+ list
23699
+ );
23313
23700
  return {};
23314
23701
  }
23315
23702
  var getLenderPublicDataViaApi = async (chainId, lenders, prices, additionalYields, tokenList = async () => {
@@ -23498,6 +23885,7 @@ function lenderApiOnly(lender, chainId) {
23498
23885
  if (isExactly(lender)) return true;
23499
23886
  if (isLiquityFamily(lender)) return true;
23500
23887
  if (isRiver(lender)) return true;
23888
+ if (isTeller(lender)) return true;
23501
23889
  return false;
23502
23890
  }
23503
23891
  function lenderApiWithOnChainFallback(lender, chainId) {
@@ -24406,6 +24794,103 @@ var buildRiverUserCall = (chainId, lender, account) => {
24406
24794
  });
24407
24795
  return calls;
24408
24796
  };
24797
+ var TELLER_CALLS_PER_BID = 4;
24798
+ var CACHE_TTL_MS2 = 5 * 6e4;
24799
+ var discoveryCache2 = /* @__PURE__ */ new Map();
24800
+ var cacheKey2 = (chainId, account) => `${chainId}:${account.toLowerCase()}`;
24801
+ var getCachedTellerBids = (chainId, account) => {
24802
+ const hit = discoveryCache2.get(cacheKey2(chainId, account));
24803
+ if (!hit || Date.now() - hit.at > CACHE_TTL_MS2) return void 0;
24804
+ return hit;
24805
+ };
24806
+ var nowSec4 = () => Math.floor(Date.now() / 1e3);
24807
+ var toBigints = (arr) => {
24808
+ if (!Array.isArray(arr)) return [];
24809
+ const out = [];
24810
+ for (const x of arr) {
24811
+ try {
24812
+ out.push(BigInt(x).toString());
24813
+ } catch {
24814
+ }
24815
+ }
24816
+ return out;
24817
+ };
24818
+ var buildTellerUserCall = async (chainId, _lender, account) => {
24819
+ const proto = tellerConfigByChain(chainId);
24820
+ const pools = tellerPoolsByChain(chainId);
24821
+ if (!proto?.tellerV2 || !proto?.collateralManager || pools.length === 0) {
24822
+ return [];
24823
+ }
24824
+ let ids = [];
24825
+ try {
24826
+ const res = await multicallRetryUniversal({
24827
+ chain: chainId,
24828
+ calls: [
24829
+ {
24830
+ address: proto.tellerV2,
24831
+ name: "getBorrowerActiveLoanIds",
24832
+ params: [account]
24833
+ }
24834
+ ],
24835
+ abi: TellerV2Abi,
24836
+ allowFailure: true
24837
+ });
24838
+ ids = toBigints(res?.[0]);
24839
+ } catch {
24840
+ return [];
24841
+ }
24842
+ if (ids.length === 0) {
24843
+ discoveryCache2.set(cacheKey2(chainId, account), { bids: [], at: Date.now() });
24844
+ return [];
24845
+ }
24846
+ const poolByAddr = /* @__PURE__ */ new Map();
24847
+ for (const p of pools) poolByAddr.set(p.pool.toLowerCase(), p);
24848
+ let lenders = [];
24849
+ try {
24850
+ lenders = await multicallRetryUniversal({
24851
+ chain: chainId,
24852
+ calls: ids.map((id) => ({
24853
+ address: proto.tellerV2,
24854
+ name: "getLoanLender",
24855
+ params: [id]
24856
+ })),
24857
+ abi: TellerV2Abi,
24858
+ allowFailure: true
24859
+ });
24860
+ } catch {
24861
+ return [];
24862
+ }
24863
+ const kept = [];
24864
+ ids.forEach((id, i) => {
24865
+ const r = lenders[i];
24866
+ const lenderAddr = typeof r === "string" ? r.toLowerCase() : "";
24867
+ const pool = poolByAddr.get(lenderAddr);
24868
+ if (pool) kept.push({ bidId: id, pool });
24869
+ });
24870
+ discoveryCache2.set(cacheKey2(chainId, account), { bids: kept, at: Date.now() });
24871
+ if (kept.length === 0) return [];
24872
+ const ts = nowSec4();
24873
+ const calls = [];
24874
+ for (const b of kept) {
24875
+ calls.push({ address: proto.tellerV2, name: "bids", params: [b.bidId] });
24876
+ calls.push({
24877
+ address: proto.tellerV2,
24878
+ name: "calculateAmountOwed",
24879
+ params: [b.bidId, ts]
24880
+ });
24881
+ calls.push({
24882
+ address: proto.collateralManager,
24883
+ name: "getCollateralAmount",
24884
+ params: [b.bidId, b.pool.collateral]
24885
+ });
24886
+ calls.push({
24887
+ address: proto.tellerV2,
24888
+ name: "isLoanDefaulted",
24889
+ params: [b.bidId]
24890
+ });
24891
+ }
24892
+ return calls;
24893
+ };
24409
24894
 
24410
24895
  // src/lending/user-data/fetch-balances/prepare.ts
24411
24896
  async function buildUserCall(chainId, lender, account, params, getClient) {
@@ -24427,6 +24912,7 @@ async function buildUserCall(chainId, lender, account, params, getClient) {
24427
24912
  if (isLiquityFamily(lender))
24428
24913
  return buildLiquityUserCall(chainId, lender, account);
24429
24914
  if (isRiver(lender)) return buildRiverUserCall(chainId, lender, account);
24915
+ if (isTeller(lender)) return buildTellerUserCall(chainId, lender, account);
24430
24916
  if (isCompoundV3Type(lender))
24431
24917
  return buildCompoundV3UserCall(chainId, lender, account);
24432
24918
  if (isEulerType(lender))
@@ -24453,10 +24939,11 @@ function organizeUserQueries(queries) {
24453
24939
  const exactly = queries.filter((q) => isExactly(q.lender));
24454
24940
  const liquity = queries.filter((q) => isLiquityFamily(q.lender));
24455
24941
  const river = queries.filter((q) => isRiver(q.lender));
24456
- if (morphos.length === 0 && gearbox.length === 0 && midnight.length === 0 && term.length === 0 && exactly.length === 0 && liquity.length === 0 && river.length === 0)
24942
+ const teller = queries.filter((q) => isTeller(q.lender));
24943
+ 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)
24457
24944
  return queries;
24458
24945
  const others = queries.filter(
24459
- (q) => !isMorphoType(q.lender) && !isGearboxV3(q.lender) && !isMidnight(q.lender) && !isTerm(q.lender) && !isExactly(q.lender) && !isLiquityFamily(q.lender) && !isRiver(q.lender)
24946
+ (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)
24460
24947
  );
24461
24948
  const morphoBlue = morphos.filter((q) => q.lender.startsWith("MORPHO_BLUE"));
24462
24949
  const moolah = morphos.filter((q) => q.lender.startsWith("LISTA_DAO"));
@@ -24517,6 +25004,14 @@ function organizeUserQueries(queries) {
24517
25004
  assets: void 0
24518
25005
  });
24519
25006
  }
25007
+ if (teller.length > 0) {
25008
+ result.push({
25009
+ lender: Lender.TELLER,
25010
+ account: teller[0].account,
25011
+ params: teller.map((p) => p.lender),
25012
+ assets: void 0
25013
+ });
25014
+ }
24520
25015
  if (liquity.length > 0) {
24521
25016
  for (const base of LIQUITY_FAMILY_LENDERS) {
24522
25017
  const members = liquity.filter((q) => q.lender.startsWith(base));
@@ -26968,7 +27463,7 @@ var getTermUserDataConverter = (_lender, chainId, account, meta) => {
26968
27463
  totalCalls
26969
27464
  ];
26970
27465
  };
26971
- var nowSec4 = () => Math.floor(Date.now() / 1e3);
27466
+ var nowSec5 = () => Math.floor(Date.now() / 1e3);
26972
27467
  function sumPreview(positions) {
26973
27468
  return positions.reduce((acc, p) => acc + p.previewValue, 0n);
26974
27469
  }
@@ -26990,7 +27485,7 @@ var getExactlyUserDataConverter = (_lender, chainId, account, meta) => {
26990
27485
  const res = data[0];
26991
27486
  if (!res || res === "0x" || !Array.isArray(res)) return void 0;
26992
27487
  const markets = res;
26993
- const now = nowSec4();
27488
+ const now = nowSec5();
26994
27489
  const out = {};
26995
27490
  for (const m of markets) {
26996
27491
  const lenderKey = exactlyLenderKey(m.market);
@@ -27475,6 +27970,148 @@ var getRiverUserDataConverter = (lender, chainId, account, meta) => {
27475
27970
  ];
27476
27971
  };
27477
27972
 
27973
+ // src/lending/user-data/teller/userCallParse.ts
27974
+ var nowSec6 = () => Math.floor(Date.now() / 1e3);
27975
+ var big3 = (v) => {
27976
+ try {
27977
+ if (typeof v === "bigint") return v;
27978
+ if (typeof v === "number" || typeof v === "string") return BigInt(v);
27979
+ } catch {
27980
+ }
27981
+ return 0n;
27982
+ };
27983
+ var field8 = (res, name, idx) => res?.[name] ?? res?.[idx];
27984
+ var getTellerUserDataConverter = (_lender, chainId, account, meta) => {
27985
+ const discovery = getCachedTellerBids(chainId, account);
27986
+ const kept = discovery?.bids ?? [];
27987
+ const expected = kept.length * TELLER_CALLS_PER_BID;
27988
+ return [
27989
+ (data) => {
27990
+ if (expected === 0 || !data || data.length < expected) return void 0;
27991
+ const now = nowSec6();
27992
+ const perPool = {};
27993
+ kept.forEach((b, i) => {
27994
+ const base = i * TELLER_CALLS_PER_BID;
27995
+ const bidRes = data[base];
27996
+ const owed = data[base + 1];
27997
+ const collAmount = big3(data[base + 2]);
27998
+ const defaulted = !!data[base + 3];
27999
+ if (!bidRes) return;
28000
+ const pool = b.pool;
28001
+ const lenderKey = tellerLenderKey(pool.pool);
28002
+ const metaMap = meta?.[lenderKey];
28003
+ if (!metaMap) return;
28004
+ const principalAddr = pool.principal.toLowerCase();
28005
+ const collAddr = pool.collateral.toLowerCase();
28006
+ const loanUid = createMarketUid(chainId, lenderKey, principalAddr);
28007
+ const collUid = createMarketUid(chainId, lenderKey, collAddr);
28008
+ const loanMeta = metaMap[loanUid];
28009
+ const collMeta = metaMap[collUid];
28010
+ const principalDecimals = loanMeta?.asset?.decimals ?? pool.principalDecimals;
28011
+ const collDecimals = collMeta?.asset?.decimals ?? pool.collateralDecimals;
28012
+ const loanDisplay = loanMeta ? getDisplayPrice(loanMeta) : 0;
28013
+ const loanOracle = loanMeta ? getOraclePrice(loanMeta) : 0;
28014
+ const loanHist = loanMeta?.price?.priceUsd24h ?? loanDisplay;
28015
+ const collDisplay = collMeta ? getDisplayPrice(collMeta) : 0;
28016
+ const collOracle = collMeta ? getOraclePrice(collMeta) : 0;
28017
+ const collHist = collMeta?.price?.priceUsd24h ?? collDisplay;
28018
+ const owedPrincipal = big3(field8(owed, "principal", 0));
28019
+ const owedInterest = big3(field8(owed, "interest", 1));
28020
+ const owedTotal = owedPrincipal + owedInterest;
28021
+ if (owedTotal === 0n && collAmount === 0n) return;
28022
+ const loanDetails = field8(bidRes, "loanDetails", 5);
28023
+ const terms = field8(bidRes, "terms", 6);
28024
+ const acceptedTs = Number(big3(field8(loanDetails, "acceptedTimestamp", 4)));
28025
+ const loanDuration = Number(big3(field8(loanDetails, "loanDuration", 6)));
28026
+ const aprBps = Number(big3(field8(terms, "APR", 2)));
28027
+ const maturity = acceptedTs > 0 ? acceptedTs + loanDuration : void 0;
28028
+ const isMatured = defaulted || maturity !== void 0 && maturity < now;
28029
+ const collStr = parseRawAmount(collAmount.toString(), collDecimals);
28030
+ const collNum = Number(collStr);
28031
+ const debtStr = parseRawAmount(owedTotal.toString(), principalDecimals);
28032
+ const debtNum = Number(debtStr);
28033
+ const interestStr = parseRawAmount(
28034
+ owedInterest.toString(),
28035
+ principalDecimals
28036
+ );
28037
+ const bucket = perPool[lenderKey] ??= {
28038
+ positions: {},
28039
+ modes: {},
28040
+ hist: {},
28041
+ metaMap
28042
+ };
28043
+ bucket.positions[b.bidId] = {
28044
+ [collUid]: {
28045
+ marketUid: collUid,
28046
+ underlying: collAddr,
28047
+ deposits: collStr,
28048
+ debt: "0",
28049
+ debtStable: "0",
28050
+ depositsUSD: collNum * collDisplay,
28051
+ debtUSD: 0,
28052
+ debtStableUSD: 0,
28053
+ depositsUSDOracle: collNum * collOracle,
28054
+ debtUSDOracle: 0,
28055
+ debtStableUSDOracle: 0,
28056
+ stableBorrowRate: "0",
28057
+ collateralEnabled: true,
28058
+ claimableRewards: 0
28059
+ },
28060
+ [loanUid]: {
28061
+ marketUid: loanUid,
28062
+ underlying: principalAddr,
28063
+ deposits: "0",
28064
+ debt: "0",
28065
+ // Fixed-term debt → stable slot (Exactly/Lista convention).
28066
+ debtStable: debtStr,
28067
+ depositsUSD: 0,
28068
+ debtUSD: 0,
28069
+ debtStableUSD: debtNum * loanDisplay,
28070
+ depositsUSDOracle: 0,
28071
+ debtUSDOracle: 0,
28072
+ debtStableUSDOracle: debtNum * loanOracle,
28073
+ stableBorrowRate: String(aprBps / 100),
28074
+ collateralEnabled: false,
28075
+ claimableRewards: 0,
28076
+ // Fixed-term loan detail — `loanId = bidId` is the repayLoanFull target.
28077
+ term: {
28078
+ loanId: b.bidId,
28079
+ isDynamic: false,
28080
+ debt: debtStr,
28081
+ apr: aprBps / 100,
28082
+ maturity,
28083
+ accruedInterest: interestStr,
28084
+ isMatured
28085
+ }
28086
+ }
28087
+ };
28088
+ bucket.modes[b.bidId] = 0;
28089
+ bucket.hist[b.bidId] = {
28090
+ totalDeposits24h: collNum * collHist,
28091
+ totalDebt24h: debtNum * loanHist
28092
+ };
28093
+ });
28094
+ const out = {};
28095
+ for (const [lenderKey, bucket] of Object.entries(perPool)) {
28096
+ if (Object.keys(bucket.positions).length === 0) continue;
28097
+ const userData = createMultiAccountTypeUserState(
28098
+ {
28099
+ chainId,
28100
+ account,
28101
+ lendingPositions: bucket.positions,
28102
+ modes: bucket.modes
28103
+ },
28104
+ bucket.metaMap,
28105
+ bucket.hist
28106
+ );
28107
+ if (userData && userData.data.length > 0) out[lenderKey] = userData;
28108
+ }
28109
+ return Object.keys(out).length > 0 ? out : void 0;
28110
+ },
28111
+ expected
28112
+ ];
28113
+ };
28114
+
27478
28115
  // src/lending/user-data/fetch-balances/parse.ts
27479
28116
  function getUserDataConverter(lender, chainId, account, params, meta) {
27480
28117
  if (isAaveV4Type(lender))
@@ -27505,6 +28142,8 @@ function getUserDataConverter(lender, chainId, account, params, meta) {
27505
28142
  return getLiquityUserDataConverter(lender, chainId, account, meta);
27506
28143
  if (isRiver(lender))
27507
28144
  return getRiverUserDataConverter(lender, chainId, account, meta);
28145
+ if (isTeller(lender))
28146
+ return getTellerUserDataConverter(lender, chainId, account, meta);
27508
28147
  if (isCompoundV3Type(lender))
27509
28148
  return getCompoundV3UserDataConverter(
27510
28149
  lender,
@@ -32276,6 +32915,8 @@ var getAbi2 = (lender) => {
32276
32915
  ];
32277
32916
  if (isRiver(lender))
32278
32917
  return [...RiverTroveManagerAbi, ...RiverStabilityPoolAbi];
32918
+ if (isTeller(lender))
32919
+ return [...TellerV2Abi, ...TellerCollateralManagerAbi];
32279
32920
  if (isInit(lender)) return InitLensAbi;
32280
32921
  if (isEulerType(lender)) return accountLensAbi;
32281
32922
  if (isCompoundV2Type(lender))
@@ -32829,7 +33470,7 @@ var MORPHO_API_CHAIN_IDS = {
32829
33470
  [Chain.UNICHAIN]: 130
32830
33471
  };
32831
33472
  var FETCH_TIMEOUT_MS = 3e3;
32832
- var CACHE_TTL_MS2 = 2e3;
33473
+ var CACHE_TTL_MS3 = 2e3;
32833
33474
  var buildSubgraphQuery = (account) => `
32834
33475
  {
32835
33476
  account(id: "${account.toLowerCase()}") {
@@ -32884,11 +33525,11 @@ async function fetchJsonWithProxyFallback(url, body, proxyConfig) {
32884
33525
  }
32885
33526
  var inflight = /* @__PURE__ */ new Map();
32886
33527
  var resolved = /* @__PURE__ */ new Map();
32887
- function cacheKey2(chainId, account) {
33528
+ function cacheKey3(chainId, account) {
32888
33529
  return `${chainId}:${account.toLowerCase()}`;
32889
33530
  }
32890
33531
  async function dedupedFetch(chainId, account, loader) {
32891
- const key = cacheKey2(chainId, account);
33532
+ const key = cacheKey3(chainId, account);
32892
33533
  const now = Date.now();
32893
33534
  const cached = resolved.get(key);
32894
33535
  if (cached && cached.expiresAt > now) {
@@ -32897,7 +33538,7 @@ async function dedupedFetch(chainId, account, loader) {
32897
33538
  const existing = inflight.get(key);
32898
33539
  if (existing) return existing;
32899
33540
  const promise = loader().then((value) => {
32900
- resolved.set(key, { value, expiresAt: Date.now() + CACHE_TTL_MS2 });
33541
+ resolved.set(key, { value, expiresAt: Date.now() + CACHE_TTL_MS3 });
32901
33542
  return value;
32902
33543
  }).finally(() => {
32903
33544
  inflight.delete(key);
@@ -33029,8 +33670,8 @@ function calculateOverallNetApr(totalDepositsUSD, totalDebtUSD, avgDepositApr, a
33029
33670
  return (totalDepositsUSD * avgDepositApr - totalDebtUSD * avgBorrowApr) / Math.abs(totalNetWorth) * (totalNetWorth > 0 ? 1 : -1);
33030
33671
  }
33031
33672
  function calculateWeightedAprs(items) {
33032
- const wa = (field8, weightField) => calculateWeightedAverage(
33033
- items.filter((i) => i[weightField] !== 0).map((i) => ({ value: i[field8], weight: Math.abs(i[weightField]) }))
33673
+ const wa = (field9, weightField) => calculateWeightedAverage(
33674
+ items.filter((i) => i[weightField] !== 0).map((i) => ({ value: i[field9], weight: Math.abs(i[weightField]) }))
33034
33675
  );
33035
33676
  return {
33036
33677
  apr: wa("apr", "nav"),
@@ -34769,8 +35410,8 @@ var TIMEOUT_MS = 8e3;
34769
35410
  var slisBnbFetcher = {
34770
35411
  label: "SLISBNB",
34771
35412
  fetch: async () => {
34772
- const nowSec5 = Math.floor(Date.now() / 1e3);
34773
- const url = `${HISTORY_URL}?name=slisBNBRate&cycle=1&startTime=${nowSec5 - LOOKBACK_SECONDS}&endTime=${nowSec5}`;
35413
+ const nowSec7 = Math.floor(Date.now() / 1e3);
35414
+ const url = `${HISTORY_URL}?name=slisBNBRate&cycle=1&startTime=${nowSec7 - LOOKBACK_SECONDS}&endTime=${nowSec7}`;
34774
35415
  const controller = new AbortController();
34775
35416
  const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
34776
35417
  try {
@@ -39050,6 +39691,108 @@ var riverFetcher = {
39050
39691
  parse: parseRiverResults,
39051
39692
  getAbi: getRiverAbi
39052
39693
  };
39694
+ function getTellerCalls(chainId) {
39695
+ const pools = tellerPoolsByChain(chainId);
39696
+ if (pools.length === 0) return [];
39697
+ const results = [];
39698
+ for (const p of pools) {
39699
+ if (!p.pool || !p.principal || !p.collateral) continue;
39700
+ const onePrincipal = 10n ** BigInt(p.principalDecimals);
39701
+ const calls = [
39702
+ {
39703
+ address: p.pool,
39704
+ name: "calculateCollateralTokensAmountEquivalentToPrincipalTokens",
39705
+ params: [onePrincipal]
39706
+ }
39707
+ ];
39708
+ results.push({
39709
+ calls,
39710
+ meta: {
39711
+ pool: p.pool.toLowerCase(),
39712
+ principal: p.principal.toLowerCase(),
39713
+ principalDecimals: p.principalDecimals,
39714
+ collateral: p.collateral.toLowerCase(),
39715
+ collateralDecimals: p.collateralDecimals
39716
+ },
39717
+ lender: tellerLenderKey(p.pool)
39718
+ });
39719
+ }
39720
+ return results;
39721
+ }
39722
+ function parseTellerResults(data, meta, context) {
39723
+ const { chainId, usdPrices, tokenList } = context;
39724
+ const entries = [];
39725
+ const principal = meta.principal;
39726
+ const collateral = meta.collateral;
39727
+ const lenderKey = tellerLenderKey(meta.pool);
39728
+ const usdOf = (addr) => {
39729
+ const key = tokenList?.[addr]?.assetGroup ?? `${chainId}-${addr}`;
39730
+ return usdPrices[key] ?? usdPrices[addr];
39731
+ };
39732
+ const principalUSD = usdOf(principal);
39733
+ const collateralUSD = usdOf(collateral);
39734
+ const rawCollateral = data?.[0];
39735
+ if (rawCollateral == null || rawCollateral === "0x") return entries;
39736
+ let equivalent;
39737
+ try {
39738
+ equivalent = BigInt(rawCollateral);
39739
+ } catch {
39740
+ return entries;
39741
+ }
39742
+ if (equivalent <= 0n) return entries;
39743
+ const collateralDecimals = meta.collateralDecimals ?? tokenList?.[collateral]?.decimals ?? 18;
39744
+ const collPerPrincipal = Number(equivalent) / 10 ** collateralDecimals;
39745
+ if (!(collPerPrincipal > 0)) return entries;
39746
+ if (principalUSD) {
39747
+ const collateralPriceInPrincipal = 1 / collPerPrincipal;
39748
+ entries.push({
39749
+ asset: principal,
39750
+ price: 1,
39751
+ priceUSD: principalUSD,
39752
+ marketUid: createMarketUid(chainId, lenderKey, principal),
39753
+ targetLender: lenderKey,
39754
+ description: "Teller principal asset",
39755
+ staticBase: true,
39756
+ baseAsset: principal
39757
+ });
39758
+ entries.push({
39759
+ asset: collateral,
39760
+ price: collateralPriceInPrincipal,
39761
+ priceUSD: collateralPriceInPrincipal * principalUSD,
39762
+ marketUid: createMarketUid(chainId, lenderKey, collateral),
39763
+ targetLender: lenderKey,
39764
+ baseAsset: principal
39765
+ });
39766
+ } else if (collateralUSD) {
39767
+ entries.push({
39768
+ asset: collateral,
39769
+ price: 1,
39770
+ priceUSD: collateralUSD,
39771
+ marketUid: createMarketUid(chainId, lenderKey, collateral),
39772
+ targetLender: lenderKey,
39773
+ description: "Teller collateral asset",
39774
+ staticBase: true,
39775
+ baseAsset: collateral
39776
+ });
39777
+ entries.push({
39778
+ asset: principal,
39779
+ price: collPerPrincipal,
39780
+ priceUSD: collPerPrincipal * collateralUSD,
39781
+ marketUid: createMarketUid(chainId, lenderKey, principal),
39782
+ targetLender: lenderKey,
39783
+ baseAsset: collateral
39784
+ });
39785
+ }
39786
+ return entries;
39787
+ }
39788
+ function getTellerAbi() {
39789
+ return LenderCommitmentGroupAbi;
39790
+ }
39791
+ var tellerFetcher = {
39792
+ getCalls: getTellerCalls,
39793
+ parse: parseTellerResults,
39794
+ getAbi: getTellerAbi
39795
+ };
39053
39796
  var CompoundV2OracleAbi = [
39054
39797
  {
39055
39798
  inputs: [{ internalType: "address", name: "cToken", type: "address" }],
@@ -40665,6 +41408,11 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40665
41408
  () => riverFetcher.getCalls(chainId),
40666
41409
  getCallsErrors
40667
41410
  ) : [];
41411
+ const tellerResults = isActive("teller") ? safeGetCalls(
41412
+ "teller",
41413
+ () => tellerFetcher.getCalls(chainId),
41414
+ getCallsErrors
41415
+ ) : [];
40668
41416
  const siloV2Results = isActive("silov2") ? safeGetCalls(
40669
41417
  "siloV2",
40670
41418
  () => siloV2Fetcher.getCalls(chainId),
@@ -40762,6 +41510,12 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40762
41510
  riverFetcher.parse,
40763
41511
  getRiverAbi()
40764
41512
  );
41513
+ const tellerGroup = buildGroup(
41514
+ "teller",
41515
+ tellerResults,
41516
+ tellerFetcher.parse,
41517
+ getTellerAbi()
41518
+ );
40765
41519
  const siloV2Group = buildGroup(
40766
41520
  "siloV2",
40767
41521
  siloV2Results,
@@ -40805,6 +41559,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40805
41559
  termGroup,
40806
41560
  liquityGroup,
40807
41561
  riverGroup,
41562
+ tellerGroup,
40808
41563
  siloV2Group,
40809
41564
  siloV3Group,
40810
41565
  fluidGroup,
@@ -40845,6 +41600,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40845
41600
  termData,
40846
41601
  liquityData,
40847
41602
  riverData,
41603
+ tellerData,
40848
41604
  morphoGqlEntries,
40849
41605
  siloV2GqlEntries,
40850
41606
  siloV3GqlEntries
@@ -40961,6 +41717,14 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
40961
41717
  allowFailure,
40962
41718
  rpcOverrides
40963
41719
  ),
41720
+ executeGroup(
41721
+ tellerGroup,
41722
+ chainId,
41723
+ chainBatchSize,
41724
+ retries,
41725
+ allowFailure,
41726
+ rpcOverrides
41727
+ ),
40964
41728
  morphoGqlPromise,
40965
41729
  siloV2GqlPromise,
40966
41730
  siloV3GqlPromise
@@ -41012,6 +41776,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
41012
41776
  { group: gearboxV3Group, data: gearboxV3Data },
41013
41777
  { group: dolomiteGroup, data: dolomiteData },
41014
41778
  { group: midnightGroup, data: midnightData },
41779
+ { group: tellerGroup, data: tellerData },
41015
41780
  ...siloV2GqlEntries != null ? [] : [{ group: siloV2Group, data: siloV2Data }],
41016
41781
  ...siloV3GqlEntries != null ? [] : [{ group: siloV3Group, data: siloV3Data }],
41017
41782
  // In hybrid mode the on-chain multicall ran too — surface its errors.
@@ -41210,6 +41975,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
41210
41975
  parseTrackers(morphoGroup, morphoData.results, false);
41211
41976
  }
41212
41977
  parseTrackers(midnightGroup, midnightData.results, false);
41978
+ parseTrackers(tellerGroup, tellerData.results, false);
41213
41979
  const totalFailedCalls = trackerDiags.reduce(
41214
41980
  (sum, d) => sum + d.failedCalls,
41215
41981
  0
@@ -41375,10 +42141,10 @@ function createAssetArrayPerChain() {
41375
42141
  return assetsPerChain;
41376
42142
  }
41377
42143
  var RELEVANT_LENDING_ASSETS = () => createAssetArrayPerChain();
41378
- function createSimpleArrayPerChain(fork, field8 = void 0) {
42144
+ function createSimpleArrayPerChain(fork, field9 = void 0) {
41379
42145
  let pools = {};
41380
42146
  Object.entries(fork ?? {}).forEach(([b2, data]) => {
41381
- Object.entries(field8 ? data[field8] : data).forEach(
42147
+ Object.entries(field9 ? data[field9] : data).forEach(
41382
42148
  ([chainId, address]) => {
41383
42149
  if (!pools[chainId]) pools[chainId] = [];
41384
42150
  pools[chainId] = uniq2([...pools[chainId], { address, pool: b2 }]);
@@ -43587,9 +44353,9 @@ query EvkByAssets($assets: [Bytes!]!) {
43587
44353
  `;
43588
44354
  var ZERO = 0n;
43589
44355
  var RAY_TO_PERCENT3 = 1e25;
43590
- function readAddress2(field8) {
43591
- if (!field8) return void 0;
43592
- return field8.toLowerCase();
44356
+ function readAddress2(field9) {
44357
+ if (!field9) return void 0;
44358
+ return field9.toLowerCase();
43593
44359
  }
43594
44360
  function parseVaultFee(v) {
43595
44361
  if (v.performanceFee == null) return 0;
@@ -50609,23 +51375,23 @@ var priceGmMarkets = async (chainId, multicallRetry, markets, prices) => {
50609
51375
  const indexMax = price(prices, m.indexToken)?.max;
50610
51376
  if (Array.isArray(dsRes) && longMax != null && shortMax != null) {
50611
51377
  const base = i * SLOTS;
50612
- const big3 = (j) => typeof dsRes[base + j] === "bigint" ? dsRes[base + j] : 0n;
51378
+ const big4 = (j) => typeof dsRes[base + j] === "bigint" ? dsRes[base + j] : 0n;
50613
51379
  const cap = computeDepositCapacityUsd(
50614
- [info?.longTokenAmount, longMax, big3(0), big3(2)],
50615
- [info?.shortTokenAmount, shortMax, big3(1), big3(3)]
51380
+ [info?.longTokenAmount, longMax, big4(0), big4(2)],
51381
+ [info?.shortTokenAmount, shortMax, big4(1), big4(3)]
50616
51382
  );
50617
51383
  if (cap != null) value.depositCapacityUsd = cap;
50618
51384
  if (indexMax != null) {
50619
51385
  const divisor = m.longToken.toLowerCase() === m.shortToken.toLowerCase() ? 2n : 1n;
50620
- const reservedUsdLong = (big3(4) + big3(5)) / divisor * indexMax;
50621
- const reservedUsdShort = (big3(6) + big3(7)) / divisor;
51386
+ const reservedUsdLong = (big4(4) + big4(5)) / divisor * indexMax;
51387
+ const reservedUsdShort = (big4(6) + big4(7)) / divisor;
50622
51388
  const liq = computeLiquidityUsd(
50623
51389
  info?.longTokenUsd,
50624
51390
  info?.shortTokenUsd,
50625
51391
  reservedUsdLong,
50626
51392
  reservedUsdShort,
50627
- big3(8),
50628
- big3(9)
51393
+ big4(8),
51394
+ big4(9)
50629
51395
  );
50630
51396
  if (liq != null)
50631
51397
  value.liquidityUsd = Math.max(0, Math.min(liq, value.tvlUsd));
@@ -50824,21 +51590,21 @@ var fetchGmxExecutionFees = async (chainId, multicallRetry, gasPriceWei) => {
50824
51590
  } catch {
50825
51591
  return void 0;
50826
51592
  }
50827
- const big3 = (i) => typeof res[i] === "bigint" ? res[i] : 0n;
50828
- const base = big3(0);
50829
- const mult = big3(1);
51593
+ const big4 = (i) => typeof res[i] === "bigint" ? res[i] : 0n;
51594
+ const base = big4(0);
51595
+ const mult = big4(1);
50830
51596
  if (base === 0n && mult === 0n) return void 0;
50831
51597
  const PRECISION = 10n ** 30n;
50832
51598
  const adjusted = (opGas) => base + opGas * mult / PRECISION;
50833
51599
  const fee = (opGas) => (adjusted(opGas) * gasPriceWei).toString();
50834
- const glvExtra = big3(6) * GLV_NOMINAL_MARKET_COUNT;
51600
+ const glvExtra = big4(6) * GLV_NOMINAL_MARKET_COUNT;
50835
51601
  return {
50836
51602
  chainId,
50837
51603
  gasPriceWei: gasPriceWei.toString(),
50838
- deposit: fee(big3(2)),
50839
- withdrawal: fee(big3(3)),
50840
- glvDeposit: fee(big3(4) + glvExtra),
50841
- glvWithdrawal: fee(big3(5) + glvExtra)
51604
+ deposit: fee(big4(2)),
51605
+ withdrawal: fee(big4(3)),
51606
+ glvDeposit: fee(big4(4) + glvExtra),
51607
+ glvWithdrawal: fee(big4(5) + glvExtra)
50842
51608
  };
50843
51609
  };
50844
51610
 
@@ -52044,6 +52810,6 @@ async function fetchTokenBalances(chainId, account, tokens, options = {}) {
52044
52810
  return parseTokenBalanceResult(rawResult, prepared.query);
52045
52811
  }
52046
52812
 
52047
- 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 };
52813
+ 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 };
52048
52814
  //# sourceMappingURL=index.js.map
52049
52815
  //# sourceMappingURL=index.js.map