Protocol docs

AI-managed stock-token vaults on Robinhood Chain — architecture, security model, deployment.

Overview

Tokenized AI trading agents for stock tokens on Robinhood Chain (chain ID 4663). Every AI agent is a NAV-backed ERC-20 vault. Users deposit USDG and receive shares whose value tracks the agent's portfolio of tokenized equities (NVDA, AAPL, SPY, …), priced onchain via per-asset Chainlink feeds.

The AI — an offchain LLM loop — executes trades, but never has unrestricted power: every order must pass the shared TradeGuard risk engine plus an onchain oracle-price slippage bound.

User ──deposit USDG──▶ AgentVault ──shares──▶ User
                         │  ▲
      AI (operator) ─────┘  │ executeTrade (whitelisted router only)
                         │  │
                         ▼  │
                 TradeGuard + PriceOracle (Chainlink, sequencer + staleness checks)

Contracts

ContractRole
AgentVaultERC-20 share vault per agent. Deposit/withdraw USDG, NAV via oracle, operator trades, 20% performance fee (high-water mark), drawdown peak tracking, inflation-guard dead shares.
AgentFactoryDeploys vaults and registers them in the registry.
AgentRegistryAgent metadata + discovery (creator, vault, strategy URI, active flag).
TradeGuardShared risk rules: token whitelist, max trade size, position cap, max drawdown halt, protocol pause.
PriceOracleChainlink wrapper: 1e18-normalized USD prices, L2 sequencer uptime check, per-feed staleness heartbeat.

Security model

Deployment

Mainnet broadcast is done by the protocol owner, never by an agent:

export PRIVATE_KEY=<your_key>
export RPC=https://rpc.mainnet.chain.robinhood.com
forge script script/Deploy.s.sol:Deploy --rpc-url $RPC --broadcast

Post-deploy configuration:

  1. oracle.setFeed(<TOKEN>, <FEED>, 0) for every stock token — feed addresses from the Chainlink Robinhood page.
  2. guard.setWhitelistedToken(<USDG>, true) + every stock token.
  3. guard.setWhitelistedRouter(<router>, true) — Uniswap V3 router / Rialto propAMM.
  4. oracle.setSequencerUptimeFeed(<feed>) — recommended on L2.
Reference addresses (chain 4663): USDG 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168 · WETH 0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73 · Uniswap V3 SwapRouter 0xE592427A0AEce92De3Edee1F18E0157C05861564 (verified deployed).

Offchain AI agent

ModuleRole
chain.pyWeb3 client: vault state, signed executeTrade submission.
prices.pyRHJ REST API + onchain feed reads.
signals.pyDecision engine: LLMProvider (DeepSeek, Gemini fallback) + HeuristicProvider (SMA crossover, offline).
executor.pyOffchain guardrail mirror (watchlist, max trade, caps) before signing; dry-run or live.
keeper.pyNAV/drawdown monitor + liquidity sweeps.
cli.pystatus, run, keeper, sweep, deposit, move-price, tokens.

End-to-end demo (local anvil, reproducible): ./agent/e2e_demo.sh — verified BUY on uptrend and SELL on downtrend with real onchain transactions (status 1), plus LLM-decided live trades and keeper liquidity sweeps.

FAQ

Can the AI rug-pull?

No. The operator only signs executeTrade calls that pass TradeGuard (whitelists, caps, drawdown halt) and the oracle slippage bound. There is no path to move USDG out of the vault except the owner's 20% HWM performance fee.

How is NAV computed?

Onchain, from Chainlink feed prices of every tracked asset, normalized to 1e18 USD. No offchain number to fudge.

When do I pay fees?

Only when the vault's NAV/share exceeds its all-time high (high-water mark), and only on the profit above it. Flat or down periods cost nothing.

Why stock tokens?

Robinhood Chain has 96 tokenized equities (NVDA, AAPL, SPY, QQQ, SGOV…) as standard ERC-20s with per-asset Chainlink feeds — a permissionless, composable equities market that no other L2 offers natively.