pith. machine review for the scientific record. sign in

arxiv: 2605.11522 · v1 · submitted 2026-05-12 · 💻 cs.DC

Recognition: no theorem link

State Twins: An Off-Chain Substrate for Agentic Reasoning over Decentralized Finance Protocols

Authors on Pith no claims yet

Pith reviewed 2026-05-13 01:47 UTC · model grok-4.3

classification 💻 cs.DC
keywords state twinautomated market makerdecentralized financeoff-chain substratedynamical systemagentic reasoningcounterfactual simulationfidelity bound
0
0 comments X

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.

The paper establishes that automated market maker pools from multiple families can be copied off-chain as typed in-memory replicas that keep the exact same mathematics as the live chain. These replicas support operations impossible on-chain, such as forking and counterfactual rollouts, because they are decoupled from block times and transaction costs. The work formalizes each AMM family as a discrete-time controlled dynamical system and proves a bound on how far the replica can drift from real on-chain state. A reader would care because this removes the structural limit that forces every agent query to wait for blockchain confirmation.

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

These are editorial extensions of the paper, not claims the author makes directly.

  • 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.

Desk editor's note, referee report, simulated authors' rebuttal, and a circularity audit. Tearing a paper down is the easy half of reading it; the pith above is the substance, this is the friction.

Referee Report

2 major / 2 minor

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)
  1. [§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.
  2. [§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)
  1. [Abstract] The abstract is information-dense; a short enumerated list of contributions would improve scannability.
  2. [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

2 responses · 0 unresolved

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
  1. 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

  2. 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

0 steps flagged

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

0 free parameters · 1 axioms · 1 invented entities

The central claim rests on treating AMM state transitions as discrete-time dynamical systems and on the existence of a fidelity bound; no free parameters or additional invented entities beyond the State Twin concept itself are mentioned.

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.
    Explicitly stated in the abstract as the modeling step that enables the fidelity proof.
invented entities (1)
  • State Twin no independent evidence
    purpose: In-memory replayable replica enabling forking, branching, and counterfactual operations not possible on-chain.
    The primary new construct introduced to serve as the off-chain substrate.

pith-pipeline@v0.9.0 · 5586 in / 1459 out tokens · 65905 ms · 2026-05-13T01:47:48.137844+00:00 · methodology

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Reference graph

Works this paper leans on

18 extracted references · 18 canonical work pages

  1. [1]

    Tranquilli and N

    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. [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. [3]

    Nadkarni, S

    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,

  4. [4]

    Angeris and T

    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

  5. [5]

    Pusceddu and M

    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

  6. [6]

    I. C. Moore,DeFiPy: Python SDK for On-chain Analytics, Amazon, ASIN B0G3RV5QRB, 2025. https: //defipy.org

  7. [7]

    I. C. Moore,DeFiPy fork-and-evaluate worked example (python/examples/state_twin_fork_evaluate.py), 2026.https://github.com/defipy-devs/defipy

  8. [8]

    Adams, N

    H. Adams, N. Zinsmeister, M. Salem, R. Keefer, and D. Robinson,Uniswap v3 Core, 2021. https://uniswap. org/whitepaper-v3.pdf

  9. [9]

    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

    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. [10]

    H. K. Khalil,Nonlinear Systems, 3rd ed. Prentice Hall, Upper Saddle River, NJ, 2002

  11. [11]

    I. C. Moore,DeFiPy: Python SDK for Agentic DeFi, PyPI v2.1, 2026. https://github.com/defipy-devs/ defipy

  12. [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

  13. [13]

    Anthropic,Model Context Protocol Specification, 2024.https://modelcontextprotocol.io

  14. [14]

    Grieves and J

    M. Grieves and J. Vickers,Digital Twin: Mitigating Unpredictable, Undesirable Emergent Behavior in Complex Systems, inTransdisciplinary Perspectives on Complex Systems, Springer, 2017

  15. [15]

    Adams, N

    H. Adams, N. Zinsmeister, and D. Robinson,Uniswap v2 Core, 2020. https://uniswap.org/whitepaper. pdf

  16. [16]

    Martinelli and N

    F. Martinelli and N. Mushegian,Balancer: A Non-Custodial Portfolio Manager, Liquidity Provider, and Price Sensor, Balancer Whitepaper, 2019.https://balancer.fi/whitepaper.pdf

  17. [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

  18. [18]

    I. C. Moore,Trustless Provenance Trees: A Game-Theoretic Framework for Operator-Gated Blockchain Registries, arXiv preprint, 2026. 14