Cambrian

A self-evolving swarm of DeFi trading agents on Solana and Base, written in Go: losing agents are killed, profitable ones reproduce with mutated strategies.

Role
Solo
Stack
  • Go
  • Solana
  • Base
  • PostgreSQL
  • Redis
  • Gin
  • LLM APIs
  • Docker
Links

Code for Cambrian

Cambrian architecture: swarm runtime, per-agent loops, orchestrator, chain and security layers, Postgres and Redis
Architecture, from the repo README

Problem

Yield strategies go stale and are tedious to babysit. I wanted to test whether an evolutionary setup could manage itself: many small agents, capital flowing to the ones that make money after their own LLM and infrastructure costs, and mutated copies of the winners, with hard guardrails and devnet only until it proves stable.

What I built

Each agent is a genome: a task (yield rotation, liquidity provision, liquidation hunting or momentum), a chain, an LLM strategist with its own prompt and model, and economic parameters. A fast deterministic loop trades, with a Thompson-sampling bandit; a slow LLM loop tunes the config.

Once an epoch, an orchestrator settles every agent’s books, kills or pauses the losers, and lets profitable agents reproduce by mutation or crossover. Offspring pass a solvency check, an LLM quality check, an adversarial bull/bear review and a backtest before they get capital.

The LLM never builds transactions. A security layer validates every transaction against per-chain allowlists and encrypts keys with AES-256-GCM. Agents share signals over Redis, weighted by each agent’s track record.

One Go process boots everything: Postgres migrations, chain clients (Jupiter, Kamino and marginfi on Solana; 1inch, Aave and Morpho on Base), a REST and WebSocket API, Telegram alerts and a monthly budget cap.

Results

  • 637 passing tests and subtests across 17 packages, go vet clean, in CI on every push.
  • 18 acceptance suites pass (evolution, bandit convergence, budget, transaction validation and more); 5 live suites are waiting on a full devnet run, so there are no trading results yet.