emirprince95aave total b&d
    Updated 2021-11-11
    with eth_gas_prices as (
    SELECT date_trunc('day', block_timestamp) AS day, avg(fee_usd) AS feepaid_usd
    FROM ethereum.transactions
    where success = 'TRUE'
    group by 1)

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

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

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

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


    Run a query to Download Data