Trend-to-Trade Execution System
Every headline has a market, and every opinion deserves a position.
Capacitr now runs as one unified app surface for discovery, market context, and trade execution intent. Discovery still starts in feed + markets, but execution is moving into app.capacitr.xyz with wallet onboarding, funding rails, and venue-specific order flows.
Thesis: Signal-to-Position
The Problem
Markets exist everywhere — prediction markets, perpetual futures, options — but finding the right market at the right time is still manual, fragmented work. A trader who follows AI policy news has to manually search Polymarket for relevant prediction markets, check HyperLiquid for NVIDIA perps, and scan Deribit for options plays.
The information that drives trading decisions — trending topics, breaking news, social sentiment, expert chatter — lives in completely different places than the markets themselves. Nobody connects them.
The Insight
Every tradeable market is downstream of a real-world narrative. "Will the Fed cut rates?" is a Polymarket prediction, a BTC perpetual trade, and a set of Treasury options all at once. The narrative is the root. The markets are leaves on the same tree.
If you know what someone cares about and you can see what the world is talking about right now, you can surface exactly the markets that matter to them, ranked by:
Does this market match their interests and expertise?
Is there enough depth to take a meaningful position?
Are people talking about this with increasing intensity?
Is the conversation bullish, bearish, or uncertain?
How much mainstream press is covering this narrative?
Is this breaking right now or fading?
The Product
Capacitr is the bridge between signals and positions.
Poll X, Reddit, Farcaster, news APIs, Google Trends, and crypto feeds continuously. Extract trending narratives.
LLM analysis categorizes, summarizes, and extracts tradeable entities. "NVIDIA earnings beat" connects to an NVIDIA perp, a semiconductor option, and a prediction market about AI chip exports.
For every narrative, surface positions across three market types:
Interests, social graph, and engagement patterns continuously refine what surfaces. The feed gets sharper over time.
Every feed card shows the narrative AND matching markets with live prices, volume, and entry points. Read a story, evaluate the trade — same view.
Who It's For
Want to trade narratives, not just charts. See a tweet, take a position.
Want relevant markets surfaced to them instead of browsing thousands.
Policy wonks, sports analysts, tech insiders — deep domain knowledge, no time to hunt for matching markets.
Fastest path from "I just saw this tweet" to "I have a position on this."
The Moat
The value compounds. As users engage — clicking, expanding, trading — Capacitr learns which signal-to-market connections actually convert. The matching algorithm improves. The feed sharpens. The proprietary dataset of "which narratives drive which markets" becomes a unique asset that no individual exchange or news platform has.
Product Scope
Enter the terminal. Paste a link to an X post or news article. System scrapes content, analyzes with LLM, returns matched Polymarket predictions + HyperLiquid perps. No auth required.
React Native app. Privy auth with social login. Calibrate the terminal to show markets that matter to you. Auto-generated trending feed with market overlays. Social data enrichment from X and Farcaster.
System Architecture
Tech Stack
| Layer | Technology | Rationale |
|---|---|---|
| Mobile Client | React Native (Expo) | Cross-platform, Privy RN SDK support |
| Web Client | Next.js | Prototype-first, SSR for SEO |
| API Server | Node.js + Hono | Fast, typed, edge-compatible |
| Database | PostgreSQL (Supabase) | Managed, real-time subscriptions |
| Cache / Queue | Redis (Upstash) + BullMQ | Serverless Redis, reliable job queues |
| LLM | GPT-4o / 4o-mini | Best cost/quality for classification |
| Image Gen | DALL-E 3 / Flux | Editorial illustrations for feed cards |
| Hosting | Vercel + Fly.io | Vercel for web, Fly for API workers |
Polymarket Trading Integration Plan (App-Native)
Polymarket trading requires user-signed orders (non-custodial). Builder attribution is attached per order via builderCode. Authentication for trading is two-layer: L1 wallet signature for API credential derivation, then L2 HMAC headers for CLOB requests.
Source: Polymarket docs — builder overview + CLOB auth/signature model.
Execution Architecture
Route markets/discovery clicks into app.capacitr.xyz/trade?venue=polymarket&market=... so trade intent is preserved.
Privy wallet is user identity. Use deposit-wallet flow for new API users (recommended: POLY_1271, signature type 3), with funderAddress set to deposit wallet.
Use user wallet signature (L1) to create/derive CLOB API creds, then persist encrypted L2 creds (api key/secret/passphrase) server-side.
Guide user through gasless relayer/deposit wallet operations, check balances + allowances before enabling submit.
Create EIP-712 signed order payload and submit to CLOB with builderCode attached on every order.
Track fills/positions in Capacitr ledger and reconcile builder-attributed volume for leaderboard + internal analytics.
Builder Program Requirements (Engineering Checklist)
| Item | Requirement | Why It Matters |
|---|---|---|
| Builder profile | Create builder profile and register builder code in Polymarket settings. | Enables volume attribution and program benefits. |
| Order attribution | Attach builderCode to every submitted order. | Only attributed orders count toward builder volume. |
| Wallet mode | New API users should use deposit-wallet flow + signature type 3 (POLY_1271). | Best path for gasless ops and current recommended integration. |
| Auth model | L1 (wallet signature) + L2 (HMAC headers) both required for trading. | Prevents failed order submissions and auth drift. |
| Signing ownership | User still signs order payloads even with L2 headers. | Non-custodial guarantee and compliance with protocol model. |
Readiness State Machine (User UX)
Capacitr Services to Implement
Builds and stores intent from discovery deep links (market, side, size, source surface).
Manages Privy wallet binding, deposit-wallet provisioning state, and signature type metadata.
Handles L1 API key derivation and encrypted L2 credential lifecycle (rotate/recover/revoke).
Creates/sends signed CLOB orders, injects builderCode, tracks order lifecycle, and handles retries/idempotency.
Pre-trade checks for market status, liquidity, slippage, max size, and user exposure limits.
Canonical records for orders/fills/positions + builder volume telemetry for leaderboard reconciliation.
API Surfaces Used
| Surface | Use Case |
|---|---|
gamma-api.polymarket.com | Public discovery/search/events/markets metadata. |
clob.polymarket.com | Authenticated order placement/cancel/query with L2 headers. |
data-api.polymarket.com | Trades, open interest, and market analytics enrichment. |
builder-relayer client | Gasless deposit-wallet deployment + wallet batch operations. |
Rollout Plan
Quotient Intelligence
AI-computed fair odds for Polymarket markets — q-api.quotient.social · Auth: x-quotient-api-key header
What It Does
Quotient provides AI-computed fair odds for Polymarket markets, identifying mispriced opportunities where the market price diverges from the model's estimated probability. Markets with >5% edge get orange badges showing the spread, direction, and a BLUF (Bottom Line Up Front) analysis.
API Endpoints
| Endpoint | Purpose | Key Params |
|---|---|---|
GET /api/v1/markets/mispriced | Batch mispriced markets with spread, direction, BLUF analysis | — |
GET /api/v1/markets/lookup | Lookup specific market by slug or condition_id | slug, condition_id |
Response Fields
| Field | Type | Description |
|---|---|---|
question | string | Market question text |
slug | string | Polymarket market slug |
quotient_odds | number | AI-computed fair probability |
market_odds | number | Current Polymarket price |
spread | number | Absolute difference between Q odds and market odds |
spread_direction | string | q_higher or q_lower |
bluf | string | Bottom Line Up Front — reasoning summary |
signal_count | number | Number of signals informing the estimate |
volume_24h | number | 24-hour trading volume |
Integration Flow
Per-query fetch from /api/v1/markets/mispriced with API key header
Match mispriced markets to user search/feed topics via keyword overlap
Merge into predictions array, sorted by spread descending. Markets with >5% edge get orange badges
Badge shows "32% EDGE — BUY NO" with BLUF analysis text
Used In
Hyperliquid Trading Integration Plan (App-Native)
Builder codes are fee attribution, not custody delegation. Capacitr should not place all user trades from a single house wallet. User wallet remains the trading identity. Capacitr orchestrates flow, UX, and attribution.
Source: Hyperliquid docs — /trading/builder-codes, /for-developers/api/exchange-endpoint.
Execution Architecture
Replace external Hyperliquid link-outs from markets with app deep links: app.capacitr.xyz/trade?venue=hyperliquid&coin=BTC&side=buy&size=....
Privy wallet create/connect. Treat that address as user Hyperliquid identity. No separate custodial account provisioning.
Fast path: already funded perps collateral. Fallback path: fund Capacitr wallet → bridge/swap to USDC on Arbitrum → deposit to Hyperliquid perps account.
One-time ApproveBuilderFee per user + builder address, signed by user main wallet (not agent/API wallet).
Submit signed order via Hyperliquid exchange endpoint with optional builder field: {"b":"builder_address","f":10} (10 = 1 bp).
Persist order/fill state internally, query referral state, and backfill builder fills for analytics + revenue reconciliation.
Builder Code Semantics (What Engineering Must Implement)
| Item | Requirement | Why It Matters |
|---|---|---|
| Builder approval | User must sign ApproveBuilderFee from main wallet. | Without this, builder fees cannot be charged or attributed. |
| Order payload | Include optional builder: {"b": address, "f": number}. | Per-order flexibility and explicit fee selection. |
| Fee bounds | Perps max builder fee is 0.1% (docs). | Prevent invalid orders and trust issues. |
| Builder account constraints | Builder address must have at least 100 USDC perps account value and standard account abstraction mode. | Required for production reliability. |
| Approval limits | User can have max 10 active builder approvals. | UI should manage approval slots and revocation. |
Readiness State Machine (User UX)
Backend Services (Capacitr App)
Parses deep-link params from discovery surfaces and creates resumable trade intent records.
Queries user account readiness, balances, open orders, and margin status by wallet address.
Checks maxBuilderFee, manages fee presets, and tracks approval state per user.
Builds order actions, enforces guardrails, submits orders, and maps Hyperliquid statuses into app status enums.
Coordinates wallet funding, bridge/swap into USDC on Arbitrum, and perps deposit status transitions.
Canonical internal record for every order/fill, builder fee attribution, and execution funnel conversion.
API Surfaces Used
Rollout Plan
Options Platforms
Third market type: crypto options. Asymmetric risk/reward and volatility exposure. All read endpoints free, no auth.
Deribit — Gold Standard (~90% of Crypto Options Volume)
www.deribit.com/api/v2 · CEX · 20 req/sec unauthed
| Endpoint | Returns |
|---|---|
GET /public/get_instruments?currency=BTC&kind=option | All BTC options (strike, expiry, type) |
GET /public/ticker?instrument_name={name} | Price, IV, greeks, OI, volume, bid/ask |
GET /public/get_order_book?instrument_name={name} | Full orderbook |
GET /public/get_book_summary_by_currency?currency=BTC&kind=option | Summary of ALL BTC options |
GET /public/get_historical_volatility?currency=BTC | Historical volatility |
TICKER DATA INCLUDES: mark_price, mark_iv (implied vol %), greeks (delta, gamma, vega, theta, rho), open_interest, bid/ask, volume_24h, underlying_price
INSTRUMENT FORMAT: BTC-28MAR25-80000-C (asset-expiry-strike-type)
Aevo — Hybrid DEX (OP Stack L2)
api.aevo.xyz · DEX · ~100 req/min
| Endpoint | Returns |
|---|---|
GET /markets?asset=BTC&instrument_type=OPTION | All BTC options markets |
GET /orderbook?instrument_name={name} | Full orderbook |
GET /index?asset=BTC | Current index/spot price |
GET /statistics | Exchange-wide OI and volume |
Derive — DEX (Formerly Lyra V2)
api.derive.xyz · DEX · ~10 req/sec · Mirrors Deribit API design
| Endpoint | Returns |
|---|---|
GET /public/get_instruments?currency=BTC&kind=option | List options (Deribit-style) |
GET /public/get_ticker?instrument_name={name} | Price, IV, greeks, OI |
GET /public/get_order_book?instrument_name={name} | Full orderbook |
Why Options Matter for Capacitr
Each market type answers a different question about the same narrative:
"Will X happen?" — Binary outcome
"Which direction?" — Directional exposure
"How volatile?" — Asymmetric risk, defined downside
Example: "Fed rate decision tomorrow" →
Polymarket: "Will Fed cut rates?" (68% Yes)
HyperLiquid: BTC-PERP (directional bet)
Deribit: BTC options at nearest expiry (volatility play, defined risk)
Other Platforms Evaluated
| Platform | Type | Status | Verdict |
|---|---|---|---|
| OKX Options | CEX | Active | Good supplementary API — /public/opt-summary with greeks/IV |
| Delta Exchange | CEX | Active | Smaller CEX, decent REST API |
| Premia Finance | DEX | Subgraph only | No REST API — requires GraphQL |
| Hegic | DEX | Low volume | Subgraph only, declining usage |
| Opyn / Squeeth | DEX | Deprecated | Wound down late 2024 |
| Zeta Markets | DEX | Pivoted | Solana — pivoted to perps only |
X / Twitter API
10K tweet reads/mo, search recent, single tweet fetch. Sufficient for link-drop and limited search.
⚠ TRENDING TOPICS = PRO TIER ($5,000/MO)
SocialData.tools: $49/mo — full Twitter-like API, no rate pain.
Apify scrapers: Pay-per-use — scraper actors for tweets and trends.
Link Drop: Tweet Extraction
News & Article Scraping
News Aggregation APIs
| API | Free Tier | Endpoint | Best For |
|---|---|---|---|
| NewsAPI.org | 100 req/day | /v2/top-headlines?category= | Headlines by category |
| GNews.io | 100 req/day | /api/v4/top-headlines | Backup source |
| CryptoPanic | Free w/ key | /api/v1/posts/?filter=hot | Crypto + sentiment |
| CoinGecko | 30 req/min | /api/v3/search/trending | Trending coins |
Article Content Extraction
https://r.jina.ai/{url} — returns clean markdown. Handles JS rendering, anti-bot. Zero config.
Self-host Mozilla Readability for speed. Firecrawl API (generous free tier) for complex pages.
Trend Sources
| Source | Endpoint | Auth | Cost |
|---|---|---|---|
| Google Trends | serpapi.com/google-trends-api | API key | Free 100/mo |
GET /r/{sub}/hot.json | Optional | Free | |
| Farcaster | api.neynar.com/v2/farcaster/feed/trending | API key | Free 300 req/min |
| Hacker News | hn.algolia.com/api/v1/search | None | Free |
| CoinGecko | api.coingecko.com/api/v3/search/trending | Optional | Free 30 req/min |
| DeFi Llama | api.llama.fi/protocols | None | Free |
Farcaster via Neynar
Privy Authentication
Single SDK. Social + wallet auth. Web and React Native.
Supported Login Methods
Data Returned Post-Auth
Privy returns identity (username, pfp) but NOT social graph (followers, interests, liked posts). Workaround:
• Farcaster: Neynar API with FID → follower graph + activity
• X: Bearer token → public timeline (limited on Basic)
Database Schema
7 tables. PostgreSQL. Users, content, and market data.
id · privy_id · display_name · avatar_url
x_username · x_user_id
farcaster_fid · farcaster_username
created_at · updated_at
id · user_id (FK)
category [crypto|politics|sports|ai|...]
weight (adjustable via engagement)
id · source · category · title · summary
image_url · source_url · source_data (JSONB)
keywords[] · entities[]
relevance_score · expires_at
id · source [polymarket|hyperliquid]
external_id · market_type [prediction|perp]
title · category · current_price
volume_24h · open_interest · metadata (JSONB)
id · topic_id (FK) · market_id (FK)
match_score (0-1)
match_reason (LLM explanation)
id · user_id (FK) · topic_id (FK)
position · seen · engaged
created_at
id · url (unique) · content_type [tweet|article] · title · body_text · author · keywords[] · entities[] · summary
API Endpoints
Auth & Users
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| POST | /api/auth/verify | — | Verify Privy JWT, upsert user |
| GET | /api/users/me | Bearer | Current user + interests |
| PUT | /api/users/me/interests | Bearer | Set interest categories |
| POST | /api/users/me/enrich | Bearer | Fetch social data, infer interests |
Link Drop — Scrape & Match
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| POST | /api/scrape | Optional | Scrape URL → text, keywords, entities |
| POST | /api/match | Optional | Keywords/entities → matched markets |
| POST | /api/analyze-link | Bearer or Skill Key | Combined scrape + match; reserves one quota unit before analysis (default 5/day UTC) |
Feed
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| GET | /api/feed?page=&limit=&category= | Bearer | Personalized feed with markets |
| GET | /api/feed/refresh | Bearer | Force-refresh |
Markets — Direct Query
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /api/markets/polymarket/trending | Top predictions by volume |
| GET | /api/markets/polymarket/search?q= | Search predictions |
| GET | /api/markets/hyperliquid/assets | All perps with prices |
| GET | /api/markets/hyperliquid/:coin | Detailed perp data |
Background Jobs
5 pipelines. BullMQ on Redis. Continuous charge cycle.
01. Trend Polling — Every 15 Min
Parallel fetch from all sources:
Dedup via fuzzy title match (Levenshtein < 0.3). Classify via GPT-4o-mini. Store in trending_topics.
02. Summarize + Image Gen
GPT-4o writes 2-3 sentence summary. Extracts keywords. DALL-E 3 generates editorial illustration per feed card.
03. Market Matching
Search Polymarket by keywords/entities. Map HyperLiquid assets via entity→ticker lookup. LLM scores relevance 0-1. Keep > 0.5.
04. Price Refresh — Every 5 Min
Batch update cached market prices. Polymarket via CLOB endpoint. HyperLiquid via single allMids call.
05. Feed Generation — Every 30 Min
Per-user: filter by interests, join market matches, rank, apply diversity rules.
MiroShark Integration
Capacitr is built on / using MiroShark as its social and prediction-market simulation layer. When a user finds a tradeable narrative in Capacitr, the app can convert that market thesis into a MiroShark-native simulation prompt, submit it through MiroShark's x402 run endpoint, track the upstream job, and surface the hosted report when the simulation completes.
- Prompt enrichment: Capacitr expands terse trade cards into richer social-market scenarios, preserving source context such as scraped article text, entities, keywords, tickers, categories, trade direction, position vehicle, horizon, and risk framing.
- x402 job launch: enriched prompts are sent to MiroShark's paid
/x402/runflow. Capacitr stores the upstream payload and IDs so simulations can be audited and debugged. - Status tracking: Capacitr polls MiroShark status JSON while keeping user-facing UI focused on progress, unread report notifications, and completed simulation summaries.
- Report handoff: when MiroShark returns a hosted
share_url, Capacitr links users to that report instead of exposing raw status endpoints as final results.
Structured market thesis, source context, entities, sentiment, proposed trade type, direction, size, and horizon.
TRADE THESIS SOURCE CONTEXT SCENARIO PROMPTSimulation status, hosted report URL, summary metadata, and notification state for returning users.
STATUS JSON SHARE URL REPORT SUMMARYWhy MiroShark Fits Capacitr
Capacitr's discovery layer answers "what can I trade from this signal?" MiroShark adds a second step: "how might this narrative evolve once agents, communities, and prediction-market participants react?" That makes the integration useful for pre-trade context, narrative stress testing, and turning raw market matches into richer decision support.
Capacitr signal → enriched market thesis → MiroShark x402 run → status polling → hosted simulation report → Capacitr notification / report link
LLM Strategy
| Task | Model | Tokens | Frequency | Cost/Cycle |
|---|---|---|---|---|
| Topic categorization | gpt-4o-mini | ~200 | 100/cycle | $0.003 |
| Summary generation | gpt-4o | ~500 | 100/cycle | $0.250 |
| Keyword extraction | gpt-4o-mini | ~200 | 100/cycle | $0.003 |
| Market scoring | gpt-4o-mini | ~300 | 500/cycle | $0.015 |
| Image prompts | gpt-4o-mini | ~200 | 50/cycle | $0.001 |
| Link analysis | gpt-4o | ~1000 | on-demand | $0.005/req |
$0.30/cycle · $7.20/day @ 4 cycles/hr · ~$10-15/day with caching
Matching Algorithm
Polymarket Matching Pipeline
Top 5 keywords → GET /public-search?q={keyword}
Named entities (person, org, event) → Polymarket search
Remove duplicates by conditionId
Active only. Volume > $1,000
GPT-4o-mini rates relevance 0-1 per topic-market pair
Score > 0.5, sorted descending
HyperLiquid Matching
Feed Ranking Formula
Implementation Phases
Cost Projections
Prototype — ~$130/mo
Production @ 10K Users — ~$1,328/mo
Key Tradeoffs
Keyword search hits too many false positives. "Trump" matches dozens of markets. LLM understands a tariff tweet → tariff market, not primary market. Cost: ~$0.015/500 pairs.
X streaming = Enterprise ($$$). Most sources lack streaming. 15-min poll is fresh enough. Exception: HL WebSocket for live prices.
Zero infra. Handles JS/anti-bot. Free. Production: add Firecrawl backup, self-host Readability for speed.
Pre-compute per-user feeds. Lower latency, enables push notifications. Trade: up to 30 min stale.
End-to-End Example
Link Drop Flow
https://x.com/elonmusk/status/1234567890
X post detected → fetch tweet → "Spoke with NVIDIA CEO about AI chip exports to China"
Keywords: nvidia, AI chips, China · Entities: NVIDIA, China, Musk · Sentiment: neutral
"US ban AI chip exports to China by 2025?" — 42% Yes ($2.1M vol)
NVIDIA-PERP: $145.20, +0.003% funding, $48M vol
Feed card: tweet summary + prediction markets + perps
Sample Feed Card
The Fed indicated a likely 25bps rate cut at the September meeting, citing cooling inflation and labor market normalization.
Future Enhancements
Trade matched markets via Privy embedded wallet
Follow others. See what markets they watch.
"Notify when this market moves 10%+"
Deep-dive any topic with citations
Connect wallet. Show P&L tied to feed.
Create and share market analysis cards