Skip to content

Commit

Permalink
fix version of api
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Aug 19, 2024
1 parent 9c6e753 commit 98ec5c1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dexs/dexalot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const historicalVolumeEndpoint = "https://api.dexalot.com/api/stats/chaindailyvo

interface IVolumeall {
volumeusd: string;
date: number;
date: string;
}

const supportedChains = [CHAIN.DEXALOT, CHAIN.AVAX, CHAIN.ARBITRUM, CHAIN.BASE]
Expand All @@ -29,13 +29,14 @@ const fetchFromChain = (chain: CHAIN) => {

return async (options: FetchOptions): Promise<FetchResultV2> => {
const dayTimestamp = new Date(options.startOfDay * 1000)
const dateStr = dayTimestamp.toISOString().split('T')[0]
const historicalVolume: IVolumeall[] = await httpGet(endpoint)

const totalVolume = historicalVolume
.filter(volItem => new Date(volItem.date) <= dayTimestamp)
.reduce((acc, { volumeusd }) => acc + Number(volumeusd), 0)
const dailyVolume = historicalVolume
.find(dayItem => new Date(dayItem.date) === dayTimestamp)?.volumeusd
.find(dayItem => dayItem.date.split('T')[0] === dateStr)?.volumeusd

return {
totalVolume: `${totalVolume}`,
Expand All @@ -53,7 +54,7 @@ const getStartTimestamp = (chain: CHAIN) => {
}

const adapter: SimpleAdapter = {
version: 2,
version: 1,
adapter: supportedChains.reduce((acc, chain) => {
return {
...acc,
Expand Down

0 comments on commit 98ec5c1

Please sign in to comment.