Query editor
-- Query 6: CCTP vs Tether — Native Stablecoin Bridge Growth-- Section 2 (USDC vs USDT) — comparing the two stablecoin-native bridge paradigms---- Instead of repeating CCTP growth (already in Query 4), this query directly-- compares CCTP (USDC native) vs Tether (USDT native/USDT0) side by side.-- Shows whether both stablecoins are converging on native infrastructure.---- Charts:-- 1. Line chart: monthly volume for CCTP vs Tether (X: month, Y: total_volume_usd, Group by: protocol)-- 2. Line chart: native share — each protocol's % of its respective stablecoin's total bridge volume-- 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.-- NOTE: This query also selects `symbol` in the DISTINCT to preserve USDC/USDT classification downstream.WITH stablecoin_tokens AS (SELECT DISTINCT contract_address, blockchain, symbolFROM tokens.erc20WHERE symbol IN ('USDC', 'USDC.e', 'USDbC', 'USDT', 'USDT0')),bridge_flows AS (SELECTb.deposit_block_date,b.bridge_name,b.amount_usd,t.symbolFROM bridges_evms.flows bINNER JOIN stablecoin_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'),monthly_totals AS (SELECTDATE_TRUNC('month', deposit_block_date) AS month,CASEWHEN symbol IN ('USDC', 'USDC.e', 'USDbC') THEN 'USDC'ELSE 'USDT'END AS stablecoin,SUM(amount_usd) AS total_stablecoin_volumeFROM bridge_flowsGROUP BY 1, 2),native_bridges AS (SELECTDATE_TRUNC('month', deposit_block_date) AS month,CASEWHEN bridge_name = 'CCTP' THEN 'CCTP (USDC native)'WHEN bridge_name = 'Tether' THEN 'Tether (USDT native)'END AS protocol,CASEWHEN bridge_name = 'CCTP' THEN 'USDC'WHEN bridge_name = 'Tether' THEN 'USDT'