/**
 * Oracle price data for a single asset
 */
export interface OraclePriceEntry {
    /** Asset address (lowercase) */
    asset: string;
    /** Raw oracle price (e.g., for Morpho this is debt/collateral rate) */
    price: number;
    /** USD price of the asset */
    priceUSD: number;
    /** Unique market identifier (lender:chainId:refAddress) */
    marketUid: string;
    /** Override lender key for output grouping (used by grouped fetchers like Morpho/Lista) */
    targetLender?: string;
    /** Oracle feed description (e.g. "ETH / USD", "Constant price feed") */
    description?: string;
    /** True when this asset IS the base asset and has a constant/identity oracle price (e.g. loan asset = 1.0) */
    staticBase?: boolean;
    /** Address of the base asset when the oracle quotes in a non-USD unit (e.g. WETH, WKLAY) */
    baseAsset?: string;
    /**
     * Config-scoped oracle identifier (e.g. spoke address for Aave V4).
     *
     * When set, this price applies only within the scope of this config.
     * The same underlying asset may have different prices from different
     * config scopes (e.g., two Aave V4 spokes using different price feeds
     * for the same token).
     *
     * `undefined` means the price is config-agnostic (all other lenders).
     */
    configId?: string;
}
/**
 * Structured oracle price data
 * chainId -> lender -> array of price entries
 */
export type StructuredOraclePrices = {
    [chainId: string]: {
        [lender: string]: OraclePriceEntry[];
    };
};
/**
 * Flat USD price map for lookups
 */
export type USDPriceMap = {
    [assetKey: string]: number;
};
/**
 * Context passed to parsers containing accumulated USD prices
 */
export interface ParseContext {
    chainId: string;
    usdPrices: USDPriceMap;
    tokenList?: TokenListMap;
}
/**
 * Token list entry (matches @1delta/data-sdk TokenListEntry)
 */
export interface TokenListEntry {
    chainId: string;
    name: string;
    address: string;
    symbol: string;
    decimals: number;
    logoURI?: string;
    assetGroup?: string;
    props?: {
        [key: string]: any;
    };
}
/**
 * Token list map (address -> entry)
 */
export type TokenListMap = {
    [address: string]: TokenListEntry;
};
/**
 * Multicall call structure
 */
export interface MulticallCall {
    address: string;
    name: string;
    params: any[];
}
/**
 * Fetcher result containing calls and metadata needed for parsing
 */
export interface FetcherResult<TMeta = any> {
    calls: MulticallCall[];
    meta: TMeta;
    lender: string;
}
/**
 * Parser function signature
 */
export type ParserFn<TMeta = any> = (data: any[], meta: TMeta, context: ParseContext) => OraclePriceEntry[];
/**
 * Fetcher module interface - plug and play design
 */
export interface OracleFetcher<TMeta = any> {
    /** Get multicall calls for this oracle type */
    getCalls: (chainId: string, context?: any) => FetcherResult<TMeta>[];
    /** Parse results from multicall */
    parse: ParserFn<TMeta>;
    /** ABI fragments needed for this oracle */
    getAbi: () => readonly any[];
}
/**
 * AAVE query metadata
 */
export interface AaveQueryMeta {
    oracle: string;
    assets: string[];
    fork: string;
}
/**
 * Morpho query metadata
 * Decimals are optional - if not provided, they will be read from the token list
 */
export interface MorphoQueryMeta {
    oracle: string;
    loanAsset: string;
    collateralAsset: string;
    loanAssetDecimals?: number;
    collateralAssetDecimals?: number;
    fork: string;
    /** Market ID (oracle address without 0x, uppercased) for unique lender key */
    marketId: string;
}
/**
 * Custom market override entry for Morpho-style markets
 */
export interface MorphoMarketOverride {
    oracle: string;
    loanAsset: string;
    collateralAsset: string;
    loanAssetDecimals?: number;
    collateralAssetDecimals?: number;
    /** Optional custom market ID (defaults to oracle address without 0x, uppercased) */
    marketId?: string;
}
/**
 * Lista query metadata
 * Uses USD oracles for both collateral and loan assets via peek(asset)
 */
export interface ListaQueryMeta {
    oracle: string;
    asset: string;
    /** Market ID for unique lender key */
    marketId: string;
}
/**
 * Custom market override entry for Lista-style markets
 */
export interface ListaMarketOverride {
    oracle: string;
    loanAsset: string;
    collateralAsset: string;
    /** Optional custom market ID (defaults to oracle address without 0x, uppercased) */
    marketId?: string;
}
/**
 * Aave V4 query metadata — per-oracle price calls.
 * Built from the flat aaveV4Oracles() metadata array.
 *
 * No fork dimension: each spoke is its own venue identity. The spoke
 * address on each entry is the join key into per-spoke lender keys
 * (`AAVE_V4_<HEX>`) that the lending normalizer emits.
 */
export interface AaveV4QueryMeta {
    /** Oracle contract address */
    oracle: string;
    /** Oracle decimals (from metadata, fallback 8) */
    oracleDecimals: number;
    /** Entries from oracle metadata for this oracle group */
    entries: {
        underlying: string;
        /** Spoke-local reserve ID needed for oracle.getReservePrice() call */
        reserveId: number;
        /** Spoke address — used as configId since oracles are spoke-scoped */
        spoke: string;
    }[];
}
/**
 * Compound V2 query metadata (legacy - for hardcoded configs)
 */
export interface CompoundV2QueryMeta {
    name: string;
    decimals: number;
    vToken: string;
}
/**
 * Compound V3 query metadata
 */
export interface CompoundV3QueryMeta {
    asset: string;
    oracle: string;
    /** Base asset for this market (prices are denominated in base asset) */
    baseAsset?: string;
    /** Lender protocol name */
    lender: string;
    /** Oracle feed description (e.g. "ETH / USD", "Constant price feed") */
    description?: string;
    /** True when this asset IS the base asset (constant price feed) */
    staticBase?: boolean;
}
/**
 * Controls which lender + chain combination wins when multiple oracles
 * report a USD price for the same assetGroup.
 *
 * Entries are processed in priority order (index 0 = highest).
 * The first write for a given assetGroup key wins; later (lower-priority)
 * entries only fill gaps.
 */
export interface FlattenPriorityConfig {
    /**
     * Lender prefixes in descending priority.
     * A lender matches if it starts with one of these prefixes.
     * Lenders not listed here fall into a middle tier.
     */
    lenderPriority: string[];
    /**
     * Chain IDs in descending priority (e.g. ["1"] = mainnet first).
     * Chains not listed here are sorted after the listed ones.
     */
    chainPriority: string[];
    /**
     * Lender prefixes that are always lowest priority (e.g. Morpho, Lista).
     * These are appended last so they only fill in assets not covered above.
     */
    lowPriorityLenders: string[];
    /**
     * Lenders whose oracle data is known to be invalid/broken on specific chains.
     * Map of chainId -> lender prefixes to skip entirely.
     */
    excludedLenders: {
        [chainId: string]: string[];
    };
    /**
     * Per-chain lender priority overrides.
     * Map of chainId -> lender prefixes in descending priority.
     * If a chain is listed here, these take precedence over the global lenderPriority.
     */
    lenderPriorityPerChain: {
        [chainId: string]: string[];
    };
    /**
     * Per-chain low-priority lender overrides.
     * Map of chainId -> lender prefixes that are always lowest priority on that chain.
     */
    lowPriorityLendersPerChain: {
        [chainId: string]: string[];
    };
    /**
     * Per-chain excluded lender overrides for specific markets.
     * Map of chainId -> market UIDs to skip entirely.
     */
    excludedLendersPerChain: {
        [chainId: string]: string[];
    };
}
/** TVL map keyed by lender -> total liquidity USD */
export type TvlMap = {
    [lender: string]: number;
};
/**
 * Per-tracker diagnostics (one entry per fetcher/lender per chain)
 */
export interface TrackerDiagnostic {
    /** Lender identifier */
    lender: string;
    /** Number of multicall slots for this tracker */
    callCount: number;
    /** Number of slots that returned '0x' (failed on-chain) */
    failedCalls: number;
    /** Number of parsed price entries produced */
    parsedEntries: number;
    /** If the parser threw, the error message */
    parseError?: string;
}
/**
 * Per-chain diagnostics
 */
export interface ChainDiagnostic {
    /** Chain ID */
    chainId: string;
    /** Total multicall slots executed */
    totalCalls: number;
    /** Total '0x' failures across all trackers */
    totalFailedCalls: number;
    /** Total parsed price entries */
    totalParsedEntries: number;
    /** Wall-clock time for this chain in ms */
    durationMs: number;
    /** Per-tracker breakdown */
    trackers: TrackerDiagnostic[];
    /** Fetchers whose getCalls() threw (fetcher name -> error message) */
    getCallsErrors: {
        [fetcher: string]: string;
    };
    /** If the entire chain failed (e.g. all RPCs down), the error message */
    chainError?: string;
    /** Morpho markets that could not derive a USD price */
    unresolvedMorphoMarkets: string[];
    /** Chainlink feeds with stale prices (updatedAt older than threshold) */
    staleFeeds: StaleFeedEntry[];
}
/**
 * Entry for a stale Chainlink price feed
 */
export interface StaleFeedEntry {
    /** Asset address */
    asset: string;
    /** Lender using this feed */
    lender: string;
    /** Feed oracle address */
    oracle: string;
    /** Seconds since the feed was last updated */
    staleSeconds: number;
}
/**
 * Top-level diagnostics report returned alongside oracle prices
 */
export interface OracleDiagnostics {
    /** Per-chain diagnostics */
    chains: ChainDiagnostic[];
    /** Total wall-clock time for all chains in ms */
    totalDurationMs: number;
    /** Chains that failed entirely */
    failedChains: string[];
}
/**
 * Combined result from fetchOraclePrices
 */
export interface OraclePricesResult {
    /** Structured oracle prices (partial if some chains failed) */
    prices: StructuredOraclePrices;
    /** Diagnostics report */
    diagnostics: OracleDiagnostics;
}
//# sourceMappingURL=types.d.ts.map