Query editor
WITH movements AS (SELECT block_time, withdrawal_chain AS chain_key, deposit_chain AS counterparty_chain,bridge_name, 'inflow' AS direction, deposit_amount_usd AS volume_usd, tx_from AS walletFROM bridges_evms.depositsWHERE withdrawal_chain IN ('avalanche_c','base','arbitrum')AND block_date >= CURRENT_DATE - INTERVAL '60' DAYUNION ALLSELECT block_time, deposit_chain, withdrawal_chain, bridge_name, 'outflow', deposit_amount_usd, tx_fromFROM bridges_evms.depositsWHERE deposit_chain IN ('avalanche_c','base','arbitrum')AND block_date >= CURRENT_DATE - INTERVAL '60' DAY), grouped AS (SELECT CASE chain_key WHEN 'avalanche_c' THEN 'Avalanche' WHEN 'base' THEN 'Base' ELSE 'Arbitrum' END AS chain,counterparty_chain, bridge_name, direction, SUM(volume_usd) AS volume_usd,COUNT(*) AS transfers, COUNT(DISTINCT wallet) AS walletsFROM movements GROUP BY 1,2,3,4)SELECT chain, counterparty_chain, bridge_name, direction,CONCAT(chain, ' · ', direction, ' · ', counterparty_chain) AS chain_route_direction,volume_usd, transfers, wallets,CASE WHEN chain='Avalanche' AND direction='inflow' THEN volume_usd END AS avalanche_inflow_usd,CASE WHEN chain='Avalanche' AND direction='outflow' THEN volume_usd END AS avalanche_outflow_usd,CASE WHEN chain='Base' AND direction='inflow' THEN volume_usd END AS base_inflow_usd,CASE WHEN chain='Base' AND direction='outflow' THEN volume_usd END AS base_outflow_usd,CASE WHEN chain='Arbitrum' AND direction='inflow' THEN volume_usd END AS arbitrum_inflow_usd,CASE WHEN chain='Arbitrum' AND direction='outflow' THEN volume_usd END AS arbitrum_outflow_usdFROM grouped ORDER BY volume_usd DESC