-
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 #2305 from anqa-ag/nhd98z/add-anqa-aggregator
Add volume adapter for anqa aggregator
- Loading branch information
Showing
1 changed file
with
29 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,29 @@ | ||
import {FetchResult,} from "../../adapters/types"; | ||
import {getUniqStartOfTodayTimestamp} from "../../helpers/getUniSubgraphVolume"; | ||
import {fetchURLWithRetry} from "../../helpers/duneRequest"; | ||
|
||
const fetch = async (_: number): Promise<FetchResult> => { | ||
const unixTimestamp = getUniqStartOfTodayTimestamp(); | ||
const data = await fetchURLWithRetry(`https://api.dune.com/api/v1/query/3835933/results`) | ||
const chainData = data.result.rows[0]; | ||
if (!chainData) throw new Error(`Dune query failed: ${JSON.stringify(data)}`) | ||
return { | ||
dailyVolume: chainData["Volume 24h"], | ||
totalVolume: chainData["Total Volume"], | ||
timestamp: unixTimestamp, | ||
}; | ||
}; | ||
|
||
const adapter: any = { | ||
timetravel: false, | ||
adapter: { | ||
"aptos": { | ||
fetch: fetch, | ||
runAtCurrTime: true, | ||
start: '2023-06-16', | ||
} | ||
}, | ||
isExpensiveAdapter: true, | ||
}; | ||
|
||
export default adapter; |