AI powered, privacy enforcing, prediction market smart router
PolyBets represents a sophisticated evolution in the prediction market ecosystem, functioning as a decentralized aggregator that unifies multiple betting platforms into a single, privacy-preserving interface. At its core, the platform addresses a fundamental inefficiency in the current prediction market landscape: the fragmentation of liquidity and pricing across numerous isolated platforms.
The project's primary innovation lies in its ability to aggregate markets from diverse sources, including major platforms like Polymarket, which operate on order book models, alongside custom markets utilizing LMSR (Logarithmic Market Scoring Rule) mechanisms. This multi-platform integration creates a comprehensive marketplace where users can access the best prices across the entire prediction market ecosystem without manually checking each platform.
What makes PolyBets particularly compelling is its intelligent bet routing system. When a user places a bet, the platform doesn't simply execute it on a single market. Instead, it employs sophisticated algorithms to calculate the optimal allocation across multiple platforms, potentially splitting a single bet into several smaller ones to maximize returns. This optimization takes into account not just the current prices but also the price impact of the bet itself, ensuring that large bets don't adversely affect the execution price. The system offers different strategies, including MaximizeShares for users seeking the highest number of outcome shares.
Privacy stands as a cornerstone of the platform's architecture. Built on the Oasis Sapphire blockchain, PolyBets leverages confidential smart contract capabilities to keep user betting activity private. Unlike traditional blockchain applications where all transactions are publicly visible, PolyBets ensures that bet details, user positions, and trading strategies remain confidential. This privacy layer extends beyond simple transaction hiding – it encompasses the entire user journey from authentication through SIWE (Sign-In With Ethereum) to the final settlement of bets.
The platform's automated market operations showcase its technical sophistication. A dedicated service continuously monitors Polymarket for new and trending markets, automatically importing them into the PolyBets ecosystem. But it doesn't stop at simple copying – the system employs Claude AI to intelligently rephrase market titles and descriptions, adapting them for different audience segments across various platforms. This ensures that a market about "Presidential Election 2024" might be presented differently on a platform catering to political enthusiasts versus one focused on crypto traders, maximizing engagement and liquidity.
Arbitrage detection and execution represent another layer of value creation. The platform continuously scans for price discrepancies across integrated markets, automatically executing trades when profitable opportunities arise. This isn't limited to simple two-market arbitrage – the system can execute complex multi-leg strategies, buying YES on one platform while simultaneously selling NO on another, capturing risk-free profits from market inefficiencies. These profits can be shared with users or used to improve platform liquidity.
The technical architecture reveals a thoughtful approach to building a production-grade DeFi application. The smart contract layer, deployed on Oasis Sapphire, consists of two primary contracts. The PolyBet contract serves as the main hub, managing user deposits, creating bet slips (on-chain representations of betting intent), handling collateral management, and tracking user balances. It emits events that trigger off-chain processing while maintaining the security and transparency benefits of blockchain technology.
The backend infrastructure employs a microservices architecture with several specialized components. The bet-router-rofl service, built on the Runtime Off-chain Logic Framework, monitors blockchain events and executes the actual betting logic. It performs the complex calculations required for optimal bet allocation, manages API interactions with external markets, and updates on-chain status. The marketplace-adapter-rest-api provides a unified interface for querying prices and market information across all integrated platforms, handling the complexities of different API formats and rate limits. The polymarket-copier service automates market creation and seeding, while the arbitrage-rofl component handles opportunity detection and execution.
The frontend application, built with Next.js, provides users with an intuitive interface for market discovery, bet placement, and portfolio management. It features real-time price comparisons, interactive charts, wallet integration, and a mobile-responsive design. The betting sidebar component guides users through the betting process, from amount selection to transaction confirmation, providing clear feedback at each step.
The user journey through PolyBets begins with wallet connection and USDC deposit. Users can then browse aggregated markets, viewing side-by-side price comparisons from different platforms. When placing a bet, they see a preview of how their bet will be optimally allocated across markets. After confirmation, the blockchain transaction creates a bet slip, which triggers the off-chain execution engine. The ROFL backend then springs into action, calculating optimal allocations using LMSR formulas and other optimization techniques, executing bets across selected platforms, and updating the on-chain status. Users can track their positions in real-time, viewing aggregated P&L across all platforms and even closing positions early if desired.
The platform's approach to security balances decentralization with practical requirements. On-chain components benefit from the security of the Oasis Sapphire blockchain, with non-custodial design ensuring users always control their funds. Off-chain components use ROFL to ensure verifiable computation, encrypted API key storage, and secure communication channels. This hybrid approach allows the platform to interact with centralized services while maintaining the security guarantees users expect from DeFi applications.
Looking at the broader market context, PolyBets addresses several critical pain points in the prediction market ecosystem. Fragmented liquidity across platforms leads to inefficient pricing and poor user experience. Privacy concerns prevent many users from participating in prediction markets. High fees and poor execution eat into user returns. PolyBets solves these problems through aggregation, privacy preservation, and intelligent routing.
PolyBets represents more than just another DeFi application – it's a comprehensive solution to the fragmentation and inefficiency in prediction markets. By combining privacy preservation, intelligent routing, automated market operations, and superior user experience, it creates a platform that benefits both retail users seeking the best prices and sophisticated traders looking for arbitrage opportunities. The project demonstrates how thoughtful application of blockchain technology, combined with traditional financial engineering and modern software architecture, can create genuinely useful products that advance the state of decentralized finance.
The implications of this project extend beyond just better betting. By aggregating liquidity and ensuring efficient pricing, PolyBets could help prediction markets fulfill their promise as information aggregation mechanisms. More efficient markets with deeper liquidity provide better signals about future probabilities, benefiting not just traders but anyone seeking to understand collective expectations about future events. In this way, PolyBets isn't just optimizing for individual user returns – it's contributing to the broader goal of creating more efficient information markets.
The PolyBets project is a sophisticated cross-chain prediction market platform that demonstrates a comprehensive integration of modern blockchain technologies. At its core, the project leverages the Oasis Network, specifically the Oasis Sapphire testnet, which provides privacy-enabled blockchain capabilities. This integration is facilitated through the @oasisprotocol/sapphire-contracts package, which offers smart contract utilities specifically designed for the Oasis ecosystem. The project makes extensive use of ROFL (Runtime Off-chain Logic), which enables secure computation within a Trusted Execution Environment (TEE), and incorporates Oasis-specific features such as Subcall for contract interactions and SiweAuth for authentication.
A key innovation of the platform is its prediction market order router, which runs as a confidential ROFL module on Oasis. This router employs sophisticated convex optimization algorithms to achieve optimal bet execution across multiple liquidity pools. The system supports various optimization methods including grid search, binary search, gradient descent, and convex optimization. The router actively seeks arbitrage opportunities and mispricings across different prediction markets to obtain the best possible prices for users. When instant arbitrage is enabled, the system can automatically trigger the selling of related bets when one bet in a group loses, effectively minimizing potential losses for users.
The platform integrates The Graph Protocol alongside large language models to discover and match similar markets across different prediction market venues. This AI-powered market discovery system uses LLMs to rephrase market questions for different platforms while maintaining identical win conditions, and to help users find relevant markets through natural language queries. The combination of The Graph's decentralized indexing capabilities with LLM analysis enables sophisticated cross-market similarity detection and aggregation.
The platform's multi-chain architecture supports both EVM-compatible chains through Oasis Sapphire and Solana through the Anchor framework. This allows users to place bets across multiple chains while maintaining a unified experience.
On the frontend, the project employs a modern web development stack built on Next.js 15 and React 19, with TypeScript providing type safety throughout the codebase. The user interface is styled using Tailwind CSS and incorporates Radix UI components for a polished user experience. Web3 connectivity is handled through Reown AppKit (formerly known as WalletConnect) and Wagmi, which provide robust wallet integration and blockchain interaction capabilities.
The backend infrastructure runs on the Bun runtime, utilizing both Hono and Elysia web frameworks for API development. The Python-based ROFL service handles secure bet routing and optimal execution within a TEE environment. Data persistence is managed through Supabase, providing a PostgreSQL backend-as-a-service solution.
The platform implements the Logarithmic Market Scoring Rule (LMSR) for pricing prediction markets, ensuring efficient price discovery and liquidity provision. The entire codebase is organized as a monorepo, which facilitates code sharing and consistent development practices across the various components of the system. This architecture enables the platform to offer privacy-preserving betting capabilities while supporting multiple blockchain networks and providing advanced features like automated trading agents, optimal order routing, and intelligent market discovery.