How olamidepy/valence works
Valence is a web app and API for recurring, guardrailed investment in tokenized equities on Robinhood Chain. A user defines a goal; the goals API requests a SERV basket and checks it against guardrails for preview. Scheduled goals repeat that reasoning and validation before the cron handler dispatches approved holdings to chain execution. The app also exposes portfolio, activity, market, account, Telegram-alert, and MCP capabilities. The sampled code uses mock data alongside Prisma; unsampled UI and route implementations limit certainty about their wiring.
Main entry points: run-due-goals/route.ts Due-goal runner · execute.ts Basket executor · mcp/route.ts MCP server · db.ts Application state
Components 34
User experience
- Valence app
app/layout.tsx - Goal form
app/goals/new/page.tsx - Dashboard
app/dashboard/page.tsx - Activity ledger
app/activity/page.tsx - Alerts and guardrails
app/settings/alerts/page.tsx
Goal and risk flow
- Goal proposal API
app/api/goals/route.ts - Goal confirmation API
app/api/goals/[id]/confirm/route.ts - Due-goal runner
app/api/cron/run-due-goals/route.ts - SERV basket generator
lib/serv/basket.ts - Guardrail evaluator
lib/guardrails.ts - MCP server
app/api/mcp/route.ts
Chain execution
- Basket executor
lib/chain/execute.ts - Chain configuration
lib/chain/config.ts - Wallet discovery
lib/chain/wallet-discovery.ts - Fee logic
lib/fees.ts
Accounts and alerts
- Authentication APIs
app/api/auth/verify-otp/route.ts - OTP and wallet derivation
lib/otp-store.ts - Email delivery
lib/auth-email.ts - Telegram endpoints
app/api/telegram/webhook/route.ts - Telegram notifications
lib/telegram.ts
Market and state
- Portfolio API
app/api/portfolio/route.ts - Activity API
app/api/activity/route.ts - Live market API
app/api/market/live/route.ts - Live market data
lib/live-market.ts - Tokenized stock registry
lib/tokenized-stocks.ts - Application state
lib/db.ts - Prisma database
lib/db.ts
Other components
- Investor
- MCP client
- Scheduler
- Robinhood Chain
- SERV or model provider
- Email provider
- Telegram
Connections 37
- Investor → Goal form: defines goal
- Goal form → Goal proposal API: requests proposal
- Goal proposal API → SERV basket generator: generates basket
- SERV basket generator → SERV or model provider: requests reasoning
- Goal proposal API → Guardrail evaluator: checks basket
- Goal proposal API → Application state: reads guardrails
- Goal proposal API → Goal confirmation API: returns preview
- Scheduler → Due-goal runner: triggers run
- Due-goal runner → Application state: reads goals
- Due-goal runner → SERV basket generator: generates proposal
- Due-goal runner → Guardrail evaluator: checks proposal
- Due-goal runner → Basket executor: dispatches approved holdings
- Due-goal runner → Application state: records rejections
- Due-goal runner → Telegram notifications: sends rejection alert
- MCP server → Live market data: fetches quotes
- MCP server → Tokenized stock registry: reads registry
- MCP server → Guardrail evaluator: checks proposal
- MCP server → Application state: reads metrics and config
- MCP server → Basket executor: dispatches swaps
- Basket executor → Chain configuration: uses chain settings
- Basket executor → Robinhood Chain: executes swaps
- Basket executor → Fee logic: calculates fees
- Basket executor → Wallet discovery: discovers wallets
- Investor → Dashboard: views portfolio
- Dashboard → Portfolio API: requests portfolio
- Investor → Activity ledger: reviews trades
- Activity ledger → Activity API: requests ledger
- Portfolio API → Application state: reads portfolio data
- Activity API → Application state: reads trades
- Live market API → Live market data: fetches prices
- Authentication APIs → OTP and wallet derivation: verifies code
- Authentication APIs → Prisma database: upserts user
- OTP and wallet derivation → Email delivery: creates OTP delivery
- Email delivery → Email provider: sends code
- Telegram endpoints → Telegram notifications: handles linking
- Telegram notifications → Telegram: sends notifications
- Investor → Alerts and guardrails: manages alerts