Query editor
WITH top_markets AS (SELECT condition_idFROM polymarket_polygon.market_tradesWHERE block_time >= TIMESTAMP '2024-01-01'GROUP BY condition_idORDER BY SUM(amount) DESCLIMIT 100),all_trades AS (SELECT maker AS trader_address, condition_id, question,token_outcome, price, amount, block_timeFROM polymarket_polygon.market_tradesWHERE condition_id IN (SELECT condition_id FROM top_markets)UNION ALLSELECT taker AS trader_address, condition_id, question,token_outcome, price, amount, block_timeFROM polymarket_polygon.market_tradesWHERE condition_id IN (SELECT condition_id FROM top_markets)),trader_market AS (SELECTtrader_address,condition_id,question,token_outcome,COUNT(*) AS n_trades,SUM(price * amount) / SUM(amount) AS vwap_price,SUM(amount) AS total_volume_usd,MIN(block_time) AS first_trade_time,MAX(block_time) AS last_trade_timeFROM all_tradesGROUP BY 1, 2, 3, 4HAVING SUM(amount) > 10),market_outcomes AS (SELECT DISTINCTfrom_hex(substr(condition_id, 3)) AS condition_id,token_outcome,outcome,resolved_on_timestampFROM polymarket_polygon.market_detailsWHERE closed = 'true')SELECTtm.trader_address,tm.condition_id,tm.question,tm.token_outcome,tm.n_trades,tm.vwap_price,tm.total_volume_usd,tm.first_trade_time,tm.last_trade_time,mo.outcome,