181_willtop_tvl_increase
    Updated 2023-04-13
    with
    now as (
    SELECT
    CHAIN,
    TVL_USD as tvl1
    from
    external.defillama.fact_chain_tvl
    where
    DATE = CURRENT_DATE - interval '1 day'
    ),
    one_week as (
    SELECT
    CHAIN,
    TVL_USD as tvl2
    from
    external.defillama.fact_chain_tvl
    where
    DATE = CURRENT_DATE - interval '8 day'
    ),
    three_weeks as (
    SELECT
    CHAIN,
    TVL_USD as tvl3
    from
    external.defillama.fact_chain_tvl
    where
    DATE = CURRENT_DATE - interval '22 day'
    )
    SELECT
    c.CHAIN,
    tvl1,
    (tvl1 - w1.tvl2) / tvl2 * 100 as one_week_change_perc,
    (tvl1 - w3.tvl3) / tvl3 * 100 as three_week_change_perc,
    tvl2 as tvl_1_week_ago,
    tvl3 as tvl_3_weeks_ago
    FROM
    Run a query to Download Data