Visualizer

Watch the brain trade.

Both episodes, replayed millisecond by millisecond from the logged observations and reproducing the on-chain spike roots exactly. The top half is the fly: every soma at its real position from the MaleCNS reconstruction, lit as it fires. The bottom half is the pool, advancing block by block as intents arrive, get decided and fill.

Drag to orbit · scroll to zoom · right-drag to pan. WebGL required; best on desktop. Open full screen ↗
Brain regionsOptic lobes, central brain and ventral nerve cord, with the body outlined for orientation. Bars rank which superclasses fired most during the episode.
Retina insetThe 160×120 image the rasterizer painted for this intent, the only thing the fly is told about the market.
Block timelineSpot price, reserves, intents in the queue and fills, in the order they happened on Sepolia. Each decision opens its episode in the brain view.
ReadoutThe four population rates converging on the fee and skew that were written on chain.
Gas Expand · Demo · Sepolia testnet

A fruit fly brain prices every swap on an Ethereum AMM.

The complete MaleCNS fruit-fly connectome, 166,700 neurons and 25.6 million synapses, runs as a Solidity contract. Every swap on the pool is priced by its own 100 ms brain episode. One episode burns more than 14,000,000,000 gas to execute. Gas Killer settles it on Sepolia for 406,341.

166,700neurons simulated on-chain
25.58 Msynapses in 4,196 data contracts
14,000,000,000+EVM gas per swap decision
16.78 MSepolia's per-transaction cap (EIP-7825)
406,341gas to settle a decision on-chain
~830×over the cap, made verifiable
What we built

The biggest computation ever settled into a single storage word.

Gas Killer's unbounded profile lets a tracked contract call run under a 240 gas budget off-chain, with only the resulting state change written on-chain under an aggregate signature. To prove that end to end we picked the heaviest deterministic workload we could find: a whole animal's brain.

01

The connectome, on-chain

The MaleCNS v1.0 fly connectome, converted to a compact integer graph and uploaded to Sepolia as immutable data contracts behind a two-level directory. The same deployment pipeline that put Qwen3 weights on-chain for our LLM consumer.

  • 4,196 graph chunks, 219 warm-state chunks
  • Content-addressed; the engine verifies every code hash before use
  • Directory root 0xe7c8…5641
02

FlyEngine

A stateless, integer-only leaky-integrate-and-fire simulator written in Solidity and Yul. It reads the connectome through STATICCALL, steps 166,700 neurons in Q24 fixed point, and is bit-for-bit identical to the Python reference across 11 pinned test vectors.

  • 149,600,000,000 gas per simulated second of brain time
  • Retina rasterizer turns market state into a 160×120 image
  • Deterministic spike root commits to every spike
03

FlySwapPool + FlySwapPolicy

A plain x·y = k pool where every swap is an escrowed intent, and a tiny Gas Killer consumer whose only tracked function runs one brain episode per intent and writes the fee it chose.

How it works

Off-chain execution. On-chain security. One swap at a time.

The pool never calls the brain. The brain never touches the pool's tokens. The two are joined by a 32-byte fill word that Gas Killer's operator network writes into the policy contract after simulating the episode and agreeing on the result.

1 · On chain

Trader calls submit(). Tokens are escrowed, the intent joins a FIFO queue.

2 · Gas Killer network

Router and operators simulate settle() under the unbounded profile: rasterize the intent, run 1,000 brain steps, read out a fee. They sign the resulting storage diff.

3 · On chain

verifyAndUpdate() checks the signature and writes the fill word. Anyone calls applyUpTo(); the pool fills the swap at the fly's fee.
Step01
On chain · FlySwapPool

A swap becomes an intent

The trader picks a side and an amount and calls submit. The pool pulls the input tokens into escrow, assigns the next id, and emits IntentSubmitted. Nothing is priced yet. Intents settle strictly in order, so nobody can jump the queue once the brain has looked at it.

Step02
Off chain · Keeper → Gas Killer router

A task is posted for the tracked function

A keeper reads the last settled fly state from the logs and posts a task: target FlySwapPolicy, calldata settle(prev), reference block latest. The router validates it, traces the call once under the 240 gas profile, and hands the digest to the operator quorum. The same call sent as a normal transaction would revert immediately: it needs over 14,000,000,000 gas and Sepolia allows 16,777,216.

Step03
Off chain · Operator quorum

Every operator runs the brain

settle STATICCALLs the pool for a storage-only observation of the head intent: side, size relative to reserves, queue depth, the 16-epoch buy/sell histogram, spot versus its moving average. The rasterizer paints that as a 160×120 retina image. The engine then integrates all 166,700 neurons for 1,000 steps of 100 µs and returns four population firing rates and a spike root. Each operator reaches the identical bytes, so each signs the identical storage diff.

Measured on the fleet's simulation node: 25 s to execute, 84 s to produce the net storage diff via the prestate tracer. Three operators plus the router finish inside the five-minute round.

Step04
On chain · FlySwapPolicy.verifyAndUpdate

14,000,000,000 gas becomes three stores and two logs

The keeper broadcasts the rendered payload. verifyAndUpdate verifies the quorum signature and applies the diff: the fill word for the intent, the decided-through counter, and the chained fly state. It also replays FlyIntentDecided and FlySettled, so the observation, the readout and the spike root are all in the event log for anyone to re-simulate.

Step05
On chain · FlySwapPool.applyUpTo

The pool fills at the fly's price

Anyone, including the trader, calls applyUpTo. The pool reads the fill word from the policy, clamps fee and skew to the safety band, computes the output on x·y = k, releases the tokens and emits Swap. If the fly's fee would breach the trader's minimum output, or the intent expired before a decision, the escrow is refunded instead.

What the fill word carries

One 32-byte slot per intent, keyed by id, is all the pool ever reads from the brain.

fee16 bits
skew16 bits
flags8 bits
epoch24 bits
spike root160 bits

Intent #1's word: 0x001f0002000000010000000065250fef…4437e6 reads fee 31, skew +2, epoch 1.

Inside the fly

How a market becomes something a fly can see.

The connectome is real. The retina input is engineered. We draw the state of the order book as an image on the fly's photoreceptors, let the whole brain react, and read the fee off four groups of neurons.

The retina image

A 160×120 canvas rasterized fresh for each intent:

  • Rows 0–39 deviation strip: spot price against its 1/8 exponential moving average
  • Rows 40–79 intent strip: which side, how big relative to a reference size, queue depth
  • Rows 80–119 slippage strip: the trader's tolerance
  • Rows 120+ volume bars: the last 16 epochs of buy and sell flow

Lit pixels become input current on the photoreceptor neurons that sit at those coordinates. Intent #1 lit 244 receptors; intent #2, with history behind it, lit 408.

The simulation

Leaky integrate-and-fire dynamics on every neuron, with signed synaptic weights straight from the electron-microscopy reconstruction. All arithmetic is 64-bit fixed point with round-half-up, decay tables precomputed in Q64, and a fixed iteration order, so the EVM, the C kernel and the Python reference agree bit for bit.

A 100 ms episode is 1,000 steps. Intent #1 produced 28,141 spikes; intent #2 produced 28,028. Every spike goes into a running hash, and the final 160-bit spike root lands in the fill word as a commitment anyone can check by re-running the episode.

The readout

Four population rates are measured over the episode. Their ratios map onto the fee and the directional skew through fixed, published tables. The pool then clamps: fee within 5 to 100 bps, skew within ±30 bps, and sells pay fee minus skew so the brain can lean the pool one way without ever charging outside the band.

Intent #1: rates 11,323 / 6,377 / 6,377 / 7,790 → fee 31, skew +2, buy paid 33 bps. Intent #2: 25,005 / 9,393 / 9,393 / 9,913 → fee 41, skew +9, sell paid 32 bps.

Honest framing

This fly does not learn, and it is not a market oracle. It is a deterministic, biologically derived controller whose outputs can be predicted by anyone willing to run the simulation. That is exactly the property Gas Killer needs: every operator must reach the same answer, and every user must be able to verify it.

What it demonstrates is scale. If an entire brain can be a tracked function, so can your risk engine, your on-chain order matching, or the invariant checks you cut because gas made them unaffordable.

On chain

Live on Sepolia, through the public Gas Killer testnet.

Two intents were submitted, priced by the brain, settled by the operator quorum and filled. Every step is a public transaction; the observation and readout are in the logs, so the episodes can be replayed from chain data alone. The visualizer below was built that way.

IntentObservationFly decisionSettlement (verifyAndUpdate)Fill (applyUpTo)
Buy #1
10 quote in
0xc09828fe…138b
size 50 bps · queue 2 · 244 receptors lit · flat history fee 31 · skew +2
28,141 spikes
0xddd22cf8…8c09
406,341 gas · 3 STOREs + 2 logs · ready in ~4 min
0x1e2f963b…5c25
paid 33 bps · out 4.958788 base
Sell #2
2 base in
0x2a465ed2…ef3a
size 20 bps · queue 1 · 408 receptors lit · spot 1.0% above EMA fee 41 · skew +9
28,028 spikes
0xfab96cfc…b523
355,521 gas · ready in ~4 min
0x2f33bb23…655f
paid 32 bps (fee − skew) · out 4.019053 quote

Where to look on Etherscan

  • The settlement transactions are calls to verifyAndUpdate on the policy. Their FlyIntentDecided log holds the observation, the four rates and the spike root.
  • The fill transactions are calls to applyUpTo on the pool. Their Swap log shows the fee actually paid, which matches the policy's fill word from the transaction before it.
  • The policy's storage is the whole interface: three slots per round. Nothing else on chain knows a brain was involved.

An earlier version, FlyAMM + FlyPolicy at 0x0147…ed50, priced the pool per 25-block window with a 300 ms episode. It stays deployed; the per-swap design above replaced it because it gives every trade its own decision.

What this means for your contract

Gas Expand: run what the block gas limit rules out.

The fly is a stress test, not the product. The product is the path it took: one line of Solidity to make a function tracked, transactions redirected to the Gas Killer RPC, execution moved off-chain under a 240 gas budget, and the final state written back under an aggregate signature by a slashable operator network. If the network is unavailable your function still executes on-chain as before.

Get in touch →   Read the docs   Code on GitHub