# Constant Product Market Maker

Last updated

Last updated

Liquidity pools on GnoSwap utilize the **Constant Product Formula **to achieve deterministic pricing of any token in a pool, ensuring that trades can occur at any price within the range of (0, ∞). Liquidity pools maintain a constant * k *value, which is the product of

$x *y=k$

When a trade occurs in a pool, the values of **x**** **and * y *change. Let's assume that

$(x+∆x)(y-∆y)=k$

Based on the above formula, we can plot a graph that illustrates changes in token reserves in a pool after a trade.

To illustrate this concept, let's consider a scenario where Pool A holds 10 $GNOT and 10,000 $USDC. If Alice wishes to exchange 1 $GNOT for $USDC in Pool A, an equation reflecting the current reserves and **∆x **(change in $GNOT) is set up as follows:

Solving for ∆y, we get:

Therefore, we can expect Alice would receive 909.090909... $USDC if she were to sell 1 $GNOT in Pool A.

When adding liquidity to an existing pool, liquidity providers must deposit an amount of **token x** and **token y **that is proportional to the current * x : y *ratio in the pool. Once liquidity is added, the value of

As * k* is proportional to the liquidity of the pool, this structure can be seen as a virtual order book where liquidity is evenly distributed across the entire price range.

$k = 10*10,000 = 100,000 = (10+1)(10,000-∆y)$

$∆y = 10,000-(100,000/11) = 909.090909...$