KyberSwap Docs

Technical Comparison

Aggregated Amplified Price Curves

Elastic vs Classic: Price curve implementation

In general, KyberSwap Classic can be represented as follows:
αx0αy0=L2\alpha x_0 \cdot \alpha y_0 = L^2
  • alpha is the amplification factor
  • L is the liquidity
  • p_max, p_min will be the price max, min that KyberSwap Classic can support.
The current price p_r can be calculated as follows:
pmax=ymaxxmin=α2(α1)2prp_{max}=\frac{y'{max}}{x'{min}}=\frac{\alpha ^2}{(\alpha-1)^2} \cdot p_{r}
pmin=(α1)2α2prp_{min}=\frac{(\alpha-1)^2}{\alpha^2}\cdot p_{r}
pr=pmaxpmin\Rightarrow p_r=\sqrt{p_{max} \cdot p_{min}}
From the price min, max and liquidity, we can represent the invariant equations of two reserves x,y in a KyberSwap Classic pool as follows:
(x+Lpmax)(y+Lpmin)=L2(x+\frac{L}{\sqrt{p_{max}}})(y+L \cdot \sqrt{p_{min}})=L^2
Hence, the representation of KyberSwap Classic can be transformed from the original:
(L,pr,α){L:Liquiditypr:Referencepriceα:Amplificationfactor(L,p_r,\alpha) \Rightarrow \begin{cases}L : Liquidity \\p_{r} : Reference \quad price \\\alpha : Amplification \quad factor \\\end{cases}
to a new one:
(L,pmax,pmin){L:Liquiditypmax:Maxpricesupportedpmin:Minpricesupported(L,p_{max},p_{min}) \Rightarrow \begin{cases}L : Liquidity \\p_{max} : Max \quad price \quad supported\\p_{min} : Min \quad price \quad supported \\\end{cases}
The following figure illustrates an example of the KyberSwap Classic curve:
KyberSwap Classic Curve

Aggregated KyberSwap Classic

In the early version, KyberSwap Classic allows people to add liquidity in a specific price range. However, this approach has a drawback: the liquidity provider has to add liquidity to a pre-defined range in a pool or create a pool with high gas cost. In KyberSwap Elastic, we want to aggregate different KyberSwap Classic pools into one single pool. In general, two KyberSwap Classic pools can be represented as:
If the two price ranges do not have any overlap range, the combined reserves curve includes two parts. Otherwise, in the overlap price range, the liquidity equal is the sum of liquidity in two positions. Let's take an example when we have:
pmax1pmax2>pmin2pmin1p_{max_1} \geq p_{max_2} > p_{min_2} \geq p_{min_1}
The liquidity in different price ranges are:
The following figure illustrates how we aggregate liquidity in the three price ranges, where the blue line show the overlap price range, where the liquidity is the sum of liquidity in two positions.
Aggregated Liquidity