Query editor
WITH-- Define 2-day windowtime_window AS (SELECT date_trunc('day', now()) - interval '4' day AS two_days_ago),-- Identify tokens that first appeared in dex.trades in last 2 daysnew_tokens AS (SELECTtoken_address,token_symbol,launch_dateFROM (SELECTtoken_bought_address AS token_address,token_bought_symbol AS token_symbol,MIN(block_time) AS launch_dateFROM dex.tradesWHERE blockchain = 'ethereum'GROUP BY 1, 2HAVING MIN(block_time) >= (SELECT two_days_ago FROM time_window)UNION ALLSELECTtoken_sold_address AS token_address,token_sold_symbol AS token_symbol,MIN(block_time) AS launch_dateFROM dex.tradesWHERE blockchain = 'ethereum'GROUP BY 1, 2HAVING MIN(block_time) >= (SELECT two_days_ago FROM time_window)) combined_tokensGROUP BY 1, 2, 3 -- Remove duplicates from UNION)SELECTn.token_address,s.name,CASEWHEN n.token_address IS NOT NULL THEN n.token_symbolELSE 'Other Token'END AS new_token_symbol,count(*) as num,sum(t.usd_value) as volume,sum(capped_payment) / 1e18 *4100 as capped_payment,sum(slippage_usd) as slippage_usdFROM cow_protocol_ethereum.trades tJOIN cow_protocol_ethereum.batches b ON t.tx_hash = b.tx_hashJOIN cow_protocol_ethereum.solvers s ON b.solver_address = s.addressJOIN new_tokens n ON t.sell_token_address = n.token_address OR t.buy_token_address = n.token_addressjoin "query_4351957" cap on t.tx_hash = cap.tx_hashjoin "query_5663909" slip on t.tx_hash = slip.tx_hashWHERE t.block_time >= (SELECT two_days_ago FROM time_window)Group by 1,2,3