AI-Powered Prediction Market Platform
Slicefund is a comprehensive prediction market aggregation and portfolio management platform that empowers users to analyze, create, and manage diversified portfolios (baskets) of prediction markets across multiple platforms.
Express your market view in plain English (e.g., "Trump tariff markets are bullish" or "BTC will reach $150k this month") and Slicefund's AI:
- Scans 3 major platforms: Polymarket, Kalshi, and Manifold
- Maps your thesis to relevant prediction markets with confidence scoring
- Ranks and scores top market picks based on relevance
- Generates research analysis with confidence levels, key drivers, risks, and market angles
- Creates instant baskets from your thesis results with one click
Create and manage diversified baskets of prediction markets — like ETFs for forecasting:
- Custom baskets: Build portfolios from thesis search results or manually
- Live basket tracking: Monitor positions across platforms
- Rebalance analysis: AI-powered drift detection and rebalance recommendations
- Equal-weight or custom: Flexible weighting strategies
- Persistent storage: All baskets saved locally and across sessions
Continuously monitor cross-platform price discrepancies:
- Real-time scanning: Compare identical/similar markets across platforms
- Spread calculation: Identify profitable arbitrage opportunities
- Risk scoring: AI-powered assessment of opportunity quality
- Alert feed: Live updates on new arbitrage opportunities
- Similarity matching: Advanced question matching to find cross-platform equivalents
Manage index positions with automated rebalancing:
- NAV drift monitoring: Track basket weight deviations
- Rebalance triggers: Automatic alerts when weights shift >5%
- Trade recommendations: Specific buy/sell actions to restore target weights
- Agent-driven analysis: Backboard AI analyzes basket health and generates rebalance plans
- Multi-platform aggregation: Real-time data from Polymarket, Kalshi, and Manifold
- Trending markets: See what's hot across all platforms
- Market overview: Total markets, average odds, arbitrage opportunities
- Volume tracking: Monitor trading activity and liquidity
┌─────────────────────────────────────────────────────────────┐
│ Frontend (React + Vite) │
│ ┌──────────────┬──────────────┬──────────────┬───────────┐ │
│ │ Thesis Search│ My Baskets │ Arb Scanner │ Markets │ │
│ └──────────────┴──────────────┴──────────────┴───────────┘ │
└────────────────────────┬────────────────────────────────────┘
│ REST API
▼
┌─────────────────────────────────────────────────────────────┐
│ Backend (Express.js) │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ API Endpoints │ │
│ │ • /api/analyze (thesis → market search) │ │
│ │ • /api/thesis/map (market mapping) │ │
│ │ • /api/scan (arbitrage detection) │ │
│ │ • /api/basket/rebalance (portfolio analysis) │ │
│ │ • /api/arb/score (opportunity scoring) │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────┬──────────────┬───────────────────────┐ │
│ │ Gemini AI │ Backboard │ Market Data APIs │ │
│ │ Function │ Agents │ │ │
│ │ Calling │ │ • Polymarket │ │
│ └───────────────┴──────────────┤ • Kalshi │ │
│ │ • Manifold │ │
│ └───────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Four specialized AI agents with stateful conversations and context retention:
-
ThesisResearcher (
agents/thesisResearcher.js)- Analyzes investment theses using historical market data
- Generates confidence scores, key drivers, risks, and market angles
- RAG-enabled to find analogues from resolved markets
- Stateful thread maintains context across analyses
- Fresh thread per analysis with 404 error recovery
-
ArbitrageScanner (
agents/arbitrageScanner.js)- Validates and deduplicates arbitrage opportunities
- Analyzes spread viability and execution risk
- Filters alert queue for high-quality opportunities
- Persistent assistant state for pattern recognition
-
IndexRebalancer (
agents/indexRebalancer.js)- Monitors basket NAV drift and weight deviations
- Triggers rebalance alerts when positions shift >5%
- Generates specific trade recommendations
- Maintains historical context of basket performance
- Fresh session per rebalance with stale-thread recovery
-
AlertDispatcher (
agents/alertDispatcher.js)- Formats arbitrage alerts for frontend consumption
- Prioritizes opportunities by urgency and spread
- Enriches alerts with market context
- Manages alert lifecycle and deduplication
Technical Details:
- Each agent has persistent
assistant_idandthread_idstored in.env - Automatic thread recreation on 404 errors (expired/deleted threads)
- Assistant recreation on 404 errors (expired/deleted assistants)
- Retry logic with fresh sessions on Backboard resource errors
- Thread-per-request pattern for thesis and rebalance agents
Google Gemini 2.0 Flash Lite for real-time AI operations:
-
thesisMapper (
ai/thesisMapper.js) ✅ Production- Maps user thesis to relevant prediction markets
- Cross-platform search across Polymarket, Kalshi, Manifold
- Confidence scoring and relevance ranking
- Structured JSON output with market metadata
- Handles ambiguous queries with semantic understanding
-
arbScorer (
ai/arbScorer.js) ✅ Production- Evaluates arbitrage opportunity quality
- Calculates spread, risk, and urgency scores
- Assesses execution difficulty and platform fees
- Returns structured risk analysis
Implementation:
- Function calling with structured schemas
- JSON mode for reliable parsing
- Error handling and retry logic
- Sub-second response times
Modern React SPA with Auth0 authentication:
Core Pages:
Dashboard.jsx— Main application shell with panel routingSignIn.jsx— Auth0 login flow
Panels (Full-Screen Views):
PanelThesis.jsx— Thesis search interfacePanelBaskets.jsx— Portfolio management with rebalancingPanelMarkets.jsx— Market browser and data explorerPanelArb.jsx— Arbitrage scanner with live alertsPanelIndex.jsx— Index builder and analyticsPanelProfile.jsx— User settings and preferences
Key Components:
ThesisCard.jsx— Search input with multi-step progress UIResultsPanel.jsx— Analysis results with market picks and "Create Basket" buttonAgentStatus.jsx— Real-time agent status indicatorsMeshBackground.jsx— Animated gradient mesh backgroundWalletConnect.jsx— Phantom wallet integration (Solana)Sidebar.jsx— Navigation with active state managementRightPanel.jsx— Market suggestions and related markets
State Management:
- Local state with React hooks
- localStorage for basket persistence and search history
- Session state for active panel and user preferences
- Real-time updates via polling (no WebSocket yet)
UI/UX Features:
- Progress indicators for long-running AI operations
- Toast notifications for success/error states
- Responsive grid layouts
- Dark mode support
- Smooth animations and transitions
RESTful API Server (server/index.js) with 2,400+ lines of production code:
Core Endpoints:
POST /api/analyze— Full thesis analysis pipeline (search → map → analyze)POST /api/thesis/map— Thesis to market mapping onlyPOST /api/scan— Arbitrage opportunity detectionPOST /api/basket/rebalance— Portfolio rebalance analysisPOST /api/arb/score— Score individual arbitrage opportunitiesGET /api/trending/*— Cached trending markets by platformGET /api/agents/status— Backboard agent health check
Mock Trading Endpoints (Development):
POST /api/mock/polymarket/orders— Simulated order placementPOST /api/mock/polymarket/execute-arb— Simulated arb executionPOST /api/mock/polymarket/execute-basket— Simulated basket tradesPOST /api/mock/polymarket/buy-basket— Simulated basket purchase
Features:
- CORS enabled for local development
- JSON body parsing
- Error handling with structured responses
- Environment variable configuration
- In-memory caching for market relationships (1-hour TTL)
- Agent registry for Backboard assistant/thread management
Market Data Integration:
- Polymarket API: Top markets, market details, odds data
- Kalshi API: Event markets, strike prices, volume
- Manifold API: Community markets, probability feeds
- Caching:
lib/trendingCache.jswith file-based persistence
Storage:
- localStorage: User baskets, thesis history, preferences
- File cache: Trending market data (1-hour TTL)
- .env files: Agent IDs, API keys, configuration
No Database Yet:
- Local-first architecture with browser storage
- Stateless server (except agent threads)
- Future: Supabase for user profiles, portfolios, history
Frontend:
- ✅ Auth0 authentication with protected routes
- ✅ Thesis search with multi-step progress UI
- ✅ Results panel with market picks and analysis
- ✅ "Create Basket" button with instant basket creation
- ✅ Basket management (create, view, rebalance)
- ✅ Arbitrage scanner with live alerts
- ✅ Market browser across 3 platforms
- ✅ Past search history
- ✅ Wallet connection UI (Phantom)
- ✅ Responsive layouts and dark mode
Backend API:
- ✅ Full thesis analysis pipeline (
/api/analyze) - ✅ Market mapping endpoint (
/api/thesis/map) - ✅ Arbitrage scanning (
/api/scan) - ✅ Basket rebalancing (
/api/basket/rebalance) - ✅ Market data aggregation (Polymarket, Kalshi, Manifold)
- ✅ Trending market caching
- ✅ Agent status monitoring
- ✅ Mock trading endpoints for development
AI/ML Systems:
- ✅ 4 Backboard agents with persistent threads
- ThesisResearcher with stale-thread recovery
- ArbitrageScanner with validation logic
- IndexRebalancer with fresh-session-per-run pattern
- AlertDispatcher with formatting logic
- ✅ 2 Gemini AI modules (thesisMapper, arbScorer)
- ✅ Function calling with structured output
- ✅ Error handling and retry logic
- ✅ 404 recovery for expired threads/assistants
Data & Storage:
- ✅ localStorage for baskets and history
- ✅ File-based trending cache (1-hour TTL)
- ✅ In-memory relationship cache
- ✅ Market data normalization across platforms
Trading Integration:
- 🚧 Solana/Anchor smart contracts for basket tokens
- 🚧 Jupiter Aggregator for swap execution
- 🚧 Real on-chain arb execution
- 🚧 SPL token minting for baskets
Backend Infrastructure:
- 🚧 Redis for real-time price feeds and pub/sub
- 🚧 Supabase for user profiles, portfolios, resolution history
- 🚧 WebSocket connections for live updates
- 🚧 Database-backed basket persistence
Advanced Features:
- 🚧 Custom basket weighting (currently equal-weight only)
- 🚧 Historical performance tracking
- 🚧 Portfolio analytics and metrics
- 🚧 Social features (share baskets, leaderboards)
- 🚧 Mobile app (React Native)
- Runtime: Node.js 18+ (ES modules)
- Package Manager: npm
- Language: JavaScript (ESNext)
- Framework: React 18.3.1
- Build Tool: Vite 6.0
- Auth: Auth0 React SDK 2.15
- Styling: CSS-in-JS (inline styles)
- Wallet: Phantom (Solana)
- Server: Express.js 4.21
- HTTP Client: Axios 1.7
- Environment: dotenv 16.4
- Process Management: Concurrently (dev)
- Backboard API: Persistent AI agents with stateful memory
- Google Gemini: 2.0 Flash Lite (via @google/generative-ai 0.21)
- OpenAI SDK: 4.77 (for Backboard client)
- Function Calling: Structured JSON output with schemas
- Polymarket API: Top markets, odds, volume
- Kalshi API: Event markets, predictions
- Manifold Markets API: Community forecasts
- Blockchain: Solana, Anchor Framework
- Swap Aggregator: Jupiter
- Database: Supabase (PostgreSQL)
- Cache: Redis
- CDN: Cloudinary
- Deployment: Vultr
- Node.js 18+ and npm
- API keys:
- Backboard API (for AI agents) — backboard.io
- Google Gemini API — ai.google.dev
- Auth0 account and SPA application — auth0.com
1. Clone and Install Dependencies:
# Install root dependencies
npm install
# Install client dependencies
cd client
npm install
cd ..2. Create Root .env File:
# API Keys
BACKBOARD_API_KEY=your_backboard_api_key
GEMINI_API_KEY=your_gemini_api_key
# Backboard Agent IDs (auto-populated on first run)
THESIS_RESEARCHER_ASSISTANT_ID=
THESIS_RESEARCHER_THREAD_ID=
ARB_SCANNER_ASSISTANT_ID=
ARB_SCANNER_THREAD_ID=
INDEX_REBALANCER_ASSISTANT_ID=
INDEX_REBALANCER_THREAD_ID=
ALERT_DISPATCHER_ASSISTANT_ID=
ALERT_DISPATCHER_THREAD_ID=3. Create client/.env File:
VITE_AUTH0_DOMAIN=your-tenant.auth0.com
VITE_AUTH0_CLIENT_ID=your_client_id
VITE_AUTH0_AUDIENCE=your_api_identifier # optional4. Configure Auth0 Application:
In your Auth0 dashboard, set these URLs for local development:
- Application Type: Single Page Application
- Allowed Callback URLs:
http://localhost:5173 - Allowed Logout URLs:
http://localhost:5173 - Allowed Web Origins:
http://localhost:5173
Development Mode (Full Stack):
# Run both server and client concurrently
npm run devThis starts:
- Backend:
http://localhost:3001 - Frontend:
http://localhost:5173
Run Server Only:
npm run dev:server
# or
node server/index.jsRun Client Only:
npm run dev:client
# or
cd client && npx viteTest Gemini AI Modules (Fast):
# Test thesis mapping
node ai/thesisMapper.js
# Test arbitrage scoring
node ai/arbScorer.jsTest Backboard Agents (Requires API Key):
# Test individual agents
node agents/thesisResearcher.js
node agents/arbitrageScanner.js
node agents/indexRebalancer.js
node agents/alertDispatcher.jsAutomated Agent Validation:
# Test all agents with schema validation
npm run test:agents
# Force create new assistants (ignore saved IDs)
npm run test:agents:fresh
# Test integrated multi-agent flows
npm run test:agents:integration
# Integration test with fresh assistants
npm run test:agents:integration:freshThe automated tests return non-zero exit code when responses don't match expected schemas.
User Input: "Trump tariff markets are bullish"
↓
[Agent 1: Parse keywords] → "trump, tariff, trade, china"
↓
[Agent 2: Search APIs] → Scan Polymarket, Kalshi, Manifold
↓
[Agent 3: Rank markets] → Score relevance and confidence
↓
[Gemini Mapper] → Map thesis to top 5 markets with metadata
↓
[Backboard Researcher] → Generate analysis (confidence, drivers, risks)
↓
Results Panel → Show ranked markets + "Create Basket" button
User clicks "Create Basket" on thesis results
↓
basketData = {
name: "Trump tariff markets are bullish",
markets: [
{ market: "Trump questions", platform: "Polymarket", weight: 0.2 },
{ market: "China questions", platform: "Kalshi", weight: 0.2 },
...
]
}
↓
Check localStorage for duplicate name → Add counter if needed
↓
Save to localStorage → Update UI state
↓
Navigate to My Baskets panel → Show new basket
Fetch trending markets from all platforms
↓
For each market pair:
- Calculate question similarity (tokenize + overlap)
- Check if different platforms
- Calculate price spread
↓
If spread ≥ 4% AND similarity ≥ 45%:
→ Flag as arbitrage opportunity
↓
Score with Gemini arbScorer (risk, urgency, spread)
↓
Validate with Backboard ArbitrageScanner
↓
Display in Arb Scanner panel with alerts
User clicks "Check Rebalance" on a basket
↓
Calculate weight drift for each position:
drift = |current_weight - target_weight|
↓
If any position drifted >5%:
→ Trigger rebalance alert
↓
Send basket to Backboard IndexRebalancer agent
↓
Agent analyzes drift and generates trades:
"BUY 0.15 on Market A"
"SELL 0.08 on Market B"
↓
Display proposed trades with execute button
- Multi-platform market aggregation
- AI-powered thesis analysis
- Basket creation and management
- Arbitrage detection
- Rebalancing recommendations
- Auth0 authentication
- Local storage persistence
- Phantom wallet connection
- Solana SPL token baskets
- Jupiter swap integration
- On-chain arb execution
- Real money basket trading
- Transaction history
- Public basket sharing
- Leaderboards and rankings
- Portfolio performance tracking
- Research notes and annotations
- Community thesis library
- Mobile app (iOS/Android)
- Custom weighting strategies
- Automated rebalancing
- Stop-loss and take-profit orders
- Market prediction contests
- API for third-party integrations
- White-label platform for institutions
Slicefund is currently in private development. Contributions are not yet accepted.
MIT
Built with ❤️ by the Slicefund team