Skip to content

Commit 3d7ab8e

Browse files
authored
Fix/volume pool v3 (#1040)
* refactor: improve combined data calculation in useVolumeEventChart hook * refactor: optimize combined data calculation in useLiquidityEventChart hook
1 parent f8d4afa commit 3d7ab8e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/pages/Pools/hooks/useLiquidityEventChart.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ export const useLiquidityEventChart = (
6161
};
6262
});
6363

64-
const combinedData = dataV2.map((dataV2ByDay) => {
65-
const dataV3ByDay = dataVolumeV3.find((item) => item.time === dataV2ByDay.time);
64+
const combinedData = dataVolumeV3
65+
.map((dataV3ByDay) => {
66+
const dataV2ByDay = dataV2.find((item) => item.time === dataV3ByDay.time);
6667

67-
return {
68-
time: dataV2ByDay.time,
69-
value: dataV2ByDay.value + (dataV3ByDay?.value ?? 0)
70-
};
71-
});
68+
return {
69+
time: dataV3ByDay.time,
70+
value: (dataV2ByDay?.value ?? 0) + (dataV3ByDay?.value ?? 0)
71+
};
72+
})
73+
.sort((a, b) => new Date(a.time).getTime() - new Date(b.time).getTime());
7274

7375
setCurrentDataLiquidity(combinedData);
7476
if (combinedData.length > 0) {

0 commit comments

Comments
 (0)