> For the complete documentation index, see [llms.txt](https://docs.gnoswap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gnoswap.io/core-concepts/amm/constant-product-market-maker.md).

# Constant Product Market Maker

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*** and ***y***, representing the quantity of **token x** and **token y** in the pool, respectively. This mechanism results in the following formula:

$$
x \*y=k
$$

When a trade occurs in a pool, the values of ***x*** and ***y*** change. Let's assume that **∆** represents the change in the quantity of a token. If a trader sells **∆*****x*** amount of **token x**, the pool receives **∆*****x*** amount of **token x** and pays out **∆*****y*** amount of ***token*****&#x20;y** (minus the swap fee) as the output in a way that satisfies the equation below:

$$
(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.

<figure><img src="/files/YF5FrGRvv9QyBgpJ89Ba" alt=""><figcaption></figcaption></figure>

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:

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

Solving for ∆y, we get:

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

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 ***k*** adjusts to the new values of ***x*** and ***y***.

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.

<figure><img src="/files/bTn5FFUlg3DhgLiZRaI2" alt=""><figcaption></figcaption></figure>
