import { type Address } from "viem"; import type { OraclePrice } from "../../utils/oracle.js"; import type { EVault } from "../../entities/EVault.js"; import type { ERC4626Vault } from "../../entities/ERC4626Vault.js"; import type { ProviderService } from "../providerService/providerService.js"; import type { DeploymentService } from "../deploymentService/deploymentService.js"; import { type PricingBackendClient } from "./backendClient.js"; import { type BuildQueryFn } from "../../utils/buildQuery.js"; import { type ServiceResult } from "../../utils/entityDiagnostics.js"; export declare const ONE_18: bigint; /** Euler virtual USD address (decimal 840 = ISO-4217 USD). */ export declare const USD_ADDRESS: Address; /** * Raw oracle price result with mid, ask, and bid prices. * `decimals` indicates the precision of the quote (output) asset — * e.g. the UoA decimals for Layer-1 oracle prices. */ export type OraclePriceResult = { amountOutMid: bigint; amountOutAsk: bigint; amountOutBid: bigint; decimals: number; }; /** USD price per whole token as a plain decimal number. */ export type PriceResult = number; export type FormatAssetValueOptions = { maxDecimals?: number; minDecimals?: number; }; export type FormattedAssetValue = { /** Formatted display string: "1,234.56 USDC" when no price available, empty when price available (caller formats USD). */ display: string; /** Whether a USD price was available. */ hasPrice: boolean; /** USD value of the amount (0 when no price). */ usdValue: number; /** Human-readable token amount. */ assetAmount: number; /** Token symbol. */ assetSymbol: string; }; export interface IPriceService { getAssetOraclePrice(vault: EVault): OraclePriceResult | undefined; getCollateralShareOraclePrice(liabilityVault: EVault, collateralVault: ERC4626Vault): OraclePrice | undefined; getCollateralOraclePrice(liabilityVault: EVault, collateralVault: ERC4626Vault): OraclePriceResult | undefined; fetchUnitOfAccountUsdRate(vault: EVault): Promise; fetchUnitOfAccountUsdRateWithDiagnostics(vault: EVault, path?: string): Promise>; fetchAssetUsdPrice(vault: ERC4626Vault): Promise; fetchAssetUsdPriceWithDiagnostics(vault: ERC4626Vault, path?: string): Promise>; fetchAssetUsdPriceByAddress(chainId: number, assetAddress: Address): Promise; fetchAssetUsdPriceByAddressWithDiagnostics(chainId: number, assetAddress: Address, path?: string): Promise>; fetchCollateralUsdPrice(liabilityVault: EVault, collateralVault: ERC4626Vault): Promise; fetchCollateralUsdPriceWithDiagnostics(liabilityVault: EVault, collateralVault: ERC4626Vault, path?: string): Promise>; formatAssetValue(amount: bigint, vault: ERC4626Vault, options?: FormatAssetValueOptions): Promise; } export declare class PriceService implements IPriceService { private providerService; private deploymentService; private backendClient?; constructor(providerService: ProviderService, deploymentService: DeploymentService, backendClient?: PricingBackendClient | undefined, buildQuery?: BuildQueryFn); setProviderService(providerService: ProviderService): void; setBackendClient(backendClient: PricingBackendClient | undefined): void; queryAssetPriceInfo: (provider: ReturnType, utilsLensAddress: Address, assetAddress: Address) => Promise<{ queryFailure: boolean; amountOutMid: bigint; }>; setQueryAssetPriceInfo(fn: typeof this.queryAssetPriceInfo): void; getAssetOraclePrice(vault: EVault): OraclePriceResult | undefined; getCollateralShareOraclePrice(liabilityVault: EVault, collateralVault: ERC4626Vault): OraclePrice | undefined; getCollateralOraclePrice(liabilityVault: EVault, collateralVault: ERC4626Vault): OraclePriceResult | undefined; /** * Get the USD rate for a vault's unit of account. * Always tries the V3 pricing API first (UoA is a common denominator — * using off-chain rates doesn't affect health factor/LTV ratios). * Falls back to on-chain utilsLens call. */ fetchUnitOfAccountUsdRate(vault: EVault): Promise; fetchUnitOfAccountUsdRateWithDiagnostics(vault: EVault, path?: string): Promise>; /** * Get asset price in USD. * Tries the V3 pricing API first, falls back to on-chain oracle. * EVault: oraclePrice × uoaRate. * EulerEarn / SecuritizeCollateral: utilsLens or backend. */ fetchAssetUsdPrice(vault: ERC4626Vault): Promise; fetchAssetUsdPriceWithDiagnostics(vault: ERC4626Vault, path?: string): Promise>; /** * Get a standalone asset price in USD by token address. * Tries the V3 pricing API first, then falls back to utilsLens.getAssetPriceInfo(asset, USD). */ fetchAssetUsdPriceByAddress(chainId: number, assetAddress: Address): Promise; fetchAssetUsdPriceByAddressWithDiagnostics(chainId: number, assetAddress: Address, path?: string): Promise>; /** * Get collateral price in USD in the context of a liability vault. * Tries the V3 pricing API first, falls back to on-chain oracle. * Collateral pricing ALWAYS uses the liability vault's oracle for on-chain fallback. */ fetchCollateralUsdPrice(liabilityVault: EVault, collateralVault: ERC4626Vault): Promise; fetchCollateralUsdPriceWithDiagnostics(liabilityVault: EVault, collateralVault: ERC4626Vault, path?: string): Promise>; /** * Format an asset amount for UI display. * Returns USD value when price is available, falls back to token amount + symbol. */ formatAssetValue(amount: bigint, vault: ERC4626Vault, options?: FormatAssetValueOptions): Promise; /** * Get asset USD price from on-chain oracles. * EVault: oraclePriceRaw × UoA rate. * EulerEarn / SecuritizeCollateral: utilsLens.getAssetPriceInfo. */ private fetchAssetUsdPriceFromOracle; private fetchDirectAssetUsdPriceFromOracle; /** * Get collateral USD price from on-chain oracles. */ private fetchCollateralUsdPriceFromOracle; /** * Call utilsLens.getAssetPriceInfo(asset, USD_ADDRESS) on-chain. */ private fetchAssetPriceInfo; } /** * Get raw oracle price for a vault's asset in the vault's unit of account. * Uses oraclePriceRaw (liabilityPriceInfo from the vault lens). */ export declare function getAssetOraclePrice(vault: EVault): OraclePriceResult | undefined; /** * Get collateral share price from the liability vault's perspective. * Returns the raw OraclePrice in the liability vault's unit of account. */ export declare function getCollateralShareOraclePrice(liabilityVault: EVault, collateralVault: ERC4626Vault): OraclePrice | undefined; /** * Get collateral ASSET price from the liability vault's perspective. * Converts share price to asset price using the collateral vault's conversion * rules. */ export declare function getCollateralOraclePrice(liabilityVault: EVault, collateralVault: ERC4626Vault): OraclePriceResult | undefined; //# sourceMappingURL=priceService.d.ts.map