Query editor
WITH Block AS (SELECT DISTINCT traderFROM (SELECT "from" AS trader FROM dune.brightspear.result_eth_token_flowsUNIONSELECT "to" AS trader FROM dune.brightspear.result_eth_token_flowsUnionSELECT buyer AS trader FROM dune.brightspear.result_nft_optimisedUNIONSELECT seller AS trader FROM dune.brightspear.result_nft_optimisedUNIONSELECT "from" AS trader FROM dune.brightspear.result_ethereum_eco_flowsUNIONSELECT "to" AS trader FROM dune.brightspear.result_ethereum_eco_flows) AS distinct_traders),inflow AS (SELECTday,"to" AS trader,contract_address AS token_address,SUM(amount_usd) as inflow,SUM(amount) as inflow_rawFROM dune.brightspear.result_eth_token_flowsINNER JOIN Block as B on "to" = B.traderGROUP BY 2,3,1),outflow AS (SELECTday,"from" AS trader,contract_address AS token_address,SUM(amount_usd) as outflow,SUM(amount) as outflow_rawFROM dune.brightspear.result_eth_token_flowsINNER JOIN Block as B on "from" = B.traderGROUP BY 2,3,1),T1 AS (SELECTCOALESCE(A.trader, B.trader) AS trader,COALESCE(A.token_address, B.token_address) AS token_address,COALESCE(A.day, B.day) AS day,COALESCE(A.inflow, 0) AS inflow,COALESCE(B.outflow, 0) AS outflow,COALESCE(A.inflow_raw, 0) AS inflow_raw,COALESCE(B.outflow_raw, 0) AS outflow_rawFROM inflow AS AFULL JOIN outflow AS BON A.token_address = B.token_address AND A.trader = B.trader AND A.day = B.day),hourly_balance AS (SELECTtrader,A.token_address AS token_address,