Query editor
-- Query 5: USDT Bridge Volume by Protocol-- Section 2 (USDC vs USDT) — how does USDT bridging differ from USDC?---- Mirrors Query 4 but for USDT. Key question: is Tether (USDT0/LayerZero)-- gaining share the way CCTP is for USDC?---- Charts:-- 1. Stacked area chart: monthly USDT volume by protocol-- 2. Line chart: protocol share % over time (compare with USDC chart)-- 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 usdt_tokens AS (SELECT DISTINCT contract_address, blockchainFROM tokens.erc20WHERE symbol IN ('USDT', 'USDT0')),usdt_bridges AS (SELECTb.deposit_block_date,b.bridge_name,b.amount_usdFROM bridges_evms.flows bINNER JOIN usdt_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 AS (SELECTDATE_TRUNC('month', deposit_block_date) AS month,CASEWHEN bridge_name IN ('Sui', 'Tether', 'Polygon', 'Across', 'Celer', 'Symbiosis', 'Orbiter', 'Avalanche')THEN bridge_nameELSE 'Other'END AS bridge_protocol,amount_usdFROM usdt_bridges)SELECTmonth,bridge_protocol,COUNT(*) AS tx_count,SUM(amount_usd) AS total_volume_usd,SUM(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