brb2javg gas spent
    Updated 2023-03-25
    with eth as (
    select
    date_trunc('day', hour) as day ,
    avg(price) as eth
    from ethereum.core.fact_hourly_token_prices
    where symbol like 'WETH'
    group by 1
    )

    ,
    main as (
    select
    date_trunc('day',a.block_timestamp) as date,
    sum(a.tx_fee) as eth_fee,
    sum(gas_used / 1e9) as gas,
    avg(a.tx_fee) as avg_eth_fee,
    avg(gas_used / 1e9) as avg_gas,
    sum(a.tx_fee * eth) as usd_fee ,
    avg(a.tx_fee * eth) as avg_usd_fee,
    sum(eth_fee) over (
    order by
    date
    ) as cumulative_eth_fee,
    sum(gas) over (
    order by
    date
    ) as cumulative_gas,
    sum(usd_fee) over (order by date) as cum_usd_fee
    from
    ethereum.core.fact_transactions a join ethereum.aave.ez_votes b join eth c on a.tx_hash = b.tx_hash AND
    a.block_timestamp::date=c.day
    where date >= current_date - {{time}}
    group by
    date
    order by
    date desc)
    Run a query to Download Data