Discrete Stochastic Calculus and Safe Multiswap Operations
Multiswap is a discrete financial system. A transaction begins at one ledger state and ends at another. Reserves, scales, and prices are defined at the states; value flow occurs along the directed transition between them.
That description is not an approximation. It is the native geometry of a blockchain.
Discrete stochastic calculus gives this geometry an exact financial accounting rule. It distinguishes quantities defined at states from flows defined on transitions, preserves the order between previsible inventory and nonprevisible price, and recovers Itô calculus in the stochastic continuum limit. Applied to Multiswap, it produces post-trade value flow directly:
The first term evaluates price at the destination state. The second revalues the opening reserve. Post-trade execution is therefore not an arbitrary conservative quote convention. It is the finite execution rule compatible with Itô accounting.
The same calculus gives an exact coefficient 1-form
whose edge coefficients determine whether an operation moves each Reserve Asset and the LP Token in the permitted direction. This coefficient order contains the familiar swap and liquidity actions, but it also identifies a wider endpoint region containing direct permanent-reserve contributions, LP Token under-minting, general withdrawals, and heterogeneous multi-asset liquidity.
On the binary tree, exact coefficient order must hold on both outgoing branches. In the stochastic continuum limit, this removes the coefficient's Brownian component and leaves a one-sided generator condition. The boundary between safe and unsafe coefficient production is the backward diffusion equation
Surplus settlement provides the central application. A direct price-preserving state edit leaves this region by expanding the receive-asset coefficient. An ordinary counter-swap remains inside it because every step is an exact supported transition.
This article develops the complete argument from first principles. No prior knowledge of discrete calculus is assumed.
The results assume exact arithmetic, positive reserves and scales, homogeneous elasticities, and
Coefficient order establishes state admissibility. A complete protocol operation must additionally specify funded token movements, valid consideration, account ownership, rounding, user limits, atomicity, and MEV policy.
1. Multiswap state
Let a pool contain Reserve Assets. Reserve Asset has reserve
scale
and marginal price
Equivalently,
The factor order will matter once the discrete differential is applied. Reserve is previsible: it is held before the next price innovation. Price is not. Scale is the resulting value process and is likewise not previsible at the destination state.
Scale elasticity and price elasticity satisfy
Define the elasticity coefficient
Using ,
Both forms place the previsible reserve factor before the nonprevisible value or price factor.
The coefficient identifies the elastic curve. A fixed-coefficient reserve transition satisfies
and
The LP Token is indexed by . It has reserve , scale
price
and coefficient
The aggregate scale identity is a ledger identity. It must hold after every primitive action, not merely after a compound transaction finishes.
2. A short introduction to discrete calculus
Ordinary calculus assigns functions to points and differentials to infinitesimal directions. Discrete calculus makes the same distinction on a directed graph:
- a discrete 0-form assigns a scalar to every node;
- a discrete 1-form assigns a scalar to every directed edge.
A blockchain state variable is a 0-form. Its change across a transaction is a 1-form.
2.1 Nodes and 0-forms
Consider first a realized sequence of states indexed by . Let denote the basis 0-form associated with state . A coefficient process is
The basis multiplication rule is
Discrete 0-forms commute. In particular,
2.2 Directed edges and 1-forms
Let denote the directed edge from state to state . Define the graph 1-form
Multiplying an edge by a 0-form from the right evaluates the 0-form at the destination:
Multiplying from the left evaluates it at the source:
Discrete 0-forms therefore commute with one another but do not commute with discrete 1-forms. This noncommutativity carries the financial ordering information.
2.3 The discrete differential
The discrete differential is the commutator with :
For a 0-form
we obtain
The object is a 1-form. The scalar difference is its coefficient on one edge; it is not the form itself.
Throughout this article, is reserved for the discrete differential and its Itô continuum limit. A finite change, or the scalar coefficient of a differential on one directed edge, is written
Because the differential is a commutator, it satisfies the exact Leibniz rule
The formula looks familiar, but multiplication order makes it an exact finite product rule. On the edge , its coefficient is
The first difference uses the destination value of the factor on its right. The second uses the source value of the factor on its left.
3. The binary tree and stochastic coordinates
A stochastic process has more than one possible successor state. The minimal example is a binary tree. At a node , let the two outgoing edge 1-forms be
For any 0-form , write its two successor values as and and its opening value as . Then
3.1 Cartesian coordinates
Place time coordinate and stochastic coordinate on the tree so that
and
Their differentials are
and
These relations invert to
Thus and span the discrete 1-forms on the binary tree. One stochastic coordinate is sufficient for this two-branch calculus. Every Multiswap variable may be a different 0-form of the same coordinates .
The finite coordinate commutation relations are
and
3.2 The stochastic continuum limit
Choose the stochastic scaling
As , the commutation relations become
For a 0-form , the discrete differential then converges to
This is the Itô formula. Its second-order term is not added by hand. It follows from the noncommutative coordinate relation .
4. Previsibility forces post-trade value flow
Return to the exact Multiswap identity
The discrete Leibniz rule gives the 1-form identity
On a directed edge from the opening state to the final state, its coefficient is
Define
The edge coefficient becomes
The two terms have distinct financial meanings:
is signed execution value flow, while
is revaluation of the opening reserve.
Reserve appears to the left of in the 1-form identity and is evaluated at the source. It is previsible. Price appears to the right of and is evaluated at the destination. It is not previsible before the edge is realized.
Under the stochastic continuum limit, the same identity becomes the Itô product rule. In ordinary commutative notation,
The quadratic-covariation term is already contained in the post-trade expression .
Post-trade execution and Itô market accounting are therefore complementary descriptions of the same ordered product rule.
5. The execution gauge
Because discrete 0-forms commute,
and therefore
The two Leibniz expansions are
and
Any weighted combination remains the same total scale 1-form:
On one edge, define
and
Then
The total scale change is gauge invariant. The attribution between execution value and market revaluation is not.
Under a finite change , the execution component receives
while the market component loses the same amount.
Three gauges are especially recognizable:
| Execution value | Market revaluation | Continuum convention | |
|---|---|---|---|
| Backward Itô | |||
| Stratonovich | |||
| Itô |
The gauge freedom is mathematically real. Previsibility fixes the financial gauge. Market P&L must apply to inventory held before the price innovation, so its integrand must be , not or a midpoint containing . Therefore
This is why midpoint value flow cannot be judged in isolation. Exact accounting forces midpoint reserve into the market term, causing newly acquired inventory to experience half of a price movement that occurred before it was acquired and disposed inventory to retain half of a movement after disposal.
At , the entire trade executes at a stale price and market P&L is assigned to destination inventory. The failure is immediate. Consider followed by returning exactly the received . The first trade satisfies
The reverse trade executes at the new opening prices. The returned to the trader is
For fixed-coefficient elasticity,
for every nonzero trade because and . Every such round trip extracts from the pool without requiring reserve depletion.
6. Coefficients as discrete 0-forms
The coefficient process is a discrete 0-form
Its discrete differential is the 1-form
The canonical ordered coefficient representation is
Therefore
and equivalently
These are exact 1-form identities. On an edge, the factors to the right of a differential are evaluated at the destination; the factors to the left are evaluated at the source.
6.1 The Itô coefficient limit
The stochastic continuum limit of is not the ordinary quotient differential. In coordinates it is
In coordinates it is
The covariance and quadratic-variation terms are essential. Along an exactly fixed-coefficient process they cancel the apparent second-order drift and give , as they must.
For protocol transitions, however, the exact discrete 1-form remains primary. No continuum approximation is required to check an edge.
6.2 The diffusion equation on the coefficient boundary
The binary tree reveals the continuum boundary of exact coefficient order. Write the two branch coefficients of as
Because and span the edge 1-forms, we may write
where
and
The two edge coefficients are therefore
Exact Reserve Asset safety requires both branches to be nonpositive:
Equivalently,
LP Token safety reverses the inequality:
Under stochastic scaling, . A smooth continuum limit with finite and can satisfy either pathwise inequality only if its Brownian coefficient vanishes:
Define the Brownian generator
The remaining finite-variation condition is
for a Reserve Asset and
for the LP Token.
The boundary of either safe region is zero coefficient production. There,
Thus the coefficient satisfies the backward diffusion equation on the coefficient-order boundary. For exact pathwise order, this boundary condition is accompanied by : the safe coefficient process has no Brownian component of its own even though reserves, prices, and scales may remain stochastic.
This is stronger than an expected-sign condition. A supermartingale or submartingale may retain a nonzero term, but it can move in the prohibited direction on an individual branch. Multiswap's finite protocol classifier remains the exact edgewise order in the next section; the generator inequalities and diffusion boundary are its stochastic continuum limit.
7. Exact coefficient order on directed edges
Multiswap uses a one-sided coefficient order. On every realized edge, the coefficient of must be nonpositive for each Reserve Asset and nonnegative for the LP Token:
Define the multiplicative edge certificate
Because every coefficient is positive, edge safety is equivalent to
for every Reserve Asset and
for the LP Token.
The additive and multiplicative descriptions belong to the same edge. Left normalization of the 1-form gives
The logarithmic 1-form gives
For a path of sequential transitions,
Coefficient safety therefore composes exactly. Every safe primitive carries the certificate required by the next primitive.
7.1 Exact endpoint inequalities
For each Reserve Asset,
For the LP Token,
These inequalities define the complete coefficient-order endpoint region. They are exact finite edge conditions, not integrations of an ordinary local differential.
8. Execution balance and LP Token safety
For a signed reserve change, define
A fixed-coefficient leg has
and
At post-trade execution,
The general value-flow identity is
For a reserve-only swap,
and therefore
The reserve-only specialization must not replace the general identity.
For , each fixed-coefficient leg admits the exact decomposition
where
The inequality is strict for every nonzero leg. Summing and using the general value-flow identity gives
For a nontrivial reserve-only swap, , so
Every Reserve Asset coefficient remains fixed, remains fixed, and increases.
8.1 General fixed linear execution
For execution price
define
The exact product rule gives
For a reserve-only swap, define opening-reserve revaluation
and execution-to-final-price shortfall
Then
The exact LP coefficient condition is
Post-trade execution eliminates the shortfall term. For every fixed , sufficiently asymmetric finite swaps make the shortfall dominate. Therefore, within ,
is the unique fixed linear execution rule that automatically makes every admissible finite fixed-coefficient reserve-only swap LP-coefficient-safe.
9. The wider coefficient-order region
The exact endpoint inequalities identify more admissible state transitions than the initially studied swap, single-asset liquidity, proportional liquidity, and burn formulas.
These are mathematical candidates. Coefficient order establishes their endpoint direction; it does not itself supply consideration or implementation.
9.1 Direct permanent-reserve allocation
Suppose Surplus contributes
directly to Reserve Asset without minting LP Tokens:
Leave every other Reserve Asset unchanged. If only scale changes, aggregate scale gives
LP coefficient safety requires . Reserve Asset safety supplies the upper bound. The complete coefficient-order interval is
At the lower endpoint, contracts and remains fixed. At the upper endpoint, remains fixed and expands. Every point between them moves both coefficients in their permitted directions.
This direct transition is endpoint-equivalent to a range of explicit liquidity-mint-and-burn constructions.
9.2 LP Token under-minting
Suppose a funded reserve operation changes LP scale from to . Conditional on every Reserve Asset satisfying its own coefficient inequality, LP Token safety requires
The maximum permitted LP Token mint is
Minting the maximum preserves . Minting less expands it. Minting nothing produces permanent liquidity. Minting the maximum and burning part of it is endpoint-equivalent to under-minting initially.
9.3 General withdrawals
If an operation reduces total Reserve Asset scale so that , LP coefficient safety requires
Conditional on every Reserve Asset satisfying its own coefficient condition, the operation must burn at least
This is a coefficient boundary, not a fair-redemption formula. The reserve consideration owed for the burned LP Tokens must be specified separately.
9.4 General multi-asset liquidity
The supported common- construction contracts every nonparticipating Reserve Asset coefficient by one multiplier
The exact discrete edge condition permits a larger region. Different Reserve Assets may have different multipliers provided
for every Reserve Asset,
and
The common- construction remains computationally useful because it can update an entire complement set through one shared multiplier. It is a sufficient implementation pattern, not the definition of every coefficient-order-admissible endpoint.
10. Surplus settlement
Multiswap Surplus is exogenous protocol inventory. When a user receives an asset held in Surplus, the protocol can supply some or all of that output and convert the inventory into reserve growth, Rewards, Treasury revenue, or an ongoing CAV token sale.
The user still receives the ordinary swap quote. The question is how Surplus changes the pool state after supplying the output.
Two constructions have been considered:
- a direct price-preserving state adjustment;
- an ordinary Surplus counter-swap composed after the user swap.
They can deliver the same tokens to the user while leaving radically different coefficient states.
10.1 Why direct price preservation fails
Consider a user swap
with receive change
If the pool settled the swap normally, the hypothetical final reserve would be
The original price-preserving construction instead supplied from Surplus and restored the pool reserve to , while adjusting scale so that the final price equaled the ordinary hypothetical price:
The ordinary fixed-coefficient state satisfies
The price-preserving state satisfies
Equating prices gives
The receive coefficient expands. The transition therefore gives a positive edge coefficient and violates Reserve Asset coefficient order immediately.
The economic problem is exact: the state prices as though it were scarce while retaining the full reserve as future pricing depth. Preserving one marginal price did not preserve the elastic curve associated with that price.
This failure does not require an immediate closed round trip. External holders can later sell inventory into the artificially deep state and receive more than the ordinary post-swap curve would permit.
10.2 The ordinary counter-swap
The corrected construction uses only ordinary state transitions:
- the user executes ;
- from the resulting state, Surplus executes ;
- the protocol allocates the actual received by Surplus.
For full settlement, Surplus pays exactly the amount of required to restore the pool's reserve:
Both swaps preserve . Restoring therefore restores and .
Surplus receives less than the user paid. The difference remains in the pool as round-trip gain. The complete pool state is not restored, and the construction does not claim price preservation.
That distinction is essential. The counter-swap reaches its final price through a path of ordinary coefficient-preserving edges. It does not manufacture a price-preserving endpoint by expanding a Reserve Asset coefficient.
10.3 Partial and multi-asset settlement
Surplus may supply any amount between zero and the user's complete output. The covered amount becomes the size of an ordinary counter-swap calculated from the actual post-user state. Partial settlement does not interpolate reserves, scales, or prices after the fact.
For an atomic multi-asset user swap, the supplied receive assets form the pay side of one ordinary multi-asset Surplus sale. The counter-action obeys
Because it is reserve-only,
and therefore
Every participating Reserve Asset coefficient remains fixed.
The counter-action is an underlying ordinary action, not a new user action eligible for another Surplus adjustment. Counter-actions do not recurse.
11. Allocating realized Surplus proceeds
After selling supplied inventory through the counter-swap, Surplus holds actual proceeds. The protocol may allocate those proceeds among Reserves, Rewards, Treasury, or other declared accounts.
The pool-state and ownership questions must remain separate.
11.1 Supported liquidity allocation
One construction applies a supported single-asset liquidity action
The active coefficient and LP coefficient remain fixed while every nonparticipating Reserve Asset coefficient contracts by one common multiplier
The protocol may then:
- retain the minted LP Tokens as protocol-owned liquidity;
- distribute them to Rewards or Treasury;
- place them in an irrevocable or time-controlled account;
- burn some or all of them without withdrawing reserves.
Holding or transferring LP Tokens among external accounts does not change pool state. Burning protocol-owned LP Tokens reduces while leaving fixed, so increases and every Reserve Asset coefficient remains unchanged.
11.2 Direct permanent-reserve allocation
The exact endpoint interval from Section 9.1 permits a direct funded reserve allocation without an intermediate mint and burn:
This is often a cleaner state transition. It does not eliminate the allocation question. Adding reserves without issuing LP Tokens benefits whoever owns the existing LP Token supply.
11.3 Temporary-liquidity capture
Coefficient safety does not make permanent-liquidity allocation neutral to transaction ordering.
Suppose a temporary provider enters proportionally with relative increase . Every reserve and LP Token supply increases by . A later Surplus allocation adds to Reserve Asset without increasing the temporary provider's LP Token balance.
When the temporary provider exits proportionally, the amount of returned is
The first term returns the provider's contribution. The second is a positive share of the Surplus allocation.
The proportional entry and exit preserve every coefficient. The allocation between them moves coefficients safely. The complete sequence remains coefficient-order admissible even though the temporary provider captures value intended for incumbent LP Token holders.
User minimum receive does not prevent this strategy because it targets ownership at the allocation, not the user's swap execution. The protocol must choose the intended beneficiary and then retain, distribute, lock, or burn LP Tokens accordingly.
12. Additive coefficient production
The logarithmic 1-form
has edge coefficient
Define component production on each edge by
for the LP Token and
for Reserve Assets. Every componentwise coefficient-safe edge has
An aggregate diagnostic is
The scalar is additive along paths because logarithmic edge coefficients telescope. It is weaker than the componentwise order: one Reserve Asset coefficient can expand while larger safe movements elsewhere keep the aggregate positive. The individual edge signs remain authoritative.
The separate thermodynamic interpretation of this logarithmic monotone is not required for the safety proofs in this article.
13. Complete-operation requirements
Coefficient order classifies the resulting state. It does not prove that an authorized transition was fairly funded.
A complete operation must specify:
- which account funds every positive reserve change;
- which account receives every negative reserve change;
- the execution or other consideration rule;
- LP Token issuance or destruction;
- aggregate scale consistency;
- reserve and scale positivity;
- pool-favorable rounding;
- user minimum-receive or maximum-pay conditions;
- atomicity of compound actions;
- ownership and MEV policy.
The complete design rule is
Every primitive and randomized composition should verify:
Positive state
Aggregate scale
General value-flow balance
For a reserve-only action, separately verify the specialization
Componentwise coefficient direction
For every Reserve Asset,
For the LP Token,
Token conservation and ownership
Every positive movement must be funded, every negative movement must reach its declared recipient, and every LP Token mint or burn must match the operation.
User and ordering controls
Enforce minimum receive, maximum pay, deterministic Surplus coverage, atomic user-plus-counter execution, and the declared policy for LP Token ownership around permanent-liquidity allocations.
14. What is established and what remains open
Within the stated exact-arithmetic domain, the analysis establishes:
- discrete stochastic calculus produces post-trade value flow from the ordered identity ;
- the stochastic continuum limit is Itô because ;
- exact pathwise coefficient order removes the coefficient's Brownian component in the continuum limit and meets the diffusion equation on its boundary;
- is the previsibility-compatible execution gauge;
- fixed-coefficient reserve transitions have zero coefficient 1-form on every edge;
- componentwise coefficient order composes exactly through the multipliers ;
- every nontrivial post-trade reserve-only swap increases the LP Token coefficient;
- no fixed linear automatically protects the LP Token coefficient for every finite swap;
- the exact coefficient region admits direct permanent reserves, LP Token under-minting, general withdrawals, and heterogeneous multi-asset liquidity candidates;
- direct price-preserving Surplus settlement expands the receive coefficient and is inadmissible;
- ordinary Surplus counter-swaps remain inside coefficient order by composition;
- coefficient-safe permanent-liquidity allocation still requires an explicit ownership and MEV policy.
Open engineering and policy boundaries include:
- fees and ownership of fee value flow;
- finite-precision power evaluation and pool-favorable rounding;
- external-price controls for protocol inventory sales;
- production eligibility and size limits for Surplus assets;
- implementation of newly identified general coefficient-order transitions;
- temporary-liquidity policy around permanent allocations;
- independent security and economic review.
Conclusion
Multiswap does not need to approximate a continuous market and then discretize it for the EVM. It begins with the directed state transitions that the EVM actually executes.
Discrete 0-forms describe reserves, scales, prices, and coefficients at ledger states. Discrete 1-forms describe changes and value flows across transaction edges. The graph 1-form generates the differential through
On a binary tree, the coordinates satisfy
in the stochastic continuum limit, so the exact discrete calculus recovers Itô rather than ordinary calculus.
Exact coefficient order on both branches removes the coefficient's own Brownian term. Its continuum safe regions satisfy opposite generator inequalities for Reserve Assets and the LP Token, and their common boundary is
Previsibility then fixes the economically meaningful ordering:
The first identity produces post-trade value flow. The second produces the coefficient 1-form whose edge coefficients define safe state motion. Together with
and
they separate four questions cleanly:
This structure explains both the wider design space and its limits. Safe operations are not a memorized list. They are directed edges that preserve balance, remain inside coefficient order, and carry economically valid boundary flows.
