Moe AAVE depositors and withdrawers
    Updated 2023-06-05

    with dep as (select
    'DEPOSIT' as actions,

    date_trunc(week , BLOCK_TIMESTAMP)::date as date,
    count(distinct DEPOSITOR_ADDRESS) as users,
    count(distinct TX_HASH) as transactions,
    sum(SUPPLIED_USD) as value_usd,
    sum(ISSUED_TOKENS) as value_aave,

    value_aave / users as usd_per_user,
    value_aave / transactions as usd_per_txn
    from
    ethereum.aave.ez_deposits
    where
    date(BLOCK_TIMESTAMP) >= current_date - {{days_back}}
    and
    symbol ilike 'aave'
    group by 2),

    witd as(
    select 'WITHDRAW' as actions,
    date_trunc(week , BLOCK_TIMESTAMP)::date as date,
    count(distinct DEPOSITOR_ADDRESS) as users,
    count(distinct TX_HASH) as transactions,
    sum(WITHDRAWN_USD) as value_usd,
    sum(WITHDRAWN_TOKENS) as value_aave,

    value_aave / users as usd_per_user,
    value_aave / transactions as usd_per_txn
    from
    ethereum.aave.ez_withdraws
    where
    date(BLOCK_TIMESTAMP) >= current_date - {{days_back}}
    and
    symbol ilike 'aave'
    Run a query to Download Data