SectorUSDC Interest Rates
    Updated 2022-05-26
    -- add: Case "Borrow, Interest Rate (%)" = then null end -to smooth graph

    with AAVE as (
    SELECT
    'AAVE' as Protocol,
    TRUNC(block_hour,'{{Time_Scale}}') AS Date,
    reserve_name,
    case when avg(borrow_rate_variable*100) = 0 then NULL
    else avg(borrow_rate_variable*100) end AS "Borrow, Interest Rate (%)"
    FROM aave.market_stats
    WHERE blockchain = 'ethereum'
    AND aave_version = 'Aave V2'
    AND reserve_name IN ('USDC')
    --AND reserve_name IN ('USDT')
    --AND reserve_name IN ('DAI')
    --AND reserve_name IN ('WBTC')
    AND date between '{{Start_Date}}' and '{{End_Date}}'
    GROUP BY 1,2, 3
    ORDER BY Date
    ),

    Compound as (
    SELECT
    'Compound' as Protocol,
    TRUNC(block_hour,'{{Time_Scale}}') AS Date,
    UNDERLYING_SYMBOL,
    case when avg(BORROW_APY*100) = 0 then NULL
    else avg(BORROW_APY*100) end AS "Comp_Borrow, Interest Rate (%)"
    FROM flipside_prod_db.compound.market_stats
    WHERE UNDERLYING_SYMBOL IN ('USDC')
    --AND UNDERLYING_SYMBOL IN ('USDT')
    --AND UNDERLYING_SYMBOL IN ('DAI')
    --AND UNDERLYING_SYMBOL IN ('WBTC')
    AND date between '{{Start_Date}}' and '{{End_Date}}'
    GROUP BY 1,2, 3
    ORDER BY Date
    Run a query to Download Data