hessDaily TVL [USD] (Exclude Borrowing)
    Updated 2024-07-02
    -- forked from Daily TVL [USD] (Including Borrow and Liquid Staking) @ https://flipsidecrypto.xyz/edit/queries/dbf36032-cb5f-441b-ac4d-c4ebc3cd3e2b

    with tvl as (select date,
    chain_tvl as tvl_usd
    from external.defillama.fact_protocol_tvl
    where chain in ('Sei')
    )
    ,
    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,
    tvl as "TVL (USD)",
    tvl/avg_price as "TVL (Sei)"
    from tvl_i a join price b on a.date = b.day
    where a.date >= '{{Start}}' and a.date <= '{{End}}'


    QueryRunArchived: QueryRun has been archived