@1delta/margin-fetcher 5.0.20 → 5.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -7859,6 +7859,347 @@ declare const accountDepositListKey: (account: Address) => Hex;
7859
7859
  /** Key of the set holding `account`'s pending GM withdrawal request keys. */
7860
7860
  declare const accountWithdrawalListKey: (account: Address) => Hex;
7861
7861
 
7862
+ /**
7863
+ * A Pendle Principal Token, modelled as a fixed-rate earn product.
7864
+ *
7865
+ * ## Why this is a provider and not an ERC-4626 vault
7866
+ *
7867
+ * A PT is a zero-coupon bond, not a share. There is no `deposit`, no
7868
+ * `convertToAssets`, and no share price that accrues: you BUY the PT on
7869
+ * Pendle's AMM at a discount to face value, and at `expiry` it redeems 1:1 for
7870
+ * the underlying. The yield is the discount, fixed the moment you buy.
7871
+ *
7872
+ * Consequences that shape every field below, and that a consumer must not
7873
+ * paper over:
7874
+ *
7875
+ * - **No `totalAssets` / `totalSupply` / `sharePrice`.** Nothing here is a
7876
+ * share/asset ratio. Size is reported in USD only, exactly like the other
7877
+ * two non-4626 providers (GMX, HyperCore), and this provider is likewise
7878
+ * excluded from `buildVaultLookup`.
7879
+ * - **Entry and exit are SWAPS.** Both legs route through the Pendle
7880
+ * aggregator (already integrated as `TradeAggregator.Pendle`), so both need
7881
+ * a slippage tolerance and both are priced by pool depth — which is what
7882
+ * `liquidityUsd` reports.
7883
+ * - **The row is only valid until `expiry`.** After it, the fixed rate is
7884
+ * meaningless (the PT redeems at par, so the forward yield is zero) and the
7885
+ * product is gone. Expired markets are dropped by the fetcher; see
7886
+ * `isLiveMarket`.
7887
+ */
7888
+ interface PendlePtMarket extends VaultClassificationFields {
7889
+ /** PT token address, lowercased. This is what a holder actually owns. */
7890
+ address: string;
7891
+ /** The Pendle AMM market contract, lowercased. Where the swap routes. */
7892
+ marketAddress: string;
7893
+ /**
7894
+ * Underlying/accounting asset address, lowercased — what the PT redeems for
7895
+ * at maturity, and the denomination of the fixed rate.
7896
+ */
7897
+ underlying: string;
7898
+ /** YT address, lowercased. The complement; `PT + YT = SY`. */
7899
+ ytAddress?: string;
7900
+ /** SY (Standardised Yield wrapper) address, lowercased. */
7901
+ syAddress?: string;
7902
+ /** PT symbol, e.g. `PT-wstETH-30DEC2027`. */
7903
+ symbol: string;
7904
+ /** Display name for the market. */
7905
+ name: string;
7906
+ /**
7907
+ * PT decimals.
7908
+ *
7909
+ * **NOT reliably equal to the underlying's** — 9 of 57 live Ethereum markets
7910
+ * disagreed at integration (PT-mHyperBTC is 8 over an 18-decimal
7911
+ * mHyperBTC). Sourced from the token list, or read on-chain; a market whose
7912
+ * PT decimals cannot be established is DROPPED rather than defaulted, since
7913
+ * a wrong value mis-scales every amount silently.
7914
+ */
7915
+ decimals: number;
7916
+ /** Underlying asset decimals. */
7917
+ assetDecimals: number;
7918
+ /** Unix SECONDS. */
7919
+ expiry: number;
7920
+ /** ISO-8601 mirror, straight from the API. */
7921
+ expiryIso: string;
7922
+ /** Snapshot at fetch time — recompute from `expiry` for a live countdown. */
7923
+ secondsToExpiry: number;
7924
+ /** `secondsToExpiry` in days, rounded to 2dp. Convenience for display. */
7925
+ daysToExpiry: number;
7926
+ /**
7927
+ * The fixed yield to maturity, as a nominal APR percent.
7928
+ *
7929
+ * Converted from the API's `impliedApy`, which is a compounded APY fraction.
7930
+ * `impliedApyPercent` below carries Pendle's own figure unconverted, because
7931
+ * that is what pendle.finance displays and a user WILL compare the two.
7932
+ */
7933
+ supplyRate: number;
7934
+ /** Always 0 — PENDLE emissions accrue to LPs, never to PT holders. */
7935
+ rewardsRate: number;
7936
+ /** `supplyRate + rewardsRate`. The headline. */
7937
+ depositRate: number;
7938
+ /** Pendle's `impliedApy` as a percent, uncompounded-out. Display parity. */
7939
+ impliedApyPercent: number;
7940
+ /**
7941
+ * The SY's own floating yield (percent APR) — what a PT buyer GIVES UP.
7942
+ * Context for "is this fixed rate a good deal", never the row's own rate.
7943
+ */
7944
+ underlyingApyPercent?: number;
7945
+ /** AMM swap fee as a fraction of the traded amount, e.g. `0.0005`. */
7946
+ feeRate?: number;
7947
+ /**
7948
+ * Whole-market TVL in USD (`details.totalTvl`).
7949
+ *
7950
+ * USD-only by construction — there is no token-denominated "total assets"
7951
+ * for a PT. Mirrors GMX/HyperCore, which also report USD and set the raw
7952
+ * base-unit fields to null.
7953
+ */
7954
+ totalAssetsUsd: number;
7955
+ /**
7956
+ * Same number as {@link totalAssetsUsd}. Present because the cross-source
7957
+ * sort field on `/v1/data/earn` is `formatted`, and for a USD-denominated
7958
+ * provider the USD figure IS the comparable magnitude — the convention GMX
7959
+ * and HyperCore already established in the recorder.
7960
+ */
7961
+ totalAssetsFormatted: number;
7962
+ /**
7963
+ * AMM pool depth in USD (`details.liquidity`) — what can actually be traded
7964
+ * in or out right now. For a PT this is the real exit constraint: the
7965
+ * position is always sellable in principle and rarely sellable in size.
7966
+ */
7967
+ liquidityUsd: number;
7968
+ /** Permissionless — anyone can buy a PT. Always true; kept explicit. */
7969
+ isMintable: boolean;
7970
+ /** `market-sale`: exit is selling on Pendle's AMM at the prevailing price. */
7971
+ withdrawalMode: 'market-sale';
7972
+ /** Hydrated underlying metadata from the token list, if available. */
7973
+ asset?: GenericCurrency;
7974
+ /** USD price of one underlying unit, when a price map was supplied. */
7975
+ priceUsd?: number;
7976
+ /** USD price of one PT, from Pendle's own price feed when available. */
7977
+ ptPriceUsd?: number;
7978
+ /** Pendle's category tags, e.g. `['eth','blue-chips','lido']`. */
7979
+ categoryIds?: string[];
7980
+ /** The protocol behind the underlying, per Pendle, e.g. `Lido`. */
7981
+ protocol?: string;
7982
+ }
7983
+ /** Per-chain map, keyed by lowercased PT address (parity with the other providers). */
7984
+ type PendlePtMarkets = {
7985
+ [ptAddress: string]: PendlePtMarket;
7986
+ };
7987
+
7988
+ interface FetchPendlePtOptions {
7989
+ /**
7990
+ * Include markets that have already matured.
7991
+ *
7992
+ * **Default `false`, and that default is the point of this provider.** An
7993
+ * expired PT redeems at par, so its forward yield is zero — but every rate
7994
+ * field the API and the token list carry still holds the last pre-expiry
7995
+ * value. Serving those rows would put a stale fixed APY at the top of an
7996
+ * APR-sorted earn list on a product that no longer exists.
7997
+ *
7998
+ * The escape hatch exists for the same reason yield-tracer's `/assets`
7999
+ * route has one: a user who HOLDS a matured PT still needs the row to
8000
+ * redeem it. Mirrors `?includeExpired=` there, including the name.
8001
+ */
8002
+ includeExpired?: boolean;
8003
+ /**
8004
+ * Clock override, unix seconds. Tests only — production always judges
8005
+ * expiry against the real clock, never against a cached flag.
8006
+ */
8007
+ nowSecs?: number;
8008
+ }
8009
+ /**
8010
+ * Fetch every LIVE Pendle PT market on a chain, modelled as fixed-rate earn
8011
+ * products.
8012
+ *
8013
+ * **HTTP-only in every normal case.** Token metadata resolves in three tiers —
8014
+ * the caller's token list, then Pendle's own global asset listing, then an
8015
+ * on-chain `decimals()` multicall — and each tier is consulted only for what
8016
+ * the previous one could not answer. A caller with a hydrated token list makes
8017
+ * exactly ONE request (the shared, cached markets listing); a caller with none
8018
+ * (the worker's `?source=live` path passes `{}`) makes two, and still never
8019
+ * touches an RPC.
8020
+ *
8021
+ * The multicall is a last resort on purpose. Reading `decimals()` for ~110 PTs
8022
+ * on Ethereum makes the entire chain's listing hostage to one multicall, and
8023
+ * viem's `allowFailure` returns `'0x'` per call instead of throwing when the
8024
+ * transport dies — so the failure mode is a silent, complete disappearance of
8025
+ * Pendle on the busiest chain rather than an error anyone would notice.
8026
+ *
8027
+ * @param chainId target chain
8028
+ * @param multicallRetry last-resort decimals gap-fill only; usually unused
8029
+ * @param prices price map keyed by oracle key / address
8030
+ * @param tokenList token list for PT + underlying metadata
8031
+ * @param options `includeExpired` and a test clock — see
8032
+ * {@link FetchPendlePtOptions}
8033
+ *
8034
+ * @returns map keyed by lowercased PT address; empty on chains without a
8035
+ * Pendle deployment.
8036
+ */
8037
+ declare const fetchPendlePtMarkets: (chainId: string, multicallRetry: MulticallRetryFunction, prices?: {
8038
+ [asset: string]: number;
8039
+ }, tokenList?: GenericTokenList, options?: FetchPendlePtOptions) => Promise<PendlePtMarkets>;
8040
+
8041
+ /**
8042
+ * Pendle V2 public market listing.
8043
+ *
8044
+ * ONE un-paginated endpoint returns every Pendle market on every chain,
8045
+ * including the per-market `details` block (implied APY, pool liquidity, TVL).
8046
+ * That is the whole data source for this provider — no multicall, no subgraph,
8047
+ * no API key.
8048
+ *
8049
+ * https://api-v2.pendle.finance/core/v1/markets/all
8050
+ *
8051
+ * There is also a per-chain `/v1/{chainId}/markets/active`, which pre-filters
8052
+ * to live markets. We deliberately do NOT use it: it costs one request per
8053
+ * chain for the same data, and — more importantly — expiry has to be judged
8054
+ * here anyway (see {@link isLiveMarket}), so taking the filter from the API
8055
+ * would just move the one rule this provider must never get wrong out of our
8056
+ * code and into someone else's.
8057
+ *
8058
+ * Docs: https://docs.pendle.finance/pendle-v2/introduction
8059
+ */
8060
+ declare const PENDLE_MARKETS_URL = "https://api-v2.pendle.finance/core/v1/markets/all";
8061
+ /**
8062
+ * Token metadata for every Pendle-known asset on every chain — decimals,
8063
+ * symbol, name, icon. One global call, same as the markets listing.
8064
+ *
8065
+ * It exists here because `/markets/all` publishes addresses but NO decimals,
8066
+ * and a PT's decimals cannot be inferred from its underlying's (they disagree
8067
+ * on ~16 % of live markets). The alternative — reading `decimals()` on-chain
8068
+ * for every PT — makes the whole provider depend on a ~110-call multicall on
8069
+ * Ethereum, and when that multicall fails viem returns `'0x'` per call rather
8070
+ * than throwing, so the entire chain's listing silently disappears. Observed,
8071
+ * not hypothesised. An HTTP source that fails loudly is the better dependency.
8072
+ */
8073
+ declare const PENDLE_ASSETS_URL = "https://api-v2.pendle.finance/core/v1/assets/all";
8074
+ /**
8075
+ * Chains with Pendle deployments. The endpoint is global (it returns every
8076
+ * chain regardless), so this set exists only to skip the round-trip on chains
8077
+ * Pendle does not cover — the parser is chain-agnostic and a new chain appears
8078
+ * as soon as it is added here.
8079
+ */
8080
+ declare const PENDLE_CHAIN_IDS: Set<string>;
8081
+ declare const hasPendleMarkets: (chainId: string) => boolean;
8082
+ /**
8083
+ * The `details` block. Every field is a FRACTION (`0.0721` = 7.21 %) except
8084
+ * the three USD amounts.
8085
+ *
8086
+ * **Only `impliedApy` describes what a PT holder earns.** The others are
8087
+ * different products' numbers sharing one object, and picking the wrong one is
8088
+ * the same class of error as TermMax's maker-side `apr()` naming:
8089
+ *
8090
+ * - `impliedApy` — the fixed yield locked in by buying PT and holding to
8091
+ * maturity. THE PT RATE.
8092
+ * - `underlyingApy` — the SY's own floating yield. What the YT side earns,
8093
+ * and what PT holders give up.
8094
+ * - `pendleApy` — PENDLE emissions paid to LPs. Not to PT holders.
8095
+ * - `aggregatedApy` / `maxBoostedApy` / `swapFeeApy` — LP-side returns.
8096
+ */
8097
+ interface PendleApiMarketDetails {
8098
+ /** AMM pool depth, USD. What can actually be traded in or out. */
8099
+ liquidity?: number | null;
8100
+ /** Whole-market TVL, USD (pool + SY backing). */
8101
+ totalTvl?: number | null;
8102
+ tradingVolume?: number | null;
8103
+ /** Fixed yield to maturity, as a FRACTION. The PT rate. */
8104
+ impliedApy?: number | null;
8105
+ /** The SY's floating yield, as a FRACTION. NOT the PT rate. */
8106
+ underlyingApy?: number | null;
8107
+ /** PENDLE emissions to LPs, as a FRACTION. NOT the PT rate. */
8108
+ pendleApy?: number | null;
8109
+ /** LP total, as a FRACTION. NOT the PT rate. */
8110
+ aggregatedApy?: number | null;
8111
+ maxBoostedApy?: number | null;
8112
+ swapFeeApy?: number | null;
8113
+ /** AMM swap fee, as a FRACTION of the traded amount. */
8114
+ feeRate?: number | null;
8115
+ yieldRange?: {
8116
+ min?: number | null;
8117
+ max?: number | null;
8118
+ } | null;
8119
+ }
8120
+ /**
8121
+ * One `markets[]` entry.
8122
+ *
8123
+ * **`pt` / `yt` / `sy` / `underlyingAsset` are `"<chainId>-<address>"`**, not
8124
+ * bare addresses — see {@link splitChainScopedAddress}. `expiry` is ISO-8601,
8125
+ * not a unix stamp (the token list carries the unix form).
8126
+ */
8127
+ interface PendleApiMarket {
8128
+ /** Underlying's display name, e.g. `wstETH` — NOT the PT symbol. */
8129
+ name?: string | null;
8130
+ /** The AMM market contract, a bare address. */
8131
+ address?: string | null;
8132
+ /** ISO-8601. */
8133
+ expiry?: string | null;
8134
+ /** `"1-0xb253…"` */
8135
+ pt?: string | null;
8136
+ yt?: string | null;
8137
+ sy?: string | null;
8138
+ underlyingAsset?: string | null;
8139
+ accountingAsset?: string | null;
8140
+ protocol?: string | null;
8141
+ icon?: string | null;
8142
+ details?: PendleApiMarketDetails | null;
8143
+ isNew?: boolean | null;
8144
+ isPrime?: boolean | null;
8145
+ categoryIds?: string[] | null;
8146
+ chainId?: number | null;
8147
+ }
8148
+ /**
8149
+ * Split Pendle's `"<chainId>-<address>"` composite into its parts.
8150
+ *
8151
+ * Returns `undefined` for anything that is not that shape — a bare address
8152
+ * included. Pendle has never returned one, and silently accepting it would
8153
+ * mean guessing the chain, which is how a market gets attributed to the wrong
8154
+ * network.
8155
+ */
8156
+ declare function splitChainScopedAddress(value: string | null | undefined): {
8157
+ chainId: string;
8158
+ address: string;
8159
+ } | undefined;
8160
+ /** Parse the ISO-8601 `expiry` to unix SECONDS. `undefined` when unparseable. */
8161
+ declare function parseExpirySeconds(expiry: string | null | undefined): number | undefined;
8162
+ /**
8163
+ * Is this market still live?
8164
+ *
8165
+ * **Judged against the clock, every time — never off a cached flag.** The
8166
+ * token list carries a `props.pendle.expired` boolean that is only as fresh as
8167
+ * the last regeneration, and an expired PT that keeps showing a pre-expiry
8168
+ * fixed APY is precisely the bug yield-tracer migration 0088 had to clean up
8169
+ * after. A market with no parseable expiry is treated as NOT live: an
8170
+ * unbounded fixed-rate row is never the safe default.
8171
+ */
8172
+ declare function isLiveMarket(market: PendleApiMarket, nowSecs?: number): boolean;
8173
+ /** One `assets[]` entry from {@link PENDLE_ASSETS_URL}. */
8174
+ interface PendleApiAsset {
8175
+ chainId?: number | null;
8176
+ address?: string | null;
8177
+ symbol?: string | null;
8178
+ name?: string | null;
8179
+ decimals?: number | null;
8180
+ /** `['PT']`, `['YT']`, `['SY']`, … */
8181
+ tags?: string[] | null;
8182
+ expiry?: string | null;
8183
+ proIcon?: string | null;
8184
+ }
8185
+ /** Drop both cached listings. Tests only. */
8186
+ declare function clearPendleMarketsCache(): void;
8187
+ /**
8188
+ * Fetch the global Pendle market listing (all chains, live and expired).
8189
+ *
8190
+ * Chain filtering, expiry filtering and normalization happen in `fetchPublic`.
8191
+ */
8192
+ declare function fetchPendleApiMarkets(): Promise<PendleApiMarket[]>;
8193
+ /** `"<chainId>-<lowercased address>"` — the key both Pendle listings use. */
8194
+ declare const assetKey: (chainId: string | number, address: string) => string;
8195
+ /**
8196
+ * Fetch Pendle's global asset metadata, keyed by {@link assetKey}.
8197
+ *
8198
+ * Only called when something is missing from the caller's token list, so a
8199
+ * fully-hydrated caller pays nothing for it.
8200
+ */
8201
+ declare function fetchPendleApiAssets(): Promise<Map<string, PendleApiAsset>>;
8202
+
7862
8203
  /**
7863
8204
  * Vault interface family, detected via ERC-165 `supportsInterface`.
7864
8205
  *
@@ -7965,7 +8306,7 @@ interface VaultLookupEntry {
7965
8306
  declare function buildVaultLookup(data: VaultPublicDataAll): Map<string, VaultLookupEntry>;
7966
8307
 
7967
8308
  /** Supported ERC-4626 vault providers. */
7968
- type VaultProvider = 'fluid' | 'gearbox' | 'morpho' | 'lista' | 'silo' | 'euler-earn' | 'termmax' | 'lst' | 'savings' | 'lagoon' | 'aave-earn' | 'upshift' | 'yearn' | 'hypercore' | 'gmx';
8309
+ type VaultProvider = 'fluid' | 'gearbox' | 'morpho' | 'lista' | 'silo' | 'euler-earn' | 'termmax' | 'lst' | 'savings' | 'lagoon' | 'aave-earn' | 'upshift' | 'yearn' | 'hypercore' | 'gmx' | 'pendle';
7969
8310
  /**
7970
8311
  * Per-provider payload returned by `getVaultPublicDataAll`. Each entry is
7971
8312
  * present only when the matching provider was requested AND its fetch
@@ -8009,12 +8350,30 @@ interface VaultPublicDataAll {
8009
8350
  /** Per-chain minimum GM/GLV execution fees (wei). Populated alongside
8010
8351
  * `gmx`. Gas-price-derived, so treat as fresh-at-fetch estimates. */
8011
8352
  gmxExecutionFees?: GmxExecutionFees;
8353
+ /** Pendle V2 Principal Tokens as fixed-rate earn products — one row per
8354
+ * LIVE market, keyed by lowercased PT address. **Matured markets are
8355
+ * never included** (an expired PT redeems at par, so its published fixed
8356
+ * APY is stale by definition); pass `pendleIncludeExpired` to override,
8357
+ * which only a holder-facing redeem flow should ever do. Not a share
8358
+ * token: no `totalAssets`/`totalSupply`/share price, USD-denominated
8359
+ * size, and excluded from `buildVaultLookup` — the GMX/HyperCore
8360
+ * precedent. */
8361
+ pendle?: PendlePtMarkets;
8012
8362
  }
8013
8363
  interface GetVaultPublicDataAllOptions {
8014
8364
  /** Narrow Silo to a single protocol version (`v2` or `v3`). */
8015
8365
  siloProtocolVersion?: 'v2' | 'v3';
8016
8366
  /** Page size hint for Silo's GraphQL query. */
8017
8367
  siloLimit?: number;
8368
+ /**
8369
+ * Include MATURED Pendle PT markets. Default `false`.
8370
+ *
8371
+ * Only a flow that services an existing holder (redeem a PT you already
8372
+ * own) should set this. Any listing, ranking or discovery surface must
8373
+ * leave it off: a matured PT still publishes its last pre-expiry implied
8374
+ * APY, and that number is not an offer.
8375
+ */
8376
+ pendleIncludeExpired?: boolean;
8018
8377
  }
8019
8378
  /**
8020
8379
  * Combined output of `getVaultPublicDataAll`: the rich per-provider
@@ -10126,4 +10485,788 @@ interface TermAdapter {
10126
10485
  declare const TERM_ADAPTERS: TermAdapter[];
10127
10486
  declare function resolveAdapter(lender: string): TermAdapter | undefined;
10128
10487
 
10129
- 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 ChainDiagnostic, type ChainLinkResponse, type ChainQuery, type ChainSummary, type CompoundV2Metadata, type CompoundV3Public, type CompoundV3UserReserveResponse, type ConfigEntry, type ConvertLenderUserDataOptions, type CoreValidators, type CounterpartyTerms, type CoverageInfo, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, type DeepPartial, type Denomination, type DepthMap, type DssMarketRaw, type DssMarketsRaw, type DssPositionInfo, EMPTY_BALANCE, type EModeAssets, type EModeData, type EModeResult, EXACTLY_LENDER_KEY, 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, type FeeTerm, type FeeWhen, type FeedObservation, type FeedStat, type FeedStatsMap, type FeedTimestampMap, type FetchListaVaultsFromChainOptions, type FetchMorphoVaultsFromChainOptions, type FetchOraclePricesOptions, type FetchTokenBalancesOptions, type FlattenPriorityConfig, type FluidFToken, type FluidFTokens, type FrankencoinMarketRaw, type FrankencoinMarketsRaw, type FrankencoinPositionInfo, 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, type ParsedBalanceData, type ParsedResponse, type ParsedUserBalance, type PermissionKind, type PermissionParams, type PoolData, 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, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, type SelectPricesOptions, type Severity, type SeverityFinding, type SiloVault, type SiloVaults, type StCeloValidatorGroup, type StaleFeedEntry, type StampOptions, type StructuredOraclePrices, type SubAccountSummary, type SumerPositionInput, type SummaryAprData, type SummaryBalanceData, type SupplyExitMode, type SupplyExitTerms, type SupplyTermSheet, TELLER_CALLS_PER_BID, TERMMAX_CALLS_PER_ACCOUNT, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, 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 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, 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_SHARE_PRICE_PROBE, VOLATILE_VAULT_OVERRIDES, type ValidationResult, type VaultAprResult, type VaultClassification, type VaultClassificationFields, type VaultLookupEntry, type VaultMarketExposure, type VaultProvider, type VaultPublicDataAll, type VaultPublicDataResult, type VaultYieldSeries, type VaultYieldSnapshot, type YDaemonVault, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, type YearnVault, type YearnVaultKind, type YearnVaults, type YieldProfile, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, borrowDescription, borrowFindings, borrowHeadline, buildExposures, buildFluidFTokensCall, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, collectFeedObservations, computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFrankencoinMarketsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, detectInterfaceKinds, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchFrankencoinMarkets, fetchGeneralYields, fetchGeneralYieldsByMarketUid, fetchGmxExecutionFees, fetchGmxTickerPrices, fetchGmxVaults, fetchHypercoreVaults, fetchInverseMarkets, fetchLagoonApiVaults, fetchLagoonVaults, fetchLiquityMarkets, fetchListaVaultsFromChain, fetchLlamaLendMarkets, fetchMorphoUserBalances, fetchMorphoUserPositionMarkets, fetchMorphoVaults, fetchMorphoVaultsFromApi, fetchMorphoVaultsFromChain, fetchOraclePrices, fetchPendlePrices, fetchResupplyMarkets, fetchRiverMarkets, fetchSiloVaults, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, finalizeInfo, findingsFor, frankencoinKeyParts, frankencoinLenderKey, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, inverseKeyParts, inverseLenderKey, isFailedCall, isStablecoinSymbol, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, llamaLendKeyParts, llamaLendLenderKey, mergeDeep, multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseMergedResult, parseMulticallRpcResponses, parseRawRpcBatchResponses, parseRawRpcResponses, parseTermMaxLtv, parseTokenBalanceResult, pct, positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveAdapter, resolveDerivation, resolveStCeloDepositGroup, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, selectAssetGroupPrices, shortDate, stampVaultClassification, supplyDescription, supplyFindings, supplyHeadline, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, tickToAprNumber, tickToPrice, toDigest, toTermSheetInput, unflattenLenderData, updateFeedStats, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData };
10488
+ /**
10489
+ * `earnUid` — the primary key of the unified earn surface.
10490
+ *
10491
+ * There is NO single unified format, and deliberately so. There are two forms
10492
+ * sharing one grammar (`<venue>:<chainId>:<ref>`):
10493
+ *
10494
+ * ```
10495
+ * lending → <Lender>:<chainId>:<ref> the EXISTING marketUid, verbatim
10496
+ * vault → vault.<provider>:<chainId>:<address> the only new form
10497
+ * ```
10498
+ *
10499
+ * Reusing the grammar rather than inventing a format is what buys zero
10500
+ * migration on the lending half: a lending row's `earnUid` IS its `marketUid`,
10501
+ * so it is already valid on every existing action route.
10502
+ *
10503
+ * **The uid is OPAQUE.** The meaning of the third segment is venue-dependent —
10504
+ * on the lending side it is the underlying for Aave/Morpho/Compound V3, the
10505
+ * cToken for Compound V2, the silo for Silo, the eVault for Euler, and an
10506
+ * INTEGER marketId for Dolomite (not an address at all). Only `parseEarnUid`
10507
+ * may split an `earnUid`; consumers read `EarnMarket.asset.address` to learn
10508
+ * what to deposit, never the uid.
10509
+ *
10510
+ * See EARN_ENDPOINT_PLAN.md §3.
10511
+ */
10512
+ /**
10513
+ * Namespace prefix marking the vault form. Vault providers are lowercase and
10514
+ * `Lender` keys are uppercase, so bare provider names would already be
10515
+ * collision-free — but only by case, which one consumer lowercasing a uid
10516
+ * somewhere would silently break. The prefix makes the distinction structural
10517
+ * and `isVaultVenue` a `startsWith`.
10518
+ */
10519
+ declare const VAULT_VENUE_PREFIX = "vault.";
10520
+ /** A lending venue is a `Lender` key; a vault venue is `vault.<provider>`. */
10521
+ type EarnVenueKind = 'lending' | 'vault';
10522
+ interface ParsedLendingEarnUid {
10523
+ kind: 'lending';
10524
+ /** The `Lender` key, e.g. `AAVE_V3`. */
10525
+ venue: string;
10526
+ chainId: string;
10527
+ /**
10528
+ * The uid's third segment. Venue-dependent — resolve it with the worker's
10529
+ * `parseMarketUid`, never by assuming it is a token address.
10530
+ */
10531
+ ref: string;
10532
+ /** Byte-identical to the input. Pass straight to `parseMarketUid`. */
10533
+ marketUid: string;
10534
+ }
10535
+ interface ParsedVaultEarnUid {
10536
+ kind: 'vault';
10537
+ /** The full venue string, e.g. `vault.savings`. */
10538
+ venue: string;
10539
+ /** The bare provider, e.g. `savings`. */
10540
+ provider: VaultProvider;
10541
+ chainId: string;
10542
+ /** Lowercased share-token address (L1 vault address for hypercore). */
10543
+ address: string;
10544
+ }
10545
+ type ParsedEarnUid = ParsedLendingEarnUid | ParsedVaultEarnUid;
10546
+ /**
10547
+ * Cheap syntactic check — does this uid use the vault form? Does not validate
10548
+ * the provider; use `parseEarnUid` when correctness matters.
10549
+ */
10550
+ declare function isVaultVenue(uidOrVenue: string): boolean;
10551
+ /** `savings` → `vault.savings`. */
10552
+ declare function vaultVenue(provider: VaultProvider): string;
10553
+ /**
10554
+ * Mint the vault form from its parts. The address is lowercased to match the
10555
+ * canonical keying used across the vault pipeline (`buildVaultLookup` and the
10556
+ * `${chainId}-${address}` DB convention both lowercase).
10557
+ *
10558
+ * @throws if any part is empty.
10559
+ */
10560
+ declare function buildVaultEarnUid(provider: VaultProvider, chainId: string, address: string): string;
10561
+ /**
10562
+ * The lending form. This is the IDENTITY FUNCTION over `marketUid` — it exists
10563
+ * so call sites read as a deliberate mapping rather than an assignment, and so
10564
+ * the shape is validated once at the boundary.
10565
+ *
10566
+ * Never RECONSTRUCT a lending uid from a row's fields. `/pools/latest` rows
10567
+ * carry `marketUid` stamped by the public-data parsers; rebuilding it as
10568
+ * `lender:chainId:underlying` is only correct for the default-format lenders
10569
+ * and silently mints a wrong key for Compound V2 (needs the cToken) and
10570
+ * Dolomite (needs the integer marketId). A wrong uid does not degrade a term
10571
+ * sheet — it routes a deposit to the wrong market. See EARN_ENDPOINT_PLAN §3.2.
10572
+ *
10573
+ * @throws if `marketUid` is not three non-empty colon-separated segments, or
10574
+ * if it collides with the `vault.` namespace.
10575
+ */
10576
+ declare function earnUidFromMarketUid(marketUid: string): string;
10577
+ /**
10578
+ * Split an `earnUid` into its parts, discriminated by form.
10579
+ *
10580
+ * `knownProviders` defaults to undefined, which accepts any `vault.<x>` venue.
10581
+ * Pass the live provider set when parsing untrusted input (an action route's
10582
+ * query param) so an unknown provider fails at the edge with a clear message
10583
+ * rather than deep inside a dispatcher.
10584
+ *
10585
+ * @throws on a malformed uid or an unrecognised provider.
10586
+ */
10587
+ declare function parseEarnUid(earnUid: string, knownProviders?: readonly VaultProvider[]): ParsedEarnUid;
10588
+ /** Non-throwing `parseEarnUid`. Returns undefined instead of throwing. */
10589
+ declare function tryParseEarnUid(earnUid: string, knownProviders?: readonly VaultProvider[]): ParsedEarnUid | undefined;
10590
+ /** Which half of the surface a uid belongs to, without a full parse. */
10591
+ declare function earnVenueKind(earnUid: string): EarnVenueKind;
10592
+
10593
+ /**
10594
+ * `EarnMarket` — one supply-side opportunity, from either half of the stack.
10595
+ *
10596
+ * This is a PROJECTION, not a replacement. The borrow side, pairs, leverage
10597
+ * and migrate stay on `/v1/data/lending/*`; a lending market appears here as
10598
+ * one row per supplyable asset with a `refs.marketUid` pointer back.
10599
+ *
10600
+ * Everything here is derived from data the two origins already return — the
10601
+ * work is unit normalization and identity, not new fetching.
10602
+ *
10603
+ * See EARN_ENDPOINT_PLAN.md §4.
10604
+ */
10605
+ interface EarnMarket {
10606
+ /**
10607
+ * TWO FORMS, not one — see `./uid`. OPAQUE: only `parseEarnUid` may split it.
10608
+ * lending → the row's `marketUid`, VERBATIM
10609
+ * vault → `vault.<provider>:<chainId>:<address>`
10610
+ */
10611
+ earnUid: string;
10612
+ chainId: string;
10613
+ /** `AAVE_V3` (a `Lender` key) or `vault.savings` (`vault.<provider>`). */
10614
+ venue: string;
10615
+ venueKind: EarnVenueKind;
10616
+ /** Display label — 'Aave V3', 'Spark', 'Ethena'. */
10617
+ brand?: string;
10618
+ /** Market or vault display name. */
10619
+ name?: string;
10620
+ /**
10621
+ * The uid's third segment, lifted out so consumers never parse the uid.
10622
+ * Venue-dependent on the lending side (underlying / cToken / silo / Dolomite
10623
+ * marketId / …); the share token on the vault side.
10624
+ */
10625
+ ref: string;
10626
+ /** Branded icon URL, when one resolved. */
10627
+ logoURI?: string;
10628
+ /** What the user deposits. */
10629
+ asset: EarnAsset;
10630
+ /** Present only when depositing mints a distinct receipt token. */
10631
+ shareToken?: EarnShareToken;
10632
+ /** What the user earns. ALWAYS PERCENT — see `EarnRate`. */
10633
+ rate: EarnRate;
10634
+ /** Size and room. */
10635
+ tvl: EarnAmount;
10636
+ /** What can actually leave right now. Absent ⇒ not reported by the source. */
10637
+ liquidity?: EarnAmount;
10638
+ /**
10639
+ * Room for new deposits, raw base units. `undefined` = uncapped,
10640
+ * `'0'` = full. Distinct from `availability.canDeposit`, which is a
10641
+ * permission — a vault can be permissionless AND full (3Jane USD3), or
10642
+ * gated AND empty.
10643
+ */
10644
+ depositCapacity?: string;
10645
+ /** Debt/supply ratio. Lending and lending-backed vaults only. */
10646
+ utilization?: number;
10647
+ /**
10648
+ * When the deal ENDS. Present only on rows that have a maturity — Pendle
10649
+ * PTs today, and the fixed-term lenders (TermMax, Exactly, Midnight, Term,
10650
+ * Teller) as the term-sheet adapter reaches them.
10651
+ *
10652
+ * Lifted to the row root rather than left inside `termSheet` because for a
10653
+ * fixed-rate product the maturity is not enrichment: a 9 % rate over eleven
10654
+ * days and a 9 % rate over two years are different offers, and a client that
10655
+ * has to opt into `?terms=full` to tell them apart will sort them into the
10656
+ * same column. Absent ⇒ perpetual.
10657
+ */
10658
+ maturity?: MaturityTerms;
10659
+ /** The deal. Digest by default, full sheet under `?terms=full`. */
10660
+ termSheet?: TermSheet | TermSheetDigest;
10661
+ exit: EarnExit;
10662
+ availability: EarnAvailability;
10663
+ risk?: EarnRisk;
10664
+ /** How to transact. Empty ⇒ nothing can be done right now. */
10665
+ capabilities: EarnCapability[];
10666
+ /** Pointers, never copies. */
10667
+ refs?: EarnRefs;
10668
+ /** Provider-specific escape hatch. Semantics unchanged from the source. */
10669
+ providerMeta?: Record<string, unknown>;
10670
+ }
10671
+ interface EarnAsset {
10672
+ /** The underlying the user supplies, lowercased. */
10673
+ address: string;
10674
+ symbol: string;
10675
+ decimals: number;
10676
+ /** Price-group key ('ETH', 'USDC') — how the price store is keyed. */
10677
+ assetGroup?: string;
10678
+ priceUsd?: number;
10679
+ }
10680
+ interface EarnShareToken {
10681
+ address: string;
10682
+ symbol: string;
10683
+ /**
10684
+ * Share decimals. Equals `asset.decimals` for plain ERC-4626, but NOT for
10685
+ * Lagoon (18-decimal shares over 6-decimal USDC) — never assume they match.
10686
+ */
10687
+ decimals: number;
10688
+ }
10689
+ /**
10690
+ * An amount, carried in whichever scales the source actually provides.
10691
+ *
10692
+ * **The two origins do NOT agree on scale, and this is a 1e18 landmine.**
10693
+ * The vault side reports `tvl.totalAssets` as a RAW base-unit integer string;
10694
+ * the lending side reports `totalDeposits` already through `parseRawAmount`,
10695
+ * which is `formatUnits` — i.e. TOKEN UNITS, despite the field being commented
10696
+ * "raw amounts" at its source. Folding both into one field would sort a $1M
10697
+ * Aave reserve below a dust vault.
10698
+ *
10699
+ * So: `formatted` is the cross-source field a consumer should compare on, and
10700
+ * `raw` is present only where the source genuinely carries base units. Never
10701
+ * infer one from the other without `asset.decimals`.
10702
+ */
10703
+ interface EarnAmount {
10704
+ /**
10705
+ * Raw base-unit integer STRING — never a number; these overflow float64 well
10706
+ * inside normal 18-decimal balances. Absent when the source is pre-formatted.
10707
+ */
10708
+ raw?: string;
10709
+ /** Human/token units. The field to compare and sort on. */
10710
+ formatted?: number;
10711
+ usd?: number;
10712
+ }
10713
+ /**
10714
+ * The headline yield.
10715
+ *
10716
+ * **Every field is a PERCENT** (`4.12` = 4.12 %). This is the single most
10717
+ * dangerous field on the row: the lending origin reports percent, the 4626
10718
+ * vault providers report percent, but realized APR, HyperCore `apr` and GMX
10719
+ * `apy`/`baseApy`/`bonusApr` are FRACTIONS at the source. Normalizing them on
10720
+ * the way in is not optional — the same column would otherwise be 100× off
10721
+ * between two rows in one list. See `vaults/DATABASE_INTEGRATION.md` §1.
10722
+ */
10723
+ interface EarnRate {
10724
+ /** The headline: base + rewards + intrinsic. */
10725
+ total: number;
10726
+ /** Protocol interest / share-price accrual. */
10727
+ base?: number;
10728
+ /** Incentive programs (Merkl et al). */
10729
+ rewards?: number;
10730
+ /** The underlying's own yield (stETH staking under an stETH market). */
10731
+ intrinsic?: number;
10732
+ /**
10733
+ * What THIS venue pays, on top of what the asset would pay in your wallet:
10734
+ * `base + rewards`, excluding `intrinsic`.
10735
+ *
10736
+ * This is the number that answers "what am I being paid for taking this
10737
+ * market's risk". `total` answers "what will my balance do", and for a
10738
+ * yield-bearing collateral the two are very different.
10739
+ */
10740
+ marketOwn?: number;
10741
+ /**
10742
+ * True when the asset carries its own yield and the venue adds ~nothing —
10743
+ * `intrinsic > 0` and `marketOwn < 0.01 %`.
10744
+ *
10745
+ * These rows are the reason an APR-sorted earn list misleads: an LST market
10746
+ * showing 3 % out-ranks a genuine 2.5 % stablecoin market, but supplying into
10747
+ * it earns you **the same as holding the token**, with the market's
10748
+ * liquidation, oracle and governance risk added for free. Filtered out by
10749
+ * default — see the `passthrough` param on `/v1/data/earn`.
10750
+ *
10751
+ * Distinct from `availability.gating === 'collateral-only'`, which is a
10752
+ * market paying nothing on an asset that also pays nothing.
10753
+ */
10754
+ passthrough?: boolean;
10755
+ /**
10756
+ * HOW the rate is set — the provenance that stops a leaderboard from lying.
10757
+ * A `variable-curve` 8 % and a `nav-accrual` 8 % are not the same promise.
10758
+ */
10759
+ kind: RateKind;
10760
+ /** WHERE the number came from. */
10761
+ source: EarnRateSource;
10762
+ /** Unix seconds — the rate is a snapshot. */
10763
+ asOf?: number;
10764
+ }
10765
+ type EarnRateSource =
10766
+ /** Read from the chain (IRM, accumulator, share price). */
10767
+ 'chain'
10768
+ /** Protocol or aggregator API (Morpho, DefiLlama, Strata S3). */
10769
+ | 'api'
10770
+ /** A price/NAV feed (Re, USPC, Apyx). */
10771
+ | 'oracle'
10772
+ /** Derived from a share-price series (`computeVaultApr`). */
10773
+ | 'realized';
10774
+ /**
10775
+ * How the money gets out. Flattened to the row root deliberately: on
10776
+ * `/v1/data/vaults` this lives in `providerMeta.withdrawalMode`, which is a
10777
+ * known integrator trap. Here it is always at the same path for every venue.
10778
+ */
10779
+ interface EarnExit {
10780
+ mode: SupplyExitMode;
10781
+ settlement?: SupplyExitTerms['settlement'];
10782
+ cooldownSecs?: number;
10783
+ /** Instant-exit fee, where taking the fast path costs something. */
10784
+ feeBps?: number;
10785
+ }
10786
+ interface EarnAvailability {
10787
+ canDeposit: boolean;
10788
+ canWithdraw: boolean;
10789
+ /** Why not, when `canDeposit` is false. */
10790
+ gating?: EarnGating;
10791
+ /** Human-readable, for the disabled-CTA tooltip. */
10792
+ reason?: string;
10793
+ }
10794
+ type EarnGating =
10795
+ /** Contract callers must be governance-approved (Inverse, Fraxlend). */
10796
+ 'allowlist-contract' | 'kyc'
10797
+ /** Permissionless but at its cap (3Jane USD3, Yield Basis). */
10798
+ | 'cap-full' | 'paused' | 'frozen'
10799
+ /**
10800
+ * A fixed-term product past its maturity. Entry is closed and the published
10801
+ * rate is stale by construction; the exit leg stays open so a holder can
10802
+ * still redeem. Should be rare — matured rows are filtered upstream — but
10803
+ * the check is repeated here because a recorder lag is exactly how a dead
10804
+ * market ends up at the top of a rate-sorted list.
10805
+ */
10806
+ | 'matured'
10807
+ /** Deposits are open but this leg earns nothing (collateral-only reserve). */
10808
+ | 'collateral-only';
10809
+ interface EarnRisk {
10810
+ /** Monotonic accrual vs a NAV that can fall. */
10811
+ yieldProfile?: YieldProfile;
10812
+ denomination?: Denomination;
10813
+ /** The trust question, one field. */
10814
+ counterparty?: CounterpartyTerms['solvency'];
10815
+ }
10816
+ interface EarnRefs {
10817
+ /** Lending only — the full market (borrow side, pairs, IRM). */
10818
+ marketUid?: string;
10819
+ /** Can this asset also be borrowed here? */
10820
+ borrowable?: boolean;
10821
+ /** What actually backs a curated vault. */
10822
+ exposures?: VaultMarketExposure[];
10823
+ }
10824
+ type EarnActionKind = 'deposit' | 'withdraw'
10825
+ /** Open an async exit (cooldown, queue, keeper ticket). */
10826
+ | 'request-withdraw'
10827
+ /** Settle a matured request. */
10828
+ | 'claim'
10829
+ /** Unwind an open request before it settles. */
10830
+ | 'cancel';
10831
+ /**
10832
+ * What can be done to this row, and what each op needs.
10833
+ *
10834
+ * This is what makes the flow genuinely unified: the client stops branching on
10835
+ * provider. It renders the CTA from `capabilities`, collects whatever
10836
+ * `requires` names, and posts one shape to `/v1/actions/earn/{action}`.
10837
+ * Yield Basis' mandatory `debt`/`minShares`, Apyx's `tokenId`, GMX's
10838
+ * `executionFee`, an LST's `validator` — all surface as DATA rather than as
10839
+ * tribal knowledge in the integrator's head.
10840
+ */
10841
+ interface EarnCapability {
10842
+ action: EarnActionKind;
10843
+ /**
10844
+ * Params required BEYOND the universal set (`earnUid`, `operator`,
10845
+ * `receiver`, `amount`). E.g. `['validator']`, `['debt','minShares']`,
10846
+ * `['tokenId']`.
10847
+ */
10848
+ requires?: string[];
10849
+ /** Deposit only — may the user pay an asset other than `asset.address`? */
10850
+ acceptsPayAsset?: boolean;
10851
+ /** Withdraw only — may the user receive something other than the asset? */
10852
+ acceptsReceiveAsset?: boolean;
10853
+ /**
10854
+ * Settles later (keeper ticket, cooldown, queue) — the client must poll
10855
+ * `/v1/data/earn/withdrawals` rather than treat the tx as terminal.
10856
+ */
10857
+ async?: boolean;
10858
+ /** Cost hint for the CTA, before quoting. */
10859
+ feeBps?: number;
10860
+ /**
10861
+ * HOW the action is executed.
10862
+ *
10863
+ * Absent (or `'native'`) ⇒ a protocol call — deposit/withdraw/redeem against
10864
+ * the venue itself, which is every 4626 vault and every lending market.
10865
+ *
10866
+ * `'swap'` ⇒ **there is no protocol entry point at all**; the position is
10867
+ * acquired and closed by TRADING the instrument. Pendle PTs are the case:
10868
+ * you buy the bond on Pendle's AMM at a discount and sell it back, so both
10869
+ * legs need a slippage tolerance, both are priced by pool depth, and neither
10870
+ * has a "deposit the underlying" path to fall back on. A client that renders
10871
+ * a 4626-style amount box for one of these builds an input the venue cannot
10872
+ * serve.
10873
+ */
10874
+ via?: 'native' | 'swap';
10875
+ }
10876
+ /**
10877
+ * `/v1/data/earn` response. The shape NEVER changes — a degraded source is
10878
+ * reported in `sources[]` with the rows that did resolve still served, rather
10879
+ * than switching to a different payload the way `/v1/data/vaults` does when
10880
+ * its origin is down.
10881
+ */
10882
+ interface EarnResponse {
10883
+ ok: boolean;
10884
+ /** Pagination offset of the first item. */
10885
+ start: number;
10886
+ /** Items in THIS page. */
10887
+ count: number;
10888
+ /** Items matching the filter across all pages. */
10889
+ total: number;
10890
+ /** Stamped so no consumer has to guess. Always `'percent'`. */
10891
+ rateUnit: 'percent';
10892
+ items: EarnMarket[];
10893
+ sources: EarnSourceStatus[];
10894
+ /**
10895
+ * Rows this endpoint removed by DEFAULT, so a UI can offer them back rather
10896
+ * than a user wondering where a market went. Only the pass-through default
10897
+ * (see `EarnRate.passthrough`) removes anything unasked; every other filter
10898
+ * is opt-in.
10899
+ */
10900
+ excluded: EarnExclusions;
10901
+ /** What a client can filter by, derived from the data. See {@link EarnFacets}. */
10902
+ facets: EarnFacets;
10903
+ }
10904
+ interface EarnExclusions {
10905
+ /** Rows hidden because the venue adds ~nothing over the asset's own yield. */
10906
+ passthrough: number;
10907
+ }
10908
+ /**
10909
+ * The filter vocabulary, published rather than hard-coded.
10910
+ *
10911
+ * **A client must never ship its own list of venues or providers.** The
10912
+ * existing frontend does — `VAULT_PROVIDERS` in `sdk/vaults-helper/types.ts`
10913
+ * is a 13-entry copy of `VaultProvider`, already two behind the SDK's 15, so a
10914
+ * newly-integrated protocol is invisible until the frontend redeploys. Facets
10915
+ * invert that: the server enumerates what exists, the UI renders whatever it
10916
+ * receives, and a new lender or vault provider appears with no client change.
10917
+ *
10918
+ * Counts are computed over the **full merged listing for the requested
10919
+ * chains**, before any filter is applied — so selecting one venue does not make
10920
+ * the other options vanish from the dropdown.
10921
+ */
10922
+ interface EarnFacets {
10923
+ /**
10924
+ * Venues grouped by BRAND — the dimension a filter UI should offer.
10925
+ *
10926
+ * A chain can carry 20+ `MORPHO_BLUE_<id>` venues; listing each is a wall of
10927
+ * hex nobody filters by. `brands` collapses them to one "Morpho Blue (23)"
10928
+ * entry. `venues` stays for precise, single-market filtering.
10929
+ */
10930
+ brands: EarnFacetBucket[];
10931
+ venues: EarnFacetBucket[];
10932
+ venueKinds: EarnFacetBucket[];
10933
+ chains: EarnFacetBucket[];
10934
+ assetGroups: EarnFacetBucket[];
10935
+ exitModes: EarnFacetBucket[];
10936
+ /** Distinct actions available anywhere in the listing. */
10937
+ actions: EarnFacetBucket[];
10938
+ }
10939
+ interface EarnFacetBucket {
10940
+ /** The value to send back as a filter param. */
10941
+ key: string;
10942
+ /**
10943
+ * Display label. **Populated for every bucket the server can name**, so a
10944
+ * client renders `label ?? key` and ships no vocabulary of its own. An
10945
+ * unlabelled key renders as itself rather than as a client-side guess.
10946
+ */
10947
+ label?: string;
10948
+ /** One-line explanation, where the dimension has one (exit modes, kinds). */
10949
+ description?: string;
10950
+ /** Rows carrying this value in the unfiltered listing. */
10951
+ count: number;
10952
+ }
10953
+ /**
10954
+ * The display vocabulary, independent of any listing.
10955
+ *
10956
+ * Served by `GET /v1/data/earn/facets` so a client can build its filter UI
10957
+ * (and label a row it already holds) **without fetching the catalogue**, and
10958
+ * without embedding a single enum value of its own.
10959
+ */
10960
+ interface EarnVocabulary {
10961
+ /** dimension → key → label, e.g. `exitMode['fixed-cooldown'] = 'Cooldown'`. */
10962
+ labels: Record<string, Record<string, string>>;
10963
+ descriptions: Record<string, Record<string, string>>;
10964
+ }
10965
+ interface EarnSourceStatus {
10966
+ source: 'pools' | 'vaults';
10967
+ status: 'ok' | 'degraded' | 'failed';
10968
+ /** Rows contributed by this source before filtering. */
10969
+ rows: number;
10970
+ /** Present when not `ok`. */
10971
+ error?: string;
10972
+ }
10973
+
10974
+ /**
10975
+ * Display vocabulary for the earn surface — **owned by the server**.
10976
+ *
10977
+ * A client must not carry its own copy of any of this. That is not a style
10978
+ * preference: every label map shipped in a frontend is a copy of server state
10979
+ * that rots silently. When a new exit mode or vault provider is integrated, a
10980
+ * client-side `switch` renders it as blank, as "Unknown", or worse, falls into
10981
+ * a `default` branch that quietly misdescribes it — and nobody notices until a
10982
+ * user acts on the wrong description.
10983
+ *
10984
+ * Putting the labels here means adding a mode is one change on one side, and
10985
+ * every consumer picks it up on the next request.
10986
+ *
10987
+ * The rule for consumers is simply: **render `label ?? key`**. An unrecognised
10988
+ * value then renders as itself, which is honest, rather than as a guess.
10989
+ */
10990
+ /**
10991
+ * Collapse a venue key to its brand.
10992
+ *
10993
+ * `MORPHO_BLUE_1E9D…` → `Morpho Blue`; `FLUID_1_11` → `Fluid`;
10994
+ * `SKY_1_ETH_A` → `Sky`; `vault.savings` → `Savings`.
10995
+ *
10996
+ * Falls back to the longest recognised prefix, then to the family key itself —
10997
+ * never to a guess. An unknown lender renders as its own key, which is terse
10998
+ * but true, and adding it to the table later is a pure improvement.
10999
+ */
11000
+ declare function venueBrand(venue: string): string;
11001
+ /** Every dimension the earn surface labels, in one lookup. */
11002
+ declare const EARN_LABELS: {
11003
+ readonly venueKind: Record<string, string>;
11004
+ readonly exitMode: Record<string, string>;
11005
+ readonly action: Record<string, string>;
11006
+ readonly gating: Record<string, string>;
11007
+ readonly rateKind: Record<string, string>;
11008
+ readonly rateSource: Record<string, string>;
11009
+ };
11010
+ declare const EARN_DESCRIPTIONS: {
11011
+ readonly venueKind: Record<string, string>;
11012
+ readonly exitMode: Record<string, string>;
11013
+ };
11014
+ type EarnLabelDimension = keyof typeof EARN_LABELS;
11015
+ /**
11016
+ * Look up a label, falling back to the raw key.
11017
+ *
11018
+ * The fallback is the contract: an unlabelled value renders as itself, so a
11019
+ * newly added mode is legible (if terse) everywhere immediately, and adding its
11020
+ * label later is a pure improvement rather than a bug fix.
11021
+ */
11022
+ declare function earnLabel(dimension: EarnLabelDimension, key: string): string;
11023
+ declare function earnDescription(dimension: keyof typeof EARN_DESCRIPTIONS, key: string): string | undefined;
11024
+
11025
+ /**
11026
+ * Multiply a formatted (human-unit) amount by a USD price.
11027
+ *
11028
+ * Returns `undefined` when either input is missing, rather than `0` — a vault
11029
+ * we could not price must not sort as worthless next to one that genuinely is.
11030
+ */
11031
+ declare function usdValue(formatted: number | undefined, priceUsd: number | undefined): number | undefined;
11032
+ /**
11033
+ * Format a raw base-unit integer string to human units.
11034
+ *
11035
+ * Uses BigInt for the integer part so large balances keep full precision, then
11036
+ * appends the fraction — `Number(raw) / 10 ** decimals` silently loses digits
11037
+ * above 2^53, which is well inside normal 18-decimal TVLs.
11038
+ */
11039
+ declare function formatRaw(raw: string | undefined, decimals: number): number | undefined;
11040
+
11041
+ /**
11042
+ * Vault half of the `/earn` normalizer: one `/vaults/latest` row → `EarnMarket`.
11043
+ *
11044
+ * The input is the recorder origin's item shape, which is loosely typed by
11045
+ * design (providers add fields without a schema bump), so every read goes
11046
+ * through a tolerant accessor and a missing field yields `undefined` rather
11047
+ * than a throw. A row missing its two load-bearing identifiers — the vault
11048
+ * address and the underlying — is DROPPED, not patched.
11049
+ *
11050
+ * See EARN_ENDPOINT_PLAN.md §4.
11051
+ */
11052
+ /** The origin's `/vaults/latest` item. Permissive on purpose — see above. */
11053
+ interface VaultSourceRow {
11054
+ provider?: string;
11055
+ vaultAddress?: string;
11056
+ underlying?: string;
11057
+ symbol?: string;
11058
+ name?: string;
11059
+ displayName?: string;
11060
+ decimals?: number;
11061
+ assetDecimals?: number;
11062
+ curatorName?: string;
11063
+ sharePrice?: number | string;
11064
+ sharePriceUsd?: number | string;
11065
+ rates?: {
11066
+ depositRate?: number | string;
11067
+ rewardsRate?: number | string;
11068
+ totalRate?: number | string;
11069
+ supplyRate?: number | string;
11070
+ fee?: number | string;
11071
+ };
11072
+ tvl?: {
11073
+ totalAssets?: string | number;
11074
+ totalAssetsFormatted?: number | string;
11075
+ totalSupply?: string | number;
11076
+ totalAssetsUsd?: number | string;
11077
+ };
11078
+ liquidity?: {
11079
+ liquidity?: string | number;
11080
+ liquidityFormatted?: number | string;
11081
+ liquidityUsd?: number | string;
11082
+ };
11083
+ underlyingInfo?: {
11084
+ asset?: {
11085
+ symbol?: string;
11086
+ decimals?: number;
11087
+ logoURI?: string;
11088
+ };
11089
+ prices?: {
11090
+ priceUsd?: number | string;
11091
+ };
11092
+ };
11093
+ vaultInfo?: {
11094
+ symbol?: string;
11095
+ name?: string;
11096
+ logoURI?: string;
11097
+ assetGroup?: string;
11098
+ yieldProfile?: string;
11099
+ denomination?: string;
11100
+ };
11101
+ providerMeta?: Record<string, any>;
11102
+ [key: string]: unknown;
11103
+ }
11104
+ /**
11105
+ * Providers whose rate fields arrive as FRACTIONS (`0.0412`) rather than
11106
+ * percent (`4.12`), and therefore need scaling.
11107
+ *
11108
+ * **EMPTY for the origin path, and that is the verified answer, not a
11109
+ * default.** The underlying hazard is real — `vaults/DATABASE_INTEGRATION.md`
11110
+ * §1 documents HyperCore's `apr` and GMX's `apy`/`baseApy`/`bonusApr` as
11111
+ * fractions where every 4626 provider reports percent — but the recorder
11112
+ * already resolves it before the row reaches us. `mapGmxToListing` /
11113
+ * `mapHypercoreToListing` in the origin's `routes/vaults.ts` run every rate
11114
+ * through `pct()` (`× 100`) and park the raw fraction under
11115
+ * `providerMeta.apr`, explicitly "for sort/filter parity".
11116
+ *
11117
+ * So scaling here would DOUBLE-convert and inflate every GMX and HyperCore row
11118
+ * 100× — the exact bug this constant was written to prevent, in the opposite
11119
+ * direction.
11120
+ *
11121
+ * The set survives as a parameter rather than being deleted because the
11122
+ * SDK-fed path has the opposite convention: `getVaultPublicDataAll` emits the
11123
+ * raw provider fractions with no `pct()` in between. Anything reading the SDK
11124
+ * directly (a recorder, a `?source=live` fallback) must pass
11125
+ * {@link SDK_FRACTION_RATE_PROVIDERS}.
11126
+ */
11127
+ declare const FRACTION_RATE_PROVIDERS: ReadonlySet<string>;
11128
+ /**
11129
+ * The fraction-reporting providers **as the SDK emits them**, before the
11130
+ * recorder's `pct()` pass. Pass this to {@link earnMarketFromVault} when the
11131
+ * rows come from `getVaultPublicDataAll` rather than from `/vaults/latest`.
11132
+ */
11133
+ declare const SDK_FRACTION_RATE_PROVIDERS: ReadonlySet<string>;
11134
+ /** Per-call overrides for sources that disagree with the origin's conventions. */
11135
+ interface EarnVaultNormalizeOptions {
11136
+ /**
11137
+ * Providers whose rates need `× 100`. Defaults to
11138
+ * {@link FRACTION_RATE_PROVIDERS} (empty — the origin already normalized).
11139
+ */
11140
+ fractionRateProviders?: ReadonlySet<string>;
11141
+ }
11142
+ /**
11143
+ * Normalize one origin vault row. Returns `undefined` when the row lacks the
11144
+ * identifiers needed to key or transact it — a dropped row is recoverable, a
11145
+ * row with a fabricated key is not.
11146
+ */
11147
+ declare function earnMarketFromVault(row: VaultSourceRow, chainId: string, opts?: EarnVaultNormalizeOptions): EarnMarket | undefined;
11148
+ /**
11149
+ * Convert a source rate to PERCENT.
11150
+ *
11151
+ * `undefined` in ⇒ `undefined` out. Zero is preserved (a real 0 % is
11152
+ * meaningful — a collateral-only leg genuinely earns nothing) rather than
11153
+ * being folded into `undefined`.
11154
+ */
11155
+ declare function ratePercent(value: unknown, provider: string, fractionProviders?: ReadonlySet<string>): number | undefined;
11156
+ /**
11157
+ * Cheap plausibility guard for the fraction/percent question.
11158
+ *
11159
+ * Not a correctness proof — a genuine 300 % vault exists and a genuine 0.02 %
11160
+ * one does too. It catches the systematic case: a whole provider's rows
11161
+ * landing three orders of magnitude off because the origin already normalized
11162
+ * and we normalized again. Call it from a test or a recorder, not per request.
11163
+ */
11164
+ declare function implausibleRatePercent(percent: number): boolean;
11165
+
11166
+ /**
11167
+ * Lending half of the `/earn` normalizer: one `/pools/latest` row →
11168
+ * `EarnMarket`, projecting the SUPPLY side only.
11169
+ *
11170
+ * The borrow side is not dropped, it is *pointed at*: `refs.marketUid` +
11171
+ * `refs.borrowable` let a consumer jump to `/v1/data/lending/*` for the full
11172
+ * market. Duplicating the borrow economics here would double the payload to
11173
+ * serve a question this endpoint does not ask.
11174
+ *
11175
+ * The origin reshapes the SDK's flat `PoolData` into a partly-nested form
11176
+ * (`caps`, `flags`, `underlyingInfo`), and the origin lives in another repo —
11177
+ * so every field is read tolerantly in BOTH shapes. That is deliberate
11178
+ * defensiveness, not indecision: a field that moves nests silently, and a
11179
+ * silently-missing `isFrozen` would advertise a dead market as depositable.
11180
+ *
11181
+ * See EARN_ENDPOINT_PLAN.md §4.
11182
+ */
11183
+ /** The origin's `/pools/latest` item (`PoolWithMeta`). Permissive by design. */
11184
+ interface PoolSourceRow {
11185
+ /** Stamped by the public-data parsers. REQUIRED — see `earnMarketFromPool`. */
11186
+ marketUid?: string;
11187
+ lender?: string;
11188
+ lenderKey?: string;
11189
+ chainId?: string;
11190
+ poolId?: string;
11191
+ underlying?: string;
11192
+ name?: string;
11193
+ asset?: {
11194
+ address?: string;
11195
+ symbol?: string;
11196
+ decimals?: number;
11197
+ logoURI?: string;
11198
+ assetGroup?: string;
11199
+ };
11200
+ underlyingInfo?: {
11201
+ asset?: {
11202
+ address?: string;
11203
+ symbol?: string;
11204
+ decimals?: number;
11205
+ logoURI?: string;
11206
+ };
11207
+ assetGroup?: string;
11208
+ prices?: {
11209
+ priceUsd?: number | string;
11210
+ };
11211
+ };
11212
+ decimals?: number;
11213
+ /** Origin-computed `depositRate + intrinsicYield`. */
11214
+ apr?: number | string;
11215
+ price?: number | string;
11216
+ depositRate?: number | string;
11217
+ intrinsicYield?: number | string;
11218
+ variableBorrowRate?: number | string;
11219
+ rewards?: Array<{
11220
+ asset?: string;
11221
+ depositRate?: number | string;
11222
+ }>;
11223
+ totalDeposits?: string | number;
11224
+ totalDepositsUSD?: number | string;
11225
+ totalDepositsUsd?: number | string;
11226
+ totalLiquidity?: number | string;
11227
+ totalLiquidityUSD?: number | string;
11228
+ totalLiquidityUsd?: number | string;
11229
+ utilization?: number | string;
11230
+ supplyCap?: number | string;
11231
+ caps?: {
11232
+ supplyCap?: number | string;
11233
+ borrowCap?: number | string;
11234
+ };
11235
+ collateralActive?: boolean;
11236
+ borrowingEnabled?: boolean;
11237
+ depositsEnabled?: boolean;
11238
+ isActive?: boolean;
11239
+ isFrozen?: boolean;
11240
+ flags?: {
11241
+ collateralActive?: boolean;
11242
+ borrowingEnabled?: boolean;
11243
+ depositsEnabled?: boolean;
11244
+ isActive?: boolean;
11245
+ isFrozen?: boolean;
11246
+ };
11247
+ [key: string]: unknown;
11248
+ }
11249
+ /**
11250
+ * Normalize one origin pool row.
11251
+ *
11252
+ * Returns `undefined` when the row carries no `marketUid`. **The uid is never
11253
+ * reconstructed** — rebuilding it as `lender:chainId:underlying` is only
11254
+ * correct for the default-format lenders and silently mints a wrong key for
11255
+ * Compound V2 (needs the cToken) and Dolomite (needs the integer marketId).
11256
+ * A wrong term sheet is a display bug; a wrong uid routes a deposit to the
11257
+ * wrong market. Drop the row and let the caller log it.
11258
+ *
11259
+ * See EARN_ENDPOINT_PLAN.md §3.2.
11260
+ */
11261
+ declare function earnMarketFromPool(row: PoolSourceRow, fallbackChainId?: string): EarnMarket | undefined;
11262
+
11263
+ /**
11264
+ * Stamp `capabilities[]` onto a normalized row.
11265
+ *
11266
+ * Mutates and returns the row — it is called once per row inside the
11267
+ * normalizer's own loop, and cloning several thousand rows to avoid a local
11268
+ * mutation is a real cost for no benefit.
11269
+ */
11270
+ declare function stampCapabilities(row: EarnMarket): EarnMarket;
11271
+
11272
+ 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 ChainDiagnostic, type ChainLinkResponse, type ChainQuery, type ChainSummary, type CompoundV2Metadata, type CompoundV3Public, type CompoundV3UserReserveResponse, type ConfigEntry, type ConvertLenderUserDataOptions, type CoreValidators, type CounterpartyTerms, type CoverageInfo, DEFAULT_MIDNIGHT_API, DEFAULT_OUTLIER_GUARD, DEFAULT_PROFILE_ID, DEFAULT_STALE_REJECT_SECONDS, DEFAULT_TERMMAX_API, type DeepPartial, type Denomination, type DepthMap, type DssMarketRaw, type DssMarketsRaw, type DssPositionInfo, EARN_DESCRIPTIONS, EARN_LABELS, EMPTY_BALANCE, type EModeAssets, type EModeData, type EModeResult, EXACTLY_LENDER_KEY, type EarnActionKind, type EarnAmount, type EarnAsset, type EarnAvailability, type EarnCapability, type EarnExclusions, type EarnExit, type EarnFacetBucket, type EarnFacets, type EarnGating, type EarnLabelDimension, type EarnMarket, type EarnRate, type EarnRateSource, type EarnRefs, type EarnResponse, type EarnRisk, type EarnShareToken, type EarnSourceStatus, type EarnVaultNormalizeOptions, 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, FRACTION_RATE_PROVIDERS, type FeeTerm, type FeeWhen, type FeedObservation, type FeedStat, type FeedStatsMap, type FeedTimestampMap, type FetchListaVaultsFromChainOptions, type FetchMorphoVaultsFromChainOptions, type FetchOraclePricesOptions, type FetchPendlePtOptions, type FetchTokenBalancesOptions, type FlattenPriorityConfig, type FluidFToken, type FluidFTokens, type FrankencoinMarketRaw, type FrankencoinMarketsRaw, type FrankencoinPositionInfo, 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, 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, STABLECOIN_SYMBOLS, STCELO_MANAGER_ADDRESS, type SelectPricesOptions, type Severity, type SeverityFinding, type SiloVault, type SiloVaults, type StCeloValidatorGroup, type StaleFeedEntry, type StampOptions, type StructuredOraclePrices, type SubAccountSummary, type SumerPositionInput, type SummaryAprData, type SummaryBalanceData, type SupplyExitMode, type SupplyExitTerms, type SupplyTermSheet, TELLER_CALLS_PER_BID, TERMMAX_CALLS_PER_ACCOUNT, DECIMAL_BASE as TERMMAX_DECIMAL_BASE, TERMMAX_LIQUIDATION_PENALTY, TERMMAX_LIQUIDATION_WINDOW_SECS, TERMMAX_LIQUIDATOR_BONUS, TERMMAX_PARTIAL_CLOSE_FACTOR, TERMMAX_PARTIAL_LIQUIDATION_THRESHOLD_USD, 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 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, 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_SHARE_PRICE_PROBE, VAULT_VENUE_PREFIX, VOLATILE_VAULT_OVERRIDES, type ValidationResult, type VaultAprResult, type VaultClassification, type VaultClassificationFields, type VaultLookupEntry, type VaultMarketExposure, type VaultProvider, type VaultPublicDataAll, type VaultPublicDataResult, type VaultSourceRow, type VaultYieldSeries, type VaultYieldSnapshot, type YDaemonVault, YEARN_CHAIN_IDS, YEARN_YDAEMON_BASE, type YearnVault, type YearnVaultKind, type YearnVaults, type YieldProfile, __resetResupplyUserCaches, accountDepositListKey, accountWithdrawalListKey, appendSnapshot, applyPositionDelta, attachImplications, attachPricesToFlashLiquidity, borrowDescription, borrowFindings, borrowHeadline, buildExposures, buildFluidFTokensCall, buildLiquityUserCall, buildLoopResult, buildMorphoTypeCall, buildMorphoTypeUserCallWithLens, buildPortfolioTotals, buildSumerAccumulators, buildSummaries, buildTellerUserCall, buildTermMaxUserCall, buildTermSheet, buildTermSheetsForGroup, buildVaultEarnUid, buildVaultLookup, calculateLeverage, calculateNetApr, calculateOverallNetApr, calculateWeightedAverage, classifyFreshness, classifyReliability, classifyVault, clearPendleMarketsCache, collectFeedObservations, computeBorrowDelta, computeCloseTradeDeltas, computeCollateralSwapDeltas, computeDebtSwapDeltas, computeDepositDelta, computeEModeAnalysis, computeOpenTradeDeltas, computePostTradeMetrics, computeRepayDelta, computeSumerBorrowDelta, computeSumerDepositDelta, computeSumerRepayDelta, computeSumerWaterfall, computeSumerWithdrawDelta, computeVaultApr, computeWithdrawDelta, computeZapTradeDeltas, consensusReference, convertDssMarketsToResponse, convertExactlyMarketsToResponse, convertFrankencoinMarketsToResponse, convertInverseMarketsToResponse, convertLenderUserDataResult, convertLiquityMarketsToResponse, convertLlamaLendMarketsToResponse, convertResupplyMarketsToResponse, convertRiverMarketsToResponse, convertTellerMarketsToResponse, convertTermMarketsToResponse, convertTermMaxMarketsToResponse, convertUsddMarketsToResponse, createMarketUid, createMidnightBookSource, createMulticallRpcCall, createRawRpcCalls, createTermBookSource, createTermMaxDataSource, decodeListaMarkets, decodeMarkets, decodePackedListaUserDataset, decodePackedMorphoUserDataset, deriveBorrowTags, deriveSupplyTags, detectInterfaceKinds, dssIlkBytes32, dssKeyParts, dssLenderKey, duration, earnDescription, earnLabel, earnMarketFromPool, earnMarketFromVault, earnUidFromMarketUid, earnVenueKind, encodeBalanceFetcherCalldata, enrichTermSheet, enrichmentIndexFromRows, exactlyPairLtv, exactlyPenaltyRateToAprPercent, exactlyWadRateToPercent, feePhrase, feedKeyOf, feedStatKey, fetchDolomiteAccountNumbers, fetchDssMarkets, fetchEulerEarnVaults, fetchEulerEarnVaultsFromSubgraph, fetchEulerSubAccountIndexes, fetchExactlyMarkets, fetchFlashLiquidityForChain, fetchFluidFTokens, fetchFrankencoinMarkets, 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, fetchTellerMarkets, fetchTermMarkets, fetchTermMaxMarkets, fetchTokenBalances, fetchTokenMetadata, fetchUpshiftApiVaults, fetchUpshiftVaults, fetchUsddMarkets, fetchYearnApiVaults, fetchYearnVaults, filterActiveLenders, filterLendersByProtocol, finalizeInfo, findingsFor, formatRaw, frankencoinKeyParts, frankencoinLenderKey, fuseLenderData, generateLendingPools, getAavesForChain, getAssetConfig, getBalanceForMarketUid, getBorrowCapacity, getCachedLiquityTroves, getCachedTellerBids, getCachedTermMaxDiscovery, getCachedTermMaxMarket, getCachedTermMaxMarkets, getCoreValidators, getFluidFTokensConverter, getGmxApiHost, getGmxReadContracts, getGmxUserPositions, getHealthFactor, getHypercoreUserPositions, getHypercoreVaultRegistry, getLenderAssets, getLenderPublicData, getLenderPublicDataAll, getLenderPublicDataViaApi, getLenderUserDataMulti, getLenderUserDataResult, getLendersForChain, getLstDelegation, getLstValidators, getLstWithdrawalRegistry, getLstWithdrawalRequests, getMaxAmountClose, getMaxAmountCollateralSwap, getMaxAmountDebtSwap, getMaxAmountOpen, getMergedUserData, getMorphoTypeMarketConverter, getReadFailurePolicy, getResolvedDolomiteAccountNumbers, getStCeloValidatorGroups, getSubAccountAddress, getSubAccountIndex, getTermProfile, getVaultPublicDataAll, getVaultWithdrawalRequests, hasCritical, hasEulerEarnVaultSubgraph, hasLagoonVaults, hasMorphoPositionIndex, hasMorphoUserApi, hasMorphoUserSubgraph, hasPendleMarkets, hasUpshiftVaults, hasYearnVaults, ilkToKeySegment, implausibleRatePercent, inverseKeyParts, inverseLenderKey, isFailedCall, isLiveMarket as isLivePendleMarket, isStablecoinSymbol, isVaultVenue, isYearnV3, keySegmentToIlk, keysFromMaps, lenderApiOnly, lenderFamily, liquityCandidateTroveIds, liquityKeyParts, liquityLenderKey, llamaLendKeyParts, llamaLendLenderKey, mergeDeep, multicall3Abi, nanTo, needsLenderApproval, needsTokenApproval, noOpResult, normalizeToBytes, parseBalanceFetcherResult, parseEarnUid, parseMergedResult, parseMulticallRpcResponses, parseExpirySeconds as parsePendleExpirySeconds, parseRawRpcBatchResponses, parseRawRpcResponses, parseTermMaxLtv, parseTokenBalanceResult, pct, assetKey as pendleAssetKey, positivePart, predictInverseEscrow, prepareLenderUserDataRpcCalls, prepareMergedMulticallParams, prepareMergedRpcCalls, prepareMulticallInputs, prepareTokenBalanceRpcCalls, priceGlvVaults, priceGmMarkets, probeAaveFeedTimestamps, pruneFeedStats, rankFindings, ratePercent, readVaultSharePrices, rejectOutliers as rejectPriceOutliers, resolveAdapter, resolveDerivation, resolveStCeloDepositGroup, resupplyKeyParts, resupplyLenderKey, resupplyMarketLabel, riverKeyParts, riverLenderKey, selectAssetGroupPrices, shortDate, splitChainScopedAddress as splitPendleChainScopedAddress, stampCapabilities, stampVaultClassification, supplyDescription, supplyFindings, supplyHeadline, tellerBpsToPercent, tellerImpliedLtv, tellerLenderKey, tellerPoolFromLenderKey, termLenderKey, termMaxApiBase, borrowNif as termMaxBorrowNif, curveApr as termMaxCurveApr, curveAprNumber as termMaxCurveAprNumber, daysToMaturity as termMaxDaysToMaturity, lendNif as termMaxLendNif, mintGtFeeRatio as termMaxMintGtFeeRatio, ratioToNumber as termMaxRatioToNumber, ratioToPercent as termMaxRatioToPercent, tickToAprNumber, tickToPrice, toDigest, toTermSheetInput, tryParseEarnUid, unflattenLenderData, updateFeedStats, usdValue, usddIlkBytes32, usddKeyParts, usddLenderKey, validateTermSheet, validateTermSheets, validateUserData, vaultVenue, venueBrand };