Skip to content

ttc915/sol-pot-turbo

Repository files navigation

SOLPOT - Solana Gaming Platform with Turborepo Monorepo

A fully automated Solana-based gaming platform where players allocate points across risk pools and compete for prizes based on randomly generated multipliers. Built as a Turborepo monorepo for optimal development workflow.

Overview

SOLPOT is a decentralized gaming protocol featuring automated lifecycle management, risk-based strategy gameplay, and batched settlement processing.

What's Inside?

This Turborepo monorepo includes:

Apps and Packages

  • contracts: Solana Anchor program for the SOLPOT game
  • web: Next.js web application with wallet integration
  • mobile: React Native mobile application with Solana Mobile Stack integration
  • @repo/eslint-config: ESLint configurations (shared)
  • @repo/typescript-config: TypeScript configurations (shared)
  • @repo/ui: Shared UI components
  • @solpot/anchor-sdk: Anchor SDK package

Each package/app is 100% TypeScript.

Key Features

  • Automated Game Lifecycle: Games start automatically every hour with no manual intervention required
  • Risk-Based Strategy: Players allocate 1000 points across Low, Medium, and High risk pools plus an in-game wallet
  • Batched Settlement: Supports up to 10 players through efficient single-transaction processing
  • Permissionless Participation: Anyone can help calculate scores during settlement
  • Prize Distribution: Top 3 players share 90% of the prize pool (60%/30%/10%)
  • Wallet Integration: Support for Phantom, Solflare, and Backpack wallets

Quick Start

Prerequisites

  • Node.js 18+
  • Rust 1.70+
  • Solana CLI 1.18+
  • Anchor CLI 0.31+
  • pnpm

Installation & Development

# Install dependencies
pnpm install

# Run development servers
pnpm dev

You can also run specific apps:

pnpm --filter @solpot/web dev
pnpm --filter @solpot/contracts build

Build

To build all apps and packages:

pnpm build

To build a specific package:

pnpm --filter @solpot/web build
pnpm --filter @solpot/contracts build

Turborepo Features

Remote Caching

Turborepo can use Remote Caching to share build caches with your team and CI/CD pipelines.

To enable Remote Caching, you need a Vercel account:

# Login to Vercel
pnpm exec turbo login

# Link your Turborepo to Remote Cache
pnpm exec turbo link

Development Commands

  • Web App: pnpm --filter @solpot/web dev - Start the Next.js development server
  • Contracts: pnpm --filter @solpot/contracts build - Build the Anchor program
  • All Apps: pnpm dev - Run all development servers

Game Flow

  1. Initialize: Admin sets up the game configuration (one-time)
  2. Automated Creation: Keeper bot creates games every hour (production) / manual for testing
  3. Join Game: Players pay 0.1 SOL to join (last 5 seconds closed in testing / 5 minutes in production)
  4. Allocate Points: Players distribute 1000 points across risk pools (one-time)
  5. Automated Settlement: After 10 seconds (testing) / 1 hour (production), keeper bot processes:
    • Generate random multipliers
    • Calculate all player scores in single transaction
    • Determine top 3 winners
  6. Claim Prizes: Winners claim their share of the prize pool
  7. Repeat: Process continues automatically

Risk Pools

  • In-Game Wallet: 1.0x multiplier (Safe storage option)
  • Low Risk: 0.95x - 1.1x multiplier (Conservative strategy)
  • Medium Risk: 0.7x - 1.8x multiplier (Balanced strategy)
  • High Risk: 0x - 3x multiplier (Aggressive strategy)

Configuration

  • Entry Fee: 0.1 SOL per player
  • House Fee: 10% of total pool
  • Points Per Player: 1000 (fixed allocation)
  • Game Duration: 10 seconds (testing) / 1 hour (production)
  • Minimum Players: 2 (auto-cancel if below)
  • Join Deadline: 5 seconds before game end (testing) / 5 minutes (production)
  • Program ID: EYiGJxS2H3bozkwDoifJ6ckwbJmJ95DNBTpBR2i3Y8Bf

Project Structure

sol-pot-turbo/
├── apps/
│   ├── contracts/         # Solana Anchor program
│   │   ├── programs/contracts/
│   ├── web/               # Next.js web application
│   └── mobile/            # React Native mobile application
└── packages/
    ├── anchor-sdk/        # Anchor SDK package
    ├── eslint-config/     # ESLint configuration (shared)
    ├── typescript-config/ # TypeScript configuration (shared)
    └── ui/                # Shared UI components

Architecture

Batched Settlement Process

Settlement processes all players (up to 10) in a single transaction for efficiency.

Keeper Bot Automation

The keeper bot (to be implemented) will run continuously to:

  • Monitor active games
  • Create new games automatically every hour (production) / as needed (testing)
  • Initiate settlement when games end
  • Cancel games with <2 players (auto-refund)
  • Maintain game lifecycle without manual intervention

Currently, keeper operations (create_game, settle_game, cancel_game) are called manually via instructions.

Security Considerations

  • PDA-based account security with deterministic addresses
  • Signer verification for all state-changing operations
  • Overflow/underflow protection using checked arithmetic
  • Timestamp validation for game timing constraints
  • Double-claim prevention for prizes
  • One-time allocation enforcement (cannot change after locking)
  • Minimum player requirement for valid games
  • Active game tracking to prevent duplicate games
  • Batched settlement for compute safety

Deployment

Devnet

# Deploy program
cd apps/contracts && anchor build
anchor deploy --provider.cluster devnet

# Initialize (one-time)
PROGRAM_ID=<deployed-program-id> pnpm run initialize

# Fund keeper wallet with 1+ SOL for transaction fees
# Deploy keeper bot to server (Railway, Heroku, etc.)

Mainnet

⚠️ NOT READY: Requires Switchboard VRF integration for secure randomness. Current implementation uses slot-based randomness for demo purposes only.

Testing

Run the comprehensive test suite:

cd apps/contracts && anchor test

Tests cover: game lifecycle, player management, batched settlement, prize distribution, and edge cases.

Current Status

✅ CONTRACT IMPLEMENTED: The SOLPOT smart contract is fully implemented with all game logic.

Key Achievements:

  • ✅ Smart contract with complete game lifecycle (create, join, allocate, settle, claim)
  • ✅ Batched settlement supporting up to 10 players per transaction
  • ✅ Permissionless score calculation during settlement
  • ✅ Comprehensive test suite
  • ✅ Production-ready security measures with checked arithmetic
  • ✅ Modern monorepo structure with Turborepo
  • ✅ Wallet integration ready for frontend

Current Limitations:

  • ⚠️ Uses slot-based randomness (demo purposes only - not cryptographically secure)
  • ⚠️ Keeper operations require manual calls (automation bot to be implemented)
  • ⚠️ Testing configuration with 10-second games (production: 1 hour)

Next Steps:

  1. Deploy to devnet for testing
  2. Implement automated keeper bot
  3. Integrate Switchboard VRF for production randomness
  4. Launch frontend application

Useful Links


Built with ❤️ on Solana

About

SOLPOT - Solana Gaming Platform

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors