emirprince95avg AAVE b&d
    Updated 2021-11-10
    with eth_gas_prices as (
    SELECT date_trunc('day', block_timestamp) AS day, AVG(gas_price/1e9) AS gas_price_gwei
    FROM ethereum.transactions
    where success = 'TRUE'
    group by 1)

    , borrows as (
    select date_trunc('day', block_timestamp) AS day, avg(BORROWED_USD) as average_borrows_in_usd
    from aave.borrows
    where blockchain = 'ethereum'
    group by 1
    )

    , deposits as (
    select date_trunc('day', block_timestamp) AS day, avg(supplied_usd) as average_deposits_in_usd
    from aave.deposits
    where blockchain = 'ethereum'
    group by 1
    )

    , gb as (select b.*, g.gas_price_gwei from eth_gas_prices g join borrows b on b.day = g.day)

    select gb.*, deposits.average_deposits_in_usd from deposits join gb on gb.day = deposits.day


    Run a query to Download Data