fix: `coin_price_change_percentage` calculation (#9774)

pull/9929/head
Maxim Filonov 7 months ago committed by GitHub
parent d7641a28f3
commit 5e59d44769
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/stats_controller.ex

@ -42,9 +42,9 @@ defmodule BlockScoutWeb.API.V2.StatsController do
coin_price_change =
case Market.fetch_recent_history() do
[today, yesterday | _] ->
today.closing_price && yesterday.closing_price &&
today.closing_price
[_today, yesterday | _] ->
exchange_rate.usd_value && yesterday.closing_price &&
exchange_rate.usd_value
|> Decimal.div(yesterday.closing_price)
|> Decimal.sub(1)
|> Decimal.mult(100)

Loading…
Cancel
Save