Updated 2022-10-06Copy Reference Fork
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
›
⌄
with t1 as ( select
trunc(hour,'day') as date,
symbol ,
avg(price) as average_price
from optimism.core.fact_hourly_token_prices
where symbol in ('WETH','OP') and hour >= CURRENT_DATE - 60
group by date, symbol
)
,
price_usd as ( select
date,
case when symbol = 'WETH' then 'ETH' else symbol end as token, average_price
from t1)
,
nft_sales as ( select
trunc(block_timestamp,'day') as day ,
tx_hash,
seller_address,
nft_address,
CURRENCY_SYMBOL,
price,
buyer_address,
price*average_price as price_usd
from optimism.core.ez_nft_sales x left outer join price_usd y on x.block_timestamp::date = y.date
where CURRENCY_SYMBOL = token)
select day ,
sum(price_usd) as sales_volume,
sum(sales_volume) over (order by day asc) as cumulative_sales_volume
from nft_sales
group by day
Run a query to Download Data