Engram
A Uniswap v4 pool whose fee is set, trade by trade, by a small neural network stored on chain. The network can be replaced only by a better one, found in sealed, time-locked training rounds that anyone can enter.
Case study 01 of 04 · Ethereum mainnet · live since 5 October 2026 · block 26,128,922
- Role
- Design, economic model, Solidity, testing, launch and website
- Deployed
- 5 October 2026, 21:40 UTCContracts at block 26,128,922; pool opened at block 26,128,981
- Contracts
- Five, all verifiedEtherscan and Sourcify, exact match
- Testing
- 90 mainnet-fork checksTwo adversarial reviews before deployment
- Stack
- Solidity 0.8.28 (via IR), Uniswap v4, drand, EIP-2537, JavaScript
- Hook permissions
- 0x20CC
The living network
109 bytes: W1 8x10, b1, W2, b2, two shiftsTen int8 features go in, eight hidden ReLU units combine them, and one number comes out: the markout the network expects for this trade, in basis points. The hook turns it into the trade’s LP fee.
LP fee = clamp(0.30% + prediction, 0.05%, 3.00%)
Hover or tap a feature to see how the hook encodes it.
The project
Engram is an ERC-20 token with a single Uniswap v4 pool, native ETH against ENGRAM. Its hook, the Hippocampus, reads ten features of every trade, asks a 109-byte neural network what the trade’s markout will be (how far the price keeps moving in the trade’s direction afterwards), and sets that trade’s liquidity-provider fee from the answer.
The network is not fixed. Once a day a second contract, the Dreams, grades sealed candidate networks on trades that did not exist when the candidates were submitted. A candidate takes over only if it clearly beats both the network in place and a flat fee. Nobody chooses the winner; the grading does.
The problem
Liquidity providers lose money to informed flow: trades that already know where the price is going. A flat fee charges an arbitrage bot and an ordinary buyer the same amount. Dynamic-fee hooks in Uniswap v4 can price that difference, but the AI-driven launch I analysed at the time ran its model off chain, and a single wallet could upgrade both its token and its hook. The fee was whatever that wallet said it was.
Engram puts the whole loop on chain: the features, the model, the grading and the replacement. Nobody, the owner included, can set the fee or change the code. A model can only be replaced by one that predicts better, and the bounty for a better model is priced below what it would cost an outsider to fake one.
What I built
- An economic model, before any Solidity
A day-stepped JavaScript model of the pool, its traders and its trainers set the constants: the 0.30% base fee, the 0.04% trainers’ pot, the 3% promotion margin and the bounty rule. It changed the design twice: labels run from the price a trade leaves, and the bounty pays per unit of improvement.
- Five contracts and a shared library
The token, the Hippocampus hook, the Dreams, a drand signature verifier (the Beacon) and a Launcher. The network’s arithmetic, the Cortex, is one library used by both the hook and the Dreams, so a model is graded by exactly the code that will later price trades with it.
- A JavaScript twin
A BigInt mirror of the network and of the hook’s features, and a drand time-lock encoder, so a browser can seal a candidate exactly as the contract will read it.
- A mainnet-fork simulation
90 checks against the live Uniswap v4 contracts, with thousands of swaps run in lockstep with the JavaScript mirror.
- Two adversarial reviews
Full reviews before deployment found two high and four medium-severity issues. Each was fixed and reproduced in the simulation, or, where no clean fix existed, stated in the contract.
- A two-step launch
A launch page deployed every contract with the pool closed, verified the source on Etherscan and Sourcify, and only then let the owner open trading. A read-back then checked 18 values on mainnet.
- The project website
Pages that read every figure from the chain, a trainer that runs in the browser, and the buttons that let anyone seed, grade and finalize a round.
Brand and website
Engram is designed as an anatomy atlas. Every page of the website is a numbered plate with a figure and a caption, set in Vollkorn on warm paper, with ink line drawings and a single carmine accent for what the mind is doing. The X profile picture, the banner and the post cards are drawn as plates of the same atlas, so the site and the account read as one book.
- Palette
- Paper
#F2ECDFInk#1C1A17Carmine#A8322ASepia#6B5440 - Type
- Vollkorn and Vollkorn SC for text and plate titlesCutive Mono for data
How it works
- 1Perceive
The hook reads ten features of the trade: its size against the pool, its direction, the time since the last swap, other swaps in the block, recent flow, volatility, trend, and the trading wallet’s own record.
- 2Predict
The living network turns those ten numbers into one: the markout it expects for this trade, in basis points.
- 3Price
The trade’s LP fee is 0.30% plus the prediction, held between 0.05% and 3.00%. A trade the network expects to be informed pays more.
- 4Charge
The hook also takes 1.04% of the trade’s ETH side: 1.00% for the owner and 0.04% for the trainers’ pot.
- 5Remember
Eight remembered trades later, the trade’s markout is known. It is written to a hash-chained trace, and the wallet’s record moves by the trade’s weight.
- 6Dream
Once a day, sealed candidates are graded on the newest trades. A candidate replaces the living network only if it beats both it and the flat fee by 3%.
Smaller trades pay their fees but are never remembered, so dust cannot move anyone’s record.
Measured from the price the trade left, so its own impact never counts. Clipped to plus or minus 200 bps.
keccak256(previous, trace). Every 512 traces close a segment and store a checkpoint the Dreams can grade against.
Fig. 2. How a trade becomes a memory, step by step as Hippocampus._remember does it.
Seal. Candidates for round r are committed with a 0.01 ETH bond, optionally time-locked to the drand round published when window r closes.
Trade. The day’s remembered trades become the test set. No candidate can change, and none can be read.
Reveal. Anyone opens a candidate against its commitment, from its own key or from the time-lock.
Seed. The drand signature is checked on chain; its hash draws up to four of the window’s segments of 512 trades.
Grade. Anyone hands in a drawn segment; it is checked against the hash chain and every named candidate is scored.
Finalize. A candidate 3% better than both the living and the default network takes over and is paid; a living network worse than the default is retired.
Fig. 3. One training round on a 66-hour axis. Rounds settle strictly in order, and every step is open to anyone.
The contracts, reviewed
Supply and minting
One billion ENGRAM were created once, when the token was deployed, and all of them went to the launch. No function can create more.
INITIAL_SUPPLY = 1_000_000_000 ether is minted to msg.sender, the Launcher, in the constructor. There is no mint. Launcher.open() places the band and sends any ENGRAM it could not hold to the owner.
Burning
Any holder can destroy their own tokens. When the locked position’s fees are collected, whatever the network charged above the base rate is destroyed too.
burn(value) and burnFrom(from, value) against an allowance. Launcher.collect() burns the excess ENGRAM with Engram.burn and sends the excess ETH to 0x...dEaD.
Transfers
A plain ERC-20: no transfer tax, no blacklist, no trading switch. Approvals can also be signed off chain.
Standard transfer, transferFrom and approve. EIP-2612 permit refuses an s in the upper half of the curve order, so a signature has one form only, and rebuilds the domain separator if the chain id changes.
Fees
Every trade pays the hook 1.04% of its ETH side, and an LP fee that the network sets for that trade, between 0.05% and 3.00%. A swap that names an ETH amount and fills only partly is refused, so nobody pays a fee on ETH that never traded.
beforeSwap returns the LP fee with the override flag, in pips: base 3,000, floor 500, ceiling 30,000. The hook fee is a BeforeSwapDelta when ETH is the specified side and an afterSwap return delta otherwise, minted to the hook as ERC-6909 claims. Mismatched fills revert PartialFill.
int256 pred = Cortex.forward(Cortex.load(champion), f);
int256 fee = FEE_BASE + pred * 100;
if (fee < FEE_MIN) fee = FEE_MIN;
if (fee > FEE_MAX) fee = FEE_MAX;The model
The network is a small data contract of 109 bytes. Only the Dreams can change which network the hook uses, and only at the end of a public round.
champion points at a contract whose code is STOP followed by the 109 bytes; Cortex.load reads them with extcodecopy, and the forward pass is unrolled assembly because grading runs it 512 times per segment per model. setChampion reverts NotDreams for any other caller.
Rewards for trainers
A trainer whose network takes over is paid from the trainers’ pot by how much it improved. Every candidate that is fully graded gets its 0.01 ETH bond back. Winners collect their payment themselves.
bounty = 4 x windowPot x (bar - loss) / bar, capped at the pot, plus bonds forfeited since the last win, credited to owed[winner] and paid by pull(). Promotion needs loss < bar x 0.97 with bar = min(living, default).
Owner and admin powers
There is no administrator. The owner wallet could open the pool once; since then it can only receive. It cannot change the code, the fees, the model or anyone’s balance.
Launcher.open() is owner-only and once-only (AlreadyOpen). No contract has a pause, an upgrade path or a setter. payOwner() and collect() can be called by anyone and pay only the owner.
Liquidity
All launch liquidity sits in one position owned by the Launcher contract, which has no function to withdraw, move or burn it. Its fees go to the owner at the base 0.30% rate; anything above that is destroyed, so a greedier network earns the owner nothing.
The position NFT is minted to the Launcher in open(). collect() runs DECREASE_LIQUIDITY with zero liquidity and TAKE_PAIR, then pays fees x atBase / charged per currency from the hook’s fee tallies, all of it when charged <= atBase.
Randomness
The only outside input is drand, a public randomness network. Its signatures are checked on chain against drand’s public key, so nobody can choose or predict the value that seals candidates and draws the grading sample.
The Beacon verifies BLS12-381 signatures on G1 against quicknet’s G2 key with the EIP-2537 precompiles (map-to-curve and pairing). The key is fixed in eight immutables; a round’s randomness is the SHA-256 of its signature.
Testing and security
The first review found that anyone could void any training round by seeding it with an empty range past the last segment; the fix pins the range to segments that exist, with checkpoint times checked at both ends. The second found that a quiet window with a single segment could be bought whole right after the deadline; now the segment that straddles the deadline is never drawn, so a round needs two completed segments.
| Operation | Gas | Plain pool |
|---|---|---|
| Buy, exact input of 0.01 ETH | 166,982 | 89,658 |
| Sell, exact input | 173,196 | 95,397 |
| Buy, exact output | 169,201 | 95,646 |
| Sell, exact output of 0.01 ETH | 172,530 | 94,806 |
| Submit a sealed candidate | 104,630 | |
| Reveal a candidate | 134,785 | |
| Seed a round | 275,251 | |
| Grade one segment of 512 trades | 8,856,083 to 8,926,208 | |
| Finalize a round | 182,007 | |
| Collect the locked position’s fees | 171,935 | |
| Deploy every contract, pool closed (mainnet) | 6,645,852 | |
| Open the pool (mainnet) | 633,757 |
Limits, stated plainly
- Memory follows the wallet that signs the transaction. A wallet that rotates always looks new, and a relayer shares one memory for everyone it carries.
- The network sees only what is on chain. It cannot know the future, and its reach is bounded: the LP fee stays between 0.05% and 3.00%, and the 1.04% hook fee never changes.
- Rounds do not run themselves. Someone has to seed, grade and finalize each one, in order. Anyone may, and trainers have reason to. A window needs at least two completed segments of 512 remembered trades to be graded at all.
- Grading uses a sample: up to four segments of 512 trades, not every trade.
- The owner receives 1% of every trade, so it can trade in this pool almost for free. That makes faking an improvement cheaper for the owner than for anyone else. The most it could win that way is the trainers’ pot, and a greedier network would earn it nothing.
Status on chain
Read from Ethereum mainnet on 20 October 2026, block 26,234,001
- The pool prices every trade with the default network, a flat 0.30% LP fee. No candidate has been promoted.
- The hook had written 5,779 trades to its trace: 11 complete segments of 512, and 147 in the open one.
- No training round has been finalized yet. Rounds settle strictly in order, and round 1 is still waiting for someone to finalize it.
What came after: Neurogenesis and Night Shift
Two more contracts went live in the days after Engram’s launch, both verified. Neither had been used on mainnet when this page was written.
- Neurogenesis, the launchpad, live since 6 October 2026
One call launches a token with an Engram of its own: the token, a hook that runs Engram’s mind unchanged, its own Dreams for training rounds, and an ETH pool that holds the whole supply in one band, locked in the launch’s own contract for ever. The creator picks the hook fee once, between 0.30% and 3.00% of each trade’s ETH side. A tenth of it goes to the launchpad: half to a payee the factory’s owner names, half to the Lysosome, an ownerless contract that can only buy ENGRAM and burn it. The owner can change that tenth for future launches only, never above 25%, and cannot touch a launch once it exists.
- Night Shift, the keeper purse, live since 7 October 2026
Rounds only happen if someone seeds, grades and wakes them, and every step costs gas. Night Shift repays it, for Engram’s Dreams and for every launch’s. Anyone can fund a pool’s purse, which pays the round’s own steps; a trainer’s backing pays only that candidate’s steps, so throwaway candidates cannot drain a purse. A step is paid 1.2 times its counted gas, at the lowest of the transaction’s gas price, the base fee plus 0.1 gwei, and 3 gwei; calldata must be exactly the call’s arguments, so the count cannot be padded. Nobody owns it.
Read from mainnet on 21 October 2026, block 26,242,782: no token had been launched through Neurogenesis, the Lysosome had burned nothing, and Night Shift had never been funded, so it had paid no step. Before release, the launch path passed 118 checks on a mainnet fork and Night Shift 44, where its counted gas came within 0.9994 to 1.0013 times the receipts over 18 paid steps.
Contracts
| Contract | Address | Verified source |
|---|---|---|
EngramERC-20 token |
0x56C915D92E24255fdC52eb114a31399c432B7Cc6 | Etherscan (opens in a new tab) |
HippocampusUniswap v4 hook |
0x0Ee851f1fe2f4BDbA79FeE78969E329C136CA0cc | Etherscan (opens in a new tab) |
DreamsTraining rounds |
0xC1182B08DD2B95f1477baa1dFD0741Eb06b1Ce9f | Etherscan (opens in a new tab) |
Beacondrand signature verifier |
0xaea57Aa43Db8960F13fF366D1d8Fd83F340fa7D9 | Etherscan (opens in a new tab) |
LauncherLaunch and liquidity custody |
0x7AD86367Bd4e12b7e0BA15e6D05754CE8E723acD | Etherscan (opens in a new tab) |
NeurogenesisLaunchpad factory |
0xC0FCb8633A87C7CBdca021774bEb43D25527E193 | Etherscan (opens in a new tab) |
LysosomeBuys ENGRAM and burns it |
0x00f46daA61190769c06935Fe2dF60A60320a0Dd5 | Etherscan (opens in a new tab) |
Night ShiftKeeper purse for the Dreams |
0x28ff0D171F536f91Cc269e1fbA871Af0e83957C8 | Etherscan (opens in a new tab) |
The five Engram contracts are verified on Etherscan and on Sourcify with an exact match, metadata included; so is Neurogenesis, and Lysosome and Night Shift are verified on Etherscan with an exact match. Compiler: solc 0.8.28, via IR, 200 optimizer runs, EVM target Cancun.









