The Solana Prediction Market is a decentralized trading platform that leverages Meteora's Dynamic Liquidity Market Makers (DLMM) SDK and the Anchor framework. It enables participants to express their outlook on market events through YES/NO positions while maintaining deep, balanced liquidity across outcomes.
flowchart TD
A[Frontend\nNext.js] --> B[Backend\nAPI Routes]
B --> C[Supabase\nDatabase]
A --> D[Solana\nBlockchain]
D --> E[prediction-market\nProgram]
E --> F[Pyth Oracle]
C -->|Market Data| A
E -->|On-chain Data| A
This project demonstrates how liquidity depth can be used as the primary signal for market confidence and price discovery. Instead of simply tracking token price fluctuations, the platform derives market odds from the balance and depth of the underlying liquidity pools. The richer the liquidity on a given outcome, the stronger the conviction reflected in the market price.
- Dual Pool Architecture: Maintains separate YES and NO liquidity pools for every market.
- Liquidity-Weighted Odds: Calculates market confidence based on available liquidity rather than spot prices alone.
- Automated Oracle Resolution: Integrates with the Pyth Network for trustworthy market outcomes.
- Adaptive Fee Model: Adjusts fees dynamically to discourage pool imbalance and incentivize participation.
- Robust Safeguards: Includes validation layers and overflow protection to preserve market integrity.
- Solana-Native Performance: Built to take advantage of Solana’s high-throughput execution environment.
Questions, feedback, or partnership inquiries can be directed via Telegram.
- Global State: Program-wide configuration and statistics
- Markets: Individual prediction markets with metadata
- Pools: YES/NO liquidity pools using constant product AMM
- Positions: User trading positions and P&L tracking
- Users: User statistics and activity tracking
classDiagram
class Market {
+creator: Pubkey
+title: String
+status: MarketStatus
+yes_pool: Pubkey
+no_pool: Pubkey
+oracle_account: Option<Pubkey>
}
class Pool {
+liquidity: u64
+fee_rate: u8
+token_mint: Pubkey
}
class User {
+positions: Vec<Pubkey>
+balance: u64
}
Market "1" *-- "2" Pool
User "1" *-- "*" Position
pub struct Market {
pub creator: Pubkey, // Market creator
pub title: [u8; 64], // Market question
pub status: MarketStatus, // Active/Resolved/Cancelled
pub end_time: i64, // Resolution deadline
pub yes_pool: Pubkey, // YES outcome pool
pub no_pool: Pubkey, // NO outcome pool
pub oracle_account: Option<Pubkey>, // Price feed
pub target_price: Option<u64>, // Oracle target
// ... additional fields
}- Next.js 14 App Router
- Tailwind CSS with custom configuration
- Radix UI component library
- Wallet integration through
@solana/wallet-adapter
graph TD
App[App Router] --> Layout
Layout --> Navbar
Layout --> ThemeProvider
App --> MarketGrid
MarketGrid --> MarketCard
MarketCard --> TradingInterface
TradingInterface --> WalletButton
Run the full test suite:
pnpm test:all # Runs both frontend and program tests# Frontend
pnpm build
pnpm start
# Program
anchor deploy --provider.cluster mainnet-beta- Fork the repository.
- Create a feature branch for your update.
- Open a pull request with a clear summary of the changes.
- Issue: Manual joins in
lib/database-service-relationship-fix.tsinstead of relying on database constraints. - Solution:
- Add foreign key constraints in the Supabase schema.
- Update definitions in
scripts/001-initial-schema.sql. - Remove manual join logic from the service layer.
- Files to Modify:
scripts/001-initial-schema.sqllib/database-service-relationship-fix.ts
- Issue: Fee accounting is unimplemented in
lib/dlmm-real-fixed.ts. - Solution:
- Implement fee collection during swaps.
- Distribute fees proportionally to liquidity providers.
- Add fee tracking within the database.
- Files to Modify:
lib/dlmm-real-fixed.tslib/database-service-fixed.tstypes/database-fixed.ts
- Issue: Market coverage is limited to ETH, BTC, and SOL in
lib/dlmm-real-fixed.ts. - Solution:
- Make the oracle symbol configurable per market.
- Add dynamic price-feed resolution.
- Support custom target prices.
- Files to Modify:
lib/dlmm-real-fixed.tstypes/market.tsprograms/pool-odds/src/lib.rs
- Issue: Placeholder tokens remain in the swap workflow (
lib/dlmm-real-fixed.ts). - Solution:
- Use production token mints from market configuration.
- Add token mint validation.
- Update the swap transaction builder.
- Files to Modify:
lib/dlmm-real-fixed.tslib/transaction-service.tstypes/dlmm.ts
- Service Consolidation: Competing fixed vs standard implementations.
- Market Resolution: Complete support for all market types.
- Error Handling: Enhance recovery logic and consistency.
- Configuration: Replace hardcoded values with a configuration system.
- UI Loading States: Add skeletons and better loading indicators.
- Market Stats: Provide tooltips and supporting explanations.
- Health Checks: Implement comprehensive system monitoring.
- Testing: Expand automated coverage.
- Style System: Standardize CSS classes.
- Error States: Improve UI for error conditions.
- Fallbacks: Refine fallback mechanisms.
- Logging: Enhance logging granularity.
MIT