Skip to content

AricRedemption/ploymarketX402

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

X402 Prediction Market

A decentralized prediction market platform on Solana with AI-generated markets, MCP protocol integration, and x402 payment support.

What Makes This Unique

🤖 AI-Generated Markets: All prediction markets are automatically generated by AI, creating diverse and timely betting opportunities across multiple categories.

🔌 MCP Protocol Support: Industry-first Model Context Protocol (MCP) integration allows AI agents to interact directly with the prediction market:

  • Add/remove liquidity positions
  • Buy and sell YES/NO tokens
  • Query market data and positions
  • Execute trades programmatically

💳 x402 Payment Protocol: Seamless USDC payments across Solana and Base chains with unified interface and gasless transactions.

How It Works

What is a Prediction Market?

Trade YES/NO tokens on future events. Token prices = probability:

  • YES token at $0.70 = 70% chance event happens
  • NO token at $0.30 = 30% chance it doesn't
  • Prices always sum to $1.00

Winners redeem tokens for $1.00 each after event resolves.

Core Features

For Traders:

  • Buy YES/NO tokens on AI-generated markets
  • Trade via x402 payment gateway (Solana USDC)
  • LMSR pricing ensures fair probability-based prices
  • Arbitrage with Complete Sets (1 USDC ↔ 1 YES + 1 NO)

For Liquidity Providers:

  • Add liquidity to earn trading fees
  • Fair fee distribution with cumulative tracking
  • Withdraw anytime with proportional share

For AI Agents (MCP Protocol):

  • Programmatic market access via MCP servers
  • Execute trades without manual intervention
  • Manage liquidity positions automatically
  • Query real-time market data

MCP Protocol Integration

This is the first prediction market with native MCP support, enabling AI agents to participate autonomously:

Available MCP Operations

Trading Operations:

  • buy_yes_tokens(market_id, usdc_amount) - Purchase YES tokens
  • buy_no_tokens(market_id, usdc_amount) - Purchase NO tokens
  • sell_yes_tokens(market_id, token_amount) - Sell YES tokens
  • sell_no_tokens(market_id, token_amount) - Sell NO tokens

Liquidity Operations:

  • add_liquidity(market_id, yes_amount, no_amount, usdc_amount) - Provide liquidity
  • remove_liquidity(market_id, lp_shares) - Withdraw liquidity
  • claim_lp_fees(market_id) - Claim accumulated fees

Query Operations:

  • get_market_info(market_id) - Fetch market details and prices
  • get_user_positions(wallet_address) - View token balances and LP positions
  • get_market_list(category) - Browse available markets

Why MCP Matters

For AI Agents:

  • Direct blockchain interaction without custom integrations
  • Standardized protocol for DeFi operations
  • Enables autonomous trading strategies
  • Real-time market analysis and execution

For Developers:

  • Build AI trading bots easily
  • Integrate prediction markets into AI applications
  • Automate liquidity provision strategies
  • Connect LLMs directly to Solana DeFi

Example Use Case: An AI agent analyzes crypto news, identifies high-probability events, automatically buys YES tokens via MCP, and manages positions based on sentiment analysis - all without human intervention.

AI-Generated Markets

Automated Hot Topic Tracking

Our AI system continuously monitors real-time news and trends to automatically create prediction markets:

How It Works:

  1. Data Collection: AI scans news feeds, social media, and crypto/finance APIs
  2. Event Detection: Machine learning identifies trending events with clear YES/NO outcomes
  3. Market Creation: AI automatically deploys new markets on-chain via smart contract
  4. Pool Initialization: Auto-seeds initial liquidity for immediate trading
  5. Monitoring: Tracks event resolution and updates market status

AI-Generated Market Features:

  • Real-Time: Markets created within minutes of trending topics emerging
  • Diverse Categories: Finance, sports, politics, technology, entertainment
  • Quality Control: AI filters for verifiable events with clear resolution criteria
  • Smart Pricing: Initial pricing parameters set based on event type and liquidity needs
  • Auto-Expiry: Markets automatically set end times based on event schedules

Example Markets Created:

  • "Will Bitcoin reach $100k by end of 2024?" (created after BTC rally news)
  • "Will the next Ethereum upgrade deploy on schedule?" (created from dev updates)
  • "Will [Team A] win the championship?" (created during playoffs)
  • "Will [Company] announce new product this quarter?" (created from earnings call)

Benefits:

  • Zero Manual Work: No human intervention needed for market creation
  • Always Fresh: Constantly updated pool of relevant markets
  • High Quality: AI ensures events are well-defined and resolvable
  • Optimal Liquidity: Smart initial seeding based on expected trading volume

x402 Payment Integration

Dual-Chain Support:

  • Solana Devnet: Prediction market trading (low fees, fast)
  • Base Sepolia: Lucky Draw game (EVM compatibility)

Payment Features:

  • SPL Token transfers (USDC, 6 decimals)
  • EIP-712 signing for gasless payments
  • Server-side verification for security
  • Unified payment interface across chains

Use Cases:

  • Market token purchases
  • Liquidity provision
  • Lucky Draw participation (Base)
  • GAME$ token sales

Technical Architecture

Smart Contract (Solana)

  • Framework: Anchor (Rust)
  • Pricing: LMSR (Logarithmic Market Scoring Rule)
  • Collateral: USDC (100% backed)
  • Security: Dual ledger system, reentrancy guards, PDA-based access control

Frontend (Next.js)

  • Wallet: Solana Wallet Adapter + Coinbase OnchainKit
  • Styling: Tailwind CSS v4
  • Payment: x402 protocol integration
  • AI Integration: Market generation API

MCP Server

  • Protocol: Model Context Protocol (MCP)
  • Operations: Trading, liquidity, queries
  • Authentication: Wallet-based signing
  • Transport: JSON-RPC over HTTP/WebSocket

Key Innovations

  1. AI Market Generation: First prediction market with fully AI-generated content
  2. MCP Protocol: First DeFi app with native AI agent support
  3. Dual Ledger: Separates collateral safety from trading efficiency
  4. Cross-Chain Payment: x402-powered USDC across Solana and Base
  5. LMSR Pricing: Probability-based pricing with fixed-point math

Security Features

  • Collateral Safety: Every YES+NO pair backed by 1 USDC (no fractional reserve)
  • Access Control: Multi-tier permissions with two-step authority transfer
  • Trading Protection: Slippage limits, time windows, reentrancy guards
  • Smart Contract: Deterministic math, PDA design, authority checks

Getting Started

For Users:

  1. Connect Solana wallet
  2. Fund with USDC
  3. Browse AI-generated markets
  4. Trade YES/NO tokens via x402 payment
  5. Claim winnings after resolution

For AI Agents:

  1. Install MCP client library
  2. Connect to MCP server endpoint
  3. Authenticate with wallet
  4. Execute trading operations programmatically

For Developers:

  1. Integrate x402 for payments
  2. Use MCP protocol for market access
  3. Build AI trading strategies
  4. Deploy on Solana devnet

Roadmap

  • Mainnet deployment
  • More AI market categories
  • Advanced MCP operations (limit orders, stop-loss)
  • Decentralized oracle integration
  • Cross-chain liquidity aggregation
  • Mobile app with MCP support

Technical Stack

  • Blockchain: Solana (Devnet) + Base Sepolia
  • Smart Contract: Anchor Framework (Rust)
  • Frontend: Next.js 15 + TypeScript
  • Payment: x402 Protocol
  • AI Integration: MCP Protocol
  • Collateral: USDC (SPL Token)

License

MIT License

Acknowledgments

  • Built with Anchor Framework
  • Inspired by Polymarket
  • LMSR pricing based on research by Robin Hanson
  • x402 Payment Protocol by Crossmint
  • MCP Protocol by Anthropic

Built for Hackathon - First prediction market with AI-generated content and MCP protocol for autonomous AI agent trading

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •