Query editor
-- Polymarket Daily & Cumulative Fee Revenue (CLOB V1 + V2)---- V2 cutover: April 28, 2026 (~11:00 UTC). V1 contracts went silent that day —-- the last V1 events are on Apr 28. Empirically verified there's no V1 activity-- after Apr 28, but we still apply explicit date guards below in case anything-- trickles in (admin txns, late settlements).---- V1 (polymarket_polygon.*): used through Apr 28, 2026. Collateral = USDC.e.-- V2 (polymarket_v2_polygon.*): used from Apr 28, 2026 onward. Collateral = pUSD.-- pUSD is a 1:1 USDC-backed ERC-20 (backing enforced onchain), so 1 pUSD = 1 USD-- and we report all values in USD throughout.---- V1 fee model:-- FeeModule emits FeeRefunded(feeCharged=NET, refund, id).-- id = 0 -> USDC.e collateral-- id != 0 -> outcome shares (priced via OrderFilled VWAP)-- Separate FeeModule per exchange variant (CTF + NegRisk).---- V2 fee model:-- Exchange itself emits FeeCharged(receiver, amount). NET, no refund.-- Always denominated in collateral (pUSD). No tokenId field.-- Both CTF and NegRisk V2 exchanges write to the SAME ctfexchange_evt_feecharged-- table — distinguished by contract_address.---- Output: only complete days (yesterday and earlier). Today's partial day is-- excluded so daily numbers are always comparable.-- Cutover boundary: anything strictly before this date is V1-only;-- anything strictly after is V2-only; the boundary day itself can have both.WITH cutover AS (SELECT DATE '2026-04-28' AS d),------------------------------------------------------------------------- STEP 1: Net fees in collateral (USDC.e for V1, pUSD for V2 — both 1:1 USD)-----------------------------------------------------------------------sell_side_fees AS (-- V1: CTFExchange FeeModule (collateral side)SELECT evt_block_date AS day, SUM(feeCharged / 1e6) AS fee_usdFROM polymarket_polygon.feemodule_evt_feerefundedWHERE id = UINT256 '0'AND evt_block_date <= (SELECT d FROM cutover)GROUP BY 1UNION ALL-- V1: NegRisk FeeModule (collateral side)SELECT evt_block_date AS day, SUM(feeCharged / 1e6) AS fee_usdFROM polymarket_polygon.negriskfeemodule_evt_feerefundedWHERE id = UINT256 '0'AND evt_block_date <= (SELECT d FROM cutover)GROUP BY 1UNION ALL-- V2: BOTH CTF and NegRisk exchanges (multiplexed onto one table).-- All V2 fees are pUSD-denominated (1:1 USDC-backed); no shares branch.SELECT evt_block_date AS day, SUM(amount / 1e6) AS fee_usdFROM polymarket_v2_polygon.ctfexchange_evt_feechargedWHERE evt_block_date >= (SELECT d FROM cutover)GROUP BY 1),