0xHaM-dOver Time Final copy
Updated 2025-01-22
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
›
⌄
-- forked from Over Time Final @ https://flipsidecrypto.xyz/studio/queries/ac8036d9-8444-4bdb-ac71-39a34bec2f50
WITH priceTb as (
select
hour,
PRICE
from crosschain.price.ez_prices_hourly
where symbol ='ETH'
and BLOCKCHAIN = 'ethereum'
-- and date_trunc(day,hour)::date >= '2024-12-01'
and TOKEN_ADDRESS is NULL
)
, swapTB as (
SELECT
BLOCK_TIMESTAMP,
TX_HASH,
FROM_ADDRESS,
TX_FEE_PRECISE as FEE_PRECISE,
TX_FEE_PRECISE*PRICE as FEE_USD,
FROM ink.core.fact_transactions
JOIN priceTb on trunc(BLOCK_TIMESTAMP, 'hour') = hour
-- WHERE TX_HASH in (SELECT DISTINCT TX_HASH FROM ink.core.ez_decoded_event_logs
-- WHERE EVENT_NAME ilike '%Swap%'
-- AND DECODED_LOG:liquidity is NULL
-- )
)
SELECT
count(DISTINCT TX_HASH) as n_swaps,
count(DISTINCT FROM_ADDRESS) as n_swappers,
sum(FEE_PRECISE) as TX_FEE_ETH,
sum(FEE_USD) as TX_FEE_USD,
TX_FEE_USD/n_swaps as fee_usd_per_tx,
FROM swapTB
QueryRunArchived: QueryRun has been archived