Raxol.Payments.Prices.CoinGecko (Raxol Payments v0.2.0)

Copy Markdown View Source

A price_fn for native gas tokens, backed by the public CoinGecko REST API.

Fetches ETH and POL (Polygon) USD prices once when the fn is built and closes over them, so aggregation does not hit the network per lookup. Any failure (or a missing symbol) yields nil for that symbol, so SettlementLedger aggregations degrade to raw fee/gas totals rather than crashing.

price_fn = Raxol.Payments.Prices.CoinGecko.price_fn()
Raxol.Payments.SettlementLedger.report(ledger, price_fn: price_fn)

Summary

Functions

Build a (symbol -> Decimal.t() | nil) after one REST fetch.

Functions

price_fn(opts \\ [])

@spec price_fn(keyword()) :: (String.t() -> Decimal.t() | nil)

Build a (symbol -> Decimal.t() | nil) after one REST fetch.

Options: :url (override endpoint), :req_options (extra Req options, e.g. plug: for Req.Test).