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.tx_hash) AS "Transactions"
FROM defi d
JOIN txs t ON d.address = t.contract_address
GROUP BY 1
ORDER BY 2 DESC