docs: add chainlink.md — price feeds, strike resolution, and RTDS integration patterns - #4
docs: add chainlink.md — price feeds, strike resolution, and RTDS integration patterns#4osr21 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit d74bd46. Configure here.
Fix 1 (Low — TS + Python): use >= not > when comparing price to strike. Polymarket rules: end >= start resolves UP. The previous FLAT / strict-> branch sent NO on a tied print, trading the wrong side. Fix 2 (Medium): resolution sanity-check now fetches the Chainlink round at windowEnd (parsed from slug: 5m/15m/1h) instead of latestRoundData(). The live price diverges from the settlement price for any past window, making the original oracleAgrees assertion unreliable after resolution.
|
This doc fills a real gap — the oracle round model and its effect on the RTDS feed trips up a lot of builders (real-time-data-client #31 is a recent example). A few additions that might be worth including: 1. Correct RTDS host The working WebSocket endpoint is 2. TWAP topics launching August 4 Two new RTDS topics are activating: { "type": "error", "message": "topic not found: crypto_prices_twap_thirty" }Recommend adding a note to back off and retry when this error is received rather than treating it as a fatal connection failure. 3. Server-side RTDS subscription from Node.js The official SDK uses // Built-in global WebSocket (Node 22+) — use addEventListener
sock.addEventListener("open", handler);
sock.addEventListener("message", (e: MessageEvent) => { const data = e.data; });
// NOT: sock.on("open", handler) ← that's the npm `ws` package APICalling 4. Filters serialisation (relates to #21) Worth a callout box: the |

Summary
Note
Low Risk
Documentation-only addition with no changes to application logic, auth, or production services.
Overview
Adds
chainlink.mdas a developer reference for Polymarket’s Chainlink-related integrations—no runtime or SDK code changes.It documents on-chain Polygon feeds (six pairs, addresses, deviation/heartbeat) with ethers v6 and web3.py examples for
latestRoundData/getRoundData, including public RPC endpoints.For RTDS
crypto_prices_chainlink, it explains the hold/gap model (repeated last on-chain answer, not interpolation), the required plain-stringfilterssubscribe/unsubscribe shape, and a known rs-clob-client-v2 serialization pitfall.For BTC/ETH-updown markets, it describes strike selection (
updatedAt ≤ windowStartUnix) with binary-search TypeScript/Python samples, agent patterns (pre-trade oracle checks, round polling, jump persistence), and resolution verification using window-end rounds vspayoutNumerators(not livelatestRoundData).Reviewed by Cursor Bugbot for commit cf3b725. Bugbot is set up for automated code reviews on this repo. Configure here.