sarathUser behavior_reduxx1
    Updated 2022-10-25
    with eth_price as (
    select
    date_trunc('day', hour) as date,
    avg(price) as price
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'WETH' and hour >= CURRENT_DATE - 90
    group by date
    ),
    op as (
    select
    date_trunc('day',block_timestamp) as date,
    'optimism' as type,
    count(distinct tx_hash) as n_txns,
    count(distinct from_address) as n_users,
    sum(((t.gas_price/1e9) * (t.gas_used)) * (price)) as gas_used_usd
    from optimism.core.fact_transactions t
    join eth_price p on t.block_timestamp::date = p.date
    where block_timestamp >= CURRENT_DATE - 90
    group by 1,2
    ),
    eth as (
    select
    date_trunc('day',block_timestamp) as date,
    'ethereum' as type,
    count(distinct tx_hash) as n_txns,
    count(distinct from_address) as n_users,
    sum(((t.gas_price/1e9) * (t.gas_used)) * (price)) as gas_used_usd
    from ethereum.core.fact_transactions t
    join eth_price p on t.block_timestamp::date = p.date
    where block_timestamp >= CURRENT_DATE - 90
    group by 1,2
    )

    select * from op
    union select * from eth

    Run a query to Download Data