shenronpct borrowed over time
    Updated 2021-11-11
    WITH deposits AS (
    SELECT SUBSTR(block_timestamp,1,10) AS ds
    , supplier
    , SUM(supplied_base_asset_usd) AS deposits

    FROM compound.deposits

    GROUP BY 1,2

    HAVING SUM(supplied_base_asset_usd) > 0
    )

    , borrows AS (
    SELECT SUBSTR(block_timestamp,1,10) AS ds
    , borrower
    , SUM(loan_amount_usd) AS loans
    FROM compound.borrows

    GROUP BY 1,2
    )

    , cumsum AS (

    SELECT d.ds
    , supplier
    , SUM(deposits) OVER (partition by supplier order by d.ds rows between unbounded preceding and current row) AS deposits
    , SUM(loans) OVER (partition by supplier order by d.ds rows between unbounded preceding and current row) AS loans

    FROM deposits d FULL OUTER JOIN borrows b ON d.supplier = b.borrower AND d.ds = b.ds

    )

    , ratio as (SELECT ds
    , supplier
    Run a query to Download Data