There are some conditions when adding liquidity to the BlueLotusDAO:
After LP contributions, the token price is unchanged.
Pmin and Pmax are also unchanged after LP contributions.
In BlueLotusDAO, the pool for pair X-Y needs to maintain 4 parameters:
The initial amount of token X that is used for amplification, denoted by x0
The initial amount of token Y that is used for amplification, denoted by y0
The change in token X amount after trading activities, denoted by Δx0
The change in token Y amount after trading activities, denoted by Δy0
Therefore, the real balances and virtual balances of the reserves are:
Real Balances
x=x0+Δx0y=y0+Δy0
Virtual Balances
x′=a⋅x0+Δx0y′=a⋅y0+Δy0
The real balances and virtual balances of the reserve after contribution are:
Real Balances
Virtual Balances
The constant product, after the LP contribution, becomes:
Example
Suppose an LP wants to contribute 20% of the current token amounts in the pool, so he should deposit:
ie. deposit 24X and 17Y tokens.
where a is the amplification factor. You may find more information about the amplification factor here.
The constant product x′⋅y′=(a⋅x0+Δx0)⋅(a⋅y0+Δy0)=k′.
Note that Pmin and Pmax at this time are:
⎩⎨⎧Pmin=k′(y0⋅a−y0)2Pmax=(x0⋅a−x0)2k′
The current price: P=x′y′=a⋅x0+Δx0a⋅y0+Δy0
Liquidity Providers have to contribute in the same proportion for all 4 amount types. We denote the contribution ratio to be b. LPs have to contribute x1+Δx1, y1+Δy1 in which:
The current price is updated to be P=x′y′=(a⋅x0+Δx0)⋅(b+1)(a⋅y0+Δy0)⋅(b+1)=a⋅x0+Δx0a⋅y0+Δy0
We see that after LP contributes, the current price, Pmin and Pmax are unchanged. It is similar in the case of LPs withdrawals, where the ratio b is negative.
Initially, the first LP put 100 X and 100 Y to the reserve, we have: x=100,y=100,Δx=0,Δy=0.
A user trades 20 X for 15 Y, so we have the updated parameters: x=100,y=100,Δx=20,Δy=−15.
0.2⋅100+0.2⋅20=24(X)0.2⋅100+0.2⋅(−15)=17(Y)
The parameters are then updated to be: x=120, y=120, Δx=24, Δy=−18.