Gauge-Equivalent Surplus Settlement: A Candidate Model
Historical proposal: This article explores a price-preserving Surplus candidate. The implemented settlement policy uses a reduced-pay second quote and Surplus top-ups; it preserves the direct user payout but can change relative pool prices. See Quote Engine for current behavior.
This article preserves an earlier large-pool coverage construction for historical context. Its receive-allocation notation and coverage algorithm have been superseded by Two-Asset Surplus Settlement for Token Launches.
Multiswap can hold protocol-owned token inventory in a Surplus account. When a user receives an asset held in Surplus, the protocol would like to deliver some or all of the output from that inventory instead of depleting the asset's pool Reserve.
The settlement source should not change the user's quote. It should not change the relative post-trade prices either. A user exchanging the same amounts against the same opening pool state should reach the same market prices whether the receive tokens come from Reserve, Surplus, or a combination of both.
That goal is harder than moving tokens between accounts. If Surplus protects a receive Reserve while the pool assigns the asset the higher price caused by direct Reserve depletion, the asset appears scarce without becoming scarce. The resulting coefficient expansion falls outside the Post-Trade Elasticity coefficient order.
This article develops a candidate alternative. The key observation is that Multiswap prices have a common scale gauge. Absolute prices depend on the internal scale unit; relative prices do not. Surplus settlement can therefore target a common multiple of the ordinary direct-swap price vector. A single global scale-accumulator update applies that gauge to the full pool without looping over every Reserve Asset. Explicit pay and receive legs then receive their own constant-time compensations.
The candidate has four principal results:
- the user's direct-swap quote is unchanged;
- every relative post-trade price equals the direct-swap relative price;
- every Reserve Asset coefficient remains fixed or contracts;
- Surplus coverage can be capped so the LP Token coefficient remains safe without minting or burning LP Tokens.
The construction is a research candidate, not implemented protocol behavior. It assumes exact arithmetic, positive reserves and scales, homogeneous elasticity
and fee-free settlement. Fees are outside this candidate model rather than an unresolved part of it. Rounding, account-level authorization, and implementation tests remain open before implementation.
1. Multiswap state
Let a Multiswap pool contain Reserve Assets indexed by
Reserve Asset has reserve
scale
and marginal price
Scale is the market-value magnitude assigned to an asset in Multiswap's internal scale unit. The derived market-value weight is
where the LP Token uses index and has scale
The elasticity coefficient of token is
Equivalently,
and
The coefficient identifies the token's elastic curve. A fixed-coefficient reserve change moves the token along that curve. A coefficient change moves the token to another curve.
The coefficient-order conditions are
for every Reserve Asset and
for the LP Token.
These conditions certify a state endpoint. A complete transaction must also have funded token movements, balanced value flow, positive state, correct rounding, and authorized account changes.
2. The hypothetical direct swap
Surplus settlement begins by calculating the ordinary direct swap. This hypothetical direct endpoint determines the user's token amounts and the market prices that settlement must preserve.
For each explicit user leg, let
be the signed token change from the protocol's perspective. A pay leg has , and a receive leg has .
Define the direct reserve multiplier
Thus:
- a pay leg has ;
- a receive leg has ;
- a nonparticipating asset has .
An ordinary Post-Trade Elasticity leg keeps its coefficient fixed:
and
Post-trade value flow is
The ordinary multi-asset quote satisfies
This direct quote remains the user's quote. Surplus changes the internal settlement sources and the pool's final Reserve state, not the amounts the user agreed to exchange.
3. The actual Reserve endpoint
Let
be the final Reserve balance under Surplus settlement. Define the actual Reserve multiplier
For a pay asset, some of the user's payment may enter Reserve while the rest goes to Rewards, Treasury, or another protocol account. If is the pay-side Reserve allocation fraction, then
Therefore
For a receive asset, let be the receive-side fraction of the user's output supplied by Surplus. Reserve supplies the remaining fraction, so
Therefore
The ratio measures how far the actual Reserve endpoint differs from direct settlement. It is at most one for a pay asset, at least one for a Surplus-funded receive asset, and exactly one for direct settlement or nonparticipation.
4. Gauge-equivalent prices
Multiplying every scale by one common positive factor gives
for every Reserve Asset and the LP Token. Consequently,
The aggregate identity remains exact:
Every relative price is unchanged:
Surplus settlement therefore does not need to reproduce each absolute . It needs a final price vector in the same gauge class:
for one common factor .
Then
for every pair of Reserve Assets.
The direct quote is also unchanged. Since
the gauge-equivalent endpoint satisfies
Thus the user exchanges the same token amounts at the same complete relative-price endpoint.
5. Choosing the safe gauge
At the candidate endpoint,
and
The final scale is
The final Reserve Asset coefficient is therefore
Choose
Because nonparticipating assets have , the maximum is at least one and
For every Reserve Asset,
Therefore
for every Reserve Asset. At least one maximally protected receive asset lies on the coefficient boundary with . Every other Reserve Asset coefficient remains fixed or contracts.
The common gauge does not conceal an unsafe receive-side expansion. It is chosen so that the complete physical endpoint passes the existing componentwise coefficient test in one fixed representation.
6. Deriving the constant-time update
Section 5 determines the effective final scale required for every explicit leg:
A nonparticipating asset has , so its required final scale is simply
This is where the implementation problem appears. The pool may contain hundreds of nonparticipating assets, but the transaction cannot write each one. The common factor must therefore be applied through the pool-wide scale accumulator that already represents effective scales as
For every untouched asset, the stored base scale must remain unchanged. The only accumulator update that produces for all of them is
The accumulator update also multiplies each explicit leg by , but an explicit leg needs the additional factor . Its new base scale is not guessed; it is obtained by solving
Substituting the required effective scale and gives
so
Only explicit legs change their stored base scales. The stored root can therefore be updated from those same changes:
Multiplying by the new accumulator gives
The constant-time structure is now a consequence of the required endpoint: one accumulator write applies the common gauge to every asset, and only explicit legs need individual base-scale changes.
7. Discovering the LP Token boundary
The Reserve Asset proof determines the largest common gauge compatible with . That does not automatically prove LP Token safety, because the explicit-leg compensations also change the sum of all scales.
The candidate keeps LP Token supply fixed:
The LP Token safety condition is
Using and the fixed LP Token supply gives
which reduces directly to
Section 6 already derived the final root. Substituting its explicit-leg update gives
Since and , the same equation can be evaluated from opening derived weights:
This calculation reveals the boundary. If a proposed Surplus allocation produces , both the Reserve Asset and LP Token coefficient conditions hold. If it produces , the receive coverage is too large for the fixed pay allocation. The candidate moves the receive coverage back toward direct Reserve settlement until . LP Token supply never changes.
8. Deriving the single-receive coverage rule
Consider one pay asset and one receive asset . Their direct reserve multipliers are
Fix the pay-side Reserve allocation and choose a receive-side Surplus coverage:
There is one Surplus-funded receive asset. Its ratio is therefore the largest ratio in the safe-gauge formula, which forces
Now apply the root equation derived in Section 7. The pay leg contributes , the receive leg contributes , and the nonparticipating complement is already contained in the opening :
The second line is only the first line after substituting the forced gauge and collecting terms. No additional model quantity has been introduced.
The goal is to use the greatest inventory-supported for which . Because rises linearly with , it is enough to understand how the displayed expression changes with .
Differentiating it gives
The factor outside braces is positive. Inside the braces, only the first term depends on , and it increases linearly. The derivative can therefore change sign only once, from negative to positive. The final LP Token scale is monotone or decreases and then increases; it has at most one interior minimum.
This observation produces the coverage algorithm rather than merely verifying it:
- fix and verify that zero Surplus coverage gives ;
- calculate the maximum allowed by available Surplus inventory;
- evaluate at that maximum;
- use the maximum if ;
- otherwise solve the unique boundary between zero and maximum coverage.
The boundary solve is bracketed because its zero-coverage endpoint is safe and its proposed maximum-coverage endpoint is unsafe. It is unique within that bracket: the derivative can turn only from negative to positive, so the function cannot cross below , cross back above it, and still end below at maximum coverage.
9. Deriving atomic multi-asset coverage
With several receive assets, each inventory balance produces its own maximum coverage fraction . Reducing those fractions independently would require a multidimensional search and would leave the protocol without a defined priority among receive assets.
The one-dimensional parameter appears by requiring the candidate to preserve the inventory-supported proportions. Choose one utilization fraction
and apply it to every receive leg:
This gives
and hence
All receive ratios are now lines beginning at one. For , the largest line is the one with the largest slope. Substituting that observation into the safe-gauge formula gives
The gauge is therefore discovered directly from the common utilization rule; no separate per-asset distortion variable is needed.
Substitute the receive endpoints into the root equation from Section 7:
This is the multi-asset coverage equation before any shorthand. It also shows why the problem remains one-dimensional: the expression in braces is affine in , and the gauge is a negative power of another affine function of .
For the sole purpose of differentiating that structure, collect the constant term in braces as , its coefficient of as , and the maximum receive-ratio slope as :
These letters do not represent new protocol state. They name the constant term, linear coefficient, and maximum slope that appeared before the shorthand was introduced. This is the first point in the derivation where naming them makes the next step shorter. The preceding equation now becomes
where , , and . Differentiation gives
The bracket is affine and nondecreasing. Therefore has at most one interior minimum, exactly as in the single-receive case.
The resulting atomic rule is:
- fix every and require ;
- calculate each inventory-supported ;
- evaluate ;
- use if ;
- otherwise solve the unique boundary on ;
- settle every receive leg with .
When the maximum-coverage endpoint is unsafe, the same derivative shape makes the bracketed boundary unique. When the maximum-coverage endpoint is safe, the candidate executes directly. Other values of describe alternative endpoints; the transaction does not traverse them on its way to .
The calculation visits only explicit pay and receive legs. It never loops over the full pool.
10. Ledger and value-flow accounting
The pool Reserve is only one account in the complete transaction. Surplus, Rewards, and Treasury are separate accounts. The accounting must distinguish the user's total token flow from the portion assigned to Reserve.
For token , define the total user-facing protocol flow
The actual Reserve flow is
The remaining protocol-account flow is
For a pay leg, is the payment routed outside Reserve. For a receive leg, is the amount supplied from Surplus.
Token amounts balance account by account:
At the common final price,
and
Therefore
The user-facing transaction remains balanced:
The Reserve subaccount need not balance by itself because it is an open subsystem receiving value from and sending value to other protocol accounts. Surplus settlement is funded by an explicit Surplus debit, not by an unsupported scale edit.
The current Multiswap ledger already distinguishes Reserve, Surplus, Rewards, and Treasury settlement destinations and already stores scales through a global accumulator. The candidate uses those architectural capabilities, but the current executable Surplus adjustment does not implement the model derived here.
11. Candidate transaction
An atomic gauge-equivalent Surplus transaction has the following planning-level sequence:
- Calculate the direct quote. Solve the ordinary Post-Trade Elasticity multi-asset swap and obtain , , , and balanced .
- Determine account allocations. Choose pay-side Reserve fractions and inventory-supported receive coverage fractions .
- Choose coverage. Evaluate the full inventory-supported vector. If its endpoint has , solve the one-dimensional boundary .
- Calculate actual Reserve endpoints. Compute every explicit leg's .
- Choose the gauge. Set .
- Update the accumulator. Apply once.
- Compensate explicit legs. Apply for each pay and receive leg.
- Update the root. Add only the explicit stored-scale deltas to .
- Settle accounts. Debit user pay amounts into Reserve, Rewards, and Treasury according to allocation; debit receive amounts from Reserve and Surplus according to coverage.
- Verify the endpoint. Require positive state, , for every explicit leg, and .
Nonparticipating Reserve Assets require no individual read-modify-write cycle beyond the data already needed to quote explicit legs. Their common transformation is carried by the accumulator.
Surplus inventory does not require a separate concurrency model. The inventory balance, coverage factor, and settlement transfers must be calculated from the same state inside one atomic transaction. EVM transaction ordering then prevents two transactions from spending the same Surplus balance: the later transaction sees the balance left by the earlier one. The current Multiswap settlement architecture already reconstructs quotes from live pool state during execution and enforces minimum receive amounts. A stale offchain quote is therefore an ordinary slippage problem, not a distinct source of coefficient unsafety. An implementation may expose a minimum Surplus-coverage condition for integrators that care about the settlement source, but the user's token amounts and the candidate's safety certificate do not require one.
12. What the candidate establishes
Under its exact-arithmetic assumptions, the construction establishes the following endpoint results:
Same user amounts
The direct quote fixes the user's token amounts before the protocol chooses their settlement accounts. From the definitions of and the user-facing flow,
Surplus settlement therefore changes how each leg is divided between Reserve and other protocol accounts, but it does not change the amount paid or received by the user.
The common gauge rescales every final price by ; it does not rescale token quantities. Consequently, the unchanged user amounts also remain balanced at the gauge-equivalent final prices:
Same complete relative-price vector
Reserve Asset coefficient order
LP Token coefficient order
Constant-time complement update
The action performs one global accumulator update and work proportional only to its explicit pay and receive legs.
Compatibility with later actions
The gauge-equivalent endpoint is a valid starting state for later swaps and liquidity actions. Under a common gauge , every value flow scales by the same factor, so the normalized quote input
is unchanged. The Post-Trade Elasticity solve therefore returns the same reserve ratio and the same token amounts. Only scale-denominated value flows and value changes inherit the common factor.
The accumulator-based single-asset liquidity calculation is homogeneous for the same reason: its liquidity multiplier is a ratio of scale differences, so a common factor cancels from its numerator and denominator. Proportional liquidity is also unchanged because the gauge preserves every derived weight .
Coefficient safety then composes by transitivity. If the Surplus endpoint satisfies
and a later action is safe relative to that endpoint, then
Thus no mathematical reset or reversal of the gauge is required before a later action. This is an exact-arithmetic composition result. Fixed-point accumulator updates, rounding, and near-depletion behavior still require randomized sequence tests in the implementation.
These results establish coefficient-order admissibility and balanced user consideration for the candidate endpoint. They do not yet establish production safety.
13. Remaining implementation work and scope decisions
The deterministic coverage policy, root selection, atomic inventory handling, and exact-arithmetic composition with later actions are specified above. The following work remains before the candidate can replace the current Surplus path:
- Rounding. Fixed-point power evaluation, coverage solving, accumulator updates, and token conversions must round toward and .
- Ledger journals. Every Reserve, Surplus, Rewards, Treasury, Protocol, and external-user debit and credit must be enumerated against the live account tree.
- Sequence tests. Randomized implementation tests must combine gauge-equivalent Surplus settlement with swaps, single-asset liquidity, proportional liquidity, and extreme near-depletion states. These tests validate fixed-point realization of the composition result; they are not standing in for a missing exact-arithmetic argument.
- Boundary elasticity scope. The formulas remain meaningful at , where . At that boundary, the terms proportional to disappear: the single-receive derivative is strictly negative and the multi-asset derivative has a constant sign, so the coverage function is monotone rather than U-shaped. Whether the launch protocol permits remains a product and safety-scope decision; this candidate assumes until that decision is made.
- Authorization. Only the intended settlement path may move protocol Surplus or change the scale accumulator.
The current implementation must not be described as supporting this candidate until the remaining work is completed and the equations are implemented and tested.
Conclusion
Surplus settlement does not need to choose between protecting a receive Reserve and preserving the user's market endpoint. Absolute Multiswap prices contain a common scale gauge. The economically relevant target is the ordinary direct swap's complete relative-price vector.
The candidate first computes the direct swap, then chooses an actual Reserve endpoint based on pay allocation and Surplus coverage. One common gauge factor converts that endpoint into the direct relative-price state. The factor is applied through the existing scale-accumulator pattern, while explicit transaction legs receive individual compensations. The resulting Reserve Asset coefficient multipliers are bounded by construction.
The LP Token supplies the final coverage boundary. Keeping LP Token supply fixed requires
When full inventory-supported coverage violates that condition, the mechanism reduces all proposed receive coverage through one common factor until . No pool-wide loop and no inventory of burnable LP Tokens is required.
This gives Multiswap a concrete candidate Surplus model with the same user quote, the same relative post-trade prices, explicit account funding, componentwise Reserve safety, LP Token safety, and transaction-leg complexity. Its remaining work is fixed-point implementation, ledger-journal specification, authorization, and adversarial validation.
