Hossein2024-07-13 11:16 PM copy copy copy
Updated 2024-07-14
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 arbitrum as (
select
block_timestamp::Date AS date,tx_hash,
amount_in_usd AS amountUSD,
origin_from_address as user
from arbitrum.defi.ez_dex_swaps
where amount_in_usd<power(10,6)
and tx_hash in (select distinct(tx_hash) from arbitrum.core.ez_decoded_event_logs where origin_to_address in ('0x5e325eda8064b456f4781070c0738d849c824258','0xef1c6e67703c7bd7107eed8303fbe6ec2554bf6b','0x4c60051384bd2d3c01bfc845cf5f4b44bcbe9de5'))
and date>='2023-01-01'
and platform = 'uniswap-v3'
)
select
case when date>='2023-10-17' then 'after fee changes' else 'before fee changes' end as type,
count(distinct(user)) as "Users",
count(distinct tx_hash) as "Swaps",
avg(amountUSD) as "Amount Avg",
sum(amountUSD) as "Volume",
date_trunc('{{ time }}', date) as dt,
sum("Swaps") over (partition by type order by date_trunc('{{ time }}', date)) as "Swaps(cum)",
sum("Volume") over (partition by type order by date_trunc('{{ time }}', date)) as "Volume(cum)",
(("Swaps" - lag("Swaps", 1) over (partition by type order by date_trunc('{{ time }}', date)))/lag("Swaps", 1) over (partition by type order by date_trunc('{{ time }}', date))) * 100 as "swap changes(%)",
(("Volume" - lag("Volume", 1) over (partition by type order by date_trunc('{{ time }}', date)))/lag("Volume", 1) over (partition by type order by date_trunc('{{ time }}', date))) * 100 as "volume changes(%)",
(("Users" - lag("Users", 1) over (partition by type order by date_trunc('{{ time }}', date)))/lag("Users", 1) over (partition by type order by date_trunc('{{ time }}', date))) * 100 as "user changes(%)"
from arbitrum
group by type,dt
QueryRunArchived: QueryRun has been archived