hessDaily per chain
    Updated 2023-03-01
    with supply_tx as ( select DISTINCT tx_hash
    from optimism.core.fact_event_logs
    where origin_to_address = '0x794a61358d6845594f94dc1db02a252b5b4814ad'
    and event_name = 'Mint'
    and block_timestamp::date >= CURRENT_DATE - {{N_Days}})
    ,
    supply as ( select date(block_timestamp) as date, tx_hash , origin_from_address, contract_address as token, EVENT_INPUTS:value as raw_amount
    from optimism.core.fact_event_logs
    where origin_to_address = '0x794a61358d6845594f94dc1db02a252b5b4814ad'
    and tx_hash in (select tx_hash from supply_tx)
    and block_timestamp::date >= CURRENT_DATE - {{N_Days}}
    and event_name = 'Transfer'
    and origin_from_address = EVENT_INPUTS:from)
    ,
    price as ( select date(hour) as date, token_address , symbol, decimals , avg(price) as avg_price
    from optimism.core.fact_hourly_token_prices
    where hour::date >= CURRENT_DATE - {{N_Days}}
    and token_address in (select token from supply)
    group by 1,2,3,4)
    ,
    tb2 as ( select a.date, tx_hash , origin_from_address, symbol, (raw_amount/pow(10,decimals))*avg_price as volume
    from supply a left outer join price b on a.date = b.date and a.token = b.token_address
    )

    select date(block_timestamp) as date, 'Ethereum' as type, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(DEPOSITOR_ADDRESS)) as total_user,
    sum(SUPPLIED_USD) as total_volume, avg(SUPPLIED_USD) as avg_volume,
    median(SUPPLIED_USD) as median_volume, max(SUPPLIED_USD) as max_volume, min(SUPPLIED_USD) as min_volume,
    sum(total_tx) over (partition by type order by date) as cum_tx,
    sum(total_user) over (partition by type order by date) as cum_user,
    sum(total_volume) over (partition by type order by date) as cum_volume,
    avg(avg_volume) over (partition by type order by date asc rows between 7 preceding and current row ) as avg_7_days_moving
    from ethereum.aave.ez_deposits
    where block_timestamp::date >= CURRENT_DATE - {{N_Days}}
    group by 1,2
    UNION
    select date, 'Optimism' as type, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(origin_from_address)) as total_user,
    Run a query to Download Data