danielrTotal supplied and withdrawn
    Updated 2023-06-04
    -- forked from Daily supplied and withdrawn @ https://flipsidecrypto.xyz/edit/queries/eb892687-ad4e-4828-8cf4-ca01b7cf6965

    with A as (
    SELECT
    date_trunc('{{Date_Trunc}}',block_timestamp) as date,
    sum(ISSUED_TOKENS) as Amount_Token,
    sum(SUPPLIED_USD) as Amount_USD,
    'Supplied' as label
    from ethereum.aave.ez_deposits
    where SYMBOL='AAVE'
    and block_timestamp>=CURRENT_DATE - {{Period_From_Current_Date}}
    group by 1
    ),
    B as(
    SELECT
    date_trunc('{{Date_Trunc}}',block_timestamp) as date,
    sum(WITHDRAWN_TOKENS) as Amount_Token,
    sum(WITHDRAWN_USD) as Amount_USD,
    'Withdrawn' as label
    from ethereum.aave.ez_withdraws
    where SYMBOL='AAVE'
    and block_timestamp>=CURRENT_DATE - {{Period_From_Current_Date}}
    group by 1
    ),
    C as(
    select * from A
    union all
    select * from B
    )
    select
    label,
    sum(Amount_USD),
    sum(Amount_Token)
    from C
    group by 1
    Run a query to Download Data