refactor xmr rate module to exchange rate module for multi crypto support

This commit is contained in:
2026-09-02 14:53:50 +02:00
parent 6818f08dbe
commit 0510695598
29 changed files with 630 additions and 388 deletions
@@ -0,0 +1,25 @@
import Decimal from 'decimal.js';
import type { ShopFiatCurrency } from '../../../types/ShopFiatCurrency';
export const extractCoinPaprikaTickerPrice = (
response: { quotes: Record<string, { price: number }> },
shopFiatCurrency: ShopFiatCurrency
): number | null => {
const quote = response.quotes[shopFiatCurrency];
if (!quote) {
return null;
}
const rate = quote.price;
if (typeof rate !== 'number' || !Number.isFinite(rate) || rate <= 0) {
return null;
}
try {
return new Decimal(rate).toDecimalPlaces(2).toNumber();
} catch {
return null;
}
};