Query editor
WITH blocks AS(SELECT time, number, hash, miner as builder, (gas_used * base_fee_per_gas)/1e18 as burned_feesFROM ethereum.blocksWHERE time > DATE('2023-06-05')),traces as (SELECT block_time, block_number, block_hash,tx_index,tx_hash,"from", "to",burned_feesFROM ethereum.traces trLEFT JOIN blocks bl ON tr.block_number = bl.numberAND tr.to = bl.builderAND tr.trace_address = array[2]WHERE 0 = 0AND tr.block_time > DATE('2023-06-05')AND bl.time > DATE('2023-06-05')AND tx_success = trueORDER BY bl.time),swaps as (SELECT logs.tx_hash,CASE WHEN cast(amount0Out as double) = 0 THEN reserve1 ELSE reserve0 END AS token_bought_reserve_raw,CASE WHEN cast(amount0In as double) = 0 OR cast(amount1Out as double)= 0 THEN reserve1 ELSE reserve0 END AS token_sold_reserve_raw,COUNT(*) as count_swapsFROM traces trLEFT JOIN ethereum.logs logs ON tr.tx_hash = logs.tx_hashLEFT JOIN uniswap_v2_ethereum.Pair_evt_Sync pes ON pes.evt_tx_hash = tr.tx_hashLEFT JOIN uniswap_v2_ethereum.Pair_evt_Swap peswap ON peswap.evt_tx_hash = tr.tx_hashWHERE topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efAND logs.block_time > DATE('2023-06-05')GROUP BY logs.tx_hash,reserve0,reserve1,amount0Out,amount0In,amount1Out)SELECT tr.block_time,tr.block_number,tr.block_hash,tr.tx_hash,project,version,token_pair,token_bought_reserve_raw / power(10, erc20a.decimals) AS token_bought_reserve,token_sold_reserve_raw / power(10, erc20b.decimals) AS token_sold_reserve,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,amount_usd,tr."to" as swap_to_builder,dex.tx_from,dex.tx_to,tr."from" as swap_from,tr.burned_fees,tr.tx_index,count_swapsFROM traces trLEFT JOIN dex.trades dex on tr.tx_hash = dex.tx_hashLEFT JOIN swaps sw on tr.tx_hash = sw.tx_hashLEFT JOIN tokens.erc20 erc20aON erc20a.contract_address = dex.token_bought_addressAND erc20a.blockchain = 'ethereum'LEFT JOIN tokens.erc20 erc20b