Skip to content

Commit

Permalink
Fix/volume pool v3 (#1040)
Browse files Browse the repository at this point in the history
* refactor: improve combined data calculation in useVolumeEventChart hook

* refactor: optimize combined data calculation in useLiquidityEventChart hook
  • Loading branch information
trungbach authored Nov 15, 2024
1 parent f8d4afa commit 3d7ab8e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/pages/Pools/hooks/useLiquidityEventChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ export const useLiquidityEventChart = (
};
});

const combinedData = dataV2.map((dataV2ByDay) => {
const dataV3ByDay = dataVolumeV3.find((item) => item.time === dataV2ByDay.time);
const combinedData = dataVolumeV3
.map((dataV3ByDay) => {
const dataV2ByDay = dataV2.find((item) => item.time === dataV3ByDay.time);

return {
time: dataV2ByDay.time,
value: dataV2ByDay.value + (dataV3ByDay?.value ?? 0)
};
});
return {
time: dataV3ByDay.time,
value: (dataV2ByDay?.value ?? 0) + (dataV3ByDay?.value ?? 0)
};
})
.sort((a, b) => new Date(a.time).getTime() - new Date(b.time).getTime());

setCurrentDataLiquidity(combinedData);
if (combinedData.length > 0) {
Expand Down

0 comments on commit 3d7ab8e

Please sign in to comment.