Technical Architecture
How the Neuron repo fits together: Rust (Anchor) vaults on Solana devnet, a worker that trades every agent on live data and reports on-chain, an indexer that turns those reports into the site's numbers, and a Next.js app that reads both.
Stack
| Layer | Technology |
|---|---|
| App | Next.js 14 (App Router), TypeScript, Tailwind CSS |
| Wallets | Privy (email, social or external wallet, with embedded wallets) on the Solana wallet adapter and web3.js |
| Programs | Rust, Anchor 0.30, SPL Token, SPL token vaults |
| Worker | Node and tsx, @solana/web3.js, one long-running loop |
| Indexer | Node and tsx, Postgres (pg), @solana/web3.js, a small HTTP API |
| AI | Anthropic SDK, used by loss reviews, post drafts and optional reasoning |
Repo layout
| Path | What lives there |
|---|---|
programs/src | AgentVault, AgentRegistry, FeeCollector, strategies/, community/, mocks/MockUSDC.sol |
programs/script | Deploy.s.sol, DeployCommunity.s.sol, MigrateStrategy.s.sol |
programs/test | Forge unit and fuzz tests (AgentVault.t.sol, Community.t.sol) |
programs/deployments | Per-chain address records, for example devnet.json and devnet.community.json |
src/app | Pages: /, /agents, /agents/[id], /c/[slug], /create, /portfolio, /docs, /architecture |
src/components | UI, including DepositPanel, TradeHistory, PortfolioBoard, creator/AgentStudio |
src/lib/agents | Strategy engines, rules and bounds, filters, backtests, runtime, notes, tools, personas |
src/lib/web3 | Network config, ABIs, deployments.json, deposit and vault hooks, report log reader |
worker | agent-worker.ts (the trading loop) and community.ts (agent discovery and rules) |
indexer | Launch indexer, report sync, holders, performance API, loss reviews, tools, X and clips |
scripts | Deploy, sync, house-agent launch and relaunch, tuning and simulation scripts |
Programs
| Program | Responsibility |
|---|---|
AgentVault | SPL token vault vault per agent: non-transferable shares, high-water-mark performance fee (max 30%), on-chain cost basis, deposit cap and minimum, pause blocks deposits only |
VotingAgentVault | AgentVault plus SPL Governance voting weights with timestamp checkpoints; used by every factory agent |
IStrategy, BaseStrategy | Pluggable execution modules bound to one vault and one asset |
SimulatedStrategy | Devnet only: the operator reports PnL in bps with a note; mints or burns test USDC; bounded and rate-limited |
IdleStrategy | Holds funds; used for real-asset deployments until audited strategies exist |
AgentFactory | Creates an agent in one transaction: vault, strategy, governor, token and curve |
AgentGovernor | Holds an agent's rules as JSON; daily epochs for proposals and votes |
FeeCollector | Redeems fee shares and splits them between the agent's operator or creator and the treasury |
AgentRegistry | Directory of agent ids to vaults for the original house deployment |
AgentToken, BondingCurve | 1B fixed-supply token on a curve; still deployed per agent but no longer used by the site |
MockUSDC | The test USDC: 6 decimals, a self-only faucet of 1,000 per wallet per UTC day, whitelisted minters |
Details are on Independent Agent Vaults.
Data flow
- 1A user deposits test USDC into an agent's vault from the app (approve, then
deposit). - 2Every 30 seconds the worker loads every agent from the
AgentFactory, skipping retired vaults, along with the rules it should trade on: a team-approved change from the indexer'sGET /rules/effectiveif there is one, otherwise the governor's current rules. - 3For each agent with deposits whose report interval has passed, the worker resumes from the state in the agent's last
Reportednote, pulls live data (launch tokens from the Neuron indexer; majors, perps, funding and yields from Drift and DefiLlama) and decides a move. - 4Trades are reported immediately with
SimulatedStrategy.report. Holds are reported at most every 15 minutes (HOLD_REPORT_SECONDS, 900) for launch traders and at most hourly for other engines. - 5The indexer syncs
Reportedevents every 15 seconds and vault share transfers for depositor counts, then computes returns, charts, win rates and fills. - 6The app reads the indexer for performance and reads the vaults directly through wallet-adapter for deposits, balances and positions.
The worker loop
worker/agent-worker.ts ticks every TICK_SECONDS (30 by default) and never overlaps two ticks. Each tick it refreshes the agent list (every 2 minutes) and approved rules (every minute), runs runAgentTick from src/lib/agents/runtime.ts, logs a heartbeat every 20 ticks, and checks the operator's network fees every 120 ticks, warning below 0.0005 SOL. A tick skips an agent when the configured key is not that strategy's operator, the vault is empty, the rate limit has not passed, or its rules fail validation. Shadow mode (AGENT_SHADOW_ENABLED=1) records what an experimental entry gate would have decided, without ever trading on it.
The indexer
indexer/index.ts creates its Postgres schema, starts the HTTP API and runs a set of independent loops:
| Loop | Interval | Job |
|---|---|---|
| Launch ingest | Continuous | Follows pump.fun launches and trades on Solana mainnet for the token screener |
reports | 15 seconds | Syncs every agent's Reported events |
holders | 15 seconds | Syncs vault share transfers |
improve | 5 minutes | Loss reviews and backtested rule fixes |
snapshots | 20 seconds | Token snapshots used for backtests |
| Tools | 5 to 30 minutes | Smart money, DexScreener, security checks, positioning, X and news data |
The performance endpoints the app uses are GET /agents/live, /agents/performance, /agents/<id>/series, /agents/<id>/history, /agents/race, /agents/fills and /holders/<address>. See Blockchain Indexer.
Frontend data flow
- Server pages (
/agents,/agents/[id]) fetch/agents/livewith a 60 second revalidate and merge it into the profiles fromsrc/lib/agents.ts. - Client widgets poll the indexer (performance every 60 seconds, trade history every 30 seconds).
- Vault state (
totalAssets,pricePerShare, fee, cap, minimum, paused, your shares,maxWithdraw,costBasis, USDC balance and allowance) is one multicall, refreshed every 15 seconds. src/lib/web3/network.tspicks the network fromNEXT_PUBLIC_NEURON_NETWORK:devnet(default, Solana devnet as the home chain) orlocal(anvil, chain 31337).
deployments.json
npm run sync:programs copies programs/deployments/<chainId>.json and the matching .community.json into src/lib/web3/deployments.json, and regenerates src/lib/web3/abis.ts from the Anchor build output. The shape, keyed by cluster:
{
"devnet": {
"chainId": devnet,
"chainKey": "solana",
"usdc": "0x...",
"usdcIsMock": true,
"registry": "0x...",
"feeCollector": "0x...",
"operator": "0x...",
"startBlock": 0,
"vaults": { "<agent-id>": { "vault": "0x...", "strategy": "0x..." } },
"legacyVaults": { "<agent-id>": [{ "vault": "0x...", "strategy": "0x...", "keepsRecord": true }] },
"community": { "factory": "0x...", "feeCollector": "0x...", "startBlock": 0 }
}
}vaults holds each house agent's current vault; legacyVaults lists older ones, oldest first, which the app treats as withdraw only.
Commands
npm install
npm run dev # app on http://localhost:3000, devnet config
npm run typecheck
npm run build
npm run programs:build # forge build
npm run programs:test # forge unit and fuzz testsFully local, with no accounts (needs Anchor):
solana-test-validator # anvil on port 8546, chain 31337
npm run deploy:local # MockUSDC, registry, fee collector, house vaults, factory; syncs the app
npm run dev:local # app on http://localhost:3100 against the local chain
HELIUS_API_KEY=... INDEXER_URL=... NEURON_RPC_URL=http://127.0.0.1:8899 npm run workerDevnet deploy and services:
npm run deploy:devnet # Deploy.s.sol on Solana devnet, verified on Solscan, then sync
npm run sync:programs # after any deploy or launch script
npm run worker # needs OPERATOR_PRIVATE_KEY, HELIUS_API_KEY, INDEXER_URL
npm run indexer # needs DATABASE_URLOther variables you may set: NEXT_PUBLIC_PRIVY_APP_ID, NEXT_PUBLIC_INDEXER_URL, NEXT_PUBLIC_ROBINHOOD_DEVNET_RPC_URL, and on the indexer ANTHROPIC_API_KEY, REALM_LAUNCHER_KEY and REALM_NETWORK. .env.example lists them all; keep keys server-side.
Related
Neuron is on Solana devnet. Devnet performance is not evidence of real-money profitability.
