FlyDegen
FAFB v783 · LIF · pump.fun
documentation

How FlyDegen works

Every layer, in order. Short version is on the lab under How it works. This page is the long version.

proof of control

This agent is controlled by a real Drosophila whole-brain connectome (FlyWire FAFB v783) simulated with leaky integrate-and-fire dynamics. Not a traditional neural network.

The claim

FlyDegen is a closed-loop experiment. A published whole-brain model of the adult fruit fly Drosophila melanogaster is driven by a market tape. Its motor neurons are read out as BUY, SELL, HOLD, or GROOM. The agent is not a trained network. There is no backpropagation, no reinforcement learning, no fine-tuning on PnL.

What is real: the FlyWire FAFB v783 neuron list (~138,639 completed root IDs), the signed synaptic edge list (~14.7 million pre→post pairs), the Shiu, Sterne, Spiller et al. 2024 leaky integrate-and-fire equations and biophysical constants, and the labelled sensory and motor populations from that paper.

What is an experiment: treating a green candle as sugar, a dump as bitter, volume as a tap on the antenna, feeding as buy, startle as sell. Flies did not evolve to trade Solana. We document the analogy so it cannot be mistaken for biology or for alpha.

One tick, start to finish

Default wall-clock period is 1.5 seconds. Each period does exactly this:

  1. Sample the market — a simulated bonding curve, or a live pump.fun / DexScreener mint.
  2. Encode features (short return, medium return, volume z-score, buy ratio, curve fill, social heat) as Poisson rates on named sensory populations, clipped to 0–200 Hz.
  3. Integrate one stochastic trial of 200 ms of biological time on the full graph, with dt = 0.5 ms.
  4. Read MN9, DN1/DN2, and aBN1 population rates. Apply thresholds, conflict margin, and an 8 s bout cooldown.
  5. Paper-fill the order (default). Live chain send only if the server is armed with a key.
  6. Build a decision trace: who was injected, who spiked, which real edges fed the winner.
  7. Broadcast the tick on the WebSocket. The lab, raster, body pose, and PnL update.

Brian2 is the reference implementation in vendor/shiu_2024/model.py. The live engine is a vectorized NumPy port of the same equations so a 138k-cell trial stays inside about a second on a laptop.

Market tape

Offline, a built-in bonding-curve token called FLYDGEN random-walks with occasional pumps and dumps so the lab runs with no RPC. Paper fills have a little impact on that curve.

Live tape (when a mint is set on the server) tries frontend-api-v3.pump.fun/coins/<mint>, then DexScreener. Price in SOL is virtual SOL reserves over virtual token reserves. Features derived from the snapshot:

  • ret_short / ret_med — fractional return over a few ticks.
  • volume_z — current volume versus a short rolling mean.
  • buy_ratio — share of aggressive buys, or a function of return in sim.
  • bonding_progress — 0–1 fill of the pump.fun curve.
  • social_heat — chatter / activity proxy, 0–1.

Market → Hertz (the analogy)

Flies do not have a price receptor. We reuse real receptor IDs as labelled Poisson entry points, the same way Shiu activated sugar GRNs at 10–200 Hz to study feeding. Rates stay inside that published window.

TapePopulationBiologyWhy
green / +returnlabellar sugar GRNsappetitive tasteShiu: sugar → MN9 feeding
red / dumplabellar bitter GRNsaversive tastebitter suppresses feeding
curve fillwater GRNswater tasteparallel GRN channel
volume / volJohnston’s organ CE/F/Dantennal mechanoJONs drive startle DNs
chatterir94econtact chemosensesecond labelled GRN class

Sketch of the encoder: sugar rises with positive return and buy-side flow; bitter with negative return; water with bonding-curve progress; JONs with volume z and volatility; ir94e with social heat. Force-stimulus presets (sugar rush, bitter dump, volume shock, …) inject those same Hertz so you can replay a Shiu-style protocol.

Sensory cells get Poisson events onto membrane voltage with quantum w_syn × 250 and refractory 0, matching the paper’s optogenetic analogue, so they can follow the injected rate.

The connectome

Dataset: FlyWire female adult fly brain (FAFB), public materialization v783. Completeness table: 138,639 proofread root IDs. Connectivity: on the order of 14.7–15.1 million unique pre→post pairs with synapse count and predicted excitatory/inhibitory sign.

A handful of v630 IDs from the original Shiu figure lists are missing in v783 and are dropped at load. Root IDs are not stable across materializations. That is expected.

First boot builds a CSR cache at data/flywire_v783_csr.npz. After that, load is a couple of seconds. The workspace dump used scrambled filenames; the loader sniffs the PAR1 magic and the CSV, not the name on disk.

Browsers: flywire.ai, Codex, Virtual Fly Brain. Edges: Zenodo 10676866.

Leaky integrate-and-fire

Current-based LIF, identical to vendor/shiu_2024/model.py:

dv/dt = (v0 − v + g) / τm
dg/dt = −g / τsyn
w_ij  = (sign × n_synapses) × 0.275 mV
ConstantValueSource
v0 / reset−52 mVKakaria & de Bivort 2017
threshold−45 mVsame
τm20 msC = 0.002 μF, R = 10 MΩ
τsyn5 msJürgensen et al.
refractory2.2 msLazar et al. 2021
axonal delay1.8 msPaul et al. 2015
w_syn0.275 mVShiu free parameter

When v crosses threshold the cell spikes, v resets, a refractory clock starts, and delayed current is queued onto postsynaptic partners. Sign comes from the connectome: excitation raises g, inhibition lowers it. Counts scale the quantum. No learned weights anywhere.

A 200 ms trial

Each market tick is one stochastic trial. Time is biological, not wall-clock: 200 ms with 0.5 ms steps (400 steps). Sensory Poisson trains are drawn anew every trial, so two identical tapes can yield different spike rasters. That is the point — the graph is deterministic; the drive is not.

After the epoch we count spikes on motor lists and convert to Hz over 200 ms. Those rates are what the decoder sees. The raster in the lab is a downsampled picture of the same trial.

Motor → trade (the analogy)

PopulationRoleActionDefault θ
MN9proboscis extension / feedingBUY8 Hz
DN1 / DN2descending startle / haltSELL8 Hz
aBN1antennal groomingGROOM (no order)12 Hz
noneHOLD

Grooming wins if aBN1 is above threshold and beats both motors by a conflict margin (default 3 Hz). If MN9 and DNs are both high, the stronger wins; if they sit inside the margin, HOLD. A bout cooldown (default 8 s) stops every trial from becoming an order. Size scales with confidence, clipped to a small SOL notionals band.

This is a population-rate readout after a stimulus epoch. It is not a claim that the fly “decided to buy.” When sugar GRNs fire, activity travels the real SEZ circuit and MN9 tends to rise — that is the Shiu result. We take that rate as the buy wire.

Neural decision trace

For each tick the backend stores:

  1. Injected sensory Hertz and a one-line note.
  2. Every cell that spiked, with its FlyWire root ID.
  3. Winning motor neurons and their rates.
  4. Strongest presynaptic partners that also spiked — real v783 edges, not a saliency map.
  5. One more hop back toward the stimulated sensory set, when such an edge exists.

The lab’s “neural decision trace” panel is that path. Logs keep the same record. If a fill happens, the trade row points at the tick that produced it.

What you see

3D brain. A dense cloud of tiny cells in an adult-fly silhouette: two optic lobes, central mass, a gap at the oesophagus, SEZ and a hint of VNC. This is a neuropil-region embedding so activity is readable. It is not EM skeleton xyz. IDs are real; coordinates are a museum stand-in. Named populations (sugar, bitter, MN9, …) sit in the neuropil they occupy and light when they fire.

Raster. Spike times in the current 200 ms trial.

Trace. Sensory → partners → motor, with FlyWire IDs.

Body. A small pose (walk, freeze, groom, idle) inferred from the same rates. Display only — not a NeuroMechFly body-CNS loop.

PnL / logs. Paper ledger and the sensory → spike → decision → fill log.

Paper vs live

Default is paper. The fly starts with 10 SOL of simulated equity against FLYDGEN. Public visitors only ever see paper. There is no public live switch and no public mint box.

Live pump.fun sends exist on the server only: they require SOLANA_PRIVATE_KEY in the process environment and an operator token. The key never enters the browser. Program 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P. Use a throwaway wallet with size you can lose. This is not financial advice.

Local vs hosted

The Next.js lab is a viewer. The 138k-cell Python process is the experiment. On your machine: backend at 127.0.0.1:8000, UI at localhost:3000. Health is /api/health. Port 8000 is the API, not the page.

Vercel hosts the UI. Without a public backend it runs a browser paper sim so the page is not stuck on “booting.” That sim is not the full connectome. To attach the hosted UI to a real brain, tunnel or host the API and set BACKEND_URL, NEXT_PUBLIC_API_URL, NEXT_PUBLIC_WS_URL, then redeploy. NEXT_PUBLIC_* is baked in at build time.

API surface

  • GET / — status
  • GET /api/health, /api/meta, /api/layout, /api/state
  • GET /api/science, /api/leaderboard, /api/presets
  • GET /api/history/logs|traces|trades
  • WS /ws — hello + tick stream

Mutating routes (mode, mint, stimulus) are locked. Public payloads are forced to paper and strip wallet and transaction fields.

What this is not

  • Not a financial advisor.
  • Not a trained trading model wearing a fly costume.
  • Not a full biomechanical NeuroMechFly loop.
  • Not evidence that Drosophila understands Solana.
  • Not EM-accurate xyz in the 3D view.

It is a transparent instrument: real wiring, published LIF, labelled sensory ports, labelled motor ports, every spike logged.

Citations

  • Dorkenwald et al., Nature 2024 — FlyWire whole-brain connectome.
  • Schlegel et al., Nature 2024 — cell types / annotations.
  • Shiu, Sterne, Spiller et al., bioRxiv 2023 / Nature 2024 — whole-brain LIF.
  • Court et al. — Virtual Fly Brain.
  • Model license: MIT, Philip Shiu & Nico Spiller (vendor/shiu_2024/).

Also see Methods and the lab.