@1delta/margin-fetcher 5.0.73 → 5.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -379,4 +379,4 @@ per market.
379
379
  > **Scope:** the fetcher and direct spot actions (supply collateral /
380
380
  > borrow-via-`take` / repay / withdraw) are wired. Composer-routed leverage and
381
381
  > native ETH are deferred — see
382
- > [`calldata-sdk/src/evm/generic/midnight/COMPOSER.md`](../calldata-sdk/src/evm/generic/midnight/COMPOSER.md).
382
+ > [`calldata-sdk/src/generic/midnight/COMPOSER.md`](../calldata-sdk/src/generic/midnight/COMPOSER.md).
package/dist/index.d.ts CHANGED
@@ -11994,7 +11994,36 @@ type TokenEntry = {
11994
11994
  assetGroup: string;
11995
11995
  currencyId: string;
11996
11996
  };
11997
- declare function fetchTokenMetadata(chain: string, addrs: string[]): Promise<Record<string, TokenEntry>>;
11997
+ interface FetchTokenMetadataOptions {
11998
+ /**
11999
+ * RPCs to read through. Defaults to the curated per-chain overrides — pass
12000
+ * an explicit list from a Worker, where `LIST_OVERRIDES` is not necessarily
12001
+ * the set the deployment is allowed to use.
12002
+ */
12003
+ rpcUrls?: string[];
12004
+ maxRetries?: number;
12005
+ }
12006
+ /**
12007
+ * Read `name`/`symbol`/`decimals` for arbitrary addresses on one chain.
12008
+ *
12009
+ * Three properties this function is responsible for, all of which the earlier
12010
+ * `allowFailure: false` version got wrong:
12011
+ *
12012
+ * 1. **One bad address must not sink the batch.** A caller resolving a pasted
12013
+ * address alongside five known ones would otherwise get nothing back.
12014
+ * 2. **A missing `decimals()` means NOT AN ERC-20, and the address is
12015
+ * OMITTED.** It is never defaulted to 18 — every amount in this codebase is
12016
+ * scaled by that number, so a wrong decimals is a wrong transaction, and a
12017
+ * silent default is the shape that produces one.
12018
+ * 3. **`name`/`symbol` are cosmetic and may legitimately be absent.** A token
12019
+ * with real `decimals` and no `symbol` still resolves; the strings fall back
12020
+ * to the address prefix rather than dropping the row.
12021
+ *
12022
+ * @returns entries keyed by LOWERCASED address. Addresses that did not resolve
12023
+ * are absent from the result — the caller must not assume input order or
12024
+ * completeness.
12025
+ */
12026
+ declare function fetchTokenMetadata(chain: string, addrs: string[], options?: FetchTokenMetadataOptions): Promise<Record<string, TokenEntry>>;
11998
12027
 
11999
12028
  interface TokenBalanceQuery {
12000
12029
  chainId: string;
@@ -14864,4 +14893,4 @@ declare const fetchFluidDexState: (chainId: string, multicallRetry: MulticallRet
14864
14893
  /** Synchronous read of whatever `fetchFluidDexState` last cached for a chain. */
14865
14894
  declare const getCachedFluidDexState: (chainId: string) => FluidDexStateMap | undefined;
14866
14895
 
14867
- export { type AaveMetadata, type AaveV2Public, type AaveV2UserReserveResponse, type AaveV3Public, type AaveV3UserReserveResponse, type AdditionalYields, type AdminKind, ApiBookSource, type AprData, type AprPercent, type AssetQuality, type AssetRiskIndex, type AuctionWindow, type AvailabilityTerms, type BalanceData, type BaseLendingPosition, type BasicReserveResponse, type BorrowExitTerms, type BorrowTermSheet, type BuildTermSheetOptions, type BuildVaultTermSheetOptions, type ChainDiagnostic, type ChainLinkResponse, type ChainQuery, type ChainSummary, type CompoundV2Metadata, type CompoundV3Public, type CompoundV3UserReserveResponse, type ConfigEntry, type ConvertLenderUserDataOptions, type CoolerDripRaw, type CoolerMarketsRaw, type CoolerPositionInfo, type CoreValidators, type CounterpartyTerms, type CoverageInfo, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, DEFAULT_TERM_ORDER_STORE, type DeepPartial, type Denomination, type DepthMap, type DssMarketRaw, type DssMarketsRaw, type DssPositionInfo, EARN_DESCRIPTIONS, EARN_LABELS, EARN_RATE_SOURCE_BY_PROVIDER, EMPTY_BALANCE, type EModeAssets, type EModeData, type EModeResult, EXACTLY_LENDER_KEY, type EarnActionInput, type EarnActionKind, type EarnAmount, type EarnAppliedDefaults, type EarnAprBreakdown, type EarnAsset, type EarnAvailability, type EarnBasket, type EarnBasketLeg, type EarnCapability, type EarnCurator, type EarnExclusions, type EarnExit, type EarnFacetBucket, type EarnFacets, type EarnGating, type EarnLabelDimension, type EarnLendingPosition, type EarnMarket, type EarnMarketLabelInput, type EarnPosition, type EarnPositionAsset, type EarnPositionBase, type EarnPositionLeg, type EarnPositionSourceStatus, type EarnPositionSubAccount, type EarnPositionTotals, type EarnPositionUid, type EarnPositionsResponse, type EarnProtocol, type EarnProtocolAndCurator, type EarnRate, type EarnRateSource, type EarnRefs, type EarnResponse, type EarnRisk, type EarnSanityResult, type EarnShareToken, type EarnSourceStatus, type EarnVaultNormalizeOptions, type EarnVaultPosition, type EarnVenueKind, type EarnVocabulary, type EndpointFailure, type EnrichmentIndex, type EulerEarnVault, type EulerEarnVaults, type EulerV2Metadata, type ExactlyFixedPool, type ExactlyFixedPosition, type ExactlyMarketAccount, type ExactlyMarketsRaw, type ExactlyUserFixedPosition, type ExposureEntry, type ExposureTerms, type ExtraValidationCall, FLYING_TULIP_LENDER_KEY, FRACTION_RATE_PROVIDERS, type FeeTerm, type FeeWhen, type FeedObservation, type FeedStat, type FeedStatsMap, type FeedTimestampMap, type FetchListaVaultsFromChainOptions, type FetchMorphoVaultsFromChainOptions, type FetchOraclePricesOptions, type FetchPendlePtOptions, type FetchSpectraPtOptions, type FetchTokenBalancesOptions, type FlattenPriorityConfig, type FluidDexShareState, type FluidDexStateMap, type FluidFToken, type FluidFTokens, type FlyingTulipAssetRaw, type FlyingTulipMarketsRaw, type FrankencoinMarketRaw, type FrankencoinMarketsRaw, type FrankencoinPositionInfo, type FraxlendPairRaw, type FraxlendPairsRaw, type FullLenderRewardsMap, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, type GenericCurrency, type GenericTokenList, type GetVaultPublicDataAllOptions, type GmxExecutionFees, type GmxPendingDeposit, type GmxPendingWithdrawal, type GmxReadContracts, type GmxUserBalance, type GmxUserPositions, type GmxUserPositionsOptions, type GmxVault, type GmxVaultKind, type GmxVaults, type GmxVaultsFetchOptions, type GovernancePower, type GovernanceRow, type GovernanceTerms, type GroupAccumulator, HYPERCORE_VAULT_REGISTRY, type HypercoreLockStatus, type HypercoreUserPositionsOptions, type HypercoreVault, type HypercoreVaultPosition, type HypercoreVaultRegistryEntry, type HypercoreVaults, type HypercoreVaultsFetchOptions, IDLE_MARKET_ID, INTERFACE_IDS, type IncompleteLenderRead, type IncompleteReason, type InitMetadata, type InitPublic, type InitUserReserveResponse, type InterfaceKind, type InvariantViolation, type InverseMarketRaw, type InverseMarketsRaw, type InversePositionInfo, LAGOON_API_URL, LAGOON_CHAIN_IDS, type LagoonApiVault, type LagoonSyncMode, type LagoonVault, type LagoonVaults, type LenderAssetReward, type LenderConfigData, type LenderConfigMap, type LenderCrossPoolMeta, type LenderData, type LenderDataEntry, type LenderInfo, type LenderInfoMap, type LenderPublicBase, type LenderRewardsMap, type LenderSummary, type LenderToLenderCrossPoolMeta, type LenderTotalAmounts, type LenderUserQuery, type LenderUserResponse, type LenderYieldComplete, type LenderYields$1 as LenderYields, LendingMode, type LiquidationPenaltyTerm, type LiquidationTerms, type LiquityBranchRaw, type LiquityDiscoveredTrove, type LiquityDiscovery, type LiquityMarketsRaw, type LiquitySpInfo, type LiquityTroveInfo, type ListaMarketOverrides, type LlamaLendMarketOverride, type LlamaLendMarketOverrides, type LlamaLendMarketRaw, type LlamaLendMarketsRaw, type LlamaLendPositionInfo, type LoopPostTradeMetrics, type LstDelegation, type LstDelegationKind, type LstValidator, type LstWithdrawalFetchOptions, type LstWithdrawalRegistryEntry, type LstWithdrawalRequest, type LstWithdrawalRequestsByLst, type LstWithdrawalStatus, MORPHO_LENS, MULTICALL_FAILURE, type MaturityTerms, MaxParamThresholds, type MergedUserData, type MidnightBook, type MidnightBookLevel, type MidnightBookSource, type ModeBase, type ModeVariant, type MorphoMarketOverrides, type MorphoSubgraphProxyConfig, type MorphoUserMarketBalance, type MorphoUserReserveResponse, type MorphoVault, type MorphoVaults, type MulticallEndpointOptions, type MulticallRpcBatch, type NumberMap, type Open, type OracleBand, type OracleDiagnostics, type OraclePriceEntry, type OraclePricesResult, type OracleRiskRow, type OracleTerms, type OutlierGuardConfig, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL, type ParsedBalanceData, type ParsedEarnUid, type ParsedLendingEarnUid, type ParsedResponse, type ParsedUserBalance, type ParsedVaultEarnUid, type PendleApiAsset, type PendleApiMarket, type PendleApiMarketDetails, type PendlePtMarket, type PendlePtMarkets, type PermissionKind, type PermissionParams, type PoolData, type PoolSourceRow, type PoolWithMeta, type PortfolioSummary, type PortfolioTotals, type PositionConstraints, type PostTradeMetrics, type PreparedCall, type PreparedMergedMulticallParams, type PreparedMergedRpcCalls, type PreparedTokenBalanceRpcCalls, type PreparedUserDataRpcCalls, type PriceDerivation, type PriceSelection, type ProtocolParams, type ProviderOptions, type RateKind, type RateMenuEntry, type RateTerms, type RawRpcBatch, type RawRpcCall, type RawRpcResponse, type ReadFailurePolicy, type RedemptionTerms, type ResupplyMarketsRaw, type ResupplyPairIdentity, type ResupplyPairRaw, type ResupplyPositionInfo, type ResupplyWrappedMarket, type RewardSourceRef, type RewardStream, type RewardTerm, type RewardTokenRef, type RiverMarketRaw, type RiverMarketsRaw, type RiverPositionInfo, SDK_FRACTION_RATE_PROVIDERS, SPECTRA_NETWORKS, SPECTRA_RATE_MAX_PERCENT, SPECTRA_RATE_MIN_PERCENT, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, type SelectPricesOptions, type Severity, type SeverityFinding, type SiloVault, type SiloVaults, type SpectraApiMarket, type SpectraApiPool, type SpectraApiToken, type SpectraPtMarket, type SpectraPtMarkets, type StCeloValidatorGroup, type StaleFeedEntry, type StampOptions, type StructuredOraclePrices, type SubAccountSummary, type SumerPositionInput, type SummaryAprData, type SummaryBalanceData, type SupplyExitMode, type SupplyExitRoute, type SupplyExitTerms, type SupplyTermSheet, TELLER_CALLS_PER_BID, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_MARKETS_PER_CALL, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, type TellerDiscoveredBid, type TellerDiscovery, type TellerMarketsRaw, type TellerPoolRaw, type TermAdapter, type TermAssetRef, type TermAuctionOrder, type TermAuctionOrders, type TermBookSource, type TermBookTop, type TermFillNow, type TermFillNowSide, type TermInfo, type TermListing, type TermMarketRaw, TermMaxApiSource, type TermMaxBookTop, type TermMaxCurveSegment, type TermMaxDataSource, type TermMaxDiscovery, type TermMaxFeeConfig, type TermMaxMarketConfig, type TermMaxMarketRaw, type TermMaxOrderState, type TermProfile, type TermSheet, type TermSheetDigest, type TermSheetInput, type TermSheetViolation, type TermStoreOrder, TermSubgraphSource, type TermTag, type TokenApprovalMeta, type TokenApprovalParams, type TokenBalanceEntry, type TokenBalanceQuery, type TokenBalanceResult, type TokenEntry, type TokenList, type TokenListInput, type TrackerDiagnostic, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, type USDPriceMap, type UpshiftApiAsset, type UpshiftApiVault, type UpshiftVault, type UpshiftVaults, type UsddMarketRaw, type UsddMarketsRaw, type DssPositionInfo as UsddPositionInfo, type UserApr, type UserConfig, type UserData, type UserDataResult, type UserLendingPosition, type UtilizationTerms, VAULT_PROVIDERS, VAULT_PROVIDER_PROFILE, VAULT_PROVIDER_TRAITS, VAULT_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VOLATILE_VAULT_OVERRIDES, type ValidationResult, type VaultAprResult, type VaultBalanceInput, type VaultClassification, type VaultClassificationFields, type VaultLookupEntry, type VaultMarketExposure, type VaultProvider, type VaultProviderTraits, type VaultPublicDataAll, type VaultPublicDataResult, type VaultSourceRow, type VaultTermInput, type VaultYieldSeries, type VaultYieldSnapshot, type YDaemonVault, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, type YearnVault, type YearnVaultKind, type YearnVaults, type YieldProfile, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyEarnSanity, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, borrowDescription, borrowFindings, borrowHeadline, buildExposures, buildFluidFTokensCall, buildLendingPositionUid, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, clearSpectraMarketsCache, collateralSymbolsByVenue, collectFeedObservations, computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertCoolerMarketsToResponse, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFlyingTulipMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, detectInterfaceKinds, dexResolverFor, disambiguateEarnNames, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnPositionFromLenderEntry, earnPositionFromVaultBalance, earnPositionTotals, earnRateAtMaturity, earnRowSubtitle, earnUidFromMarketUid, earnVaultTerms, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchCoolerMarkets, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidDexState, fetchFluidFTokens, fetchFlyingTulipMarkets, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRiverMarkets, fetchSiloVaults, fetchSpectraApiMarkets, fetchSpectraPtMarkets, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTermStoreOrders, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, fillableRemaining, filterActiveLenders, filterLendersByProtocol, finalizeInfo, findingsFor, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedFluidDexState, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasSpectraMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isIlliquid, isLendingPosition, isLiveMarket as isLivePendleMarket, isLiveSpectraMarket, isMaturedTerm, isSecondaryMarketOnly, isStablecoinSymbol, isUnearnableEarnRate, isUnrealizableEarnRate, isVaultPosition, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, llamaLendKeyParts, llamaLendLenderKey, meetsLiquidityFloor, mergeDeep, multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, organizeUserQueries, parseBalanceFetcherResult, parseEarnUid, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseCurveFee as parseSpectraCurveFee, parsePtRate as parseSpectraPtRate, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, pickPool as pickSpectraPool, positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, repairImpossibleTvl, resolveAdapter, resolveDerivation, resolveEarnIdentity, resolveModeConfig, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, sanePercent as saneSpectraPercent, savingsAddresses, savingsBalanceKind, secondaryMarketVault, selectAssetGroupPrices, setMysticApiKey, shortDate, spectraAddress, spectraNetwork, spectraPoolsUrl, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampEarnSubtitles, stampVaultClassification, stampVaultTermSheets, stripLeadingBrand, supplyDescription, supplyFindings, supplyHeadline, swapRoutedProvidersArePriceConsistent, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termApiBaseUrl, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, termOfferRateToAprPct, termOrderStoreBaseUrl, tickToAprNumber, tickToPrice, toDigest, toTermFillNow, toTermSheetInput, toVaultTermInput, trancheFromCounterparty, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultSharesToAssets, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand, venueBrandKey, withMaturityLabel, withTrancheLabel };
14896
+ export { type AaveMetadata, type AaveV2Public, type AaveV2UserReserveResponse, type AaveV3Public, type AaveV3UserReserveResponse, type AdditionalYields, type AdminKind, ApiBookSource, type AprData, type AprPercent, type AssetQuality, type AssetRiskIndex, type AuctionWindow, type AvailabilityTerms, type BalanceData, type BaseLendingPosition, type BasicReserveResponse, type BorrowExitTerms, type BorrowTermSheet, type BuildTermSheetOptions, type BuildVaultTermSheetOptions, type ChainDiagnostic, type ChainLinkResponse, type ChainQuery, type ChainSummary, type CompoundV2Metadata, type CompoundV3Public, type CompoundV3UserReserveResponse, type ConfigEntry, type ConvertLenderUserDataOptions, type CoolerDripRaw, type CoolerMarketsRaw, type CoolerPositionInfo, type CoreValidators, type CounterpartyTerms, type CoverageInfo, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, DEFAULT_TERM_ORDER_STORE, type DeepPartial, type Denomination, type DepthMap, type DssMarketRaw, type DssMarketsRaw, type DssPositionInfo, EARN_DESCRIPTIONS, EARN_LABELS, EARN_RATE_SOURCE_BY_PROVIDER, EMPTY_BALANCE, type EModeAssets, type EModeData, type EModeResult, EXACTLY_LENDER_KEY, type EarnActionInput, type EarnActionKind, type EarnAmount, type EarnAppliedDefaults, type EarnAprBreakdown, type EarnAsset, type EarnAvailability, type EarnBasket, type EarnBasketLeg, type EarnCapability, type EarnCurator, type EarnExclusions, type EarnExit, type EarnFacetBucket, type EarnFacets, type EarnGating, type EarnLabelDimension, type EarnLendingPosition, type EarnMarket, type EarnMarketLabelInput, type EarnPosition, type EarnPositionAsset, type EarnPositionBase, type EarnPositionLeg, type EarnPositionSourceStatus, type EarnPositionSubAccount, type EarnPositionTotals, type EarnPositionUid, type EarnPositionsResponse, type EarnProtocol, type EarnProtocolAndCurator, type EarnRate, type EarnRateSource, type EarnRefs, type EarnResponse, type EarnRisk, type EarnSanityResult, type EarnShareToken, type EarnSourceStatus, type EarnVaultNormalizeOptions, type EarnVaultPosition, type EarnVenueKind, type EarnVocabulary, type EndpointFailure, type EnrichmentIndex, type EulerEarnVault, type EulerEarnVaults, type EulerV2Metadata, type ExactlyFixedPool, type ExactlyFixedPosition, type ExactlyMarketAccount, type ExactlyMarketsRaw, type ExactlyUserFixedPosition, type ExposureEntry, type ExposureTerms, type ExtraValidationCall, FLYING_TULIP_LENDER_KEY, FRACTION_RATE_PROVIDERS, type FeeTerm, type FeeWhen, type FeedObservation, type FeedStat, type FeedStatsMap, type FeedTimestampMap, type FetchListaVaultsFromChainOptions, type FetchMorphoVaultsFromChainOptions, type FetchOraclePricesOptions, type FetchPendlePtOptions, type FetchSpectraPtOptions, type FetchTokenBalancesOptions, type FetchTokenMetadataOptions, type FlattenPriorityConfig, type FluidDexShareState, type FluidDexStateMap, type FluidFToken, type FluidFTokens, type FlyingTulipAssetRaw, type FlyingTulipMarketsRaw, type FrankencoinMarketRaw, type FrankencoinMarketsRaw, type FrankencoinPositionInfo, type FraxlendPairRaw, type FraxlendPairsRaw, type FullLenderRewardsMap, GMX_API_HOSTS, GMX_READ_CONTRACTS, GMX_SUPPORTED_CHAINS, type GenericCurrency, type GenericTokenList, type GetVaultPublicDataAllOptions, type GmxExecutionFees, type GmxPendingDeposit, type GmxPendingWithdrawal, type GmxReadContracts, type GmxUserBalance, type GmxUserPositions, type GmxUserPositionsOptions, type GmxVault, type GmxVaultKind, type GmxVaults, type GmxVaultsFetchOptions, type GovernancePower, type GovernanceRow, type GovernanceTerms, type GroupAccumulator, HYPERCORE_VAULT_REGISTRY, type HypercoreLockStatus, type HypercoreUserPositionsOptions, type HypercoreVault, type HypercoreVaultPosition, type HypercoreVaultRegistryEntry, type HypercoreVaults, type HypercoreVaultsFetchOptions, IDLE_MARKET_ID, INTERFACE_IDS, type IncompleteLenderRead, type IncompleteReason, type InitMetadata, type InitPublic, type InitUserReserveResponse, type InterfaceKind, type InvariantViolation, type InverseMarketRaw, type InverseMarketsRaw, type InversePositionInfo, LAGOON_API_URL, LAGOON_CHAIN_IDS, type LagoonApiVault, type LagoonSyncMode, type LagoonVault, type LagoonVaults, type LenderAssetReward, type LenderConfigData, type LenderConfigMap, type LenderCrossPoolMeta, type LenderData, type LenderDataEntry, type LenderInfo, type LenderInfoMap, type LenderPublicBase, type LenderRewardsMap, type LenderSummary, type LenderToLenderCrossPoolMeta, type LenderTotalAmounts, type LenderUserQuery, type LenderUserResponse, type LenderYieldComplete, type LenderYields$1 as LenderYields, LendingMode, type LiquidationPenaltyTerm, type LiquidationTerms, type LiquityBranchRaw, type LiquityDiscoveredTrove, type LiquityDiscovery, type LiquityMarketsRaw, type LiquitySpInfo, type LiquityTroveInfo, type ListaMarketOverrides, type LlamaLendMarketOverride, type LlamaLendMarketOverrides, type LlamaLendMarketRaw, type LlamaLendMarketsRaw, type LlamaLendPositionInfo, type LoopPostTradeMetrics, type LstDelegation, type LstDelegationKind, type LstValidator, type LstWithdrawalFetchOptions, type LstWithdrawalRegistryEntry, type LstWithdrawalRequest, type LstWithdrawalRequestsByLst, type LstWithdrawalStatus, MORPHO_LENS, MULTICALL_FAILURE, type MaturityTerms, MaxParamThresholds, type MergedUserData, type MidnightBook, type MidnightBookLevel, type MidnightBookSource, type ModeBase, type ModeVariant, type MorphoMarketOverrides, type MorphoSubgraphProxyConfig, type MorphoUserMarketBalance, type MorphoUserReserveResponse, type MorphoVault, type MorphoVaults, type MulticallEndpointOptions, type MulticallRpcBatch, type NumberMap, type Open, type OracleBand, type OracleDiagnostics, type OraclePriceEntry, type OraclePricesResult, type OracleRiskRow, type OracleTerms, type OutlierGuardConfig, PASSTHROUGH_RATE_EPSILON, PENDLE_ASSETS_URL, PENDLE_CHAIN_IDS, PENDLE_MARKETS_URL, type ParsedBalanceData, type ParsedEarnUid, type ParsedLendingEarnUid, type ParsedResponse, type ParsedUserBalance, type ParsedVaultEarnUid, type PendleApiAsset, type PendleApiMarket, type PendleApiMarketDetails, type PendlePtMarket, type PendlePtMarkets, type PermissionKind, type PermissionParams, type PoolData, type PoolSourceRow, type PoolWithMeta, type PortfolioSummary, type PortfolioTotals, type PositionConstraints, type PostTradeMetrics, type PreparedCall, type PreparedMergedMulticallParams, type PreparedMergedRpcCalls, type PreparedTokenBalanceRpcCalls, type PreparedUserDataRpcCalls, type PriceDerivation, type PriceSelection, type ProtocolParams, type ProviderOptions, type RateKind, type RateMenuEntry, type RateTerms, type RawRpcBatch, type RawRpcCall, type RawRpcResponse, type ReadFailurePolicy, type RedemptionTerms, type ResupplyMarketsRaw, type ResupplyPairIdentity, type ResupplyPairRaw, type ResupplyPositionInfo, type ResupplyWrappedMarket, type RewardSourceRef, type RewardStream, type RewardTerm, type RewardTokenRef, type RiverMarketRaw, type RiverMarketsRaw, type RiverPositionInfo, SDK_FRACTION_RATE_PROVIDERS, SPECTRA_NETWORKS, SPECTRA_RATE_MAX_PERCENT, SPECTRA_RATE_MIN_PERCENT, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, type SelectPricesOptions, type Severity, type SeverityFinding, type SiloVault, type SiloVaults, type SpectraApiMarket, type SpectraApiPool, type SpectraApiToken, type SpectraPtMarket, type SpectraPtMarkets, type StCeloValidatorGroup, type StaleFeedEntry, type StampOptions, type StructuredOraclePrices, type SubAccountSummary, type SumerPositionInput, type SummaryAprData, type SummaryBalanceData, type SupplyExitMode, type SupplyExitRoute, type SupplyExitTerms, type SupplyTermSheet, TELLER_CALLS_PER_BID, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_MARKETS_PER_CALL, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, TERM_ADAPTERS, TERM_PROFILES, TERM_SHEET_SCHEMA_VERSION, type TellerDiscoveredBid, type TellerDiscovery, type TellerMarketsRaw, type TellerPoolRaw, type TermAdapter, type TermAssetRef, type TermAuctionOrder, type TermAuctionOrders, type TermBookSource, type TermBookTop, type TermFillNow, type TermFillNowSide, type TermInfo, type TermListing, type TermMarketRaw, TermMaxApiSource, type TermMaxBookTop, type TermMaxCurveSegment, type TermMaxDataSource, type TermMaxDiscovery, type TermMaxFeeConfig, type TermMaxMarketConfig, type TermMaxMarketRaw, type TermMaxOrderState, type TermProfile, type TermSheet, type TermSheetDigest, type TermSheetInput, type TermSheetViolation, type TermStoreOrder, TermSubgraphSource, type TermTag, type TokenApprovalMeta, type TokenApprovalParams, type TokenBalanceEntry, type TokenBalanceQuery, type TokenBalanceResult, type TokenEntry, type TokenList, type TokenListInput, type TrackerDiagnostic, UPSHIFT_CHAIN_IDS, UPSHIFT_VAULTS_URL, type USDPriceMap, type UpshiftApiAsset, type UpshiftApiVault, type UpshiftVault, type UpshiftVaults, type UsddMarketRaw, type UsddMarketsRaw, type DssPositionInfo as UsddPositionInfo, type UserApr, type UserConfig, type UserData, type UserDataResult, type UserLendingPosition, type UtilizationTerms, VAULT_PROVIDERS, VAULT_PROVIDER_PROFILE, VAULT_PROVIDER_TRAITS, VAULT_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VOLATILE_VAULT_OVERRIDES, type ValidationResult, type VaultAprResult, type VaultBalanceInput, type VaultClassification, type VaultClassificationFields, type VaultLookupEntry, type VaultMarketExposure, type VaultProvider, type VaultProviderTraits, type VaultPublicDataAll, type VaultPublicDataResult, type VaultSourceRow, type VaultTermInput, type VaultYieldSeries, type VaultYieldSnapshot, type YDaemonVault, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, type YearnVault, type YearnVaultKind, type YearnVaults, type YieldProfile, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyEarnSanity, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, borrowDescription, borrowFindings, borrowHeadline, buildExposures, buildFluidFTokensCall, buildLendingPositionUid, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, buildVaultTermSheet, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, clearSpectraMarketsCache, collateralSymbolsByVenue, collectFeedObservations, computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertCoolerMarketsToResponse, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFlyingTulipMarketsToResponse, convertFrankencoinMarketsToResponse, convertFraxlendPairsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, detectInterfaceKinds, dexResolverFor, disambiguateEarnNames, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnMarketLabel, earnPositionFromLenderEntry, earnPositionFromVaultBalance, earnPositionTotals, earnRateAtMaturity, earnRowSubtitle, earnUidFromMarketUid, earnVaultTerms, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchCoolerMarkets, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidDexState, fetchFluidFTokens, fetchFlyingTulipMarkets, fetchFrankencoinMarkets, fetchFraxlendPairs, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendleApiAssets, fetchPendleApiMarkets, fetchPendlePrices, fetchPendlePtMarkets, fetchResupplyMarkets, fetchRiverMarkets, fetchSiloVaults, fetchSpectraApiMarkets, fetchSpectraPtMarkets, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTermStoreOrders, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, fillableRemaining, filterActiveLenders, filterLendersByProtocol, finalizeInfo, findingsFor, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fraxlendAssetPerCollateral, fraxlendKeyParts, fraxlendLenderKey, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedFluidDexState, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasSpectraMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isBoundNeed, isFailedCall, isIlliquid, isLendingPosition, isLiveMarket as isLivePendleMarket, isLiveSpectraMarket, isMaturedTerm, isSecondaryMarketOnly, isStablecoinSymbol, isUnearnableEarnRate, isUnrealizableEarnRate, isVaultPosition, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, llamaLendKeyParts, llamaLendLenderKey, meetsLiquidityFloor, mergeDeep, multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, organizeUserQueries, parseBalanceFetcherResult, parseEarnUid, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseCurveFee as parseSpectraCurveFee, parsePtRate as parseSpectraPtRate, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, pickPool as pickSpectraPool, positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, repairImpossibleTvl, resolveAdapter, resolveDerivation, resolveEarnIdentity, resolveModeConfig, resolveStCeloDepositGroup, resolveVaultProfileId, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, sanePercent as saneSpectraPercent, savingsAddresses, savingsBalanceKind, secondaryMarketVault, selectAssetGroupPrices, setMysticApiKey, shortDate, spectraAddress, spectraNetwork, spectraPoolsUrl, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampEarnSubtitles, stampVaultClassification, stampVaultTermSheets, stripLeadingBrand, supplyDescription, supplyFindings, supplyHeadline, swapRoutedProvidersArePriceConsistent, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termApiBaseUrl, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, termOfferRateToAprPct, termOrderStoreBaseUrl, tickToAprNumber, tickToPrice, toDigest, toTermFillNow, toTermSheetInput, toVaultTermInput, trancheFromCounterparty, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultSharesToAssets, vaultTermInputFromEarnMarket, vaultTermInputFromSourceRow, vaultTraits, vaultVenue, venueBrand, venueBrandKey, withMaturityLabel, withTrancheLabel };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, erc20Abi, stringToHex, isAddress, pad, encodeFunctionData, formatUnits, getAddress, decodeFunctionResult, decodeAbiParameters, concat, parseAbiParameters, AbiEncodingLengthMismatchError, concatHex, toBytes, slice, hexToString, InvalidAddressError, boolToHex, integerRegex, numberToHex, bytesRegex, BytesSizeMismatchError, arrayRegex, UnsupportedPackedAbiType } from './chunk-JUYF2XLF.js';
1
+ import { parseAbi, keccak256, encodeAbiParameters, formatEther, BaseError, erc20Abi, stringToHex, isAddress, pad, encodeFunctionData, formatUnits, getAddress, decodeFunctionResult, decodeAbiParameters, concat, parseAbiParameters, hexToString, AbiEncodingLengthMismatchError, concatHex, toBytes, slice, InvalidAddressError, boolToHex, integerRegex, numberToHex, bytesRegex, BytesSizeMismatchError, arrayRegex, UnsupportedPackedAbiType } from './chunk-JUYF2XLF.js';
2
2
  import './chunk-BYTNVMX7.js';
3
3
  import './chunk-PR4QN5HX.js';
4
4
  import { Lender, isExactly, isMidnight, isTerm, isTermMax, isTeller, isListaDao, isLiquityFamily, isRiver, isInverse, isCooler, isDssType, isCompoundV3Type, isFluid, isGearboxV3, isLlamaLend, isFrankencoin, isResupply, isCurvance, isFlyingTulip, isTwyne, isFraxlend, isAaveV4Type, LIQUITY_FAMILY_LENDERS, isAaveType, isCompoundV3, isCompoundV2Type, isMultiMarket, isSiloV2Type, isSiloV3Type, isDolomite, isMorphoType, isUsdd, isSky, hasCrossMarginRisk, isEulerType, isInit, isVenusType, isSumerType, AAVE_V3_LENDERS, AAVE_V2_LENDERS, isMorphoBlue, isAaveV2Type, isAaveV32Type, isAaveV3Type, isYLDR, isLista, hasSubAccounts, isTectonicType, isKineticType, isBenqiType } from '@1delta/lender-registry';
5
5
  export { hasCrossMarginRisk, 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, flyingTulipLendersByChain, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, coolerLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, fraxlendLendersByChain, twyneLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, resolveTermApiBase, flyingTulipConfigFor, flyingTulipAssetsFor, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, coolerConfigFor, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, fraxlendConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, listaCollateralProvider, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, compoundV2TokenArray, gearboxV3LenderKey, midnightMarketsByChain, twyneConfigFor, twyneChainData, parseAaveV4SpokeLenderKey, fraxlendPairsFor, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles, morphoTypeOracles } 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, flyingTulipLendersByChain, liquityLendersByChain, riverLendersByChain, inverseLendersByChain, coolerLendersByChain, llamaLendLendersByChain, usddLendersByChain, skyLendersByChain, frankencoinLendersByChain, resupplyLendersByChain, curvanceLendersByChain, fraxlendLendersByChain, twyneLendersByChain, tellerConfigByChain, tellerPoolsByChain, termMaxConfigByChain, aaveReserves, compoundV3Reserves, resolveTermApiBase, flyingTulipConfigFor, flyingTulipAssetsFor, liquityConfigFor, liquityBranchesByChain, riverConfigFor, riverChainData, termMaxApiBaseUrl, termMaxLenderKey, inverseConfigFor, inverseChainData, coolerConfigFor, llamaLendConfigFor, llamaLendChainData, llamaLendApiBaseUrl, resupplyConfigFor, fraxlendConfigFor, dssConfigFor, dssChainData, dssDebtToken, dssDebtJoin, frankencoinConfigFor, frankencoinChainData, aaveOracles, morphoTypeMarkets, resolveMidnightApiBase, llamaLendMarketByVault, getSiloV2MarketEntry, getSiloV3MarketEntry, dolomiteEmode, curvanceConfigFor, aaveTokens, morphoTypeVaults, listaCollateralProvider, eulerConfigs, gearboxMarketCompressor, gearboxMarketConfigurators, compoundV2TokenArray, gearboxV3LenderKey, midnightMarketsByChain, twyneConfigFor, twyneChainData, midnightCollateralRef, parseAaveV4SpokeLenderKey, fraxlendPairsFor, gearboxAccountCompressor, compoundV2Tokens, exactlyMarketsByChain, aaveOraclesConfig, compoundV2Oracles, compoundV2OraclesConfig, compoundV3OraclesData, compoundV3BaseData, compoundV2Reserves, aaveV4Oracles, morphoTypeOracles } from '@1delta/data-sdk';
7
7
  import lodash from 'lodash';
8
8
  import { Chain, isEvmChainId } from '@1delta/chain-registry';
9
- import { multicallRetryUniversal, getEvmClient, getEvmChain, getEvmClientUniversal } from '@1delta/providers';
9
+ import { multicallRetryUniversal, getEvmClient, getEvmChain, createMulticallRetryUniversal, LIST_OVERRIDES, getEvmClientUniversal } from '@1delta/providers';
10
10
  import { LiquityTroveManagerAbi, LiquityActivePoolAbi, LiquityStabilityPoolAbi, LiquityPriceFeedAbi, LiquitySortedTrovesAbi, RiverTroveManagerAbi, RiverStabilityPoolAbi, TellerMarketRegistryAbi, TellerV2Abi, InverseMarketAbi, InverseOracleAbi, InverseDbrAbi, CurveTricryptoOracleAbi, Erc20Abi, CoolerMonoAbi, CoolerLtvOracleAbi, LlamaLendControllerAbi, LlamaLendControllerV1Abi, LlamaLendControllerV2Abi, LlamaLendVaultAbi, LlamaLendAmmAbi, TwyneCollateralVaultAbi, MetaMorphoAbi, FluidDexResolverAbi, ExactlyPreviewerAbi, ExactlyAuditorAbi, FlyingTulipLendingLensAbi, LenderCommitmentGroupAbi, ResupplyRegistryAbi, ResupplyPairAbi, ResupplyUtilitiesAbi, ResupplyRewardHandlerAbi, ResupplyPairEmissionsAbi, ConvexPoolUtilAbi, FraxlendPairAbi, FraxlendLeverAbi, FrankencoinPositionAbi, FluidLendingResolverAbi, FluidVaultResolverAbi, FluidLiquidityResolverAbi, MoolahVaultAbi, UsddVatAbi, UsddJugAbi, UsddSpotAbi, MorphoLensAbi, AaveV4SpokeAbi, AaveV4OracleAbi, AaveV4HubAbi, DolomiteMarginAbi, GearboxMarketCompressorV310Abi, MorphoBlueAbi, MidnightAbi, TermRepoTokenAbi, TermRepoServicerAbi, TermRepoCollateralManagerAbi, LiquityTroveNFTAbi, LiquityCollSurplusPoolAbi, TellerCollateralManagerAbi, TermMaxViewerAbi, InverseEscrowAbi, CurvanceMarketManagerAbi, CurvanceCTokenAbi, GearboxCreditAccountCompressorV310Abi, TwyneVaultManagerAbi, TwyneCollateralVaultFactoryAbi, AaveV2V3Abi, TwyneATokenWrapperAbi, UsddCdpManagerAbi, UsddProxyRegistryAbi, CurvanceProtocolReaderAbi, CurvanceCentralRegistryAbi, TermPriceConsumerAbi, CurvanceOracleManagerAbi, TermMaxOracleAggregatorV2Abi } from '@1delta/abis';
11
11
  export { MorphoLensAbi } from '@1delta/abis';
12
12
  import { prepareDebitDataMulticall, prepareLenderDebitMulticall, parseDebitDataResult, parseLenderDebitResult, getPermit2ContractAddress, getLstAcceptedInputs, savingsVerbRequires, savingsSupportsVerb, getCompoundV2Comptroller as getCompoundV2Comptroller$1, getCompoundV3CometAddress as getCompoundV3CometAddress$1, getMorphoAddress, FLUID_VAULT_FACTORY, getAaveStyleLenderTokenAddress, LendingMode, getAaveCollateralTokenAddress, getSiloHalfForUnderlying, findSavingsWithdrawEntry, bandLtvCurve, InitMarginAddresses, ignoresReceiver, buildLstWithdrawRequest, SAVINGS_RECEIVER_CAPABILITY } from '@1delta/calldata-sdk';
@@ -11737,58 +11737,72 @@ function convertMarketsToMorphoResponse(response, chainId, additionalYields = {
11737
11737
  m,
11738
11738
  collateralAssetAddress
11739
11739
  );
11740
- data[m].data[collateralMarketUid] = {
11741
- marketUid: collateralMarketUid,
11742
- name: "Collateral " + (metaCollateral?.symbol ?? collateralAsset.symbol ?? ""),
11743
- poolId: collateralAssetAddress,
11744
- underlying: collateralAssetAddress,
11745
- asset: metaCollateral,
11746
- totalDeposits: formatNr(
11747
- state.collateralAssets,
11748
- collateralAsset.decimals
11749
- ),
11750
- totalDebtStable: 0,
11751
- totalDebt: 0,
11752
- totalLiquidity: formatNr(
11753
- state.collateralAssets,
11754
- collateralAsset.decimals
11755
- ),
11756
- borrowLiquidity: formatNr(
11757
- state.collateralAssets,
11758
- collateralAsset.decimals
11759
- ),
11760
- totalLiquidityUSD: Number(state.collateralAssetsUsd),
11761
- borrowLiquidityUSD: Number(state.collateralAssetsUsd),
11762
- totalDepositsUSD: Number(state.collateralAssetsUsd),
11763
- totalDebtStableUSD: 0,
11764
- totalDebtUSD: 0,
11765
- utilization: 0,
11766
- depositRate: 0,
11767
- variableBorrowRate: 0,
11768
- stableBorrowRate: 0,
11769
- intrinsicYield: additionalYields?.intrinsicYields?.[metaCollateral?.assetGroup] ?? 0,
11770
- rewards: void 0,
11771
- decimals: collateralAsset.decimals,
11772
- config: {
11740
+ const existingLoanRow = data[m].data[collateralMarketUid];
11741
+ if (existingLoanRow) {
11742
+ existingLoanRow.collateralActive = true;
11743
+ existingLoanRow.config = {
11773
11744
  0: {
11774
- category: 0,
11745
+ ...existingLoanRow.config?.[0] ?? {},
11775
11746
  borrowCollateralFactor: ltv,
11776
11747
  collateralFactor: ltv,
11777
- borrowFactor: 1,
11778
11748
  liquidationPenalty,
11779
- closeFactor: 1,
11780
- collateralDisabled: false,
11781
- debtDisabled: true
11749
+ collateralDisabled: false
11782
11750
  }
11783
- },
11784
- closeFactor: 1,
11785
- collateralActive: true,
11786
- borrowingEnabled: false,
11787
- depositsEnabled: true,
11788
- hasStable: false,
11789
- isActive: true,
11790
- isFrozen: false
11791
- };
11751
+ };
11752
+ } else {
11753
+ data[m].data[collateralMarketUid] = {
11754
+ marketUid: collateralMarketUid,
11755
+ name: "Collateral " + (metaCollateral?.symbol ?? collateralAsset.symbol ?? ""),
11756
+ poolId: collateralAssetAddress,
11757
+ underlying: collateralAssetAddress,
11758
+ asset: metaCollateral,
11759
+ totalDeposits: formatNr(
11760
+ state.collateralAssets,
11761
+ collateralAsset.decimals
11762
+ ),
11763
+ totalDebtStable: 0,
11764
+ totalDebt: 0,
11765
+ totalLiquidity: formatNr(
11766
+ state.collateralAssets,
11767
+ collateralAsset.decimals
11768
+ ),
11769
+ borrowLiquidity: formatNr(
11770
+ state.collateralAssets,
11771
+ collateralAsset.decimals
11772
+ ),
11773
+ totalLiquidityUSD: Number(state.collateralAssetsUsd),
11774
+ borrowLiquidityUSD: Number(state.collateralAssetsUsd),
11775
+ totalDepositsUSD: Number(state.collateralAssetsUsd),
11776
+ totalDebtStableUSD: 0,
11777
+ totalDebtUSD: 0,
11778
+ utilization: 0,
11779
+ depositRate: 0,
11780
+ variableBorrowRate: 0,
11781
+ stableBorrowRate: 0,
11782
+ intrinsicYield: additionalYields?.intrinsicYields?.[metaCollateral?.assetGroup] ?? 0,
11783
+ rewards: void 0,
11784
+ decimals: collateralAsset.decimals,
11785
+ config: {
11786
+ 0: {
11787
+ category: 0,
11788
+ borrowCollateralFactor: ltv,
11789
+ collateralFactor: ltv,
11790
+ borrowFactor: 1,
11791
+ liquidationPenalty,
11792
+ closeFactor: 1,
11793
+ collateralDisabled: false,
11794
+ debtDisabled: true
11795
+ }
11796
+ },
11797
+ closeFactor: 1,
11798
+ collateralActive: true,
11799
+ borrowingEnabled: false,
11800
+ depositsEnabled: true,
11801
+ hasStable: false,
11802
+ isActive: true,
11803
+ isFrozen: false
11804
+ };
11805
+ }
11792
11806
  data[m].params = {
11793
11807
  market: {
11794
11808
  lender: m,
@@ -16664,13 +16678,13 @@ var REPAIR_BACKOFF_JITTER_MS = 60;
16664
16678
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
16665
16679
  var backoffForRound = (round) => REPAIR_BACKOFF_BASE_MS * 2 ** round + Math.random() * REPAIR_BACKOFF_JITTER_MS;
16666
16680
  var endpointUrl = (client, rpcId) => client?.transport?.url ?? `rpc#${rpcId}`;
16667
- var resolveEndpoint = (chainId, getEvmClient20, startRpcId, tried, maxProbe = 12, timeoutMs) => {
16681
+ var resolveEndpoint = (chainId, getEvmClient19, startRpcId, tried, maxProbe = 12, timeoutMs) => {
16668
16682
  let fallback = null;
16669
16683
  for (let probe = 0; probe < maxProbe; probe++) {
16670
16684
  const rpcId = startRpcId + probe;
16671
16685
  let client;
16672
16686
  try {
16673
- client = getEvmClient20(chainId, rpcId, { timeoutMs });
16687
+ client = getEvmClient19(chainId, rpcId, { timeoutMs });
16674
16688
  } catch {
16675
16689
  break;
16676
16690
  }
@@ -16699,7 +16713,7 @@ var recordPermanentFailures = (slots, offset, collector) => {
16699
16713
  if (slots[i].permanent) collector.add(offset + i);
16700
16714
  }
16701
16715
  };
16702
- var repairFailedSlots = async (chainId, contracts, slots, getEvmClient20, nextRpcId, batchSize, logs, rounds = MULTICALL_REPAIR_ROUNDS, options) => {
16716
+ var repairFailedSlots = async (chainId, contracts, slots, getEvmClient19, nextRpcId, batchSize, logs, rounds = MULTICALL_REPAIR_ROUNDS, options) => {
16703
16717
  let searchFrom = nextRpcId;
16704
16718
  for (let round = 0; round < rounds; round++) {
16705
16719
  const failedIdx = [];
@@ -16709,7 +16723,7 @@ var repairFailedSlots = async (chainId, contracts, slots, getEvmClient20, nextRp
16709
16723
  if (failedIdx.length === 0) return slots;
16710
16724
  const endpoint = resolveEndpoint(
16711
16725
  chainId,
16712
- getEvmClient20,
16726
+ getEvmClient19,
16713
16727
  searchFrom,
16714
16728
  options?.tried
16715
16729
  );
@@ -16761,7 +16775,7 @@ var repairFailedSlots = async (chainId, contracts, slots, getEvmClient20, nextRp
16761
16775
  }
16762
16776
  return slots;
16763
16777
  };
16764
- var multicallShardedAbiArray = async (chainId, abi, calls, getEvmClient20, poolSize, retries = maxRetries, allowFailure = true, batchSize = MULTICALL_DEFAULT_BATCH_SIZE, logs = false, retryFailed = false, permanentFailures, options) => {
16778
+ var multicallShardedAbiArray = async (chainId, abi, calls, getEvmClient19, poolSize, retries = maxRetries, allowFailure = true, batchSize = MULTICALL_DEFAULT_BATCH_SIZE, logs = false, retryFailed = false, permanentFailures, options) => {
16765
16779
  const abiIsArray = isArray(abi[0]);
16766
16780
  const contracts = calls.map(({ address, name, params }, i) => ({
16767
16781
  abi: abiIsArray ? abi?.[i] : abi,
@@ -16835,7 +16849,7 @@ var multicallShardedAbiArray = async (chainId, abi, calls, getEvmClient20, poolS
16835
16849
  const attemptHedged = async (items, startRpcId, tried) => {
16836
16850
  const primary = resolveEndpoint(
16837
16851
  chainId,
16838
- getEvmClient20,
16852
+ getEvmClient19,
16839
16853
  startRpcId,
16840
16854
  tried,
16841
16855
  12,
@@ -16859,7 +16873,7 @@ var multicallShardedAbiArray = async (chainId, abi, calls, getEvmClient20, poolS
16859
16873
  clearTimeout(timer);
16860
16874
  const alt = resolveEndpoint(
16861
16875
  chainId,
16862
- getEvmClient20,
16876
+ getEvmClient19,
16863
16877
  primary.rpcId + 1,
16864
16878
  tried,
16865
16879
  12,
@@ -16911,7 +16925,7 @@ var multicallShardedAbiArray = async (chainId, abi, calls, getEvmClient20, poolS
16911
16925
  chainId,
16912
16926
  batch.items,
16913
16927
  slots,
16914
- getEvmClient20,
16928
+ getEvmClient19,
16915
16929
  won.rpcId + 1,
16916
16930
  requestBytes,
16917
16931
  logs,
@@ -16933,7 +16947,7 @@ var multicallShardedAbiArray = async (chainId, abi, calls, getEvmClient20, poolS
16933
16947
  const tried = /* @__PURE__ */ new Set();
16934
16948
  const start = resolveEndpoint(
16935
16949
  chainId,
16936
- getEvmClient20,
16950
+ getEvmClient19,
16937
16951
  workerId,
16938
16952
  void 0,
16939
16953
  12,
@@ -21544,31 +21558,17 @@ function convertMidnightMarketsToResponse(raw, chainId, prices = {}, _additional
21544
21558
  isActive: true,
21545
21559
  isFrozen: false
21546
21560
  };
21547
- config.collateralParams.forEach((c) => {
21561
+ config.collateralParams.forEach((c, i) => {
21548
21562
  const collAddr = c.token.toLowerCase();
21549
21563
  const ltv = parseLtv(c.lltv);
21550
21564
  const cursor = toBigIntOr0(c.liquidationCursor);
21551
21565
  const liquidationPenalty = cursor > 0n ? midnightLiquidationPenaltyNumber(toBigIntOr0(c.lltv), cursor) : liquidationPenaltyFromLltv(ltv);
21552
- const collUid = createMarketUid(chainId, m, collAddr);
21566
+ const collUid = createMarketUid(chainId, m, midnightCollateralRef(collAddr, i));
21553
21567
  const collAsset = tokens[collAddr];
21554
21568
  const collKey = toOracleKey(collAsset?.assetGroup) || toGenericPriceKey(collAddr, chainId);
21555
21569
  const collPrice = prices[collKey] ?? 0;
21556
21570
  const collCapacityUSD = ltv > 0 ? borrowLiquidity * loanPrice / ltv : borrowLiquidity * loanPrice;
21557
21571
  const collCapacity = collPrice > 0 ? collCapacityUSD / collPrice : 0;
21558
- const existing = entry.data[collUid];
21559
- if (existing) {
21560
- existing.collateralActive = true;
21561
- existing.config = {
21562
- 0: {
21563
- ...existing.config?.[0] ?? {},
21564
- borrowCollateralFactor: ltv,
21565
- collateralFactor: ltv,
21566
- liquidationPenalty,
21567
- collateralDisabled: false
21568
- }
21569
- };
21570
- return;
21571
- }
21572
21572
  entry.data[collUid] = {
21573
21573
  marketUid: collUid,
21574
21574
  name: "Collateral " + (tokens[collAddr]?.symbol ?? ""),
@@ -35021,7 +35021,11 @@ var getMidnightUserDataConverter = (_lender, chainId, account, meta) => {
35021
35021
  if (collAmt === 0n) return;
35022
35022
  anyBalance = true;
35023
35023
  const collAddr = c.token.toLowerCase();
35024
- const collUid = createMarketUid(chainId, lenderKey, collAddr);
35024
+ const collUid = createMarketUid(
35025
+ chainId,
35026
+ lenderKey,
35027
+ midnightCollateralRef(collAddr, i)
35028
+ );
35025
35029
  const collMeta = metaMap[collUid];
35026
35030
  const collDec = collMeta?.asset?.decimals ?? c.decimals;
35027
35031
  const collDisplayPrice = collMeta ? getDisplayPrice(collMeta) : 0;
@@ -42365,7 +42369,7 @@ function unflattenLenderData(pools) {
42365
42369
  }
42366
42370
  return result;
42367
42371
  }
42368
- var getLenderUserDataResult = async (chainId, queriesRaw, getEvmClient20, allowFailure = true, batchSize = MULTICALL_DEFAULT_BATCH_SIZE, retries = 3, logs = false, concurrency = 1, permanentFailures, onEndpointFailure) => {
42372
+ var getLenderUserDataResult = async (chainId, queriesRaw, getEvmClient19, allowFailure = true, batchSize = MULTICALL_DEFAULT_BATCH_SIZE, retries = 3, logs = false, concurrency = 1, permanentFailures, onEndpointFailure) => {
42369
42373
  const queries = organizeUserQueries(queriesRaw);
42370
42374
  const builtCalls = await Promise.all(
42371
42375
  queries.map(async (query3) => {
@@ -42375,7 +42379,7 @@ var getLenderUserDataResult = async (chainId, queriesRaw, getEvmClient20, allowF
42375
42379
  query3.lender,
42376
42380
  query3.account,
42377
42381
  query3.params,
42378
- getEvmClient20
42382
+ getEvmClient19
42379
42383
  );
42380
42384
  return callData.map((call) => ({ call, abi: call.abi ?? abi }));
42381
42385
  })
@@ -42385,7 +42389,7 @@ var getLenderUserDataResult = async (chainId, queriesRaw, getEvmClient20, allowF
42385
42389
  chainId,
42386
42390
  calls.map((call) => call.abi),
42387
42391
  calls.map((call) => call.call),
42388
- getEvmClient20,
42392
+ getEvmClient19,
42389
42393
  concurrency,
42390
42394
  retries,
42391
42395
  allowFailure,
@@ -54970,15 +54974,16 @@ function getMidnightCalls(chainId) {
54970
54974
  if (!market.marketId || !market.loanToken) continue;
54971
54975
  const legs = [];
54972
54976
  const calls = [];
54973
- for (const c of market.collateralParams ?? []) {
54974
- if (!c.oracle || !c.token) continue;
54977
+ (market.collateralParams ?? []).forEach((c, collateralIndex) => {
54978
+ if (!c.oracle || !c.token) return;
54975
54979
  legs.push({
54976
54980
  collateralAsset: c.token.toLowerCase(),
54977
54981
  collateralDecimals: c.decimals,
54978
- oracle: c.oracle
54982
+ oracle: c.oracle,
54983
+ collateralIndex
54979
54984
  });
54980
54985
  calls.push({ address: c.oracle, name: "price", params: [] });
54981
- }
54986
+ });
54982
54987
  if (legs.length === 0) continue;
54983
54988
  results.push({
54984
54989
  calls,
@@ -55027,7 +55032,11 @@ function parseMidnightResults(data, meta, context) {
55027
55032
  price: priceDebtToCollateral,
55028
55033
  // raw: collateral price in loan asset terms
55029
55034
  priceUSD: priceDebtToCollateral * loanAssetUSD,
55030
- marketUid: createMarketUid(chainId, lenderKey, leg.collateralAsset),
55035
+ marketUid: createMarketUid(
55036
+ chainId,
55037
+ lenderKey,
55038
+ midnightCollateralRef(leg.collateralAsset, leg.collateralIndex)
55039
+ ),
55031
55040
  targetLender: lenderKey,
55032
55041
  baseAsset: loanAsset
55033
55042
  });
@@ -76210,7 +76219,7 @@ function parseMulticallRpcResponses(responses, batches, allowFailure = true, per
76210
76219
  });
76211
76220
  return allResults;
76212
76221
  }
76213
- var ERC20MetadataAbi = [
76222
+ var ERC20_STRING_ABI = [
76214
76223
  {
76215
76224
  inputs: [],
76216
76225
  name: "name",
@@ -76233,38 +76242,110 @@ var ERC20MetadataAbi = [
76233
76242
  type: "function"
76234
76243
  }
76235
76244
  ];
76236
- async function fetchTokenMetadata(chain, addrs) {
76237
- const tokens = {};
76238
- const client = getEvmClient(chain);
76239
- const results = await client.multicall({
76240
- allowFailure: false,
76241
- batchSize: 300,
76242
- contracts: addrs.map((addr4) => [
76243
- {
76244
- abi: ERC20MetadataAbi,
76245
- functionName: "name",
76246
- address: addr4,
76247
- args: []
76248
- },
76249
- {
76250
- abi: ERC20MetadataAbi,
76251
- functionName: "symbol",
76252
- address: addr4,
76253
- args: []
76254
- },
76255
- {
76256
- abi: ERC20MetadataAbi,
76257
- functionName: "decimals",
76258
- address: addr4,
76259
- args: []
76260
- }
76261
- ]).flat()
76245
+ var ERC20_BYTES32_ABI = [
76246
+ {
76247
+ inputs: [],
76248
+ name: "name",
76249
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
76250
+ stateMutability: "view",
76251
+ type: "function"
76252
+ },
76253
+ {
76254
+ inputs: [],
76255
+ name: "symbol",
76256
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
76257
+ stateMutability: "view",
76258
+ type: "function"
76259
+ }
76260
+ ];
76261
+ var FAILED = "0x";
76262
+ function decodeBytes32(value) {
76263
+ if (typeof value !== "string" || !value.startsWith("0x")) return void 0;
76264
+ if (value === FAILED) return void 0;
76265
+ try {
76266
+ const decoded = hexToString(value).replace(/\0+$/, "").trim();
76267
+ return decoded.length > 0 ? decoded : void 0;
76268
+ } catch {
76269
+ return void 0;
76270
+ }
76271
+ }
76272
+ function asString(value) {
76273
+ if (typeof value !== "string") return void 0;
76274
+ if (value === FAILED) return void 0;
76275
+ const trimmed = value.trim();
76276
+ return trimmed.length > 0 ? trimmed : void 0;
76277
+ }
76278
+ async function fetchTokenMetadata(chain, addrs, options = {}) {
76279
+ const { rpcUrls, maxRetries: maxRetries2 = 3 } = options;
76280
+ const unique = [
76281
+ ...new Set(
76282
+ addrs.filter((a) => typeof a === "string" && isAddress(a, { strict: false })).map((a) => a.toLowerCase())
76283
+ )
76284
+ ];
76285
+ if (unique.length === 0) return {};
76286
+ const multicall = createMulticallRetryUniversal(
76287
+ rpcUrls?.length ? { [chain]: rpcUrls } : LIST_OVERRIDES
76288
+ );
76289
+ const calls = unique.flatMap((address) => [
76290
+ { address, name: "name", args: [] },
76291
+ { address, name: "symbol", args: [] },
76292
+ { address, name: "decimals", args: [] }
76293
+ ]);
76294
+ const results = await multicall({
76295
+ chain,
76296
+ calls,
76297
+ abi: ERC20_STRING_ABI,
76298
+ maxRetries: maxRetries2,
76299
+ allowFailure: true
76300
+ });
76301
+ const names = /* @__PURE__ */ new Map();
76302
+ const symbols = /* @__PURE__ */ new Map();
76303
+ const decimalsByAddr = /* @__PURE__ */ new Map();
76304
+ unique.forEach((address, i) => {
76305
+ names.set(address, asString(results[i * 3]));
76306
+ symbols.set(address, asString(results[i * 3 + 1]));
76307
+ const raw = results[i * 3 + 2];
76308
+ decimalsByAddr.set(
76309
+ address,
76310
+ typeof raw === "number" ? raw : typeof raw === "bigint" ? Number(raw) : void 0
76311
+ );
76262
76312
  });
76263
- addrs.forEach((addr4, i) => {
76264
- const name = results[i * 3];
76265
- const symbol = results[i * 3 + 1];
76266
- const decimals = results[i * 3 + 2];
76267
- const address = addr4.toLowerCase();
76313
+ const needsBytes32 = unique.filter(
76314
+ (a) => decimalsByAddr.get(a) !== void 0 && (names.get(a) === void 0 || symbols.get(a) === void 0)
76315
+ );
76316
+ if (needsBytes32.length > 0) {
76317
+ const b32Calls = needsBytes32.flatMap((address) => [
76318
+ { address, name: "name", args: [] },
76319
+ { address, name: "symbol", args: [] }
76320
+ ]);
76321
+ try {
76322
+ const b32 = await multicall({
76323
+ chain,
76324
+ calls: b32Calls,
76325
+ abi: ERC20_BYTES32_ABI,
76326
+ maxRetries: maxRetries2,
76327
+ allowFailure: true
76328
+ });
76329
+ needsBytes32.forEach((address, i) => {
76330
+ if (names.get(address) === void 0) {
76331
+ const decoded = decodeBytes32(b32[i * 2]);
76332
+ if (decoded) names.set(address, decoded);
76333
+ }
76334
+ if (symbols.get(address) === void 0) {
76335
+ const decoded = decodeBytes32(b32[i * 2 + 1]);
76336
+ if (decoded) symbols.set(address, decoded);
76337
+ }
76338
+ });
76339
+ } catch {
76340
+ }
76341
+ }
76342
+ const tokens = {};
76343
+ for (const address of unique) {
76344
+ const decimals = decimalsByAddr.get(address);
76345
+ if (decimals === void 0 || !Number.isInteger(decimals)) continue;
76346
+ if (decimals < 0 || decimals > 36) continue;
76347
+ const symbol = symbols.get(address) ?? `${address.slice(0, 6)}\u2026`;
76348
+ const name = names.get(address) ?? symbol;
76268
76349
  tokens[address] = {
76269
76350
  chainId: String(chain),
76270
76351
  decimals,
@@ -76274,7 +76355,7 @@ async function fetchTokenMetadata(chain, addrs) {
76274
76355
  assetGroup: `${symbol}::${name}`,
76275
76356
  currencyId: `${symbol}::${name}`
76276
76357
  };
76277
- });
76358
+ }
76278
76359
  return tokens;
76279
76360
  }
76280
76361
  function balanceFetcher() {