Skip to content

SamsShow/BlackboxAlpha

Repository files navigation

Blackbox Alpha

Privacy-enhanced prediction/trading platform integrating prediction markets, zero-knowledge privacy, and AI-driven trading.

Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                           Frontend (Next.js)                        │
│                    Wallet Connect  •  Market Dashboard              │
└────────────────────────────────┬────────────────────────────────────┘
                                 │
                                 ▼
┌─────────────────────────────────────────────────────────────────────┐
│                         Privacy RPC Layer                           │
│            Encrypted Orders  •  ZK Proof Validation                 │
└────────────────────────────────┬────────────────────────────────────┘
                                 │
          ┌──────────────────────┼──────────────────────┐
          ▼                      ▼                      ▼
┌──────────────────┐  ┌──────────────────┐  ┌──────────────────┐
│  PNP Exchange    │  │  AI Agent        │  │  ZK Contracts    │
│  Prediction Mkts │  │  Signals/Trade   │  │  Proof Verifier  │
└──────────────────┘  └──────────────────┘  └──────────────────┘

Monorepo Structure

BlackboxAlpha/
├── apps/
│   └── web/              # Next.js frontend
├── packages/
│   ├── ui/               # Shared UI components
│   ├── config/           # Shared configurations
│   ├── types/            # Shared TypeScript types
│   └── zk-circuits/      # Circom ZK circuits
├── services/
│   ├── privacy-relay/    # Privacy RPC layer (Express.js)
│   └── ai-agent/         # AI trading agent (FastAPI)
└── contracts/
    └── privacy/          # Solana programs (Anchor)
        ├── shielded_pool        # Privacy pool for deposits/withdraws
        ├── pnp_market_wrapper   # PNP prediction market wrapper
        └── groth16_verifier     # ZK proof verification

Getting Started

Prerequisites

  • Node.js >= 18.0.0
  • pnpm >= 8.0.0
  • Python >= 3.10 (for AI agent)
  • Rust >= 1.70 (for Solana contracts)
  • Solana CLI (for contract deployment)

Installation

# Install all dependencies
pnpm install

# Install AI agent dependencies
cd services/ai-agent && pip install -e .

Running the Full Stack

You need to run three services for the full application:

1. Start the Privacy Relay (Port 3001)

cd services/privacy-relay
cp .env.example .env   # Configure your settings
pnpm dev

2. Start the AI Agent (Port 8000)

cd services/ai-agent
cp .env.example .env   # Configure your settings
python -m uvicorn src.main:app --reload --port 8000

3. Start the Frontend (Port 3000)

cd apps/web
cp .env.example .env.local   # Configure your settings
pnpm dev

Or run all services from the root:

pnpm dev  # Starts frontend with Turbo

Environment Configuration

Each service has an .env.example file. Copy and configure:

  • Frontend (apps/web/.env.local): API URLs, Solana RPC, contract addresses
  • Privacy Relay (services/privacy-relay/.env): Solana RPC, private key for signing
  • AI Agent (services/ai-agent/.env): Privacy relay URL, optional API keys

Build

pnpm build

Core Features

1. Privacy Trading

  • Deposit SOL to the shielded pool
  • Trade on prediction markets with hidden positions
  • Withdraw with zero-knowledge proofs

2. Prediction Markets (PNP)

  • Browse live markets from PNP Exchange
  • LONG (YES) or SHORT (NO) positions
  • Real-time price updates via AMM

3. AI Trading Signals

  • News sentiment analysis
  • Market momentum indicators
  • Automated trade execution

4. Portfolio Management

  • View all positions across markets
  • Track unrealized P&L
  • Redeem winning positions

API Endpoints

Privacy Relay (http://localhost:3001)

Endpoint Method Description
/api/markets GET List all PNP markets
/api/markets/:id GET Get market details
/api/markets POST Create new market
/api/trading/buy POST Buy YES/NO tokens
/api/trading/sell POST Sell tokens
/api/trading/redeem POST Redeem winning position
/api/trading/positions/:wallet GET Get wallet positions
/api/proof/verify POST Verify ZK proof
Endpoint Method Description
/health GET Service health check
/signals/{market_id} GET Get trading signal
/analyze POST Analyze multiple markets
/trade POST Execute AI trade
/status GET Agent status

Solana Contracts

Program Address
Shielded Pool HmbTLCmaGvZhKnn1Zp6QahzU3cU9kNuZmBfKn5s2yPze
PNP Wrapper G5a4u8VDvE1X8p6i3hDyJLM7vWqGMYxHZ7LjJvNMpmf1
Groth16 Verifier Ds1WkRKa2qDQhwZxSv2xkNKHqKnf8eJnDFPxPFpKLpTN

License

Private - All Rights Reserved

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors