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-05-05')),traces as (-- traces for all general txns. this includes both single hash and different hash within teh same blockSELECT block_time, block_number, block_hash,tx_index,tx_hash,"from", "to",burned_fees, tr.value as builder_paymentFROM ethereum.traces trLEFT JOIN blocks bl ON tr.block_number = bl.numberAND tr.to = bl.builderWHERE tr.block_time > DATE('2023-05-05')AND bl.time > DATE('2023-05-05')AND tx_success = trueAND value > CAST(0 as uint256)ORDER BY bl.time),swaps_2 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-05-05')GROUP BY logs.tx_hash,reserve0,reserve1,amount0Out,amount0In,amount1Out),swaps_with_builder_payments as (SELECT DISTINCT tr.block_time,tr.block_number,tr.block_hash,tr.tx_hash,tr.tx_index,project,version,token_pair,token_bought_reserve_raw / power(10, erc20a.decimals) AS token_bought_reserve_raw,token_sold_reserve_raw / power(10, erc20b.decimals) AS token_sold_reserve_raw,tr."to" as block_builder, -- swap to buildertr."from" as swap_from,dex.tx_from,dex.tx_to,tr.burned_fees,tr.builder_payment,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,amount_usd,count_swapsFROM traces trLEFT JOIN dex.trades dex on tr.tx_hash = dex.tx_hashLEFT JOIN swaps_2 sw on tr.tx_hash = sw.tx_hashLEFT JOIN tokens.erc20 erc20aON erc20a.contract_address = dex.token_bought_address