|
|
|
@ -124,6 +124,11 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def coin_id(symbol) do |
|
|
|
|
id_mapping = bridged_token_symbol_to_id_mapping_to_get_price(symbol) |
|
|
|
|
|
|
|
|
|
if id_mapping do |
|
|
|
|
{:ok, id_mapping} |
|
|
|
|
else |
|
|
|
|
url = "#{base_url()}/coins/list" |
|
|
|
|
|
|
|
|
|
symbol_downcase = String.downcase(symbol) |
|
|
|
@ -149,6 +154,7 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do |
|
|
|
|
resp |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp get_btc_price(currency \\ "usd") do |
|
|
|
|
url = "#{base_url()}/exchange_rates" |
|
|
|
@ -172,4 +178,11 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do |
|
|
|
|
defp config(key) do |
|
|
|
|
Application.get_env(:explorer, __MODULE__, [])[key] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp bridged_token_symbol_to_id_mapping_to_get_price(symbol) do |
|
|
|
|
case symbol do |
|
|
|
|
"UNI" -> "uniswap" |
|
|
|
|
_symbol -> nil |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|