Autonomous AI strategy execution for Uniswap v4 pools using Reactive Contracts. UniBrain turns pool telemetry into deterministic, authenticated, on-chain strategy updates without keepers or bot operators.
LP strategy operations in AMMs are still mostly manual or bot-driven:
- Strategy updates are delayed or inconsistent under volatile market conditions.
- Off-chain keepers create liveness and trust assumptions.
- Execution auth is often weak across origin and destination chains.
- Protocol teams cannot easily prove deterministic, replay-safe decisioning to judges, auditors, or partners.
UniBrain implements an event-driven strategy loop with strict on-chain verification:
Origin: Uniswap v4 hook emits telemetry on pool activity.Reactive: deterministic AI logic extracts features, scores risk/regime, and computes bounded strategy decisions.Destination: executor authenticates callback source + RVM identity + nonce, then applies bounded updates to strategy state.
- Uniswap v4 hook architecture (
PoolManager, hook permission bits, swap hook flow) - Reactive Network / Lasna (
subscribe(...),react(LogRecord), callback payload path with RVM argument replacement) - Base Sepolia as both origin and destination execution domain
contracts/src/UniBrainTelemetryHook.sol: telemetry emission and fee-target reads from strategy statecontracts/src/UniBrainStrategyBook.sol: bounded strategy state, replay checks, fee/range storagecontracts/src/UniBrainStrategyExecutor.sol: callback authenticity checks, RVM allowlist checks, non-reentrant executionreactive/src/UniBrainReactiveStrategy.sol: subscription lifecycle, deterministic decisioning, callback emissionshared/solidity/src/DeterministicAI.sol: deterministic feature extraction and scoring modelscripts/demo-sepolia.sh: end-to-end proof runner with detailed tx URL loggingfrontend/: dashboard for telemetry, decisions, and execution visibility
flowchart LR
U["LP Operator"]
D["Demo Script"]
H["UniBrainTelemetryHook"]
R["UniBrainReactiveStrategy"]
E["UniBrainStrategyExecutor"]
B["UniBrainStrategyBook"]
U -->|Run demo script| D
D -->|Generate pool activity swap| H
H -->|Emit telemetry| R
R -->|Compute decision and callback| E
E -->|Apply decision| B
B -->|Updated fee and range state| U
flowchart TB
subgraph Origin[Origin - Base Sepolia]
PM[PoolManager]
HK[UniBrainTelemetryHook]
PM --> HK
end
subgraph Reactive[Reactive - Lasna]
RC[UniBrainReactiveStrategy]
SYS[Reactive Service]
SYS --> RC
end
subgraph Destination[Destination - Base Sepolia]
EX[UniBrainStrategyExecutor]
SB[UniBrainStrategyBook]
EX --> SB
end
HK -->|Telemetry logs| RC
RC -->|Callback payload| EX
sequenceDiagram
participant PM as PoolManager
participant H as UniBrainTelemetryHook
participant R as UniBrainReactiveStrategy
participant E as UniBrainStrategyExecutor
participant B as UniBrainStrategyBook
PM->>H: beforeSwap/afterSwap
H-->>R: TelemetryEmitted(poolId,...)
R->>R: deterministic feature extraction + scoring
R-->>E: Callback(rvmId, decision payload)
E->>E: proxy + RVM + nonce checks
E->>B: applyDecision(...)
B-->>E: applied=true
- Owner:
0x4b992F2Fbf714C0fCBb23baC5130Ace48CaD00cd - Base Sepolia PoolManager:
0x05E73354cFDd6745C338b50BcFDfA3Aa6fA03408 - Base Sepolia CallbackProxy:
0xa6eA49Ed671B8a4dfCDd34E36b7a75Ac79B8A5a6 - Base Sepolia StrategyBook:
0x25159820b8e4E1d7661bA50E0093b244fCCcCc22 - Base Sepolia StrategyExecutor:
0x7aD1473337C4E1b5B808e897b41B353b4cC5A597 - Base Sepolia UniBrainTelemetryHook:
0xB40207558471cA465978Dbb02e96E07d335b40C0 - Reactive Lasna UniBrainReactiveStrategy:
0x994987B24486717DDa19411c56d82c29f6B19CDC - Reactive Lasna Service:
0x0000000000000000000000000000000000fffFfF
- StrategyBook create: https://sepolia.basescan.org/tx/0xb8f9963601051e1790ff250c377280ed140721d46ff57228fc3801f6a2c07f7b
- StrategyExecutor create: https://sepolia.basescan.org/tx/0xcb8a11603757f2d5779373638d54df0ba586f020ea8e62fa7fcf5497e2d7d114
- StrategyBook setExecutor: https://sepolia.basescan.org/tx/0x8bba29cea72a382bcbfd4288c84404dcf96b1c15ceb9ddffed8ff7a58e200b77
- Hook create2: https://sepolia.basescan.org/tx/0x9d4b7f372af50549847cb32a077fa5aff7bd57460aee02c3bfc150cb54dc0d4f
- Reactive deploy: https://lasna.reactscan.net/tx/0xadd29b5374baf40e9f21d498f1ec18368ac7f8b0a6b1d8e8f19867d4be402c3f
- activateSubscriptions: https://lasna.reactscan.net/tx/0x0862a271909fe75033035d9db6768c41b8afcdce457b8f0d2ce49c15838647c3
The make demo-sepolia flow validates:
- Chain + bytecode preflight checks on Base Sepolia and Lasna.
- Reactive health checks (
subscriptionsActive, expected count, debt coverage). - Fresh Base Sepolia activity generation to guarantee telemetry.
- Reactive-side proof via RNK RPC (
DecisionComputed+Callbacklog detection). - Destination execution scan on Base (
DecisionExecutionAttempt).
- Base telemetry reference tx: https://sepolia.basescan.org/tx/0x5709f71f9b27c6ed083d816265085ef812eeee4d114db7c96956287bb0df0539
- Lasna decision tx: https://lasna.reactscan.net/tx/0xc2051f9bd583a32dc966767a83331c6b921173e3e2c55dd56f612e800b2cf948
- Lasna callback tx: https://lasna.reactscan.net/tx/0xc2051f9bd583a32dc966767a83331c6b921173e3e2c55dd56f612e800b2cf948
- Activity poolId:
0xd3be67c93d778d581b23fb1396b7c7b86cd88b5c3047c9217ea52abf241607e1
- https://sepolia.basescan.org/tx/0xa832360ac56e7eb0ccbc96722c301af677e119e758da9ce30ba3eedaafd947ed
- https://sepolia.basescan.org/tx/0x0a75702549ebc107ba6e9768a24455d35e5f46220237a5e97a9e77e56aeecc8d
- https://sepolia.basescan.org/tx/0x0ccf6cbb90c0e6e729815e72c0a07c1531f756784d5b89f7b1293ba2a6a55c30
- https://sepolia.basescan.org/tx/0x7003da3dc30dd7453af7e506e63bf8aaf74dd763184cd6a9c691d9d1b43de41c
- https://sepolia.basescan.org/tx/0x5c9cb11088eb58c21e4752cf3b19b6743632217e0c716a732ab343005f7fd489
- https://sepolia.basescan.org/tx/0xa55ffb2fc29de868c87e1655576a2587a46f364b51b88d8dd70aa7633dac0c38
- https://sepolia.basescan.org/tx/0x3cc7d28a2ffa014ad87beece94bfe9e3ce1ba0a1a3deb5e1433469520c95bc44
- https://sepolia.basescan.org/tx/0x5a2f969a855b7e311714778d5481b2a0a483150cf150fcf2d62d8514403425ac
- https://sepolia.basescan.org/tx/0x226cceae329d5caf7d77e6d216c32c68d018ed3d53d102f9c6c8e941c0593c21
- https://sepolia.basescan.org/tx/0x9774e18a3863b46ff4d5e085341f11c9bcac7a7689bd72be3816e20590dce8c2
- https://sepolia.basescan.org/tx/0x85a5a6e86f34e5a98aedfd7849ed5abdf1d5a3f24ccbaaea2f28f28a8f77ec0e
- https://sepolia.basescan.org/tx/0x16e416d86950e7a611f0262d2ae3c065356c37b8f00fadcacfeace7c7c8870ad
- https://sepolia.basescan.org/tx/0xf40e1cd31cdc1cca2bc1d0f23315f30a4229b9af7bb731abf04de64b0460f7de
- https://sepolia.basescan.org/tx/0xaeb0ac67c74bbdfcc9d2080ab7a468dea53b998432c0fcf852a8aa7e1d19d5de
- https://sepolia.basescan.org/tx/0x5709f71f9b27c6ed083d816265085ef812eeee4d114db7c96956287bb0df0539
make demo-sepoliaforge test:38/38passing (root contracts)forge test --root reactive:8/8passing (reactive package)- Combined Forge pass rate:
46/46passing
- Command used:
cd contracts && forge coverage --ir-minimum --report summary - Total coverage from latest report:
- Lines:
73.83% (347/470) - Statements:
71.00% (377/531) - Branches:
42.72% (44/103) - Functions:
92.31% (60/65)
- Lines:
- Critical contract highlights:
UniBrainTelemetryHook.sol:100%lines, statements, branches, funcsUniBrainStrategyBook.sol:97.50%lines,100%branches,100%funcsUniBrainStrategyExecutor.sol:100%branches,100%funcsUniBrainReactiveStrategy.sol:98.90%lines/statements,100%funcs
- Unit tests
- Edge-case tests
- Fuzz tests
- Integration lifecycle tests
- Callback authentication / replay tests
- Subscription reliability tests (constructor-no-subscribe, strict activate, failure reverts, health views)
- Raise total branch/line coverage to full 100% by expanding branch-focused tests in shared AI and deploy script paths.
- Add destination execution assertion path to demo for deterministic
DecisionExecutionAttempt/state-diff proof in one run. - Add richer frontend observability for per-decision provenance, nonce tracking, and replay diagnostics.
- Add gas benchmark gates in CI for hook and executor critical paths.
- Expand multi-pool/multi-regime stress testing and invariant suites.