hessDaily TVL copy
    Updated 2024-11-04
    with tvl as (select date,
    chain_tvl as tvl_usd
    from external.defillama.fact_protocol_tvl
    where chain in ('Sei','Sei-borrowed')
    )
    ,
    tvl_i as ( select date,
    tvl_usd as tvl
    from external.defillama.fact_chain_tvl
    where date < '2024-05-30'
    and chain = 'Sei'
    UNION
    select date,
    sum(tvl_usd) as tvl
    from tvl
    group by 1
    )
    ,
    price as ( select hour::date as day,
    avg(price) as avg_price
    from crosschain.price.ez_prices_hourly
    where token_address in ('ibc/71F11BC0AF8E526B80E44172EBA9D3F0A8E03950BB882325435691EBC9450B1D')
    group by 1)

    select date,
    case when date >= '2024-05-27' then 'TVL USD (Sei V2 Launch)' else 'TVL USD' end as type,
    tvl as "TVL (USD)",
    tvl/avg_price as "TVL (Sei)"
    from tvl_i a join price b on a.date = b.day
    where date = current_date
    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived