Query editor
WITH deduped_flows AS (SELECT *,ROW_NUMBER() OVER (PARTITION BY deposit_tx_hash, withdrawal_tx_hashORDER BY amount_usd DESC) AS rnFROM bridges_crosschain.flowsWHERE ((withdrawal_chain = 'base' AND withdrawal_block_time >= NOW() - INTERVAL '{{days}}' DAY)OR(deposit_chain = 'base' AND deposit_block_time >= NOW() - INTERVAL '{{days}}' DAY))),transactions AS (SELECTCASEWHEN withdrawal_chain = 'base' THEN withdrawal_block_timeELSE deposit_block_timeENDAS "date",CASEWHEN withdrawal_chain = 'base' THEN 'inflow'ELSE 'outflow'END AS flow_direction,CASEWHEN withdrawal_chain = 'base' THEN deposit_chainELSE withdrawal_chainEND AS counterparty_chain,bridge_name,amount_usd AS amount_bridged,sender,recipient,CASEWHEN withdrawal_chain = 'base' THEN withdrawal_token_addressELSE deposit_token_addressEND AS token_address,CASEWHEN withdrawal_chain = 'base' THEN withdrawal_tx_hashELSE deposit_tx_hashEND AS txn_hashFROM deduped_flowsWHERE rn = 1),wallets_with_tokens AS (SELECTtx."date",tx.token_address,CASEWHEN lower(tx.token_address) = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'THEN 'ETH (Native)'WHEN lower(tx.token_address) = '0x0000000000000000000000000000000000000000'THEN 'ETH (Protocol / Accounting)'ELSE COALESCE(t.symbol,CONCAT('0x', SUBSTRING(CAST(tx.token_address AS VARCHAR), 1, 6)))END AS token_symbol,tx.flow_direction,