From 1084182a2df534dbc50b4306d6c3b3128a11efbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sim=C3=A3o?= Date: Tue, 22 Aug 2023 14:27:00 +0100 Subject: [PATCH] fix: use-get-dex-volumes hook (#1534) --- src/hooks/api/use-get-dex-volume.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hooks/api/use-get-dex-volume.tsx b/src/hooks/api/use-get-dex-volume.tsx index 82ce60870b..4d494d20f3 100644 --- a/src/hooks/api/use-get-dex-volume.tsx +++ b/src/hooks/api/use-get-dex-volume.tsx @@ -57,7 +57,11 @@ const GET_DEX_VOLUMES = gql` ...AmountFields } } - endVolumes: cumulativeDexTradingVolumes(limit: 1, orderBy: tillTimestamp_DESC, where: { tillTimestamp_lte: $end }) { + endVolumes: cumulativeDexTradingVolumes( + limit: 1 + orderBy: tillTimestamp_DESC + where: { tillTimestamp_lte: $end, tillTimestamp_gte: $start } + ) { tillTimestamp amounts { ...AmountFields @@ -95,6 +99,10 @@ const useGetDexVolumes = (range: DateRangeVolume): UseGetCurrenciesResult => { const data = await graphQLClient.request(GET_DEX_VOLUMES, { start, end }); + if (!data.startVolumes.length || !data.endVolumes.length) { + return {}; + } + const [startVolumes] = data.startVolumes; const [endVolumes] = data.endVolumes;