Updated 2021-11-11

    select
    distinct date_trunc('day', block_hour) as date,
    contract_name,
    avg(borrows_usd) OVER (PARTITION BY date, ctoken_address ORDER BY block_hour RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as borrows,
    avg(supply_usd) OVER (PARTITION BY date, ctoken_address ORDER BY block_hour RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as supply,
    avg(supply_usd - borrows_usd) OVER (PARTITION BY date, ctoken_address ORDER BY block_hour RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as tvl,
    avg(reserves_usd) OVER (PARTITION BY date, ctoken_address ORDER BY block_hour RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as reserves
    from compound.market_stats
    Run a query to Download Data