Query editor
-- Query 1: Monthly Stablecoin Bridge Volume by Protocol-- Section 1 (Macro Picture) — frames the scale and growth of stablecoin bridging---- Approach:-- Join bridges_evms.flows with tokens.erc20 to identify stablecoin transfers,-- then aggregate monthly volume by bridge protocol.---- Stablecoins included: USDC, USDT, DAI, BUSD, TUSD, FRAX, LUSD, USDP, PYUSD, GHO, USDe, USDS, crvUSD-- (filtering by symbol after join, so we catch all chains automatically)---- Known data issues:-- - Agglayer excluded (inflated volume: $6.28T on 10K txs)-- - LayerZero has near-zero amount_usd (pricing issue) — included but will show as low---- Chart: Line chart with monthly volume total + breakdown by top protocols-- 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.deposit_block_date,b.bridge_name,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 >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '12' MONTH)AND b.amount_usd > 0AND b.bridge_name != 'Agglayer' -- exclude inflated data)SELECTDATE_TRUNC('month', deposit_block_date) AS month,bridge_name,COUNT(*) AS tx_count,SUM(amount_usd) AS total_volume_usd,COUNT(DISTINCT DATE_TRUNC('day', deposit_block_date)) AS active_daysFROM stablecoin_bridgesGROUP BY 1, 2-- HAVING SUM(amount_usd) > 100000000 -- uncomment to show only protocols with >$100M total volumeORDER BY 1 DESC, 4 DESC