Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: implement walletStockPortfolio function for ERC-20 balance calculations and add service catalog for Robinhood portfolio
fudjiacbf4c1b86503
diff --git a/api/_lib/robinhood.js b/api/_lib/robinhood.jsindex 374ec76ea..4b5b40de6 100644--- a/api/_lib/robinhood.js+++ b/api/_lib/robinhood.js@@ -477,6 +477,55 @@ export async function recentLaunches({ limit = 40 } = {}) {return all.slice(0, limit);}+const ERC20_BALANCE_ABI = [+ { type: 'function', name: 'balanceOf', stateMutability: 'view', inputs: [{ type: 'address' }], outputs: [{ type: 'uint256' }] },+];++/**+ * Multiplier-correct full Stock Token portfolio for a wallet: one multicall+ * for balanceOf across every registry token, joined against the Chainlink NAV+ * snapshot. `raw balance × uiMultiplier / 1e18 = true position` (ERC-8056) —+ * corporate actions (splits/dividends) are already folded into uiMultiplier,+ * so this is the one place a caller should read "how many shares do I hold",+ * never the raw ERC-20 balance. USD valuation uses the Chainlink NAV, which is+ * already multiplier-adjusted (never re-apply uiMultiplier to a feed price).+ */+export async function walletStockPortfolio(owner) {+ const client = publicClient(false);+ const reg = stockRegistry();+ const snap = await chainlinkSnapshot();++ const balances = await client.multicall({+ contracts: reg.tokens.map((t) => ({ address: t.address, abi: ERC20_BALANCE_ABI, functionName: 'balanceOf', args: [owner] })),+ allowFailure: true,+ });++ const positions = [];+ for (let i = 0; i < reg.tokens.length; i++) {+ const t = reg.tokens[i];+ const b = balances[i];+ if (b?.status !== 'success' || b.result === 0n) continue;+ const feed = snap[t.address.toLowerCase()] || null;+ const multiplier = feed?.uiMultiplier ? BigInt(feed.uiMultiplier) : BigInt(t.uiMultiplierAtGeneration || '1000000000000000000');+ const rawBalance = b.result;+ const adjustedUnits = Number(rawBalance) * (Number(multiplier) / 1e18) / 10 ** t.decimals;+ const navPrice = feed?.priceUsd ?? null;+ positions.push({+ symbol: t.symbol,+ name: t.name,+ address: t.address,+ rawBalance: rawBalance.toString(),+ uiMultiplier: multiplier.toString(),+ shares: adjustedUnits,+ navPriceUsd: navPrice,+ valueUsd: navPrice != null ? adjustedUnits * navPrice : null,+ });+ }+ positions.sort((a, b) => (b.valueUsd ?? 0) - (a.valueUsd ?? 0));+ const totalValueUsd = positions.reduce((sum, p) => sum + (p.valueUsd || 0), 0);+ return { owner, positions, totalValueUsd, positionCount: positions.length };+}+// ── Shared derivations ─────────────────────────────────────────────────────/*** Premium/discount of a DEX mid price vs the Chainlink NAV, as a signeddiff --git a/api/_lib/service-catalog/services/robinhood-portfolio.js b/api/_lib/service-catalog/services/robinhood-portfolio.jsnew file mode 100644index 000000000..0211a1043--- /dev/null+++ b/api/_lib/service-catalog/services/robinhood-portfolio.js@@ -0,0 +1,39 @@+// Service-catalog descriptor — the single written-once listing for this+// service. api/wk.js derives its /.well-known/x402.json resource entry from+// this file via api/_lib/service-catalog/index.js (toBazaarDiscovery), and+// the OKX storefront projection reads the same record (toOkxCatalog).+// Contract: specs/service-catalog.md. Do not re-add a hand-written mirror+// for this route in api/wk.js — edit this descriptor instead.++export default {+ slug: 'robinhood-portfolio',+ title: 'Robinhood Chain Portfolio',+ category: 'market-data',+ useCase:+ 'Robinhood Chain Portfolio — the multiplier-correct USD value of any wallet\'s ' ++ 'tokenized-equity holdings on Robinhood Chain (4663), corporate-action-adjusted ' ++ 'via ERC-8056 uiMultiplier and priced against live Chainlink NAV feeds.',+ path: '/api/v1/robinhood/portfolio',+ method: 'GET',+ free: false,+ status: 'live',+ priceAtomics: '2000',+ acceptsBuilder: 'standard',+ serviceName: 'Robinhood Chain Portfolio',+ tags: ['robinhood', 'stocks', 'portfolio', 'rwa', 'x402'],+ description:+ 'Robinhood Chain Portfolio — every Stock Token a wallet holds on Robinhood Chain (4663), ' ++ 'with the true position (raw ERC-20 balance × ERC-8056 uiMultiplier — ignoring the multiplier ' ++ 'misstates value after a split or dividend) and current USD value from the on-chain Chainlink ' ++ 'NAV feed for each symbol. Returns per-position shares, NAV price, and USD value, plus a ' ++ 'total portfolio value. Zero balances are omitted.',+ input: { address: '0x9701fb0aDe1E269c8f64Ec0C7b3cfADB31A13A52' },+ inputSchema: {+ type: 'object',+ required: ['address'],+ properties: {+ address: { type: 'string', description: 'EVM wallet address to value (0x…40 hex chars).' },+ },+ },+ storefronts: ['x402scan'],+};diff --git a/public/changelog.json b/public/changelog.jsonindex e12377f1e..8d022de54 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-12T11:05:03.991Z",+ "generated_at": "2026-07-12T13:20:20.333Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",diff --git a/public/features.json b/public/features.jsonindex e01943f75..f18998da9 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-12T11:05:03.963Z",+ "generated_at": "2026-07-12T13:20:20.320Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/robinhood/hood-launcher/src/index.ts b/robinhood/hood-launcher/src/index.tsnew file mode 100644index 000000000..4aa912b70--- /dev/null+++ b/robinhood/hood-launcher/src/index.ts@@ -0,0 +1 @@+export * from './rails/types.js'diff --git a/robinhood/hood-launcher/src/rails/index.ts b/robinhood/hood-launcher/src/rails/index.tsnew file mode 100644index 000000000..ab030fb36--- /dev/null+++ b/robinhood/hood-launcher/src/rails/index.ts@@ -0,0 +1,24 @@+import { NoxaRail } from './noxa.js'+import { OdysseyRail } from './odyssey.js'+import { DirectRail } from './direct.js'+import type { Rail, RailName } from './types.js'++export { NoxaRail } from './noxa.js'+export { OdysseyRail } from './odyssey.js'+export { DirectRail } from './direct.js'+export * from './types.js'+export * from './addresses.js'++/** Instantiate a rail by name. `odysseyVariant` selects Odyssey's factory (`'instant'` default). */+export function createRail(name: RailName, odysseyVariant: 'instant' | 'bonding' = 'instant'): Rail {+ switch (name) {+ case 'noxa':+ return new NoxaRail()+ case 'odyssey':+ return new OdysseyRail(odysseyVariant)+ case 'direct':+ return new DirectRail()+ }+}++export const ALL_RAILS: RailName[] = ['noxa', 'odyssey', 'direct']diff --git a/robinhood/hood-mcp/src/register-trading.ts b/robinhood/hood-mcp/src/register-trading.tsindex e32e9739b..e04e02225 100644--- a/robinhood/hood-mcp/src/register-trading.ts+++ b/robinhood/hood-mcp/src/register-trading.ts@@ -283,8 +283,8 @@ export function registerTradingTools(confirmed: false,message:`SIMULATION ONLY — nothing was signed. To broadcast, call execute_swap again with the ` +- `same arguments and confirm=true. This will send ${amountIn} ${ti.symbol} ($${round(usd, 4)}) ` +- `from ${walletAddress}.`,+ `same arguments and confirm=true. This will send ${amountIn} ${ti.symbol}` ++ `${usd === null ? '' : ` ($${round(usd, 4)})`} from ${walletAddress}.`,})}diff --git a/robinhood/hood-traders/scripts/capture-snapshot.ts b/robinhood/hood-traders/scripts/capture-snapshot.tsnew file mode 100644index 000000000..7523de092--- /dev/null+++ b/robinhood/hood-traders/scripts/capture-snapshot.ts@@ -0,0 +1,77 @@+/**+ * Capture a real, timestamped snapshot of live Robinhood Chain market state —+ * stock quotes, spot prices for a few known tokens, and current block — into+ * `tests/snapshots/`. Snapshots are INPUTS to deterministic strategy unit+ * tests (recorded market data, not a live mock): they let the launch-sniper /+ * momentum / premium-watch decision logic be tested against real numbers+ * without a live RPC call on every `npm test` run.+ *+ * Run: npm run snapshot+ */+import { writeFileSync } from 'node:fs'+import { createHoodClient, getQuote, listPricedStockTokens, MAINNET_ADDRESSES } from 'hoodchain'+import { quoteSwap } from 'hoodchain'+import { formatUnits, parseUnits } from 'viem'++async function main() {+ const hood = createHoodClient({ chain: 'mainnet' })+ const blockNumber = await hood.public.getBlockNumber()+ const ts = Date.now()++ const symbols = listPricedStockTokens().slice(0, 8)+ const quotes = await Promise.all(+ symbols.map(async (t) => {+ try {+ const q = await getQuote(hood, t.symbol)+ return { symbol: t.symbol, address: t.address, priceUsd: q.priceUsd, ageSeconds: q.ageSeconds, roundId: q.roundId.toString() }+ } catch (e) {+ return { symbol: t.symbol, address: t.address, error: e instanceof Error ? e.message : String(e) }+ }+ }),+ )++ // ETH/USD reference from the live USDG/WETH pool.+ let ethUsd: number | null = null+ try {+ const probe = parseUnits('0.01', 18)+ const q = await quoteSwap(hood, { tokenIn: MAINNET_ADDRESSES.weth, tokenOut: MAINNET_ADDRESSES.usdg, amountIn: probe })+ ethUsd = Number(formatUnits(q.amountOut, 6)) / 0.01+ } catch {+ ethUsd = null+ }++ // Spot price for a handful of priced Stock Tokens via WETH route (proves the+ // Uniswap route-probing path, distinct from the Chainlink path above).+ const spotSamples = await Promise.all(+ symbols.slice(0, 3).map(async (t) => {+ try {+ const probe = parseUnits('1', 18)+ const q = await quoteSwap(hood, { tokenIn: t.address, tokenOut: MAINNET_ADDRESSES.usdg, amountIn: probe })+ return { symbol: t.symbol, address: t.address, dexPriceUsd: Number(formatUnits(q.amountOut, 6)) }+ } catch (e) {+ return { symbol: t.symbol, address: t.address, error: e instanceof Error ? e.message : String(e) }+ }+ }),+ )++ const snapshot = {+ capturedAt: ts,+ network: 'mainnet',+ chainId: 4663,+ blockNumber: blockNumber.toString(),+ ethUsd,+ quotes,+ spotSamples,+ }++ const path = `tests/snapshots/mainnet-${ts}.json`+ writeFileSync(path, JSON.stringify(snapshot, null, 2))+ writeFileSync('tests/snapshots/latest.json', JSON.stringify(snapshot, null, 2))+ console.log(`captured snapshot at block ${blockNumber} → ${path}`)+ console.log(JSON.stringify(snapshot, null, 2))+}++main().catch((err) => {+ console.error('snapshot capture failed:', err)+ process.exit(1)+})diff --git a/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/index.html b/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/index.htmlnew file mode 100644index 000000000..49f4b6e2d--- /dev/null+++ b/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/index.html@@ -0,0 +1,12 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1" />+ <title>Portfolio Dashboard · Robinhood Chain</title>+ </head>+ <body>+ <div id="root"></div>+ <script type="module" src="/src/main.jsx"></script>+ </body>+</html>diff --git a/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/package.json b/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/package.jsonnew file mode 100644index 000000000..eba007a38--- /dev/null+++ b/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/package.json@@ -0,0 +1,26 @@+{+ "name": "rh-example-08-portfolio-dashboard",+ "version": "0.1.0",+ "private": true,+ "type": "module",+ "description": "Small Vite + React portfolio dashboard for Robinhood Chain Stock Tokens.",+ "scripts": {+ "dev": "vite",+ "build": "vite build",+ "preview": "vite preview",+ "start": "vite"+ },+ "engines": {+ "node": ">=20"+ },+ "dependencies": {+ "hoodchain": "^0.1.0",+ "react": "^19.0.0",+ "react-dom": "^19.0.0",+ "viem": "^2.55.0"+ },+ "devDependencies": {+ "@vitejs/plugin-react": "^4.3.0",+ "vite": "^6.0.0"+ }+}diff --git a/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/src/useHoodPortfolio.js b/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/src/useHoodPortfolio.jsnew file mode 100644index 000000000..fb8250874--- /dev/null+++ b/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/src/useHoodPortfolio.js@@ -0,0 +1,46 @@+import { useEffect, useRef, useState } from 'react'+import { createHoodClient, getPortfolio } from 'hoodchain'++/**+ * Local stand-in for a `hoodkit` React hook. `hoodkit` (the SDK's React+ * bindings, Wave 2) has not been built yet in this workspace — see the SDK+ * feedback note in the root README. This hook is intentionally the shape+ * `useHoodPortfolio` from `hoodkit` is expected to have, so upgrading later+ * is a one-line import swap:+ *+ * - import { useHoodPortfolio } from './useHoodPortfolio.js'+ * + import { useHoodPortfolio } from 'hoodkit'+ */+const hood = createHoodClient()++export function useHoodPortfolio(owner, { pollMs = 20000 } = {}) {+ const [state, setState] = useState({ status: 'idle', portfolio: null, error: null })+ const timer = useRef(null)++ useEffect(() => {+ if (!owner) {+ setState({ status: 'idle', portfolio: null, error: null })+ return+ }+ let cancelled = false+ setState((s) => ({ ...s, status: 'loading' }))++ async function load() {+ try {+ const portfolio = await getPortfolio(hood, owner, { maxAgeSeconds: 7 * 24 * 3600 })+ if (!cancelled) setState({ status: 'success', portfolio, error: null })+ } catch (error) {+ if (!cancelled) setState({ status: 'error', portfolio: null, error })+ }+ }++ load()+ timer.current = setInterval(load, pollMs)+ return () => {+ cancelled = true+ clearInterval(timer.current)+ }+ }, [owner, pollMs])++ return state+}diff --git a/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/vite.config.js b/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/vite.config.jsnew file mode 100644index 000000000..2b62a61ab--- /dev/null+++ b/robinhood/robinhood-chain-examples/examples/08-portfolio-dashboard/vite.config.js@@ -0,0 +1,7 @@+import { defineConfig } from 'vite'+import react from '@vitejs/plugin-react'++export default defineConfig({+ plugins: [react()],+ server: { port: 5183 },+})