File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Dependencies , FetchOptions , SimpleAdapter } from '../../adapters/types' ;
2+ import { CHAIN } from '../../helpers/chains' ;
3+ import { queryDuneSql } from '../../helpers/dune' ;
4+
5+ const fetch = async ( _a :any , _b :any , options : FetchOptions ) => {
6+ const query = `
7+ WITH buy_volume AS (
8+ SELECT SUM(usd_in) AS total_buy_usd
9+ FROM query_5971327
10+ WHERE block_time >= from_unixtime(${ options . startTimestamp } )
11+ AND block_time < from_unixtime(${ options . endTimestamp } )
12+ ),
13+ sell_volume AS (
14+ SELECT SUM(usd_out) AS total_sell_usd
15+ FROM query_5971367
16+ WHERE block_time >= from_unixtime(${ options . startTimestamp } )
17+ AND block_time < from_unixtime(${ options . endTimestamp } )
18+ )
19+ SELECT
20+ COALESCE(b.total_buy_usd, 0) + COALESCE(s.total_sell_usd, 0) AS total_volume_usd
21+ FROM buy_volume b
22+ CROSS JOIN sell_volume s;
23+ `
24+
25+ let dailyVolume = options . createBalances ( )
26+ const result = await queryDuneSql ( options , query )
27+
28+ if ( result && result . length > 0 ) {
29+ dailyVolume . addUSDValue ( result [ 0 ] . total_volume_usd )
30+ }
31+
32+ return { dailyVolume }
33+ }
34+
35+ const adapter : SimpleAdapter = {
36+ version : 1 ,
37+ fetch,
38+ chains : [ CHAIN . KATANA ] ,
39+ start : '2025-10-16' ,
40+ dependencies : [ Dependencies . DUNE ] ,
41+ isExpensiveAdapter : true ,
42+ }
43+
44+ export default adapter
You can’t perform that action at this time.
0 commit comments