DefiLlamaOracle
Current and past USD prices from the keyless coins.llama.fi.
client is REQUIRED and injected: the oracle never constructs a
transport of its own, never retries, never rate-limits. Structurally a
prices.inquirer.PriceOracle and a prices.inquirer .HistoricalPriceOracle; imports neither.
__init__
__init__(self, client: httpx.Client, base_url: str = https://coins.llama.fi) -> None
Bind the injected client and base URL. Performs no I/O.
base_url is refused here because .rstrip is the first
thing to touch it: see Esplora, which has the same door.
Parameters
clientrequired, httpx.Clientnone
base_urloptional, str, default 'https://coins.llama.fi'none
usd_prices
usd_prices(self, caip19s: Sequence[str]) -> dict[str, Money]
Current USD price for each priceable input CAIP-19.
Unmapped ids contribute no request key and are absent from the
result; if NO input maps, returns {} with zero HTTP. Keys
absent from the response's coins object are unpriced and
absent from the result. Response keys are reverse-mapped onto the
caller's ids (ids sharing one key each receive its price).
Amounts are Decimal(str(price)) wrapped in Money(…, 'USD').
A non-2xx response or a malformed body raises SourceError.
Parameters
caip19srequired, Sequence[str]none
Raises
usd_prices_at
usd_prices_at(self, caip19s: Sequence[str], at_ms: int) -> dict[str, Money]
USD price for each priceable input CAIP-19 at at_ms.
The id mapping, the chunking, the reverse mapping of response keys
onto the caller's ids and the Money(Decimal(str(price)), 'USD')
conversion are usd_prices's, unchanged. Only the URL
differs: {base_url}/prices/historical/{at_ms // 1000}/{coins}.
at_ms goes on the wire verbatim, floored to whole seconds and
never bucketed: the historian is the only bucketer.
Unmapped ids contribute no request key and are absent from the
result; if NO input maps, returns {} with zero HTTP. A key
absent from the response's coins object is unpriced and absent
from the result, which is "not listed" and not an unreachable
instant.
caip19s must be a list or tuple of strings and at_ms a
non-negative integer, both refused with SourceError before any
HTTP. A non-2xx response or a malformed body raises SourceError
too, so every failure this method has is one channel.
Parameters
caip19srequired, Sequence[str]none
at_msrequired, intnone