Query editor
WITH metamask_swap_data AS(SELECT*FROM(SELECTblockchain,block_date,block_time,tx_hash,tx_from AS swap_address,tx_to AS swap_router,amount_usd,ROW_NUMBER()OVER(PARTITION BY tx_hash ORDER BY amount_usd DESC) AS rkFROM dex.tradesWHERE tx_to IN (SELECT DISTINCT swap_router FROM dune.wenjuan.dataset_wallet_swap_router WHERE wallet = 'MetaMask'))tabWHERE rk = 1ORDER BY block_time)SELECTdate_trunc('week',block_date) AS block_date,blockchain,COUNT(tx_hash) AS swap_trade,sum(amount_usd) AS swap_volume,COUNT(DISTINCT swap_address) AS swap_user,sum(amount_usd)*0.00875 AS swap_revenueFROM metamask_swap_dataGROUP BYdate_trunc('week',block_date),blockchain