Skip to main content
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

Two-Asset Surplus Settlement for Token Launches

· 13 min read
Eric Forgy
Founder of CavalRe

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.

Multiswap pools can hold protocol-owned token inventory in a Surplus account. For a token-launch pool containing a pay asset AA and a launched receive asset BB, the protocol would like to sell available Surplus BB without changing the user's direct quote. Some of the user's AA can enter Reserve, and the rest can be divided between Rewards and Treasury.

The allocation cannot be chosen independently of pool safety. Protecting the BB Reserve changes the physical Reserve endpoint. Preserving the direct relative prices then requires a common price gauge, and that gauge changes the LP Token's total scale.

For a two-asset pool, the resulting allocation problem has a simple solution:

  1. available Surplus inventory determines the fraction of BB paid by Reserve;
  2. LP safety determines the minimum fraction of AA that must enter Reserve;
  3. an optional configured floor may increase that pay-side Reserve fraction;
  4. Rewards and Treasury divide the remainder equally; and
  5. an infeasible Surplus attempt uses ordinary direct settlement instead.

The minimum pay allocation is closed form for every 0<es<10<e_s<1. When es=eP=1/2e_s=e_P=1/2, the direct receive quote and the complete receive-side safety boundary are also closed form.

This article derives that candidate from first principles. It is not current implemented protocol behavior.

1. State and elasticity

Consider a fee-free Multiswap pool with exactly two Reserve Assets, AA and BB. Reserve Asset ii has:

  • Reserve amount ai>0a_i>0;
  • scale si>0s_i>0; and
  • marginal price Pi=si/aiP_i=s_i/a_i.

The LP Token has scale

s0=sA+sB.s_0=s_A+s_B.

The derived opening scale share of AA is

wA=sAs0.w_A=\frac{s_A}{s_0}.

Because there are only two assets, the derived share of BB is

wB=1wA.w_B=1-w_A.

The absolute scale unit will cancel from every allocation condition. The candidate needs wAw_A, not sAs_A and sBs_B separately. The weight is a derived ratio, not an independent state variable.

Let the scale and price elasticities satisfy

0<es<1,eP=1es.0<e_s<1, \qquad e_P=1-e_s.

The elasticity coefficient of Reserve Asset ii is

ci=siaies.c_i=\frac{s_i}{a_i^{e_s}}.

The coefficient-order safety conditions are

ciScic_i^S\le c_i

for each Reserve Asset and

c0Sc0c_0^S\ge c_0

for the LP Token.

The candidate keeps LP Token supply fixed. LP safety is therefore equivalent to

s0Ss0.s_0^S\ge s_0.

2. Calculate the ordinary direct quote first

For an ABA\to B swap, let the direct Reserve multipliers be

gAD=aADaA>1,g_A^D=\frac{a_A^D}{a_A}>1, gBD=aBDaB(0,1).g_B^D=\frac{a_B^D}{a_B}\in(0,1).

The direct Post-Trade Elasticity prices are

PAD=PA(gAD)eP,P_A^D=P_A(g_A^D)^{-e_P}, PBD=PB(gBD)eP.P_B^D=P_B(g_B^D)^{-e_P}.

Post-trade value-flow balance gives

0=wA(gAD1)(gAD)eP+(1wA)(gBD1)(gBD)eP.\begin{aligned} 0={}& w_A(g_A^D-1)(g_A^D)^{-e_P}\\ &+(1-w_A)(g_B^D-1)(g_B^D)^{-e_P}. \end{aligned}

The direct quote determines the user's token amounts. Surplus settlement does not change those amounts. It changes only the accounts that fund and receive them.

Ordinary direct settlement is always available. It keeps every Reserve Asset coefficient fixed. Its normalized final LP scale is

s0Ds0=wA(gAD)es+(1wA)(gBD)es.\frac{s_0^D}{s_0} = w_A(g_A^D)^{e_s} + (1-w_A)(g_B^D)^{e_s}.

Post-trade balance makes this equal to

wA(gAD)eP+(1wA)(gBD)eP.w_A(g_A^D)^{-e_P} + (1-w_A)(g_B^D)^{-e_P}.

Jensen's inequality shows that the common value is at least one. If the scale-weighted average of the logarithmic Reserve multipliers is nonnegative, the positive-exponent expression is at least one. If it is nonpositive, the equal negative-exponent expression is at least one. The inequality is strict for a nonzero trade. Ordinary direct settlement is therefore the safe fallback.

3. Define the two settlement fractions symmetrically

Let

πApay[0,1]\pi_A^{\mathrm{pay}}\in[0,1]

be the fraction of the user's AA payment credited to Reserve.

Let

πBrec[0,1]\pi_B^{\mathrm{rec}}\in[0,1]

be the fraction of the user's BB output paid from Reserve.

The endpoints have direct interpretations:

  • πApay=1\pi_A^{\mathrm{pay}}=1: all pay enters Reserve;
  • πApay=0\pi_A^{\mathrm{pay}}=0: no pay enters Reserve;
  • πBrec=1\pi_B^{\mathrm{rec}}=1: Reserve supplies all receive tokens; and
  • πBrec=0\pi_B^{\mathrm{rec}}=0: Surplus supplies all receive tokens.

The actual Reserve multipliers are

gAS=1+πApay(gAD1),g_A^S = 1+\pi_A^{\mathrm{pay}}(g_A^D-1), gBS=1+πBrec(gBD1).g_B^S = 1+\pi_B^{\mathrm{rec}}(g_B^D-1).

Thus

1gASgAD1\le g_A^S\le g_A^D

and

gBDgBS1.g_B^D\le g_B^S\le1.

4. Available inventory determines the receive fraction

The user receives

daBD.\lvert da_B^D\rvert.

If the available protocol Surplus balance is aBSurplusa_B^{\mathrm{Surplus}}, the maximum amount that Surplus can supply is

min(daBD,aBSurplus).\min\left( \lvert da_B^D\rvert, a_B^{\mathrm{Surplus}} \right).

Reserve supplies the remainder. Therefore

πBrec=1min(daBD,aBSurplus)daBD.\pi_B^{\mathrm{rec}} = 1- \frac{ \min\left( \lvert da_B^D\rvert, a_B^{\mathrm{Surplus}} \right) }{ \lvert da_B^D\rvert }.

This choice attempts to use as much available Surplus BB as the user can receive. It is an inventory rule, not a safety proof. The pay-side calculation must still determine whether that receive allocation is feasible.

5. Preserve the direct relative-price endpoint

The candidate requires the final price vector to be one common positive multiple of the direct post-trade price vector:

PiS=λSPiD.P_i^S = \lambda_S P_i^D.

The common factor does not change relative prices:

PASPBS=PADPBD.\frac{P_A^S}{P_B^S} = \frac{P_A^D}{P_B^D}.

It also preserves post-trade value-flow balance for the unchanged user amounts:

idaiDPiS=λSidaiDPiD=0.\sum_i da_i^D P_i^S = \lambda_S \sum_i da_i^D P_i^D =0.

At the candidate endpoint, the Reserve Asset coefficient multiplier is

ciSci=λS(giSgiD)eP.\frac{c_i^S}{c_i} = \lambda_S \left( \frac{g_i^S}{g_i^D} \right)^{e_P}.

The receive asset has the largest endpoint distortion. Choosing

λS=(gBDgBS)eP\lambda_S = \left( \frac{g_B^D}{g_B^S} \right)^{e_P}

keeps the BB coefficient fixed:

cBS=cB.c_B^S=c_B.

For the pay asset,

gASgAD1,\frac{g_A^S}{g_A^D}\le1,

so

cAScA.c_A^S\le c_A.

Reserve Asset safety is therefore satisfied by construction. The remaining condition is LP Token safety.

6. Derive the two-asset LP condition

The final scales are

sAS=sAgAS(gBDgADgBS)eP,s_A^S = s_Ag_A^S \left( \frac{g_B^D}{g_A^Dg_B^S} \right)^{e_P}, sBS=sB(gBS)es.s_B^S = s_B(g_B^S)^{e_s}.

After dividing by s0s_0, LP safety becomes

1wAgAS(gBDgADgBS)eP+(1wA)(gBS)es.\begin{aligned} 1\le{}& w_Ag_A^S \left( \frac{g_B^D}{g_A^Dg_B^S} \right)^{e_P}\\ &+(1-w_A)(g_B^S)^{e_s}. \end{aligned}

For a fixed πBrec\pi_B^{\mathrm{rec}}, every quantity in this inequality is known except gASg_A^S. The condition is linear in gASg_A^S. That observation determines the pay allocation directly.

7. Calculate the minimum safe pay allocation

Solving the LP condition for gASg_A^S gives

gA,minS=1(1wA)(gBS)eswA×(gADgBSgBD)eP.\begin{aligned} g_{A,\min}^S ={}& \frac{ 1-(1-w_A)(g_B^S)^{e_s} }{w_A}\\ &\times \left( \frac{g_A^Dg_B^S}{g_B^D} \right)^{e_P}. \end{aligned}

Since

gAS=1+πApay(gAD1),g_A^S = 1+\pi_A^{\mathrm{pay}}(g_A^D-1),

the minimum safe pay-side Reserve fraction is

πA,minpay=gA,minS1gAD1.\pi_{A,\min}^{\mathrm{pay}} = \frac{ g_{A,\min}^S-1 }{ g_A^D-1 }.

The interpretation is immediate:

  • if the result is at most zero, zero pay allocation is sufficient;
  • if it lies in (0,1](0,1], it is the unique minimum safe pay allocation; and
  • if it exceeds one, the proposed receive allocation is infeasible.

At the exact interior minimum,

s0S=s0.s_0^S=s_0.

Every larger pay allocation remains safe and gives the LP Token additional scale.

8. Apply an optional configured Reserve floor

A pool may require a minimum pay allocation for reasons beyond endpoint safety, including future Reserve depth. Let that configured floor be

πApay[0,1].\underline{\pi}_A^{\mathrm{pay}}\in[0,1].

The final pay allocation is

πApay=max(πApay,πA,minpay).\pi_A^{\mathrm{pay}} = \max\left( \underline{\pi}_A^{\mathrm{pay}}, \pi_{A,\min}^{\mathrm{pay}} \right).

Setting the floor to zero uses exactly the minimum required for safety and automatically replaces a negative calculated minimum with zero. It therefore maximizes the non-Reserve proceeds. A positive floor preserves at least the configured fraction for Reserve.

The amount outside Reserve is divided equally:

Rewards fraction=1πApay2,\text{Rewards fraction} = \frac{1-\pi_A^{\mathrm{pay}}}{2}, Treasury fraction=1πApay2.\text{Treasury fraction} = \frac{1-\pi_A^{\mathrm{pay}}}{2}.

The earlier 70/15/15 allocation is therefore not fundamental. It occurs when the final pay fraction is 0.700.70.

9. Safe direct fallback

If

πA,minpay>1,\pi_{A,\min}^{\mathrm{pay}}>1,

the inventory-selected receive allocation cannot satisfy the constraints. The transaction does not revert for this reason. It uses ordinary direct settlement:

πApay=1,πBrec=1.\pi_A^{\mathrm{pay}}=1, \qquad \pi_B^{\mathrm{rec}}=1.

The user receives the original direct quote either way. The optional Surplus path changes settlement accounts only when its endpoint is admissible.

10. Closed forms at half elasticity

Suppose

es=eP=12.e_s=e_P=\frac12.

The normalized direct pay value flow is

σAD=gAD1gAD.\sigma_A^D = \frac{g_A^D-1}{\sqrt{g_A^D}}.

Balance gives

σBD=wA1wAσAD.\sigma_B^D = -\frac{w_A}{1-w_A}\sigma_A^D.

The direct receive multiplier is then

gBD=σBD+(σBD)2+42.\sqrt{g_B^D} = \frac{ \sigma_B^D+ \sqrt{(\sigma_B^D)^2+4} }{2}.

No numerical inversion is required.

There is an exact one-step constant-product coincidence when wA=1/2w_A=1/2. In that case,

gBD=1gAD.g_B^D=\frac{1}{g_A^D}.

This identity follows from post-trade execution. It does not make the complete Multiswap state transition equivalent to constant product because the scales generally evolve differently.

At half elasticity, LP safety is

wAgASgBDgADgBS+(1wA)gBS1.w_Ag_A^S \sqrt{ \frac{g_B^D}{g_A^Dg_B^S} } + (1-w_A)\sqrt{g_B^S} \ge1.

Introducing y=gBSy=\sqrt{g_B^S} is useful here because the condition becomes the quadratic

(1wA)y2y+wAgASgBDgAD0.(1-w_A)y^2 -y +w_Ag_A^S \sqrt{ \frac{g_B^D}{g_A^D} } \ge0.

This quadratic explains why receive-side safety need not be monotone. Depending on the opening state and pay allocation, safe allocations can occur near full Surplus funding, near direct Reserve funding, or in both regions with an unsafe interval between them. The candidate does not rely on monotonicity because it tests the inventory-selected endpoint and derives the pay minimum at that exact endpoint.

11. A concrete token-launch example

Take a two-asset pool with

aA=aB=100,a_A=a_B=100, sA=25,sB=100,s_A=25, \qquad s_B=100,

and

es=eP=12.e_s=e_P=\frac12.

The derived opening share is

wA=0.20.w_A=0.20.

A user pays 1010 units of AA, so

gAD=1.10.g_A^D=1.10.

The direct post-trade quote gives

gBD0.9764458333,g_B^D\approx0.9764458333,

so the user receives approximately

2.355416672.35541667

units of BB.

Suppose Surplus holds at least that much BB. Then

πBrec=0.\pi_B^{\mathrm{rec}}=0.

The minimum safe pay allocation is

πA,minpay0.613833348.\pi_{A,\min}^{\mathrm{pay}} \approx0.613833348.

With no higher configured floor, the user's 1010 units of AA are allocated as follows:

  • approximately 6.138333486.13833348 to Reserve;
  • approximately 1.930833261.93083326 to Rewards; and
  • approximately 1.930833261.93083326 to Treasury.

Surplus supplies the full 2.355416672.35541667 units of BB. The final scales are

sAS=25,sBS=100,s_A^S=25, \qquad s_B^S=100,

so

s0S=s0=125.s_0^S=s_0=125.

The BB coefficient remains fixed, the AA coefficient contracts, and the LP Token lies exactly on its safety boundary. The final relative price equals the direct post-trade relative price.

If the pool instead configures a 70%70\% pay-side floor, the final pay allocation is 70%70\%. Reserve receives 77 units of AA, while Rewards and Treasury each receive 1.51.5. The endpoint remains safe and gives the LP Token positive scale slack.

12. Why the two-asset scope matters

The gauge acts on every asset in a pool. In a pool with nonparticipating assets, protecting the receive Reserve forces the same downward gauge onto those unrelated scales. That can make useful Surplus allocations difficult or impossible.

This does not require Multiswap to abandon Surplus settlement. Multiswap is a network of pools with different cardinalities, including two-asset pools. The launch candidate enables this mechanism only for proven two-asset pools. Pools with more than two Reserve Assets continue using ordinary direct settlement unless a separate construction is established.

13. The boundary es=0e_s=0

At

es=0,eP=1,e_s=0, \qquad e_P=1,

direct settlement keeps both Reserve scales fixed. Any receive protection forces a downward gauge, while diverting any pay amount prevents the pay leg from restoring the lost scale. LP safety then requires

πApay=1,πBrec=1.\pi_A^{\mathrm{pay}}=1, \qquad \pi_B^{\mathrm{rec}}=1.

Only ordinary direct settlement remains. Burning LP Tokens cannot help because a0es=1a_0^{e_s}=1 when es=0e_s=0. Nontrivial Surplus settlement therefore requires es>0e_s>0.

14. Candidate transaction

For an eligible two-asset pool, an atomic transaction follows this sequence:

  1. Calculate the ordinary direct Post-Trade Elasticity quote.
  2. Read the live receive-asset Surplus balance.
  3. Calculate the inventory-supported πBrec\pi_B^{\mathrm{rec}}.
  4. Calculate gBSg_B^S.
  5. Calculate the minimum safe πApay\pi_A^{\mathrm{pay}}.
  6. Apply the configured pay-side Reserve floor, if any.
  7. If the required pay allocation exceeds one, discard the optional Surplus endpoint and use ordinary direct settlement.
  8. Otherwise calculate the common gauge and explicit scale updates.
  9. Credit the selected pay fraction to Reserve.
  10. Divide the remaining pay amount equally between Rewards and Treasury.
  11. Fund the receive amount from Reserve and Surplus according to πBrec\pi_B^{\mathrm{rec}}.
  12. Apply every account and scale update atomically.

The quote does not search over allocations. Inventory fixes the receive fraction, and the safety equation fixes the minimum pay fraction.

15. Implementation status and remaining work

This article specifies a research candidate. The current executable Surplus adjustment does not implement this gauge-equivalent two-asset mechanism.

Before implementation, the candidate still needs:

  • fixed-point rounding rules that round the pay minimum upward;
  • exact ledger journals for Reserve, Surplus, Rewards, Treasury, LP, and user movements;
  • tests at the feasibility boundary and around direct fallback;
  • randomized repeated-action tests as scale shares evolve;
  • authorization rules for Surplus debits and scale-accumulator changes; and
  • an explicit pool-level enablement rule restricting launch support to proven two-asset configurations with es>0e_s>0.

Conclusion

Two-asset Multiswap pools admit a focused Surplus mechanism suitable for token launches. The direct quote determines the user's amounts and relative price endpoint. Available Surplus inventory determines how much of the receive leg Reserve must fund. The LP safety condition then gives the minimum fraction of the pay leg that must enter Reserve. Any configured Reserve floor can raise that fraction, and Rewards and Treasury divide what remains.

The result is a deterministic allocation rule:

inventoryπBrecπA,minpayπApay.\text{inventory} \longrightarrow \pi_B^{\mathrm{rec}} \longrightarrow \pi_{A,\min}^{\mathrm{pay}} \longrightarrow \pi_A^{\mathrm{pay}}.

When the optional endpoint is infeasible, the transaction executes its ordinary direct quote. The mechanism therefore adds protocol-owned token distribution and revenue allocation to eligible two-asset pools without making user execution depend on Surplus feasibility.