DigitalDanGas Prices and Deposit/Borrow Amounts
    Updated 2021-11-12
    --As gas prices have continued to rise, how have average deposit and borrow amounts changed in response?

    with borrow as(
    select date_trunc('day', block_timestamp) as day, avg(borrowed_usd) as avg_borrowed_usd
    from aave.borrows
    --where day > '2021-11-01'
    group by day
    ),

    deposit as (
    select date_trunc('day', block_timestamp) as day, avg(supplied_usd) as avg_supplied_usd
    from aave.deposits
    --where day > '2021-11-01'
    group by day
    ),

    gas as (
    select date_trunc('day', block_timestamp) as day, avg(gas_price)/1e9 as av_gas
    from ethereum.transactions
    group by day
    )

    select b.day, b.avg_borrowed_usd, d.avg_supplied_usd, av_gas
    from borrow as b
    left join deposit as d on b.DAY = d.DAY
    left join gas as g on g.day = d.day
    Where b.day > current_date - 60
    order by b.day desc

    Run a query to Download Data