Skip to content

williamfanofficial-crypto/Universe

Repository files navigation

Universe — Solana Mobile DApp + AI Telegram Bot

On-chain RWA trading for Android. Trade tokenized stocks, commodities, forex, and crypto from your phone via Drift Protocol + Jupiter, powered by Pyth price feeds and x402 micropayments — now with a fully autonomous OpenClaw AI Telegram bot you control with your own API key.

Solana MWA x402 Drift Jupiter Pyth OpenClaw Expo

Publish target: Solana dApp Store + Google Play Store


What It Does

  • Trade any asset on-chain — tokenized stocks (AAPL, TSLA, NVDA), commodities (Gold, Oil), forex (EUR/USD), and crypto (BTC, ETH, SOL) via Drift Protocol perpetuals
  • Mobile Wallet Adapter — connects to Phantom, Solflare, Backpack, and any MWA-compatible wallet. Keys never leave the device
  • Live Pyth prices — real-time feeds refreshed every 3 seconds via Hermes REST API
  • x402 premium data — pay $0.001 USDC micropayments for Corbits aggregated price signals and optimal trade routing
  • Hardware wallet support — Ledger via Bluetooth; Trezor via watch-only + QR signing
  • Biometric auth — fingerprint / Face ID required before every transaction
  • OpenClaw AI Telegram bot — connect your personal Telegram bot to the full platform. Trade, monitor prices, and set autonomous strategies entirely from Telegram using your own AI key

AI Telegram Bot (OpenClaw Integration)

Universe now ships a self-contained bot server that gives every user a personal, private AI trading assistant on Telegram — powered by their own OpenAI or Anthropic API key.

How it works

┌─────────────────────────────────────────────────────────────────────┐
│  Universe App  ──▶  Bot Server  ──▶  OpenClaw Gateway (per user)   │
│  [🤖 Bot tab]                            │                          │
│                                          ├──▶  Telegram Bot         │
│                                          ├──▶  AI Agent (user key)  │
│                                          ├──▶  Pyth Prices          │
│                                          ├──▶  Drift / Jupiter      │
│                                          └──▶  Autonomous Scheduler │
└─────────────────────────────────────────────────────────────────────┘

Setup (3 steps)

  1. Get an AI API keyOpenAI or Anthropic
  2. Create a Telegram bot — open @BotFather, send /newbot, copy the token
  3. Open the 🤖 Bot tab in the Universe app, enter your key + token, tap Launch My Bot

Your personal bot is live instantly. Open it in Telegram and send /start.

Privacy guarantee: Your API key is transmitted over HTTPS and held only in server RAM (24 h TTL). It is never written to any database, log file, or disk.

Telegram Commands

Command Description
/price BTC Live price from Pyth Network
/price AAPL Stock price, any supported asset
/markets crypto Market overview (crypto / stocks / forex / commodities)
/trade long ETH 500 3x Open a leveraged position via Drift
/trade short AAPL 1000 Short a tokenized stock
/portfolio Open positions and P&L
/balance Wallet SOL + USDC balance
/alert BTC above 70000 One-shot price alert → Telegram notify
/auto add dca SOL 100 every 24h Dollar-cost average on a schedule
/auto add stop_loss TSLA below 200 Auto-close if price falls
/auto add take_profit ETH above 4000 Auto-close at profit target
/auto enable Switch to fully autonomous (bot-signed) trading
/auto disable Revert to notify-only mode
/auto rules List active automation rules
/auto clear Remove all rules
/status Bot + OpenClaw gateway status
/help Full command reference

Natural language is also supported — just chat with your bot:

"What's the price of gold right now?" "Buy $200 of ETH with 2x leverage" "Set a stop loss on AAPL if it drops below $180"

Autonomous Trading Modes

Mode How it works
Notify-only (default) Alerts sent to Telegram; user confirms trades in the app
Autonomous (/auto enable) Bot signs and submits trades directly (hot-wallet optional)

Tech Stack

Layer Technology
Framework React Native + Expo 51
Navigation Expo Router
Wallet Solana Mobile Wallet Adapter (MWA) v2
Blockchain @solana/web3.js + @coral-xyz/anchor
Prices Pyth Network (Hermes REST)
Trading Drift Protocol (perpetuals) + Jupiter (swaps)
Payments x402 protocol — USDC SPL micropayments
Premium data Corbits Ride-or-Die API
State Zustand + TanStack Query
Security expo-secure-store + expo-local-authentication
Bot Runtime OpenClaw (self-hosted AI gateway)
Bot Messaging grammY (Telegram Bot API)
AI Providers OpenAI GPT-4o / Anthropic Claude
Bot Server Node.js + Express + TypeScript

Project Structure

universe-dapp/
├── App.tsx                        # Root app + bottom tab navigation (5 tabs)
├── app.json                       # Expo config (Android package, permissions, deep links)
├── package.json
├── tsconfig.json
│
├── server/                        # Bot Server — OpenClaw + Telegram integration
│   ├── package.json
│   ├── tsconfig.json
│   ├── .env.example
│   └── src/
│       ├── index.ts               # Express server entry point
│       ├── config.ts              # Environment configuration
│       ├── types.ts               # Shared TypeScript interfaces
│       ├── services/
│       │   ├── sessionService.ts  # In-memory API key store (24 h TTL, never on disk)
│       │   ├── openclawBridge.ts  # Per-user OpenClaw gateway manager
│       │   ├── botManager.ts      # grammY bot factory + all /commands + NLP
│       │   ├── aiService.ts       # OpenAI / Anthropic SDK (uses caller's key)
│       │   ├── tradingService.ts  # Drift Protocol + Jupiter trade execution
│       │   └── priceService.ts    # Pyth Hermes price feed (30 s cache)
│       ├── handlers/
│       │   └── autonomousHandler.ts  # Cron-based alerts, DCA, stop-loss
│       └── routes/
│           └── api.ts             # REST API + OpenClaw internal skill endpoints
│
└── src/
    ├── screens/
    │   ├── HomeScreen.tsx              # Dashboard: wallet balance + live Pyth prices
    │   ├── TradeScreen.tsx             # Trade flow: market → asset → side → size → confirm
    │   ├── WalletScreen.tsx            # MWA connect, Ledger, watch-only
    │   ├── PortfolioWalletsScreen.tsx  # Non-custodial wallets: create, import, swap (NEW)
    │   ├── X402Screen.tsx              # x402 premium features (Corbits)
    │   └── BotScreen.tsx               # AI Bot setup + status (NEW)
    ├── hooks/
    │   ├── useWallet.ts           # MWA wallet adapter hook
    │   ├── usePyth.ts             # Pyth price feed hook (Hermes REST)
    │   └── useX402.ts             # x402 micropayment hook
    ├── services/
    │   ├── x402.ts                # X402Client + CorbitsClient
    │   └── botService.ts          # Bot server REST client (NEW)
    ├── components/
    │   └── AssetCard.tsx          # Animated price card with flash on update
    └── utils/
        ├── solana.ts              # RPC connections, xStocks mints, helpers
        ├── format.ts              # Price formatting, asset emojis
        └── theme.ts               # Design tokens (colors, spacing, radius)

Getting Started

Prerequisites

  • Node.js 18+
  • Expo CLI: npm install -g expo-cli
  • EAS CLI: npm install -g eas-cli
  • Android device or emulator with a Solana wallet app installed (Phantom, Solflare, etc.)

Install

# Mobile app dependencies
npm install

# Bot server dependencies
cd server && npm install

Run (development)

# Start the bot server (terminal 1)
cd server && npm run dev

# Start Metro bundler (terminal 2)
npm start

# Run on connected Android device (terminal 2)
npm run android

Bot server environment

Copy server/.env.example to server/.env and set:

PORT=3001
SOLANA_NETWORK=mainnet-beta
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
SESSION_ENCRYPTION_KEY=<64-char hex>   # node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

No AI API keys go in .env — users supply their own keys through the app at runtime.

Build for Android

# Preview APK (internal testing / sideload)
npm run build:android:preview

# Production AAB (Play Store + Solana dApp Store)
npm run build:android

Submit to store

# Google Play Store via EAS Submit
npm run submit:store

Screens

Home

Dashboard showing wallet balance, SOL holdings, and live Pyth prices for BTC, ETH, SOL, AAPL, TSLA, Gold, and EUR/USD. Pull to refresh.

Trade

Step-by-step flow:

  1. Select market category (Stocks / Commodities / Forex / Crypto)
  2. Select specific asset
  3. Choose Long or Short
  4. Enter USD size — quick-select buttons: $100 / $500 / $1000 / $5000
  5. Set leverage (up to 20x for crypto/forex, 10x for stocks/commodities)
  6. Review order summary and confirm — signed via MWA with biometric auth

Wallet (MWA)

Mobile Wallet Adapter integration for signing trades:

  • Mobile Wallet Adapter (recommended) — Phantom, Solflare, Backpack, etc.
  • Ledger — hardware wallet via Bluetooth
  • Watch-only — import any Solana public key for read-only monitoring

Wallets (Universe Non-Custodial)

NEW: Native multi-chain wallet management for saving trading profits:

  • Create new wallets — secure mnemonic generation on-device
  • Import wallets — bring your own Bitcoin, Ethereum, Solana, or Monero wallets
  • Multi-chain support — manage Bitcoin, Ethereum, Solana, and Monero in one app
  • Live balances — real-time balance sync with USD valuation
  • Cross-chain swaps — move assets between blockchains with optimal routing
  • Non-custodial — all private keys encrypted and stored locally, Universe never holds custody
  • Biometric auth — fingerprint / Face ID required before any transaction

x402 Premium

Access Corbits premium data paid with USDC micropayments:

  • Aggregated price signals (multiple DEX sources) — $0.001 USDC per call
  • Live order book depth — $0.001 USDC
  • Optimal trade routing (minimises slippage) — $0.005 USDC

Bot (NEW)

Personal AI Telegram bot setup:

  • Choose AI provider (OpenAI / Anthropic)
  • Enter your API key (held in RAM only, never stored)
  • Enter Telegram bot token from @BotFather
  • Tap Launch — bot is live instantly
  • Running view shows bot status, OpenClaw gateway state, active automations, and a quick-command reference

x402 Protocol Flow

Client → Request → Server
           ↓
        402 Payment Required
        PAYMENT-REQUIRED: base64(PaymentRequired)
           ↓
Client builds USDC transfer tx on Solana
Signs via MWA (keys stay in wallet app)
           ↓
Client → Retry Request + PAYMENT-SIGNATURE header
           ↓
Server verifies via x402 facilitator
           ↓
200 OK + resource data + PAYMENT-RESPONSE
// Automatic 402 → pay → retry handled by X402Client
const client = new X402Client(publicKey, 'mainnet-beta');
const result = await client.get('/v1/prices/premium');

Non-Custodial Wallets

Universe includes native multi-chain wallet management built with industry-standard cryptography, allowing users to create and manage private wallets across multiple blockchains directly within the app.

Features

Create & Import

  • Generate new wallets with BIP39 mnemonics for Bitcoin, Ethereum, Solana, and Monero
  • Import existing wallets via private key
  • Manage multiple wallets per blockchain
  • Friendly aliases for easy identification

Portfolio Management

  • View all wallets in one dashboard, organized by chain
  • Live balance sync with real-time USD valuation
  • Transaction history per wallet
  • Quick actions: view on explorer, delete wallet

Save Trading Profits After a successful trade, users can immediately withdraw profits to their non-custodial wallets:

  1. Tap "Save Profit to Wallet"
  2. Select destination blockchain
  3. Choose or create target wallet
  4. Enter amount (or use % presets: 25%, 50%, 75%, 100%)
  5. Review estimated output and fees
  6. Confirm with biometric auth
  7. Monitor swap execution in real-time

Cross-Chain Swaps

  • Swap assets between Bitcoin, Ethereum, Solana, and Monero
  • Automatic routing through best providers (Jupiter, Wormhole)
  • Transparent fee breakdown
  • Real-time status monitoring

Security Guarantees

  • ✅ Private keys never leave the device — encrypted with AES-256 and stored locally
  • Biometric authentication required before every transaction
  • Non-custodial — Universe holds no keys or funds
  • No central server — wallets persist only on-device via expo-secure-store
  • ✅ Full on-chain audit trail on each blockchain

Supported Assets

Blockchain Support Decimals
Bitcoin BTC 8
Ethereum ETH, USDC, DAI 18
Solana SOL, USDC, USDT 9
Monero XMR 12

Security

Mobile App

  • Private keys never stored in the app — all signing delegated to MWA wallet
  • Biometric authentication (fingerprint / Face ID) required before every transaction
  • expo-secure-store (AES-256) for persisting wallet public key only
  • Squads v4 multisig compatible for shared/DAO wallets
  • Full on-chain audit trail on Solana

Bot Server

  • AI API keys held only in Node.js heap memory — never written to disk, database, or logs
  • Sessions expire after 24 hours; keys are zeroed in memory on expiry or disconnect
  • OpenClaw config files written to OS temp dir and deleted when the session ends
  • HTTPS enforced for all mobile ↔ server communication
  • Rate limiting (60 req/min per IP) on all REST endpoints
  • Helmet.js security headers on every response
  • Input validated with Zod schemas before any processing

Supported Assets

Category Symbols
Crypto BTC, ETH, SOL, BNB, AVAX
Stocks AAPL, TSLA, MSFT, NVDA, SPY
Commodities XAU (Gold), XAG (Silver), WTI (Oil)
Forex EUR/USD, GBP/USD, USD/JPY

Publishing Checklist

Solana dApp Store

  • Solana Mobile Wallet Adapter (MWA v2)
  • x402 protocol with USDC micropayments
  • Biometric auth for all transactions
  • Non-custodial (keys stay in MWA wallet apps)
  • OpenClaw AI Telegram bot integration
  • EAS Build — production AAB
  • App icon + splash screen assets
  • Store listing + screenshots
  • Submit via Solana dApp Store

Google Play Store

  • Sign APK with upload keystore
  • Privacy policy URL
  • Submit via Google Play Console or eas submit

References

About

Universe, the trading bot & non-custodial wallet on Solana Mobile/Android

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors