diff --git a/libs/ledger-live-common/src/market/api/api.ts b/libs/ledger-live-common/src/market/api/api.ts index e21cc405ad30..120091e0b1f4 100644 --- a/libs/ledger-live-common/src/market/api/api.ts +++ b/libs/ledger-live-common/src/market/api/api.ts @@ -10,11 +10,10 @@ import { RawCurrencyData, MarketPerformersParams, MarketItemResponse, - MarketItemPerformer, SupportedCoins, } from "../types"; import { rangeDataTable } from "../utils/rangeDataTable"; -import { currencyFormatter, formatPerformer } from "../utils/currencyFormatter"; +import { currencyFormatter } from "../utils/currencyFormatter"; import URL from "url"; import { getRange } from "../utils/rangeFormatter"; @@ -285,7 +284,7 @@ export async function fetchMarketPerformers({ top = 50, sort, supported, -}: MarketPerformersParams): Promise { +}: MarketPerformersParams): Promise { const sortParam = `${sort === "asc" ? "positive" : "negative"}-price-change-${getRange(range)}`; const url = URL.format({ @@ -301,7 +300,7 @@ export async function fetchMarketPerformers({ const { data } = await network({ method: "GET", url }); - return data.map((currency: MarketItemResponse) => formatPerformer(currency)); + return data; } export default { diff --git a/libs/ledger-live-common/src/market/v2/useMarketPerformers.ts b/libs/ledger-live-common/src/market/v2/useMarketPerformers.ts index 28e1b44e6769..c9dd9ba0fc56 100644 --- a/libs/ledger-live-common/src/market/v2/useMarketPerformers.ts +++ b/libs/ledger-live-common/src/market/v2/useMarketPerformers.ts @@ -1,7 +1,8 @@ import { fetchMarketPerformers } from "../api/api"; -import { MarketPerformersParams } from "../types"; +import { MarketItemResponse, MarketPerformersParams } from "../types"; import { QUERY_KEY } from "./queryKeys"; import { useQuery } from "@tanstack/react-query"; +import { formatPerformer } from "../utils/currencyFormatter"; export function useMarketPerformers({ counterCurrency, @@ -16,6 +17,7 @@ export function useMarketPerformers({ queryKey: [QUERY_KEY.MarketPerformers, counterCurrency, range, sort], queryFn: () => fetchMarketPerformers({ counterCurrency, range, limit, top, sort, supported }), refetchInterval: 60 * 1000 * Number(refreshRate), + select: data => data.map((currency: MarketItemResponse) => formatPerformer(currency)), }); return {