-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #907 from Rajwanshi1/master
Kriya-dex volume dimension adapter
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import fetchURL from "../../utils/fetchURL" | ||
import { Chain } from "@defillama/sdk/build/general"; | ||
import { SimpleAdapter } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; | ||
|
||
type IUrl = { | ||
[s: string]: string; | ||
} | ||
|
||
const url: IUrl = { | ||
[CHAIN.SUI]: `https://tkmw8dmcp8.execute-api.ap-southeast-1.amazonaws.com/prod/volume/` | ||
} | ||
|
||
interface IVolume { | ||
totalVolume: number, | ||
dailyVolume: number, | ||
weeklyVolume: number, | ||
monthlyVolume: number, | ||
} | ||
|
||
const fetch = (chain: Chain) => { | ||
return async (timestamp: number) => { | ||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); | ||
// fetch for the passed timestamp. | ||
const volumeUrl = url[chain] + String(timestamp); | ||
const volume: IVolume = (await fetchURL(volumeUrl))?.data; | ||
return { | ||
totalVolume: `${volume?.totalVolume || undefined}`, | ||
dailyVolume: `${volume?.dailyVolume || undefined}`, | ||
timestamp: dayTimestamp, | ||
}; | ||
}; | ||
} | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.SUI]: { | ||
fetch: fetch(CHAIN.SUI), | ||
start: async () => 1683604174, | ||
} | ||
}, | ||
}; | ||
|
||
export default adapter; |