Rujira.Prices behaviour (rujira_ex v0.0.1)

Copy Markdown View Source

Behaviour and configurable delegator for asset price lookups.

Ships with two built-in implementations:

Consumers can override via application env:

config :rujira_ex, prices: MyApp.CustomPrices

Defaults to Rujira.Prices.Default.

Cache TTL

The default implementation memoizes prices using the global cache TTL. See Rujira.cache_ttl/0.

Summary

Callbacks

get(t)

@callback get(String.t()) :: {:ok, Decimal.t()} | {:error, term()}

value_usd(t, integer, integer)

@callback value_usd(String.t(), integer(), integer()) :: integer()

Functions

get(symbol)

@spec get(String.t()) :: {:ok, Decimal.t()} | {:error, term()}

value_usd(symbol, amount, decimals \\ 8)

@spec value_usd(String.t(), integer(), integer()) :: integer()