MLDZMNuni.2
Updated 2022-09-22Copy 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
31
32
33
34
35
›
⌄
with tb1 as(SELECT
BLOCK_TIMESTAMP::date as day,
PLATFORM,
SYMBOL_IN as coins,
sum(AMOUNT_IN_USD) as volume_in,
count(tx_hash) as swaps_in
from ethereum.core.ez_dex_swaps where PLATFORM ilike '%uniswap%'
and SYMBOL_IN in ('USDC','USDT','DAI')
and BLOCK_TIMESTAMP>='2022-05-01'
group by 1,2,3
),
tb2 as(SELECT
BLOCK_TIMESTAMP::date as day,
PLATFORM,
SYMBOL_OUT as coins,
sum(AMOUNT_OUT_USD) as volume_out,
count(tx_hash) as swaps_out
from ethereum.core.ez_dex_swaps where PLATFORM ilike '%uniswap%'
and SYMBOL_OUT in ('USDC','USDT','DAI')
and BLOCK_TIMESTAMP>='2022-05-01'
group by 1,2,3
)
select
tb1.day as day,
tb1.coins as "Stable coins",
tb1.PLATFORM,
volume_in+volume_out as "Total volume",
swaps_in+swaps_out as "Number of swaps",
sum("Total volume") over (partition by tb1.PLATFORM order by tb1.day) as cumulative_usage,
sum("Number of swaps") over (partition by tb1.PLATFORM order by tb1.day) as cumulative_swaps
from tb1 join tb2 on tb1.day=tb2.day
where "Total volume" is not null
Run a query to Download Data