Lux.Lenses.TransposePriceLens (Lux v0.5.0)
View SourceLens for fetching token prices from the Transpose API.
Example
alias Lux.Lenses.TransposePriceLens
# Single token
TransposePriceLens.focus(%{
token_addresses: ["0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"], # UNI token
timestamp: DateTime.utc_now() |> DateTime.to_iso8601()
})
# Multiple tokens
TransposePriceLens.focus(%{
token_addresses: [
"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", # UNI
"0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9" # AAVE
],
timestamp: DateTime.utc_now() |> DateTime.to_iso8601()
})
Summary
Functions
Transforms the API response into a more usable format.
Focuses the lens with the given input.
Returns the Lens struct for this module.
Functions
Transforms the API response into a more usable format.
Examples
iex> after_focus(%{"prices" => [%{"price" => 5.20, "token_address" => "0x..."}]})
{:ok, %{prices: [%{price: 5.20, token_address: "0x...", ...}]}}
iex> after_focus(%{"error" => "Invalid API key"})
{:error, "Invalid API key"}
Focuses the lens with the given input.
Returns the Lens struct for this module.