Query editor
WITH verified_users AS (-- Using the provided query for verified users with wallet statusSELECTweek,verified_address,wallet_statusFROM query_4124441),dex_trades_extended AS (-- Extend the dex trades table with additional columns for analysisSELECTt.*,DATE_TRUNC('week', t.block_time) AS trade_week,CASEWHEN vu.verified_address IS NOT NULLAND vu.wallet_status NOT IN ('Not Yet Verified', 'Error - Unexpected State')THEN trueELSE falseEND AS is_verified_userFROM dex.trades tLEFT JOIN verified_users vuON t.tx_from = vu.verified_addressAND DATE_TRUNC('week', t.block_time) = vu.weekWHERE t.blockchain = 'base' -- Filter for Base chain),weekly_trade_metrics AS (-- Calculate weekly metrics for tradesSELECTtrade_week,is_verified_user,COUNT(DISTINCT tx_hash) AS num_trades,COUNT(DISTINCT tx_from) AS num_unique_traders,SUM(amount_usd) AS total_volume_usd,AVG(amount_usd) AS avg_trade_size_usd,COUNT(DISTINCT token_bought_symbol) + COUNT(DISTINCT token_sold_symbol) AS num_tokens_tradedFROM dex_trades_extendedGROUP BY 1, 2),weekly_totals AS (-- Calculate weekly totals for percentage calculationsSELECTtrade_week,SUM(num_trades) AS total_trades,SUM(num_unique_traders) AS total_unique_traders,SUM(total_volume_usd) AS total_volume_usdFROM weekly_trade_metricsGROUP BY 1)-- Final query to calculate weekly metrics and ratiosSELECTwtm.trade_week,wtm.is_verified_user,wtm.num_trades,wtm.num_unique_traders,wtm.total_volume_usd,wtm.avg_trade_size_usd,