Skip to content
TajudeeenPublic

About

24/7 intelligence for tokenized stocks on Solana

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

179 Commits

Folders and files

Repository files navigation

AfterHours

Solana Pyth Network PreStocks Tests Next.js TypeScript License

24/7 Intelligence & Bounded Execution Layer for Tokenized Stocks on Solana

Live Markets • Gap Radar • Proof & Verification • Activity • System Intro

Screenshot


Receipts

Bare facts. No marketing hedges. Every claim is backed by executable code and passing tests.

  • 79 / 79 Tests Passing: 100% test pass rate across 8 workspace packages (types, config, market-engine, risk-engine, agent, solana, api, web).
  • Pyth Network Dual-Feed Market Intelligence: Directly compares TradFi equity feeds (Equity.US.*) with on-chain tokenized stock feeds (Crypto.*X xStocks and Ondo feeds) via Pyth Hermes oracle feeds, computing real-time basis divergence and dynamic slippage bounds.
  • Live PreStocks Integration: Ingests real-time prices for 8 pre-IPO stocks (Anthropic, SpaceX, OpenAI, Anduril, Neuralink, Figure AI, Kalshi, Polymarket) via https://prestocks.com/api/prestocks.
  • Real Gap Telemetry: Directly computes divergence between fair valuation (markPrice) and on-chain DEX trading (tokenPrice) - e.g. SpaceX (-22.3%), OpenAI (+16.2%), Neuralink (+26.7%).
  • Fail-Closed Risk Governor: Hard policy constraints (MAX_SINGLE_ASSET = 35%, MAX_TRADE = $1,500) that deterministically reject non-compliant trades before signing.
  • On-Chain Attestation: Every user-approved trade signs a Solana transaction recorded via the official SPL Memo Program (MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr) with clickable Solscan links. Settles on Solana Mainnet-Beta.
  • Live Proof Route (/proof): Standalone verification page executing live endpoint re-queries and documenting 6 automated negative rejection proofs.

The Problem & The Edge

Traditional equity markets close at 4:00 PM ET on Friday and do not open until 9:30 AM ET Monday - a 65-hour information blackout.

Tokenized equities on Solana trade 24 hours a day, 7 days a week.

When real-world news or private funding events break over the weekend:

  1. On-chain DEX prices drift from traditional reference and fair-value marks.
  2. Liquidity thins, causing high slippage and volatility spikes.
  3. Retail portfolios face unseen exposure risk without automated guardrails.

AfterHours bridges this gap: It monitors divergence in real time, routes the best execution path, applies deterministic risk limits, and requires human cryptographic sign-off before executing on Solana.

The AI interprets. The Governor enforces. The human approves. Solana settles.


System Architecture

                        AFTERHOURS PROTOCOL
                                 │
                                 ▼
                        ┌──────────────────┐
                        │   TRADE INTENT   │
                        │   BUY $1K NVDA   │
                        └────────┬─────────┘
                                 │
                                 ▼
                     MARKET GAP & DISCOVERY
                                 │
                ┌────────────────┼────────────────┐
                ▼                ▼                ▼
            PRESTOCKS       PYTH ORACLE      JUPITER DEX
         Fair Value Mark    Equity Feed    DEX Liquid Quote
                │                │                │
                └────────────────┼────────────────┘
                                 ▼
                        PRICE INTELLIGENCE
                       (Spread, Gap %, Vol)
                                 │
                                 ▼
                           ROUTE ENGINE
                        (Select Best Venue)
                                 │
                                 ▼
                       RISK GOVERNOR ENGINE
                    ┌────────────┴────────────┐
                    │                         │
                  PASS                      BLOCK
                    │                         │
                    ▼                         ▼
             USER APPROVAL            ADJUST OR REJECT
          (Human in the loop)       (Cap: 35%, Max: $1.5k)
                    │
                    ▼
          SOLANA ON-CHAIN EXECUTION
         (SPL Memo Attestation Tx)
                    │
                    ▼
          VERIFIABLE ON-CHAIN RECEIPT
           (Solscan Explorer Link)

Features

1. Market Discovery (/markets)

Live dashboard tracking 8 pre-IPO equities with live mark valuation, on-chain price, dollar gap, and percentage divergence with verified source tags (● LIVE · PRESTOCKS).

2. Gap Radar (/gaps)

Public, wallet-free 24/7 gap monitor showing real-time divergence between PreStocks fair value and on-chain DEX prices, ranked by magnitude with regime classification and 30-second auto-refresh.

3. Live Verification Suite (/proof)

Dedicated transparency surface performing real-time endpoint re-queries, showing on-chain SPL Memo schemas, and documenting deterministic negative tests.

4. Route Engine

Compares PreStocks DEX pricing against Jupiter DEX quotes, calculating price impact, fees, and effective price per token.

5. Deterministic Risk Governor

The AI Analyst is strictly advisory. The mathematical risk evaluation is 100% deterministic:

  • Max Single-Asset Exposure: 35% of total portfolio.
  • Max Single Trade: $1,500 USD.
  • Min USDC Reserve: 10% liquidity floor.
  • Max Daily Drawdown: 3%.
  • Human-in-the-Loop: 100% of trades require explicit wallet signature.

6. Solana Settlement

Dual-mode execution supporting both real wallet connections (Phantom, Solflare) on Solana Mainnet-Beta and instant single-click demo simulations for reviewers.


Tech Stack

Layer Technologies Purpose
Frontend Next.js 15 (App Router), React 19, TypeScript High-performance dashboard with ISR (30s cache)
Styling Vanilla CSS Design System, Solana & Pyth Palettes Terminal aesthetic, high-contrast accessible buttons
Backend API Hono, Node.js Low-latency REST API (:8787) with security headers
Blockchain @solana/web3.js, @solana/wallet-adapter Solana Mainnet-Beta connection, SPL Memo transaction assembly
Data & Oracles PreStocks API, Pyth Network Hermes Live pre-IPO token feeds and equity price feeds
Testing Vitest, ESLint, TypeScript compiler 79 unit, integration, and security regression tests

Quick Start

Prerequisites

  • Node.js >= 20.0.0
  • pnpm >= 9.0.0

1. Clone & Install

git clone git@github.com:Tajudeeen/afterhour.git
cd afterhour
pnpm install

2. Configure Environment

cp .env.example .env

(Optional: Set PYTH_HERMES_API_KEY for live Pyth Hermes equity updates, or OPENAI_API_KEY for live LLM completions. Both have robust fallback modes).

3. Run Verification Gate

pnpm run verify

Runs lint, TypeScript typechecking, all 79 tests, and Next.js production build.

4. Start Local Development

pnpm dev
  • Web UI: http://localhost:3000
  • API Server: http://localhost:8787

Deterministic Negative Proofs

A production risk system is defined by the dangerous operations it rejects. AfterHours tests and proves fail-closed behavior across four critical vectors:

  1. Exposure Cap Violation: Rejects orders that would push portfolio asset concentration above 35%. Returns REJECTED: Portfolio exposure cap exceeded. Zero gas spent.
  2. Order Size Ceiling: Orders larger than $1,500 are blocked or clamped down to the policy maximum, preventing rogue or fat-finger executions.
  3. Unauthenticated Execution: Any execution request sent without a valid cryptographic signature returns HTTP 401 Unauthorized.
  4. Oracle Staleness Lockout: If feed timestamps exceed 120 seconds, the asset is tagged PYTH STALE and receives an automatic risk penalty.

Known Limitations & Boundaries

In alignment with honest engineering standards, current boundaries are disclosed openly:

  • On-Chain Attestation Scope: Real transactions sign and commit to Solana (Mainnet-Beta by default) via the SPL Memo program. Tokenized stock liquidity pools are experimental-scale.
  • PreStocks Rate Limiting: The PreStocks API is cached using Next.js ISR (30-second stale-while-revalidate window) to maintain high availability and stay within upstream limits.
  • In-Memory Portfolio State: Demo portfolio states are maintained in-memory on the API server for hackathon evaluation; PostgreSQL schema definitions are packaged in packages/db.

Repository Layout

afterhours/
├── apps/
│   ├── web/                     # Next.js 15 App Router frontend (Dashboard, Gap Radar, Markets, Proof, Action)
│   └── api/                     # Hono REST backend API (:8787)
├── packages/
│   ├── types/                   # Shared TypeScript interfaces & schemas
│   ├── config/                  # Environment variable configuration
│   ├── market-engine/           # Gap detection, regime memory, risk score computation
│   ├── risk-engine/             # Deterministic Risk Governor policy engine
│   ├── agent/                   # AI Analyst prompting & structured reasoning
│   ├── solana/                  # Solana connection, SPL Memo execution, asset registry
│   └── db/                      # Database models & Prisma configuration
├── docs/                        # Architecture decisions (ADRs) & contest audits
├── CHANGELOG.md                 # Project iteration log
├── TASKS.md                     # Milestone tracking
└── package.json                 # Monorepo root scripts

License

MIT (c) 2026 AfterHours

About

24/7 intelligence for tokenized stocks on Solana

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages