Query editor
-- Query 4: USDC Bridge Volume by Protocol (CCTP vs Others)-- Section 2 (USDC vs USDT) — is CCTP gaining share for USDC transfers?---- Tracks monthly USDC bridge volume split by protocol, highlighting CCTP's growth.-- Charts:-- 1. Stacked area chart: monthly USDC volume by protocol (X: month, Y: total_volume_usd, Group by: bridge_protocol)-- 2. Line chart: CCTP as % of total USDC bridge volume over time (X: month, Y: cctp_pct)-- FIX: tokens.erc20 contains duplicate rows per token (same contract_address + blockchain-- with slightly different metadata). Joining bridges_evms.flows directly against tokens.erc20-- causes a fan-out join, multiplying each bridge row by the number of duplicates and inflating-- COUNT(*), SUM(amount_usd), AVG(), and APPROX_PERCENTILE(). Deduplicating into a CTE first-- ensures a 1:1 join so each bridge transaction is counted exactly once.WITH usdc_tokens AS (SELECT DISTINCT contract_address, blockchainFROM tokens.erc20WHERE symbol IN ('USDC', 'USDC.e', 'USDbC')),usdc_bridges AS (SELECTb.deposit_block_date,b.bridge_name,b.amount_usdFROM bridges_evms.flows bINNER JOIN usdc_tokens tON b.deposit_token_address = t.contract_addressAND b.deposit_chain = t.blockchainWHERE b.deposit_block_date >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '12' MONTH)AND b.amount_usd > 0AND b.bridge_name != 'Agglayer'),-- Group smaller protocols into "Other" to keep the chart cleanmonthly AS (SELECTDATE_TRUNC('month', deposit_block_date) AS month,CASEWHEN bridge_name IN ('Hyperliquid', 'CCTP', 'Lighter', 'Across', 'Polygon', 'Symbiosis', 'Celer', 'Arbitrum', 'Synapse')THEN bridge_nameELSE 'Other'END AS bridge_protocol,amount_usdFROM usdc_bridges)SELECTmonth,bridge_protocol,COUNT(*) AS tx_count,SUM(amount_usd) AS total_volume_usd,-- CCTP share calculation: usable for a separate line chartSUM(amount_usd) * 100.0 / SUM(SUM(amount_usd)) OVER (PARTITION BY month) AS pct_of_monthly_volumeFROM monthlyGROUP BY 1, 2ORDER BY 1, 4 DESC