cyphereth borrowed from aave
    Updated 2022-09-17
    with eth_borrowed as (select
    date_trunc('day', block_timestamp) as day,
    sum(borrowed_tokens) as eth_borrowed
    from ethereum.aave.ez_borrows
    where contains(symbol, 'ETH')
    and day >= current_date() - 30
    group by DAY),

    eth_repayed as (select
    date_trunc('day', block_timestamp) as day,
    sum(repayed_tokens) as eth_repayed
    from ethereum.aave.ez_repayments
    where contains(symbol, 'ETH')
    and day >= current_date() - 30
    group by DAY)

    SELECT
    b.day,
    b.eth_borrowed,
    r.eth_repayed,
    b.eth_borrowed - r.eth_repayed as net_borrowed
    from eth_borrowed b, eth_repayed r
    where b.day = r.day
    Run a query to Download Data