tkvresearch2024-05-29 02:19 PM
    Updated 2024-08-26

    with

    L AS ( select * from (VALUES

    ( 'L2','OptimisticRollup','Arbitrum'),
    ( 'L2','OptimisticRollup','Optimism'),
    ( 'L2','OptimisticRollup','Base'),
    ( 'L2','OptimisticRollup','Manta'),
    ( 'L2','OptimisticRollup','Kroma'),
    ( 'L2','OptimisticRollup','Public Good'),
    ( 'L2','zkRollup','Scroll'),
    ( 'L2','zkRollup','zkSync Era'),
    ( 'L2','zkRollup','Linea'),
    ( 'L2','zkRollup','Polygon zkEVM'),
    ( 'L2','zkRollup','Starknet'),
    ( 'L2','Optimium','Mantle')

    ) as l1(tag, technology, chain) ),

    A as( select date,
    a.chain,
    --CASE when a.chain in ('Arbitrum','Optimism') then a.chain else 'New L2s' end as chain,
    tvl_usd as tvl
    from external.defillama.fact_chain_tvl as a
    JOIN L as c on a.chain = c.chain
    where tvl_usd is not null and tvl_usd > 0
    and date >= '2022-01-01')

    select date,
    chain,
    tvl,
    (tvl/lag(tvl,7) over (partition by chain order by date)-1)*100 as change_7d,
    (tvl/lag(tvl,30) over (partition by chain order by date)-1)*100 as change_30d
    from
    (select date,
    QueryRunArchived: QueryRun has been archived