Query editor
WITH daily_router_gas AS (SELECTt.block_date AS day,SUM(CAST(t.gas_used AS DOUBLE) * CAST(t.effective_gas_price AS DOUBLE)) / 1e18 AS total_candidate_router_gas_ethFROM robinhood.transactions tJOIN dune.tusa3112.result_rh_cluster_map c ON c.wallet = t."from"WHERE t.block_date >= DATE '2026-07-01'AND t."to" = 0x44B2484a01683778B9dcB2b7241cF8C8657548C0AND (varbinary_starts_with(t.data,0xcce7ec13)OR varbinary_starts_with(t.data,0x6a272462))GROUP BY 1),allocated_daily AS (SELECTrealized_day AS day,SUM(router_gas_eth) AS closed_trade_allocated_router_gas_ethFROM dune.tusa3112.result_rh_closed_trade_ledgerGROUP BY 1),prices AS (SELECTday,MAX(net_realized_pnl_usd/ NULLIF(net_realized_pnl_eth,0e0)) AS eth_usdFROM dune.tusa3112.result_rh_cluster_dailyGROUP BY 1),cohorts AS (SELECTrealized_day AS day,entry_rank_bucket,hold_bucket,COUNT(*) AS closed_trades,COUNT(DISTINCT wallet) AS wallets,COUNT_IF(net_after_router_gas_eth > 0e0) AS net_winning_trades,100.0 * COUNT_IF(net_after_router_gas_eth > 0e0) / COUNT(*) AS net_win_pct,SUM(buy_cost_eth) AS buy_cost_eth,SUM(gross_pnl_eth) AS gross_pnl_eth,SUM(router_gas_eth) AS allocated_router_gas_eth,SUM(net_after_router_gas_eth) AS net_after_allocated_router_gas_eth,SUM(CASEWHEN net_after_router_gas_eth > 0e0 THEN net_after_router_gas_eth ELSE 0e0 END) / NULLIF(-SUM(CASEWHEN net_after_router_gas_eth < 0e0 THEN net_after_router_gas_eth ELSE 0e0 END),0e0) AS net_profit_factor,APPROX_PERCENTILE(net_after_router_gas_eth,0.5) AS median_net_trade_eth,APPROX_PERCENTILE(buy_attempts,0.5) AS median_buy_attempts,SUM(failed_buy_attempts) AS failed_buy_attemptsFROM dune.tusa3112.result_rh_closed_trade_ledgerGROUP BY 1,2,3)SELECTc.*,g.total_candidate_router_gas_eth,a.closed_trade_allocated_router_gas_eth,