Query editor
-- TOP WALLETS BY TRADING VOLUME (LAST 30 DAYS) - WASH TRADING DETECTION-- This query identifies wallets with highest trading volumes to detect potential wash tradingWITH wallet_volumes AS (SELECTtrader_id,COUNT(*) AS total_trades,SUM(ABS(amount_usd)) AS total_volume_usd, -- Use absolute value for total volumeCOUNT(DISTINCT DATE(block_time)) AS active_days,AVG(ABS(amount_usd)) AS avg_trade_size_usd,MIN(ABS(amount_usd)) AS min_trade_usd,MAX(ABS(amount_usd)) AS max_trade_usd,STDDEV(ABS(amount_usd)) AS stddev_trade_size,-- For DEX swaps, we need to classify based on which token is being acquired-- Approach: Consider trades where user is buying the project token vs selling it-- This assumes pumpswap tokens are the "project tokens" being traded against SOL/USDC-- Method 1: Based on token symbols (if project tokens have specific patterns)-- We'll consider buying the less common token as a "buy" and selling it as a "sell"SUM(CASEWHEN token_bought_symbol NOT IN ('SOL', 'USDC', 'USDT', 'WSOL')AND token_sold_symbol IN ('SOL', 'USDC', 'USDT', 'WSOL')THEN amount_usd ELSE 0END) AS buy_volume_usd,SUM(CASEWHEN token_sold_symbol NOT IN ('SOL', 'USDC', 'USDT', 'WSOL')AND token_bought_symbol IN ('SOL', 'USDC', 'USDT', 'WSOL')THEN amount_usd ELSE 0END) AS sell_volume_usd,COUNT(CASEWHEN token_bought_symbol NOT IN ('SOL', 'USDC', 'USDT', 'WSOL')AND token_sold_symbol IN ('SOL', 'USDC', 'USDT', 'WSOL')THEN 1END) AS buy_trades,COUNT(CASEWHEN token_sold_symbol NOT IN ('SOL', 'USDC', 'USDT', 'WSOL')AND token_bought_symbol IN ('SOL', 'USDC', 'USDT', 'WSOL')THEN 1END) AS sell_trades,-- Alternative method: Split each trade as both buy and sell (since every swap has both)-- This gives us the total volume in each directionSUM(amount_usd) AS total_buy_volume, -- Total USD when acquiring tokensSUM(amount_usd) AS total_sell_volume, -- Total USD when disposing tokens (same as above for swaps)-- Count different trade patterns for analysisCOUNT(CASEWHEN token_bought_symbol NOT IN ('SOL', 'USDC', 'USDT', 'WSOL')THEN 1END) AS project_token_acquisitions,COUNT(CASEWHEN token_sold_symbol NOT IN ('SOL', 'USDC', 'USDT', 'WSOL')THEN 1END) AS project_token_disposals,