adambalaMonthly Swap Volume
Updated 2021-12-15Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
›
⌄
with tx_ids as (select tx_id from ethereum.transactions where
block_timestamp >= CURRENT_DATE -365
and (
to_address = '0xf92c1ad75005e6436b4ee84e88cb23ed8a290988' -- paraswap
or to_address = '0x86969d29f5fd327e1009ba66072be22db6017cc6' -- paraswap 2
or to_address = '0xf90e98f3d8dce44632e5020abf2e122e0f99dfab' -- paraswap v3
or to_address = '0x1bd435f3c054b6e901b7b108a0ab7617c808677b' -- paraswap router
or to_address = '0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57'
)
GROUP by tx_id
UNION
(select tx_id from polygon.transactions where
block_timestamp >= CURRENT_DATE -365
and (
to_address = '0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57'
)
GROUP by tx_id
)
),
transactions_events as (
select max(amount_usd/1e18) as amount, max(block_timestamp) as time_stamp from tx_ids INNER join ethereum.udm_events
on(tx_ids.tx_id =ethereum.udm_events.tx_id )
GROUP BY ethereum.udm_events.tx_id
UNION
select max(amount_usd/1e18) as amount, max(block_timestamp) as time_stamp from tx_ids INNER join polygon.udm_events
on(tx_ids.tx_id =polygon.udm_events.tx_id )
GROUP BY polygon.udm_events.tx_id
)
select Month(time_stamp) , sum (amount) as monthly_volume from transactions_events
GROUP BY Month(time_stamp) ORDER BY Month(time_stamp)
Run a query to Download Data