MasiMonthly
Updated 2024-10-07
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
›
⌄
with tb1 as ( select BLOCK_TIMESTAMP,
'Uniswap' as platform,
tx_hash,
ORIGIN_FROM_ADDRESS as user,
symbol_in,
symbol_out,
case when amount_in_USD is null then amount_out_usd else amount_in_usd end as volume
from ethereum.defi.ez_dex_swaps
where platform in ('uniswap-v3', 'uniswap-v2')
and (AMOUNT_IN_USD between AMOUNT_OUT_USD - 500 and AMOUNT_OUT_USD + 500
or AMOUNT_out_USD between AMOUNT_in_USD - 500 and AMOUNT_in_USD + 500)
and BLOCK_TIMESTAMP::date >= '2022-01-01'
UNION all
select BLOCK_TIMESTAMP,
'Thorchain' as platform,
tx_id as tx_hash,
ifnull(from_address,NATIVE_TO_ADDRESS) as user,
from_asset as symbol_in,
to_asset as symbol_out ,
case when FROM_AMOUNT_USD is null then TO_AMOUNT_USD else FROM_AMOUNT_USD end as volume
from thorchain.defi.fact_swaps
where BLOCK_TIMESTAMP::date >= '2022-01-01'
)
select trunc(block_timestamp,'month') as month,
platform,
count(DISTINCT user) as users,
count(DISTINCT tx_hash) as swaps,
sum(volume) as volume_usd,
sum(volume_usd) over (partition by platform order by month asc) as Cumulative_volume,
avg(volume) as avg_volume_usd,
count(DISTINCT symbol_in) as traded_tokens
from tb1
group by 1,2
QueryRunArchived: QueryRun has been archived