STOCKFACTORY DOCS
The onchain portfolio assembly line. Assemble baskets of Robinhood Stock Tokens, push them through a real quality-control pipeline, and stamp a portable Blueprint that anyone can inspect, fork, or manufacture.
TABLE OF CONTENTS
1. WHAT IS STOCKFACTORY?
StockFactory is a workbench for building deterministic, portable equity-basket strategies from Robinhood Stock Tokens — ERC-20 wrappers of real US equities that live on Robinhood Chain (ID 4663).
Instead of clicking around a brokerage, you drop tokens onto an assembly line, set target weights, run quality control, and mint a Blueprint: a hash-stamped recipe that anyone can look up, share, or reproduce.
The whole app is intentionally shaped like a factory floor:
- Warehouse — raw parts (every listed Stock Token).
- Assembly Line — the conveyor where you build the basket.
- Quality Control — 6 stations that must clear before shipping.
- Blueprint Vault — the archive of shipped strategies.
- Control Room — live NAV + wallet-side portfolio view.
2. GLOSSARY
- Stock Token — ERC-20 on Robinhood Chain that represents 1:1 exposure to a listed US equity.
- Basket — an unshipped draft on the assembly line: 2–6 slots with target weights.
- Weight (bps) — target allocation in basis points. Weights must sum to 10,000.
- Blueprint — a shipped, hash-stamped recipe. Immutable; new edits create a new version.
- Recipe hash — SHA-256 over the canonical (sorted) list of
symbol → weightBps. - NAV — Net Asset Value: sum(weight × mid-price) for a blueprint, sampled every 15 min.
- QC Grade — PASS / WARN / FAIL rollup from the 6 QC stations.
3. PARTS WAREHOUSE
The Warehouse is a live index of every Stock Token exposed by the Robinhood public REST API (/rhj/assets). Metadata includes the on-chain contract, ticker, venue (NYSE/NASDAQ), current halt status, corporate actions, and mid-price.
Prices come from /rhj/prices/{symbol} and are cached server-side inside a TanStack server function. The Warehouse is read-only — it's where you shop for parts before heading to the line.
4. THE ASSEMBLY LINE
The Assemble page is a 2–6 slot conveyor. Drop a Stock Token into a slot, dial its weight in bps, then either rebalance manually or hit Auto-Balance to distribute the remainder evenly.
Rules enforced client-side:
- Minimum 2 slots, maximum 6.
- No duplicate symbols.
- Weights must sum to exactly 10,000 bps to ship.
- No single component > 60% (concentration guard).
You also set a Paper Notional (USDG). That number is what the Route Inspector uses to simulate a real 1inch-style split across the basket.
5. QUALITY CONTROL — 6 STATIONS
Pressing RUN QC pushes the basket through six checks:
- WEIGHT CHECK — sum = 10,000 bps, concentration ≤ 60%, slot count in range.
- AUTHENTICITY — every symbol resolves to a listed Stock Token with a valid on-chain contract on chain 4663.
- PRICE FRESHNESS — the Robinhood price snapshot for each component is under 5 minutes old.
- CORPORATE ACTIONS — flags any component with an active halt, split, or dividend event that would break the basket.
- ORACLE CROSS-CHECK — Robinhood mid vs Pyth mid. Divergence > 2% raises a WARN; > 5% is a FAIL.
- ROUTE INSPECTOR — effective slippage from the Paper Routing engine must stay under the 50 bps cap.
The overall QC Grade is FAIL if any station fails, else WARN if any warns, else PASS. Only PASS or WARN blueprints can be shipped to the vault.
6. BLUEPRINTS & HASHING
A Blueprint is what comes off the end of the line. It records the components, weights, QC grade, and a deterministic recipe hash.
The hash is computed as:
sha256(
components
.sort((a,b) => a.symbol.localeCompare(b.symbol))
.map(c => `${c.symbol}:${c.weightBps}`)
.join("|")
)Order-independent: AAPL 60% / MSFT 40% hashes identically no matter what order you added them. Two people who build the same basket land on the same Blueprint ID.
Public blueprints live in the Blueprint Vault. Every version is retained in blueprint_versions so you can fork or diff over time.
7. PAPER ROUTING ENGINE
Robinhood Chain doesn't have 1inch yet, so StockFactory ships a deterministic Paper Router. Given a notional and a basket, it:
- Splits the notional per component using weight × notional.
- Prices each leg at the Robinhood ask (buy side).
- Applies a spread-derived slippage per leg.
- Charges a flat 25 bps protocol fee.
- Reports per-leg tokens out + a blended effective slippage in bps.
Halted or unpriced components short-circuit the route so QC can flag the basket instead of silently misquoting.
8. ORACLES — PYTH CROSS-CHECK
Every priced component is looked up on Pyth Hermes under the Equity.US.<TICKER>/USD feed. The Oracle panel on the assembly line renders Robinhood mid vs Pyth mid with a live Δ%, and the same values feed the QC station.
This catches stale Robinhood snapshots, mispriced feeds, and any drift that would make a Blueprint dangerous to manufacture at scale.
9. CONTROL ROOM & NAV
The Control Roomis the operator view once a wallet is connected. It reads your token balances on Robinhood Chain and matches them against known Stock Tokens and Blueprints.
NAV for every public Blueprint is snapshotted every 15 minutes by a cron job and stored in nav_snapshots. That's what powers the historical strip on each Blueprint card.
10. WALLET & ROBINHOOD CHAIN
Wallet auth uses Reown AppKit + wagmi v2. StockFactory is wired to chain ID 4663 (Robinhood Chain). Reads only, today: no swaps, no signatures beyond wallet connect.
Anonymous sign-in on Lovable Cloud lets you save blueprints and QC runs without creating an account — link a wallet later and the history follows.
11. BACKGROUND JOBS
- stockfactory-nav-snapshot — every 15 min. Recomputes NAV for every public Blueprint and inserts into
nav_snapshots. - stockfactory-api-health — every 5 min. Probes the Robinhood REST endpoints, records latency + status into
api_health_events, and drives the status bar in the header.
12. ROADMAP
- Live 1inch quotes + execution when routing is available on chain 4663.
FactoryBlueprintRegistry.sol— on-chain blueprint registration and manufacture receipts.- Chainlink price feeds as a second oracle when supported on Robinhood Chain.
- Fork + diff UI for public Blueprints.
- Mobile-tuned assembly line.
13. FAQ
No. Milestone 1 + 2 are paper-only. Nothing signs a swap, nothing custodies funds.
Concentration guardrail — keeps blueprints diversified enough that a single halt doesn't sink NAV.
No. Edits produce a new version under the same blueprint slug; the original hash stays immutable.
Robinhood public REST API for mids/bid/ask/halts and Pyth Hermes for the oracle cross-check.