MLDZMNsushi7
    Updated 2022-10-04
    with pools as (
    select * from (
    select
    pool_name,
    pool_address
    from flipside_prod_db.ethereum_core.dim_dex_liquidity_pools
    where platform = 'sushiswap'
    )
    ),
    pool_bals as (
    select
    BLOCK_TIMESTAMP::date as day,
    case
    when BLOCK_TIMESTAMP<'2022-09-15' and BLOCK_TIMESTAMP>='2022-09-01' then 'Two weeks before merge'
    when BLOCK_TIMESTAMP>='2022-09-15'and BLOCK_TIMESTAMP<'2022-09-29' then 'Two weeks after merge'
    else null end as time_frame,
    sum(CURRENT_BAL_USD) as tvl,
    --lag(tvl) ignore nulls over(ORDER BY day ASC) as lag_TVL,
    sum(PREV_BAL_USD) as TVL_prev,
    tvl-TVL_prev as tvl_change
    from ethereum.core.ez_balance_deltas
    where user_address in (select pool_address from pools)
    and CURRENT_BAL_USD is not null
    and PREV_BAL_USD is not null
    and CURRENT_BAL_USD < 100000000
    group by 1,2 having time_frame is not null
    )

    select * from pool_bals
    order by 1
    Run a query to Download Data