Recognition: no theorem link
State Twins: An Off-Chain Substrate for Agentic Reasoning over Decentralized Finance Protocols
Pith reviewed 2026-05-13 01:47 UTC · model grok-4.3
The pith
State Twins replicate on-chain AMM pools in memory to let agents fork, replay, and branch scenarios without blockchain latency.
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
Core claim
The central claim is that a State Twin is a typed, in-memory, replayable replica of an on-chain AMM pool that preserves protocol mathematics while admitting forking, replay, branching, and counterfactual rollout. Each AMM family is formalized as a discrete-time controlled dynamical system, a quantitative fidelity bound is proved on the divergence between twin and chain, and a single primitive implements the substrate for notebook use, backtesting, and LLM agent tools alike. The architecture is shown by seeding multiple independent twins from one RPC read and evaluating them under distinct price-shock scenarios in sub-second time.
What carries the argument
The State Twin, a typed in-memory replayable replica of an AMM pool formalized as a discrete-time controlled dynamical system that carries the fidelity bound and enables branching operations.
If this is right
- The same primitive works without modification for notebook quant work, strategy backtesting, and exposure as typed tools to an LLM agent.
- One live RPC read can initialize any number of independent twins to run parallel evaluations under distinct scenarios.
- Agent action spaces expand because queries no longer incur block confirmation latency or gas costs.
- Counterfactual and branching analysis becomes routine for exploring what-if paths in DeFi protocols.
Where Pith is reading between the lines
- The same modeling pattern could be applied to other DeFi components such as lending markets or derivatives if equivalent dynamical-system formalizations are written.
- Rapid off-chain simulation might allow agents to perform deeper multi-step planning by testing many branches before any on-chain action.
- The dynamical-systems view opens a route to importing analysis techniques from control theory for predicting pool behavior under stress.
- Extending the substrate to full protocol stacks rather than single pools would require only additional state-transition rules while keeping the same twin interface.
Load-bearing premise
Modeling AMM pools as discrete-time controlled dynamical systems accurately captures all relevant on-chain state transitions and the quantitative fidelity bound between the in-memory twin and live chain holds under real-world conditions including price shocks and liquidity events.
What would settle it
A direct comparison that records the twin state diverging from the live AMM pool by more than the proved bound immediately after a major price shock or liquidity event on an active chain.
read the original abstract
We introduce the State Twin: a typed, in-memory, replayable replica of an on-chain automated market maker (AMM) pool that serves as a substrate for agentic reasoning over decentralized finance (DeFi) protocols. Agentic DeFi stacks today couple reasoning to chain time, since every "what if?" query incurs a new RPC read or a real transaction, so the agent's effective action space is bounded by block confirmation latency and gas. We argue this coupling is a structural problem rather than a performance one, and that the missing layer is an off-chain substrate that preserves the protocol's exact mathematics while admitting the operations on-chain state cannot: forking, replay, branching, counterfactual rollout. We formalize each AMM family (Uniswap V2, V3, Balancer, Stableswap) as a discrete-time controlled dynamical system, prove a quantitative fidelity bound on the divergence between twin and chain, and give the open architecture used in DeFiPy v2, an open-source Python toolkit that ships the State Twin substrate and a reference Model Context Protocol server exposing typed analytical primitives as LLM tools. The same primitive (i.e., one Python class, one calling pattern) serves a notebook quant, a backtest, and an LLM agent without modification. We close with a fork-and-evaluate worked example: a single live RPC read seeds N independent in-memory twins under distinct price-shock scenarios, in sub-second wall-clock time. The contribution is the substrate, not a particular agent, which is what the specification of what an agentic DeFi substrate must look like
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper introduces State Twins as typed, in-memory, replayable replicas of on-chain AMM pools to enable agentic reasoning over DeFi protocols without coupling to block latency or gas costs. It formalizes AMM families (Uniswap V2, V3, Balancer, Stableswap) as discrete-time controlled dynamical systems, proves a quantitative fidelity bound on divergence between the twin and live chain, and details the open architecture implemented in DeFiPy v2 (including a Model Context Protocol server exposing typed primitives as LLM tools). The same substrate supports notebooks, backtests, and agents; a worked example demonstrates forking a live RPC read into N independent twins under distinct price-shock scenarios in sub-second time.
Significance. If the formalization and fidelity bound hold, the work supplies a practical off-chain substrate that preserves exact AMM mathematics while enabling forking, replay, and counterfactual rollouts unavailable on-chain. The open-source DeFiPy v2 implementation and uniform calling pattern across use cases add reproducibility and immediate utility for quant and agentic workflows. This addresses a structural bottleneck in agentic DeFi and could accelerate development of more sophisticated reasoning systems.
major comments (2)
- [§3] §3 (Dynamical System Formalization): The central claim requires explicit state variables, control inputs, and transition functions for each AMM family (e.g., how concentrated liquidity in V3 or invariant curves in Stableswap map to discrete steps). Without these, it is unclear whether all relevant on-chain transitions (including liquidity events) are captured, directly affecting the fidelity bound.
- [§4] §4 (Fidelity Proof): The quantitative fidelity bound is load-bearing for the substrate's validity. The manuscript must supply the full derivation, including error accumulation analysis under price shocks and liquidity events, plus any assumptions on discretization granularity, so the bound's tightness and applicability can be verified.
minor comments (2)
- [Abstract] The abstract is information-dense; a short enumerated list of contributions would improve scannability.
- [Final section] The worked example in the final section would benefit from a small diagram or pseudocode snippet showing the fork-and-evaluate flow.
Simulated Author's Rebuttal
We thank the referee for the positive evaluation and constructive feedback on the State Twins substrate. The comments correctly identify areas where greater explicitness will improve the manuscript. We respond to each major comment below and will revise the paper accordingly.
read point-by-point responses
-
Referee: [§3] §3 (Dynamical System Formalization): The central claim requires explicit state variables, control inputs, and transition functions for each AMM family (e.g., how concentrated liquidity in V3 or invariant curves in Stableswap map to discrete steps). Without these, it is unclear whether all relevant on-chain transitions (including liquidity events) are captured, directly affecting the fidelity bound.
Authors: We agree that §3 would be strengthened by explicit definitions. The manuscript already models each AMM family as a discrete-time controlled dynamical system, but the presentation is currently at the level of the overall framework rather than the per-family mappings. In the revision we will add the state vector (reserves, liquidity positions, and fee parameters), control inputs (swap amounts, liquidity additions/removals), and the exact transition function for Uniswap V2, V3 (including concentrated liquidity ticks), Balancer, and Stableswap. Liquidity events will be shown as discrete state updates that preserve the on-chain invariant at each step. revision: yes
-
Referee: [§4] §4 (Fidelity Proof): The quantitative fidelity bound is load-bearing for the substrate's validity. The manuscript must supply the full derivation, including error accumulation analysis under price shocks and liquidity events, plus any assumptions on discretization granularity, so the bound's tightness and applicability can be verified.
Authors: We accept that the current §4 provides the bound and a high-level argument but omits the complete derivation. The revised manuscript will include the full step-by-step proof, a bound on accumulated divergence over multiple discrete steps, explicit treatment of error growth under price shocks and liquidity events, and the discretization assumptions (block-time granularity and floating-point precision). This will allow direct verification of the bound's tightness. revision: yes
Circularity Check
No significant circularity; contribution is architectural formalization plus open implementation
full rationale
The paper introduces the State Twin substrate, formalizes AMM families as discrete-time controlled dynamical systems, states a quantitative fidelity bound, and supplies the open-source DeFiPy v2 architecture and primitives. No load-bearing step reduces by construction to a fitted parameter, self-referential definition, or self-citation chain; the claimed proof and bound are presented as independent results of the formalization, and the core deliverable is the inspectable code substrate rather than a closed derivation that presupposes its own outputs. The derivation chain is therefore self-contained against external benchmarks.
Axiom & Free-Parameter Ledger
axioms (1)
- domain assumption Each AMM family can be formalized as a discrete-time controlled dynamical system whose state evolution matches on-chain behavior up to a quantifiable bound.
invented entities (1)
-
State Twin
no independent evidence
Reference graph
Works this paper leans on
-
[1]
J. Tranquilli and N. Gupta,Formal State-Machine Models for Uniswap v3 Concentrated-Liquidity AMMs: Priced Timed Automata, Finite-State Transducers, and Provable Rounding Bounds, arXiv:2512.06203, 2025
-
[2]
R. E. Kalman,A new approach to linear filtering and prediction problems, Journal of Basic Engineering, vol. 82, no. 1, pp. 35–45, 1960.https://doi.org/10.1115/1.3662552
-
[3]
V . Nadkarni, S. Kulkarni, and P. Viswanath,Adaptive Curves for Optimally Efficient Market Making, in6th Conference on Advances in Financial Technologies (AFT 2024), LIPIcs vol. 316, pp. 1:1–1:25, Schloss Dagstuhl,
work page 2024
-
[4]
G. Angeris and T. Chitra,Improved Price Oracles: Constant Function Market Makers, inProceedings of the 2nd ACM Conference on Advances in Financial Technologies (AFT 2020), pp. 80–91, 2020
work page 2020
-
[5]
D. Pusceddu and M. Bartoletti,Formalizing Automated Market Makers in the Lean 4 Theorem Prover, in5th International Workshop on Formal Methods for Blockchains (FMBC 2024), OASIcs vol. 118, pp. 5:1–5:13, Schloss Dagstuhl, 2024
work page 2024
-
[6]
I. C. Moore,DeFiPy: Python SDK for On-chain Analytics, Amazon, ASIN B0G3RV5QRB, 2025. https: //defipy.org
work page 2025
-
[7]
I. C. Moore,DeFiPy fork-and-evaluate worked example (python/examples/state_twin_fork_evaluate.py), 2026.https://github.com/defipy-devs/defipy
work page 2026
- [8]
-
[9]
R. Lipschitz,Sur la possibilité d’intégrer complètement un système donné d’équations différentielles, Bulletin des Sciences Mathématiques et Astronomiques, vol. 10, pp. 149–159, 1876
-
[10]
H. K. Khalil,Nonlinear Systems, 3rd ed. Prentice Hall, Upper Saddle River, NJ, 2002
work page 2002
-
[11]
I. C. Moore,DeFiPy: Python SDK for Agentic DeFi, PyPI v2.1, 2026. https://github.com/defipy-devs/ defipy
work page 2026
-
[12]
Snyder,Multicall3: Aggregate results from multiple read-only function calls, 2022
M. Snyder,Multicall3: Aggregate results from multiple read-only function calls, 2022. https://github.com/ mds1/multicall
work page 2022
-
[13]
Anthropic,Model Context Protocol Specification, 2024.https://modelcontextprotocol.io
work page 2024
-
[14]
M. Grieves and J. Vickers,Digital Twin: Mitigating Unpredictable, Undesirable Emergent Behavior in Complex Systems, inTransdisciplinary Perspectives on Complex Systems, Springer, 2017
work page 2017
- [15]
-
[16]
F. Martinelli and N. Mushegian,Balancer: A Non-Custodial Portfolio Manager, Liquidity Provider, and Price Sensor, Balancer Whitepaper, 2019.https://balancer.fi/whitepaper.pdf
work page 2019
-
[17]
Egorov,StableSwap: Efficient Mechanism for Stablecoin Liquidity, Curve Whitepaper, 2019
M. Egorov,StableSwap: Efficient Mechanism for Stablecoin Liquidity, Curve Whitepaper, 2019. https:// classic.curve.fi/files/stableswap-paper.pdf
work page 2019
-
[18]
I. C. Moore,Trustless Provenance Trees: A Game-Theoretic Framework for Operator-Gated Blockchain Registries, arXiv preprint, 2026. 14
work page 2026
discussion (0)
Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.