dariustay_0512DeFi protocols by unique active users
    Updated 2023-04-13
    WITH defi AS (
    SELECT *
    FROM avalanche.core.dim_labels
    WHERE label_type = 'defi'
    ),

    txs AS (
    SELECT *
    FROM avalanche.core.fact_event_logs
    WHERE tx_status = 'SUCCESS'
    )

    SELECT
    d.project_name AS "Project",
    COUNT(DISTINCT t.origin_from_address) AS "Users"
    FROM defi d
    JOIN txs t ON d.address = t.contract_address
    GROUP BY 1
    ORDER BY 2 DESC
    Run a query to Download Data