Skip to content

Commit

Permalink
Fix 24h vol
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnd committed Sep 2, 2024
1 parent da3370f commit e6c92be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/handlers/getBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ const getBridge = async (bridgeNetworkId?: number) => {
const currentTimestamp = getCurrentUnixTimestamp();
const dailyStartTimestamp = currentTimestamp - 30 * secondsInDay;
const lastMonthDailyVolume = await getDailyBridgeVolume(dailyStartTimestamp, currentTimestamp, queryChain, id);
let last24hVolume = await getAggregatedDataClosestToTimestamp(
currentTimestamp - secondsInDay,
secondsInDay,
false,
undefined,
id
);
if (last24hVolume) {
last24hVolume = (last24hVolume.depositUSD + last24hVolume.withdrawUSD) / 2;
}
let lastDailyTs = 0;
if (lastMonthDailyVolume?.length) {
const lastDailyVolumeRecord = lastMonthDailyVolume[lastMonthDailyVolume.length - 1];
Expand Down Expand Up @@ -99,6 +109,7 @@ const getBridge = async (bridgeNetworkId?: number) => {
dayBeforeLastVolume: dayBeforeLastVolume ?? 0,
weeklyVolume: weeklyVolume ?? 0,
monthlyVolume: monthlyVolume ?? 0,
last24hVolume: last24hVolume ?? 0,
lastHourlyTxs: Object.keys(lastHourlyTxs).length ? lastHourlyTxs : { deposits: 0, withdrawals: 0 },
currentDayTxs: Object.keys(currentDayTxs).length ? currentDayTxs : { deposits: 0, withdrawals: 0 },
prevDayTxs: Object.keys(prevDayTxs).length ? prevDayTxs : { deposits: 0, withdrawals: 0 },
Expand All @@ -124,7 +135,7 @@ const getBridge = async (bridgeNetworkId?: number) => {
monthlyTxs,
} = chainBreakdown["all"];

if (destinationChain){
if (destinationChain) {
chainBreakdown[destinationChain] = chainBreakdown["all"];
}
delete chainBreakdown["all"];
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/getBridges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ const getBridges = async () => {
});
}

const last24hVolume = await getAggregatedDataClosestToTimestamp(
let last24hVolume = await getAggregatedDataClosestToTimestamp(
currentTimestamp - secondsInDay,
secondsInDay,
false,
undefined,
id
);
if (last24hVolume) {
lastDailyVolume = (last24hVolume.depositUSD + last24hVolume.withdrawUSD) / 2;
last24hVolume = (last24hVolume.depositUSD + last24hVolume.withdrawUSD) / 2;
}

const hourlyStartTimestamp = startOfTheDayTs - secondsInDay;
Expand Down

0 comments on commit e6c92be

Please sign in to comment.