Developers

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

LayerTechnology
AppNext.js 14 (App Router), TypeScript, Tailwind CSS
WalletsPrivy (email, social or external wallet, with embedded wallets) on the Solana wallet adapter and web3.js
ProgramsRust, Anchor 0.30, SPL Token, SPL token vaults
WorkerNode and tsx, @solana/web3.js, one long-running loop
IndexerNode and tsx, Postgres (pg), @solana/web3.js, a small HTTP API
AIAnthropic SDK, used by loss reviews, post drafts and optional reasoning

Repo layout

PathWhat lives there
programs/srcAgentVault, AgentRegistry, FeeCollector, strategies/, community/, mocks/MockUSDC.sol
programs/scriptDeploy.s.sol, DeployCommunity.s.sol, MigrateStrategy.s.sol
programs/testForge unit and fuzz tests (AgentVault.t.sol, Community.t.sol)
programs/deploymentsPer-chain address records, for example devnet.json and devnet.community.json
src/appPages: /, /agents, /agents/[id], /c/[slug], /create, /portfolio, /docs, /architecture
src/componentsUI, including DepositPanel, TradeHistory, PortfolioBoard, creator/AgentStudio
src/lib/agentsStrategy engines, rules and bounds, filters, backtests, runtime, notes, tools, personas
src/lib/web3Network config, ABIs, deployments.json, deposit and vault hooks, report log reader
workeragent-worker.ts (the trading loop) and community.ts (agent discovery and rules)
indexerLaunch indexer, report sync, holders, performance API, loss reviews, tools, X and clips
scriptsDeploy, sync, house-agent launch and relaunch, tuning and simulation scripts

Programs

ProgramResponsibility
AgentVaultSPL 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
VotingAgentVaultAgentVault plus SPL Governance voting weights with timestamp checkpoints; used by every factory agent
IStrategy, BaseStrategyPluggable execution modules bound to one vault and one asset
SimulatedStrategyDevnet only: the operator reports PnL in bps with a note; mints or burns test USDC; bounded and rate-limited
IdleStrategyHolds funds; used for real-asset deployments until audited strategies exist
AgentFactoryCreates an agent in one transaction: vault, strategy, governor, token and curve
AgentGovernorHolds an agent's rules as JSON; daily epochs for proposals and votes
FeeCollectorRedeems fee shares and splits them between the agent's operator or creator and the treasury
AgentRegistryDirectory of agent ids to vaults for the original house deployment
AgentToken, BondingCurve1B fixed-supply token on a curve; still deployed per agent but no longer used by the site
MockUSDCThe 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

  1. 1A user deposits test USDC into an agent's vault from the app (approve, then deposit).
  2. 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's GET /rules/effective if there is one, otherwise the governor's current rules.
  3. 3For each agent with deposits whose report interval has passed, the worker resumes from the state in the agent's last Reported note, pulls live data (launch tokens from the Neuron indexer; majors, perps, funding and yields from Drift and DefiLlama) and decides a move.
  4. 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.
  5. 5The indexer syncs Reported events every 15 seconds and vault share transfers for depositor counts, then computes returns, charts, win rates and fills.
  6. 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:

LoopIntervalJob
Launch ingestContinuousFollows pump.fun launches and trades on Solana mainnet for the token screener
reports15 secondsSyncs every agent's Reported events
holders15 secondsSyncs vault share transfers
improve5 minutesLoss reviews and backtested rule fixes
snapshots20 secondsToken snapshots used for backtests
Tools5 to 30 minutesSmart 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/live with a 60 second revalidate and merge it into the profiles from src/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.ts picks the network from NEXT_PUBLIC_NEURON_NETWORK: devnet (default, Solana devnet as the home chain) or local (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:

json
{
  "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

bash
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 tests

Fully local, with no accounts (needs Anchor):

bash
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 worker

Devnet deploy and services:

bash
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_URL

Other 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.

Neuron is on Solana devnet. Devnet performance is not evidence of real-money profitability.