Query editor
-- ============================================================-- EPL Polymarket Match Prices - Minute by Minute-- All known EPL match markets from on-chain data-- Output: market_slug, question, timestamp, YES_price, NO_price, volume-- ============================================================WITH epl_matches AS (SELECT condition_id, question, market_slugFROM dune.dylorr.dataset_polymarket_sports_sept_16WHERE (LOWER(tags) LIKE '%epl%' OR LOWER(tags) LIKE '%premier league%')AND LOWER(sport) = 'soccer'AND (LOWER(question) LIKE '%vs%' OR LOWER(question) LIKE '%win vs%' OR LOWER(question) LIKE '%win against%')AND LOWER(question) NOT LIKE '%arch %' AND LOWER(question) NOT LIKE '%champions league%'AND LOWER(question) NOT LIKE '%fa cup%' AND LOWER(question) NOT LIKE '%olympic%'AND LOWER(question) NOT LIKE '%germany%' AND LOWER(question) NOT LIKE '%scotland%'AND LOWER(question) NOT LIKE '%real madrid%' AND LOWER(question) NOT LIKE '%barcelona%'AND LOWER(question) NOT LIKE '%psg%' AND LOWER(question) NOT LIKE '%atletico%'AND LOWER(question) NOT LIKE '%dortmund%' AND LOWER(question) NOT LIKE '%bayern%'AND LOWER(question) NOT LIKE '%spain%' AND LOWER(question) NOT LIKE '%france%'AND LOWER(question) NOT LIKE '%usa%'),token_raw AS (SELECT t.conditionId, t.token0 as no_token, t.token1 as yes_token,m.question, m.market_slug,ROW_NUMBER() OVER (PARTITION BY t.conditionId ORDER BY t.evt_block_time) as rnFROM polymarket_polygon.negriskctfexchange_evt_tokenregistered tINNER JOIN epl_matches m ON t.conditionId = CAST(m.condition_id AS varbinary)),tokens AS (SELECT * FROM token_raw WHERE rn = 1),-- Get YES pricesyes_agg AS (SELECT t.market_slug, t.question,date_trunc('minute', o.evt_block_time) as minute_ts,SUM(CAST(o.makerAmountFilled AS DOUBLE) / NULLIF(CAST(o.takerAmountFilled AS DOUBLE), 0)* CAST(o.makerAmountFilled AS DOUBLE) / 1e6)/ NULLIF(SUM(CAST(o.makerAmountFilled AS DOUBLE) / 1e6), 0) as yes_price,SUM(CAST(o.makerAmountFilled AS DOUBLE) / 1e6) as yes_volumeFROM polymarket_polygon.negriskctfexchange_evt_orderfilled oINNER JOIN tokens t ON o.takerAssetId = t.yes_tokenWHERE o.evt_block_date >= DATE '2024-08-01' AND o.evt_block_date <= DATE '2025-06-01'AND o.makerAssetId = CAST(0 AS uint256)AND CAST(o.makerAmountFilled AS DOUBLE) / NULLIF(CAST(o.takerAmountFilled AS DOUBLE), 0) > 0AND CAST(o.makerAmountFilled AS DOUBLE) / NULLIF(CAST(o.takerAmountFilled AS DOUBLE), 0) < 1GROUP BY 1,2,3),-- Get NO pricesno_agg AS (SELECT t.market_slug,date_trunc('minute', o.evt_block_time) as minute_ts,SUM(CAST(o.makerAmountFilled AS DOUBLE) / NULLIF(CAST(o.takerAmountFilled AS DOUBLE), 0)* CAST(o.makerAmountFilled AS DOUBLE) / 1e6)/ NULLIF(SUM(CAST(o.makerAmountFilled AS DOUBLE) / 1e6), 0) as no_price,SUM(CAST(o.makerAmountFilled AS DOUBLE) / 1e6) as no_volumeFROM polymarket_polygon.negriskctfexchange_evt_orderfilled oINNER JOIN tokens t ON o.takerAssetId = t.no_tokenWHERE o.evt_block_date >= DATE '2024-08-01' AND o.evt_block_date <= DATE '2025-06-01'AND o.makerAssetId = CAST(0 AS uint256)AND CAST(o.makerAmountFilled AS DOUBLE) / NULLIF(CAST(o.takerAmountFilled AS DOUBLE), 0) > 0AND CAST(o.makerAmountFilled AS DOUBLE) / NULLIF(CAST(o.takerAmountFilled AS DOUBLE), 0) < 1GROUP BY 1,2)