Reconciling Polymarket's TWAP: A Python Monitoring Script
Follow-up to my post on why Polymarket is moving crypto market settlement to TWAP starting August 7 - this one's the actual implementation.
Chainlink doesn't publish the exact sampling boundaries or weighting methodology for the custom TWAP feed, so you can't independently derive the resolution price from scratch. What you can do: store every raw tick you observe (not pre-averaged data), compute your own TWAP over the same window Polymarket uses, and reconcile it against the published resolution price with a defined drift tolerance.
The script also handles a failure mode that didn't exist under the old single-tick resolution - feed gaps mid-window. If the last tick goes stale beyond a threshold, that needs to be caught before it matters for a live position, not after.
Testnet TWAP feeds are live now. Mainnet and RTDS launch August 4, giving a three-day live-fire testing window before settlement actually depends on it.
Full code + writeup: [Dev.to link]














