Skip to content

Add Synth Overlay — Polymarket Edge Extension#5

Open
bitloi wants to merge 9 commits intoentrius:mainfrom
bitloi:feature/synth-overlay-polymarket-extension
Open

Add Synth Overlay — Polymarket Edge Extension#5
bitloi wants to merge 9 commits intoentrius:mainfrom
bitloi:feature/synth-overlay-polymarket-extension

Conversation

@bitloi
Copy link

@bitloi bitloi commented Feb 26, 2026

Tool Name

Synth Overlay — Polymarket Edge Extension

Summary

Synth Overlay adds a live decision layer to Polymarket Up/Down and range markets using Synth forecasts. It surfaces actionable signals directly in the UI with a side panel and in-context overlay: signal direction, edge %, confidence, and clear reasoning.

This PR also addresses reviewer feedback by:

  • using a side panel (instead of only a floating card),
  • showing specific numbers (market YES, Synth fair value, edge %),
  • using confidence colors where medium confidence (e.g., 45%) is not green,
  • and displaying an actionable overlay near the trading controls.

Demo

Technical Document

The required 1-page technical document is in:

  • tools/synth-overlay/README.md

It covers:

  • problem and tool behavior,
  • architecture (extension + local Flask API + Synth client),
  • Synth API usage,
  • run/verify/test instructions.

Related Issues

Fixes #3 — Synth Overlay: Polymarket Edge Extension

Testing

  • Tests pass in mock mode (python -m pytest tools/synth-overlay/tests/ -v)
  • Manually tested with mock data
  • Tests added in tools/synth-overlay/tests/

Test result summary:

  • 63 passed (mock mode)

Manual verification summary:

  • Side panel opens from Synth tab.
  • Data & Analysis shows market YES price, Synth fair value, and edge %.
  • Confidence bar shows medium values in amber (not green).
  • Action overlay appears near trading UI with YES/NO guidance and numeric context.

Checklist

  • 1-page technical document at tools/synth-overlay/README.md
  • Tool lives in its own subfolder under tools/
  • Tool uses synth_client.SynthClient for all Synth API access
  • Code follows project style guidelines
  • Self-review completed

- edge.py: compute YES-edge from Synth vs market prob, classify signal (underpriced/fair/overpriced) and strength (strong/moderate/none)
- matcher.py: normalize slug from Polymarket URL, infer market type (daily/hourly/range), is_supported()
- server.py: Flask API on 127.0.0.1:8765 — GET /api/health, GET /api/edge?slug=... using SynthClient (mock or live)
- extension/: MV3 content script on polymarket.com, injects badge + detail card, fetches edge from local server
- tests: 26 tests for edge, matcher, server (mock mode)
- README: technical doc and run instructions
- analyzer.py: EdgeAnalyzer class with dual-horizon analysis, percentile-based
  confidence scoring (0-1), signal explanations, and invalidation conditions
- server.py: wired through EdgeAnalyzer; API returns confidence_score,
  explanation, invalidation alongside edge/signal/strength
- content.js: slide-out panel with full analysis (why signal exists, what
  invalidates it, confidence bar); fixed MutationObserver infinite loop;
  SPA navigation handled via URL polling + slug tracking
- content.css: slide-out panel, confidence bar, hover states
- tests: 56 total (19 new analyzer tests covering aligned/conflicting/fair
  signals, confidence scoring, explanations, invalidation, bias detection)
- content.js: capture requestedSlug before fetch, discard response if
  page slug changed during network round-trip (prevents stale overlay
  on fast SPA navigation)
- analyzer.py: add analyze_range() with range-specific explanation,
  invalidation, and percentile-based confidence for range markets
- server.py: wire analyze_range for range endpoint; range API now
  returns confidence_score, explanation, invalidation like up/down
- matcher.py: remove dead code (redundant conditions, unused constant);
  broaden hourly detection from hardcoded "6pm" to regex matching any
  time pattern (e.g. 10am, 3pm)
- tests: 63 total — 7 new range analysis tests, broader hourly matcher
  tests, range server response now asserts analysis fields
- _build_range_explanation: fix "X of X" bug — now correctly shows
  mispriced count vs total bracket count (e.g. "8 of 11")
- Remove unused BracketEdge dataclass
- Remove unused 'field' import from dataclasses
…E verification

- Position overlay badge fixed top-right (always visible on Polymarket)
- Format API timestamps as 'Feb 25, 11:45 PM UTC' in detail card and panel
- Add 'Verify the overlay (before recording)' section to README
@e35ventura
Copy link
Collaborator

  1. Make it a Side Panel not a floating card.
  • Improve Data & Analysis Visibility: Show specific numbers and a clear explanation of the data behind the decision.
  • The confidence bar is good—keep and enhance it (45% confidence should not be green).
  1. Currently, it’s not intuitive enough as an "actionable signal." Users should see the overlays directly on one or both of these UI elements and immediately know how what it means and how to act on it (image attached).
image image

@bitloi
Copy link
Author

bitloi commented Feb 27, 2026

@e35ventura I fixed the issues, please check this demo video .
https://screenrec.com/share/1yp3anEiY7

…able bar

- Side panel (not floating card); Synth tab opens panel
- Data & Analysis: market YES, Synth FV, edge %, explanation
- Confidence bar: discrete colors (45% amber, not green)
- Action bar near trade widget: Up/Down guidance + FV/MKT numbers
- Server: accept hourly/daily slugs by pattern (active markets)
- README and PR description with demo link
@bitloi bitloi force-pushed the feature/synth-overlay-polymarket-extension branch from 6c98760 to e7157e8 Compare February 27, 2026 07:18
@e35ventura
Copy link
Collaborator

you need to make it a side panel and move the overlay to one of those UI elements. example screenshot:
659EE315-24DF-47B4-A34E-FE9F5FB366A6

  • also need to make the market price you show track polymarket exactly because it is currently way off/delayed. a potential way to solve this may be just only showing the synth prices for up and down in the UI right below the actual buttons. and in the side panel just show latest update (maybe add a manual refresh button too)

@bitloi
Copy link
Author

bitloi commented Mar 1, 2026

you need to make it a side panel and move the overlay to one of those UI elements. example screenshot: 659EE315-24DF-47B4-A34E-FE9F5FB366A6

  • also need to make the market price you show track polymarket exactly because it is currently way off/delayed. a potential way to solve this may be just only showing the synth prices for up and down in the UI right below the actual buttons. and in the side panel just show latest update (maybe add a manual refresh button too)

@e35ventura Thanks for the detailed feedback and example screenshot.

Quick clarification before I iterate:

  1. Side Panel — Do you want me to use Chrome's native Side Panel API (chrome.sidePanel), or is a custom slide-out panel on the right side acceptable as long as the layout/content matches your example?

  2. Chart + card layout — Should I match the visual style in your screenshot (bar chart comparing MKT vs FV, card-style values), or is a clean text-based layout with the same data acceptable?

  3. Overlay on buttons — You mentioned "just only showing the synth prices for up and down in the UI right below the actual buttons." I've implemented that — Synth prices appear below the Up/Down buttons when the DOM structure allows it. Is that the right approach, or do you want the overlay styled differently?

Current state of this branch:

  • Side panel with Synth Forecast, Live Market (DOM-read), Signal, Confidence, Invalidation
  • Synth prices below Up/Down buttons (+ fallback bar)
  • Manual refresh button + last-update timestamp in panel
  • 63 tests passing

I will match your example screenshot exactly once I know which parts are required vs nice-to-have.

…resh

- Show Synth Up/Down prices directly below Up/Down buttons
- Read live market prices from page DOM (not stale API cache)
- Scope DOM reads and button targeting to trade widget
- Add manual refresh button in side panel (updates in-place)
- Show last-update timestamp in panel footer
- Remove old action bar and floating badge approaches
@e35ventura
Copy link
Collaborator

thanks for asking for clarifications

  1. use Chrome's native Side Panel
  2. you do not have to match, just do whatever you like best (dont have redundant data and make everything as clear to understand and data oriented as possible) see point 3 for directional vision of development for this.
  3. problem is market value is not insync with market value displayed on polymarket, so a solution could be just display prices for up and down based on synth data and then show when that was last updated. the overlay isnt even necessary anymore, i think you could do it all on the side panel. think like a UI basically but in a side panel because after this we will scale this side panel you can use it for all synth data on any website (ie trading view, polymarket, kalshi)

…dation, no overlay

- Remove DOM-scraped Polymarket prices; show only Synth-sourced data
- Add Invalidation card to side panel (required by issue entrius#3)
- Use API current_time for 'Data as of' timestamp instead of local clock
- Confidence bar: 45% renders amber, not green
- Remove content.css overlay injection; all UI in native Chrome Side Panel
- Simplify content.js to slug extraction only (no DOM price scraping)
- Update README to reflect current implementation
@bitloi
Copy link
Author

bitloi commented Mar 1, 2026

@e35ventura I just fixed the issues. Would you mind reviewing again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Synth Overlay: Polymarket Edge Extension

2 participants