diff --git a/fees/thalaswap.ts b/fees/thalaswap.ts index 25b1eab2c7..1f5559d8c0 100644 --- a/fees/thalaswap.ts +++ b/fees/thalaswap.ts @@ -11,6 +11,7 @@ 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; @@ -18,8 +19,8 @@ interface IVolumeall { 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);