Updated 2023-03-09

    --How many unique borrowers of SNX, UNI, & MKR are there on Aave V2?
    --What is total cumulative borrow for each asset on Aave V2?
    --Can you visualize borrowing of each asset over time?
    with
    news as (
    select distinct borrower_address,symbol,
    min(block_timestamp) as debut
    from ethereum.aave.ez_borrows where symbol in ('SNX','UNI','MKR')
    and aave_version = 'Aave V2'
    group by 1,2
    )
    SELECT
    trunc(debut,'{{granularity}}') as date,
    count(distinct borrower_address) as new_borrowers,
    sum(new_borrowers) over (order by date) as cum_new_borrowers
    from news where symbol = '{{token}}' and debut >= current_date - INTERVAL '{{period}}'
    group by 1 order by 1 asc




    Run a query to Download Data