Lux.Lenses.TransposePriceLens (Lux v0.5.0)

View Source

Lens 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

add_api_key(lens)

after_focus(body)

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"}

before_focus(params)

focus(input \\ %{}, opts \\ [])

Focuses the lens with the given input.

view()

Returns the Lens struct for this module.