Jor-elVertex TVL by Tokens copy
    Updated 2024-04-13
    -- forked from Ario / Vertex TVL by Tokens @ https://flipsidecrypto.xyz/Ario/q/toU312Ggb7-W/vertex-tvl-by-tokens

    with priceT as (
    select
    TOKEN_ADDRESS,
    avg(PRICE) as Price
    from arbitrum.price.ez_hourly_token_prices
    where HOUR >= current_timestamp - interval '24 hours'
    and token_address in (select
    DISTINCT TOKEN_ADDRESS
    from arbitrum.vertex.ez_clearing_house_events
    )
    group by 1
    )
    select
    sum(AMOUNT * price) as Net_Deposit
    from arbitrum.vertex.ez_clearing_house_events
    join priceT using (TOKEN_ADDRESS)


    QueryRunArchived: QueryRun has been archived