Fug603Hourly copy
Updated 2024-04-05
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 hess / Hourly @ https://flipsidecrypto.xyz/hess/q/6Qt8q1m-bFQq/hourly
with price as ( select date(hour) as date,
avg(price) as avg_price
from ethereum.price.ez_hourly_token_prices
where symbol = 'WETH'
group by 1)
,
volume as ( select date(block_timestamp) as date,
trader,
symbol,
tx_hash,
modification_type,
case when symbol = 'USDB' then amount else amount*avg_price end as volume
from blast.blitz.ez_clearing_house_events a left outer join price b on a.block_timestamp::date = b.date)
,
price_2 as ( Select trunc(TO_TIMESTAMP(value[0]::string),'hour') as hour, value[1] as avg_price
from (
SELECT livequery.live.udf_api(
'https://api.coingecko.com/api/v3/coins/ethereum/market_chart?vs_currency=usd&days=90') as resp
)
,LATERAL FLATTEN (input => resp:data:prices)
group by all
order by 1 desc
limit 1)
,
deposit as ( select trunc(block_timestamp,'day') as date,
tx_hash,
trader,
symbol,
amount,
case when symbol = 'USDB' then amount else amount*avg_price end as deposit_volume
from blast.blitz.ez_clearing_house_events, price_2
where MODIFICATION_TYPE = 'deposit')
,
withdraw as ( select trunc(block_timestamp,'day') as date,
QueryRunArchived: QueryRun has been archived