About the Project

Bayesly was born from a simple observation: prediction markets are only efficient when traders can identify mispricings, but manually analyzing hundreds of markets for correlations and arbitrage opportunities is nearly impossible for retail traders.

Inspiration

While exploring Polymarket, I noticed markets asking fundamentally related questions with contradictory probabilities. For example, two Formula 1 markets might both price different drivers winning at low odds creating potential arbitrage if you consider that other drivers exist. I realized AI could systematically identify these opportunities at scale.

What I Learned

This project taught me the complexities of arbitrage detection in prediction markets. The biggest challenge was distinguishing true arbitrage from false positives. Two markets can both have low probabilities without creating arbitrage if third options exist (e.g., "Will Russell win F1?" at 1% and "Will Leclerc win F1?" at 1% isn't arbitrage Hamilton could win). I had to design sophisticated prompts and scoring systems to make the AI understand probability space coverage.

How I Built It

  • Frontend: React + TypeScript with shadcn/ui for a clean, modern interface
  • Backend: Supabase Edge Functions (serverless Deno) for scalable API endpoints
  • AI Integration: OpenRouter API with Gemini 2.5 Flash for relationship analysis
  • Data Source: Polymarket Gamma API for real-time market data
  • Visualization: React Flow for interactive market relationship diagrams

The architecture syncs markets every few hours, runs AI analysis to compute similarity scores (0-99), and generates natural language explanations for each opportunity.

Challenges Faced

  1. False Positives: Initial versions flagged everything as arbitrage. I implemented heuristic scoring combined with AI analysis and added strict rules about probability space coverage.
  2. API Rate Limits: Managing OpenRouter costs while maintaining responsiveness required batching analysis and caching results.
  3. UX Complexity: Presenting complex arbitrage concepts in an intuitive way. Solved with visual flow diagrams and AI-generated plain-English explanations.
  4. Data Quality: Polymarket's API has inconsistent field formats (outcomes as strings vs arrays, prices as strings vs numbers). I built robust normalization layers to handle edge cases.

The result is a tool that democratizes prediction market intelligence, giving retail traders institutional-grade analysis capabilities.

Built With

  • deno
  • google-gemini-2.5-flash
  • node.js
  • openrouter-api
  • polymarket-gamma-api
  • postgresql
  • react
  • react-flow
  • react-router
  • shadcn/ui
  • supabase
  • supabase-edge-functions
  • tailwind-css
  • tanstack-query
  • typescript
  • vite
Share this project:

Updates