bertaDistribution 4
Updated 2022-10-20Copy 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
33
34
35
36
›
⌄
with eth_price as
(
SELECT
date_trunc('day', hour) as day,
avg(price) as token_price
FROM optimism.core.fact_hourly_token_prices
WHERE symbol = 'ETH'
group by 1
),op_price as
(
SELECT
date_trunc('day', hour) as day,
avg(price) as token_price
FROM optimism.core.fact_hourly_token_prices
WHERE symbol = 'OP'
group by 1
),op_price_in_eth as (
select op_price.day as daily,
op_price.token_price/eth_price.token_price as op_in_eth
from eth_price,op_price
where eth_price.day = op_price.day
),processed as (
SELECT
date_trunc('day', block_timestamp) as day,
CASE
WHEN currency_symbol = 'OP' then op_in_eth*price
WHEN currency_symbol in ('WETH','ETH') then price
END as NFT_price_eth,
*
FROM optimism.core.ez_nft_sales left join op_price_in_eth
on date_trunc('day', block_timestamp) = daily
WHERE currency_symbol is not null)
,op_nft as(
SELECT date_trunc('month', block_timestamp),
'Optimism' as type,
Run a query to Download Data