Query editor
WITH pool_ids AS (select name,evt_tx_hash,evt_block_time,poolId as lbp_idFROM fjord_arbitrum.FjordLbpProxyV6_evt_PoolCreatedUNION ALLselect name,evt_tx_hash,evt_block_time,poolId as lbp_idFROM fjord_arbitrum.CopperProxyV1_evt_PoolCreatedUNION ALLselect name,evt_tx_hash,evt_block_time,poolId as lbp_idFROM fjord_arbitrum.CopperProxyV2_evt_PoolCreated),volumes AS (SELECTevt_tx_hash as hash,tokenOut as token_bought_address_,tokenIn as token_sold_address_,poolId as lbp_idFROM balancer_v2_arbitrum.Vault_evt_SwapWHERE poolId IN (SELECT lbp_id FROM pool_ids)),trades AS (SELECTt.token_bought_address,t.token_sold_address,t.tx_hash,t.amount_usdFROM dex.trades t)SELECTp.name,COALESCE(SUM(t.amount_usd), 0) as total_amount_usdFROM pool_ids pJOIN volumes v ON p.lbp_id = v.lbp_idJOIN trades t ONt.token_bought_address = v.token_bought_address_ ANDt.token_sold_address = v.token_sold_address_ ANDt.tx_hash = v.hashGROUP BY p.name;