Ali3NAverage Daily Blockchains DEX Activity Before and After FTX Collapse
    Updated 2022-12-04
    with maintable as (
    select 'Arbitrum' as chain,
    date_trunc (day,block_timestamp) as date,
    case when date < '2022-11-08' then 'Before Collapse'
    when date >= '2022-11-08' and date <= '2022-11-10' then 'Main Collapse Days'
    when date > '2022-11-10' then 'After Collapse' end as timespan,
    count (distinct tx_hash) as TX_Count,
    count (distinct origin_from_address) as Unique_Users,
    count (origin_from_address) as Non_Unique_Users
    from arbitrum.core.fact_event_logs
    where origin_to_address in (select distinct address from arbitrum.core.dim_labels where label_type ilike 'dex')
    and block_timestamp >= '2022-10-25' and block_timestamp::date != CURRENT_DATE
    and tx_status = 'SUCCESS'
    group by 1,2,3

    union ALL

    select 'Optimism' as chain,
    date_trunc (day,block_timestamp) as date,
    case when date < '2022-11-08' then 'Before Collapse'
    when date >= '2022-11-08' and date <= '2022-11-10' then 'Main Collapse Days'
    when date > '2022-11-10' then 'After Collapse' end as timespan,
    count (distinct tx_hash) as TX_Count,
    count (distinct origin_from_address) as Unique_Users,
    count (origin_from_address) as Non_Unique_Users
    from optimism.core.fact_event_logs
    where origin_to_address in (select distinct address from optimism.core.dim_labels where label_type ilike 'dex')
    and block_timestamp >= '2022-10-25' and block_timestamp::date != CURRENT_DATE
    and tx_status = 'SUCCESS'
    group by 1,2,3

    union ALL

    select 'Ethereum' as chain,
    date_trunc (day,block_timestamp) as date,
    case when date < '2022-11-08' then 'Before Collapse'
    Run a query to Download Data