SocioCryptoStats per Protocols - DEX
    Updated 2023-10-12
    -- forked from Stats per Protocols @ https://flipsidecrypto.xyz/edit/queries/a6e8ed1c-9600-4db7-98bc-d329ed454a66

    SELECT
    date_trunc('week', block_timestamp) as date,
    b.project_name as project,
    count(DISTINCT tx_hash) as n_txns,
    count(DISTINCT from_address) as users,
    sum(tx_fee) as t_tx_fee
    FROM avalanche.core.fact_transactions a
    LEFT JOIN avalanche.core.dim_labels b
    ON a.to_address = b.address
    WHERE b.label_type = 'dex'
    AND date > dateadd('month', -{{last_n_month}}, current_date)
    AND date < current_date
    GROUP BY 1 , 2
    ORDER BY 1 DESC


    Run a query to Download Data