Pine Analyticsmiddle-olive copy copy
Updated 2024-10-15
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
36
›
⌄
with tab1 as (
SELECT
DISTINCT tx_hash
FROM ethereum.defi.ez_dex_swaps
where (platform LIKE '%uniswap%'
or platform LIKE '%Uniswap%')
and block_timestamp > '2022-01-01'
), tab2 as (
SELECT
date_trunc('day', hour) as day,
median(price) as price
FROM ethereum.price.ez_prices_hourly
WHERE token_address LIKE lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
GROUP BY 1
)
SELECT
date_trunc('week', block_timestamp) as week,
count(DISTINCT tx_hash) as events,
median(TX_FEE_PRECISE) * avg(price) as median_fee,
avg(TX_FEE_PRECISE) * avg(price) as average_fee
FROM ethereum.core.fact_transactions
left outer join tab2
on date(block_timestamp) = day
WHERE block_timestamp > '2022-01-01'
and tx_hash in (SELECT * from tab1)
GROUP by 1
QueryRunArchived: QueryRun has been archived