Virtual Balances
Last updated
Last updated
To guarantee the safety of the pool, there are some conditions which need to be fulfilled when adding liquidity to KyberSwap Classic pools:
After LP contributions, the token price remains unchanged.
and are also unchanged after LP contributions.
In KyberSwap, the pool for pair X-Y needs to maintain 4 parameters:
The initial amount of token that is used for amplification, denoted by
The initial amount of token that is used for amplification, denoted by
The change in token amount after trading activities, denoted by
The change in token amount after trading activities, denoted by
Therefore, the real balances and virtual balances of the reserves are:
Real Balances
Virtual Balances
The real balances and virtual balances of the reserve after contribution are:
Real Balances
Virtual Balances
The constant product, after the LP contribution, becomes:
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.
The parameters are then updated to be: x = 120$, $y = 120$, $\Delta x = 24$, $\Delta y = −18.
where is the amplification factor.
The constant product . Note that and at this time are:
The current price:
Liquidity Providers have to contribute in the same proportion for all 4 amount types. We denote the contribution ratio to be . LPs have to contribute x_1 + \Delta x_1$, $y_1 + \Delta y_1in which:
and at this time are:
The current price is updated to be
We see that after LP contributes, the current price, and are unchanged. It is similar in the case of LPs withdrawals, where the ratio is negative.
Initially, the first LP put 100 and 100 to the reserve, we have: .
A user trades 20 for 15 , so we have the updated parameters: .