/** A pluggable fiat FX rate oracle consumed by the valuation endpoint. */ export type Oracle = { /** Returns the cache-key suffix for the oracle's current publication window. */ cacheKey?: (() => string) | undefined; /** Oracle identifier, surfaced as valuation rate provenance (e.g. `ecb`). */ name: string; /** Fetches the oracle's current rate set. */ rates: () => Promise; /** Cache lifetime for a fetched rate set, in milliseconds. */ ttl: number; }; /** One oracle-published set of exchange rates quoted against a base currency. */ export type RateSet = { /** Publication date of the rate set as an ISO 8601 timestamp. */ asOf: string; /** Currency the rates are quoted against (e.g. `EUR`). */ base: string; /** Currency code to units of that currency per one `base` unit, as decimal strings. */ rates: Record; }; /** Fixed-point scale (decimal places) of cross rates returned by {@link rate}. */ export declare const precision = 18; /** Canonical ECB daily reference-rate feed (public, no key required). */ export declare const ecbUrl = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"; /** * Normalizes an oracle definition into an {@link Oracle}: applies the default * `ttl` and rethrows `rates()` failures as {@link RatesError}. */ export declare function from(oracle: from.Value): Oracle; export declare namespace from { /** Oracle definition accepted by {@link from}. */ type Value = Pick & { /** Cache lifetime for a fetched rate set, in milliseconds. @default `Ttl.hours(1)` */ ttl?: number | undefined; }; } /** European Central Bank reference rates, cached for one day to match their publication cadence. */ export declare function ecb(options?: ecb.Options): Oracle; export declare namespace ecb { /** Options for the ECB oracle. */ type Options = { /** Fetch implementation used to retrieve the feed. @default `globalThis.fetch` */ fetch?: typeof globalThis.fetch | undefined; /** Feed URL. @default {@link ecbUrl} */ url?: string | undefined; }; } /** * Derives the cross rate from one currency to another through the set's base, * scaled to {@link precision} decimal places. Returns `undefined` when the set * prices neither leg of a currency. */ export declare function rate(set: RateSet, options: rate.Options): bigint | undefined; export declare namespace rate { /** Options for deriving a cross rate. */ type Options = { /** Currency code to convert from. */ from: string; /** Currency code to convert to. */ to: string; }; } /** Thrown when an oracle fails to produce its rate set. */ export declare class RatesError extends Error { name: string; constructor(oracle: string, options: { cause: unknown; }); } //# sourceMappingURL=FxOracle.d.ts.map