MostlyData_Daily DEX Volume
    Updated 2025-01-20
    with dex_tvl as(
    select
    date as dt,
    chain,
    --category,
    --protocol,
    sum(chain_tvl) as daily_tvl

    from external.defillama.fact_protocol_tvl

    where
    (
    chain = 'Solana'
    or chain = 'Ethereum'
    or chain = 'Avalanche'
    or chain = 'Arbitrum'
    or chain = 'Optimism'
    or chain = 'Near'
    or chain = 'Aptos'
    )
    and date >= current_date() - interval '30 days'
    and date < current_date()
    and category = 'Dexes'

    group by 1,2

    )

    ,dex_volume as(
    select
    date as dt,
    case
    when chain = 'solana' then 'Solana'
    when chain = 'ethereum' then 'Ethereum'
    when chain = 'avalanche' then 'Avalanche'
    when chain = 'arbitrum' then 'Arbitrum'
    QueryRunArchived: QueryRun has been archived