This will be all the background needed to understand the ConstantSum
DFMM.
The ConstantSum
DFMM gives the LP a portfolio that will allow exchange of a pair of tokens at a single price.
We can allow this price to be dynamically chosen.
We mark reserves as:
$x \equiv \mathtt{rX}$ $y \equiv \mathtt{rY}$
ConstantSum
has one variable parameter:
$P \equiv \mathtt{price}$
The trading function is:
$$
\boxed{\varphi(x,y,L;P) =P \frac{x}{L} + \frac{y}{L} -1}
$$
where
The reported price of the pool given the reserves is
The ConstantSum
pool can be initialized with any given price and any given value of reserves.
A user may supply
We require that the trading function remain invariant when a swap is applied, that is: $$ P\frac{x+\Delta_X}{L + \Delta_L} + \frac{y+\Delta_Y}{L + \Delta_L}-1 = 0 $$
where either
If we want to trade in
If we want to trade in
Allocations and deallocations should not change the price of a pool and since this pool only quotes a single price, any amount of reserves can be allocated at any time.
We need only compute the new
Given that we treat
In this case, the value function is that of a limit order and follows: $$V(L,S) = \begin{cases} LS & \text{if } S \leq P \ LP & \text{if } S \geq P \end{cases}$$