Skip to content

Commit

Permalink
fix backfill data
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Jun 30, 2023
1 parent ad8ea3c commit 92bdbf5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fees/thalaswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ const protocolRatioQueryURL = `${thalaDappURL}/api/protocol-revenue-ratio`;
const feesEndpoint = (startTimestamp: number, timeframe: string) =>
startTimestamp ? feesQueryURL + timeframe + `&startTimestamp=${startTimestamp}` : feesQueryURL + timeframe;

const historicalEndpoint = "https://app.thala.fi/api/trading-fee-chart";
interface IVolumeall {
value: number;
timestamp: string;
}

const fetch = async (timestamp: number) => {
const dayTime = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000));
const dayFeesQuery = (await fetchURL(feesEndpoint(dayTime, "1D")))?.data.data;
const dailyFees = dayFeesQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0);
const dayFeesQuery = (await fetchURL(historicalEndpoint))?.data.data;
const dailyFees = dayFeesQuery.find((a:IVolumeall) => Number(a.timestamp) === dayTime)?.value;

const totalFeesQuery = (await fetchURL(feesEndpoint(0, "ALL")))?.data.data;
const totalFees = totalFeesQuery.reduce((partialSum: number, a: IVolumeall) => partialSum + a.value, 0);
Expand Down

0 comments on commit 92bdbf5

Please sign in to comment.