# Concentrated Liquidity

To address the lazy liquidity problem, Gnoswap leverages a novel architecture called **Concentrated Liquidity Pools (CLPs). **CLPs allow liquidity providers to set a minimum and maximum price range, in which their liquidity will be active. This ensures that liquidity is concentrated around a specific price range, improving capital efficiency and reducing slippage for traders.

As liquidity in CLPs only requires each amount of * x* and

*within the designated range*

**y***, its behavior can be plotted into a graph as the following:*

**(Pa, Pb)**The **real reserve curve** is a parallel translation of the **virtual reserve curve** by the number of x tokens in price b (* xb*) towards the y-axis and the number of y tokens in price a (

*) towards the x-axis, giving the following equation:*

**ya**Although the real reserve curve represents the actual amount of tokens deposited by a liquidity provider, the liquidity pool must track two values to compute the virtual reserve curve that the pool behaves as: liquidity * L* and the square root of price

*.*

**√P**We define * L* as

*, a geometric mean of the quantity of two tokens in a pool, and also a constant that reflects the liquidity of the pool. We can solve for*

**√k***using*

**L***:*

**k = xy**Similarly, we can solve for * √P *by simply square-rooting the price equation:

Using the above formulas, we can compute the virtual reserves by solving for * x* and

*respectively:*

**y**Solving for * x*:

Solving for * y*:

If we substitute these values for * xb* and

*for the initial formula, we arrive at*

**ya****the concentrated liquidity formula**(the real reserve curve):

### Output Calculation

Based on the formulas derived in the previous section, we can calculate the output of a swap.

When trading y for x (calculating * ∆x *with

*), we first calculate*

**∆y****∆**

*using the first equation, then use the value to calculate*

**√P**

**∆x:**Similarly, we can also calculate * ∆y* when we trade x for y:

### Price Tick

Since the price range of each LP Token in a pool is unique, we need a mechanism to uniformly divide the price units of a pool to merge the liquidity of tokens provided at the same price within a single liquidity pool. The boundaries that partition the range are called **ticks**. The default tick spacing for pools is 1 basis point, meaning that liquidity is divided into intervals of 0.01%.

The pricing mechanism and the fee distribution mechanism remain the same as regular CPMM pools within a single tick. After a tick's liquidity is drained, the remaining input rolls over to the following tick to be swapped at a different rate.

Price at tick * i* can be expressed as the following formula:

Since prices are stored as a square root in Gnoswap's contracts, we use the following formula to calculate the square root of the price at tick* ** i*:

As the logarithmic calculation to derive * i* from a select price doesn't always end up as an integer, once a user inputs a value as a price, the contract automatically finds the nearest tick out of lower ones. For example, the exact value of the price at a tick index of 50,000, can be calculated as:

As the next highest tick (50,001) would result in a value of 148.383481541, a lower price range of 148.37 would translate into a lower tick of 50,000.

Last updated