From 5bde781db82bca38dd7314ade24e33efc0b3a5d2 Mon Sep 17 00:00:00 2001
From: Pavel Levchenko
Date: Thu, 14 May 2026 09:42:48 +0300
Subject: [PATCH 1/2] use old price as 100%
---
pkg/api/rates_handlers.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pkg/api/rates_handlers.go b/pkg/api/rates_handlers.go
index 0395c459..d97dbfac 100644
--- a/pkg/api/rates_handlers.go
+++ b/pkg/api/rates_handlers.go
@@ -225,7 +225,7 @@ func (h *Handler) convertRates(
diff := 0.0
cp, _ := calculateConvertedPrice(entry.hist, currency, token)
if cp != 0 && convertedTodayPrice != 0 {
- diff = math.Round(((convertedTodayPrice-cp)/convertedTodayPrice)*10000) / 100
+ diff = math.Round((convertedTodayPrice/cp)*10000) / 100
}
switch {
case diff < 0:
From 479695c2b6d4c65135d4ef0de1059657ecc84e44 Mon Sep 17 00:00:00 2001
From: Pavel Levchenko
Date: Thu, 14 May 2026 10:20:15 +0300
Subject: [PATCH 2/2] use old price as base
---
pkg/api/rates_handlers.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pkg/api/rates_handlers.go b/pkg/api/rates_handlers.go
index d97dbfac..9525da04 100644
--- a/pkg/api/rates_handlers.go
+++ b/pkg/api/rates_handlers.go
@@ -225,7 +225,7 @@ func (h *Handler) convertRates(
diff := 0.0
cp, _ := calculateConvertedPrice(entry.hist, currency, token)
if cp != 0 && convertedTodayPrice != 0 {
- diff = math.Round((convertedTodayPrice/cp)*10000) / 100
+ diff = math.Round(((convertedTodayPrice-cp)/cp)*10000) / 100
}
switch {
case diff < 0: