Inspiration
The first was a frustration with how DeFi vaults work today. If you deposit $10k into a yield strategy, every other depositor, and every MEV bot, every indexer, every competing strategy can see your size, your timing, and your exit. Your alpha leaks the moment you sign the transaction. On a public chain, "my position" is a contradiction in terms.
The second was watching prediction markets quietly become a real asset class. Polymarket settles billions a year now. Binary-option markets carry real yield: short-dated questions with well-defined edges. But the operational overhead (orderbooks, resolution, allowance management, news monitoring) keeps it out of reach for anyone who isn't doing this full-time.
GenV is the intersection: a vault where the structure is public (total size, share price) but your participation is private (deposit, balance, PnL), and where the actual trading is done by an AI agent that watches markets on your behalf. You deposit. You sleep. You withdraw.
What it does
GenV is a manager-trusted yield vault on Midnight. The vault is a Compact smart contract that owns the share accounting and the float cap; the AI agent is the manager and runs off-chain.
- Depositors send pUSD to the vault and receive shielded share coins. Their balance lives only in their wallet, and never in a public map.
- The AI agent scores live Polymarket binary markets every cycle, picks one with a structured thesis (edge, risk, sizing), deploys pooled capital into the position, waits for resolution, and returns the principal plus yield to the vault. The share price moves with each successful cycle.
- Shareholders can request a withdrawal at any time. The agent fills the ticket from the vault's liquid balance at the current share price.
The chain knows that the vault exists, what it's worth in aggregate, and who the manager is. It doesn't know who deposited, who holds what, or what each shareholder's PnL is.
How we built it
The contract is a single Compact circuit suite on Midnight: 11
circuits covering initialization, two-step manager rotation, deposit
authorization, claim, withdrawal request, processing, cancellation, and float
management. The privacy primitive is mintShieldedToken for share coins; the
public state is a small set of counters (total_share_supply,
total_liquid, float_outstanding) plus opaque-hash maps for in-flight
authorizations and tickets.
The agent is a Node.js process with two responsibilities sharing one runtime:
- A Fastify HTTP server that accepts deposit intents from the UI and calls
authorize_depositon Midnight. - A trading loop that, every 30 seconds, pulls 3 eligible markets from
Polymarket's Gamma API, asks an LLM for a structured
Decision(scan + commit), and runs the cycle through to settlement.
The LLM call uses a single structured-output request returning both a
3-market scan (with per-market verdicts and reasons) and a commit (thesis,
edge, risk, size). The same prompt and code run against either OpenRouter
(free reasoning models like GLM 4.5 Air) or Anthropic; provider is selected
by which API key is present. Failure path: invalid JSON or API timeout falls
through to a deterministic mockDecision so the loop never crashes mid-demo.
The frontend is a React 19 + Vite app with Tailwind v4 and shadcn/ui. It includes a Public Ledger View tab, a live read of the on-chain state, so users can verify the privacy claim themselves.
Challenges we ran into
Polymarket has no 5-minute markets. Our original design assumed BTC binary options that resolve every five minutes, which would let the demo fire a real trade and watch it settle live. They don't exist. We scanned 200 active markets. Soonest closes in 1095 hours. We pivoted to real markets + real Claude reasoning + mocked execution.
Shielded mint is blocked at the protocol level. As of the build window,
we couldn't end-to-end test claim_deposit because the minted shielded coin
can't be observed or spent from a wallet yet, a Midnight community-help
item that's pending resolution. We mocked share balance in the UI and kept
building everything else in parallel.
Free LLM models on OpenRouter are a moving target. Models we picked at
build start were either discontinued, rate-limited upstream, or returned
content: null because they were reasoning models burning all their tokens
on internal thinking before emitting JSON. We landed on z-ai/glm-4.5-air:free
with a 2000-token budget and a fallback that reads from the reasoning
field if content is null.
Coordinating two repos, two people, one demo. The agent depends on the contract address; the contract depends on shielded-mint plumbing; the demo depends on both. We unblocked by mocking the dependency directions until the real artifacts shipped.
What we learned
- Privacy is a feature you can FEEL, but only if you SHOW the absence. Our Public Ledger View is the demo's privacy beat: users see the live on-chain state and confirm with their own eyes that per-user data isn't there. Telling people something is private is not the same as showing what the chain doesn't know.
- AI in a yield vault doesn't need a tool-use loop in v1. A single structured-output call returning a layered (scan + commit) decision reads as smart, fits in a 30-second demo beat, and is bulletproof under retry. The tool-use agent harness is a v2 upgrade, not a v1 requirement.
- Compact's privacy model rewards clean separation between counters and maps. Anything you want public goes in counters; anything you want private goes in opaque maps. That separation shaped the contract's data layout.
What's next for GenV
- Trust-minimized capital movement. The manager's attestations (
float_outstanding, returns from Polymarket) are taken on trust in the MVP. A future Midnight↔Polygon bridge would replace attestation with proof. - Real on-chain settlement of
manager_withdrawandmanager_depositonce the contract address lands. - Tool-use agent harness: replace the deterministic TS loop with a Claude agent that has
list_markets,get_orderbook,place_trade, andcheck_resolutionas tools. Multi-step reasoning, no fixed cycle shape. - Multi-position portfolio. The agent holds 2-3 positions at once, manages exposure across them, rebalances when one resolves.
Built With
- anthropic-claude
- chalk
- compact
- fastify
- midnight-js-contracts
- midnight-js-ledger
- midnight-network
- midnight-proof-server
- node.js
- openrouter
- polygon
- polymarket-gamma-api
- react-19
- shadcn-ui
- tailwindcss-v4
- tsx
- typescript
- vite
- zod

Log in or sign up for Devpost to join the conversation.