Query editor
-- Query 8: Chain Pair Coverage by Bridge Protocol-- Section 3 (What Drives Choice) — is bridge choice constrained by route availability?---- Approach:-- Count the unique chain pairs (source → destination) each bridge supports-- for stablecoin transfers. Bridges with narrow coverage force users onto them-- for specific routes; broad-coverage bridges compete on cost/speed instead.---- Output: matrix of bridge × chain pair, plus summary stats per bridge.-- Two result sets in one query — use the summary for a bar chart,-- and the detail CTE (uncomment) for a heatmap if needed.---- Known data issues:-- - Agglayer excluded (inflated volume)-- - LayerZero has near-zero amount_usd (pricing issue)---- Chart: Bar chart (unique chain pairs per bridge), optional heatmap of bridge × route-- 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 stablecoin_tokens AS (SELECT DISTINCT contract_address, blockchainFROM tokens.erc20WHERE symbol IN ('USDC', 'USDC.e', 'USDbC', 'USDT', 'USDT0','DAI', 'BUSD', 'TUSD', 'FRAX', 'LUSD','USDP', 'PYUSD', 'GHO', 'USDe', 'USDS', 'crvUSD')),stablecoin_bridges AS (SELECTb.bridge_name,b.deposit_chain,b.withdrawal_chain,b.amount_usdFROM bridges_evms.flows bINNER JOIN stablecoin_tokens tON b.deposit_token_address = t.contract_addressAND b.deposit_chain = t.blockchainWHERE b.deposit_block_date >= CURRENT_DATE - INTERVAL '12' MONTHAND b.amount_usd > 0AND b.bridge_name != 'Agglayer'),-- Top 10 bridges by volume (keeps output manageable)top_bridges AS (SELECT bridge_nameFROM stablecoin_bridgesGROUP BY bridge_nameORDER BY SUM(amount_usd) DESCLIMIT 10)SELECTsb.bridge_name,COUNT(DISTINCT (sb.deposit_chain, sb.withdrawal_chain)) AS unique_chain_pairs,