boomer77aave fees
    Updated 2021-09-27
    with deposits as (select tx_id, aave_version
    from aave.deposits
    where aave_version in ('Aave V2', 'Aave AMM')
    and block_timestamp >= CURRENT_DATE - 365),

    v1 as (select tx_id, aave_version
    from aave.deposits
    where aave_version = 'Aave V1'
    and block_timestamp >= CURRENT_DATE - 365),

    feesv2 as (select block_timestamp, tx_id, fee_usd
    from ethereum.transactions
    where tx_id in (select tx_id from deposits)),

    feesv1 as (select block_timestamp, tx_id, fee_usd
    from ethereum.transactions
    where tx_id in (select tx_id from v1))

    select a.aave_version, date_trunc('week',b.block_timestamp) as block_week, sum(b.fee_usd)
    from deposits a
    join fees b on a.tx_id = b.tx_id
    group by 1,2
    Run a query to Download Data