<p>I've never heard of this before so I have no idea if this works well. However, In some sense I think the concept is quite interesting.</p>
<p>Let <span class="math-container">$B$</span> be the amount of rice in the pool and <span class="math-container">$A$</span> the amount of dollars. Let me write the price for 1kg of rice as a function of <span class="math-container">$A$</span> and <span class="math-container">$B$</span>.<br />
<span class="math-container">$$
p = f(A,B) \tag{1}
$$</span>
For this to work, we need <span class="math-container">$f$</span> to be increasing in <span class="math-container">$A$</span> (the more money in the pool the more expensive the rice), we need <span class="math-container">$f$</span> to be decreasing in <span class="math-container">$B$</span> (the more rice in the pool, the cheaper the rice) and ideally, <span class="math-container">$p \to 0$</span> if <span class="math-container">$A \to 0$</span>, so rice becomes infinitely cheap, and <span class="math-container">$p \to \infty$</span> if <span class="math-container">$B \to 0$</span>, so rice becomes infinitely expensive.</p>
<p>One function that satisfies this is:
<span class="math-container">$$
p = \frac{A}{B}.
$$</span>
Now consider an exchange in the pool. Assume that I add <span class="math-container">$dA$</span> units of money. With this money I get some rice in exchange. Say that the change of rice in the pool resulting from this is <span class="math-container">$dB$</span>. Notice that <span class="math-container">$dB&lt; 0$</span> as I remove rice from the pool. Each unit of rice costs <span class="math-container">$p$</span> units so we get the equation:
<span class="math-container">$$
\begin{align*}
&amp;dB = -\frac{dA}{p},\\
\to &amp;\frac{dA}{dB} = -p \tag{2}
\end{align*}
$$</span>
Equating <span class="math-container">$(1)$</span> and <span class="math-container">$(2)$</span> gives:
<span class="math-container">$$
\frac{dA}{dB} = -f(A,B).
$$</span>
Let's take the case where <span class="math-container">$p = \frac{A}{B}$</span>:
<span class="math-container">$$
\frac{dA}{dB} = -\frac{A}{B}.
$$</span>
This is a differential equation with solution:
<span class="math-container">$$
AB = K.
$$</span>
Which is the pool equation from the question. However, this is not the only option. Take for example the case where:
<span class="math-container">$$
\frac{dA}{dB} = -p = \frac{\alpha}{\beta} \frac{A}{B},
$$</span>
with <span class="math-container">$\alpha, \beta &gt; 0$</span>. A solution for this is:
<span class="math-container">$$
A^\alpha B^\beta = K,
$$</span>
which gives us a <em>Cobb-Douglass liquidity pool</em>.</p>
<p>As another example, consider:
<span class="math-container">$$
\frac{dA}{dB} = -p = \left(\frac{A}{B}\right)^\sigma
$$</span>
with <span class="math-container">$\sigma &gt; 0$</span>. Then a solution for this differential equation is:
<span class="math-container">$$
\frac{A^{1 - \sigma}}{1 - \sigma} + \frac{B^{1-\sigma}}{1 - \sigma} = K
$$</span>
which is a <em>CES-liquidity pool</em>.</p>
<p>In general, take any smooth utility function <span class="math-container">$u(A,B)$</span> where the marginal rate of substitution varies over <span class="math-container">$]0, \infty[$</span> . Then we can set:
<span class="math-container">$$
U(A,B) = K \to \frac{dA}{dB} = -p = \frac{U_A}{U_B}
$$</span>
So price is set by the slope at the indifference curve. By exchanging at this slope, you make sure that the <em>utility</em> in the liquidity pool is constant.</p>
<p>Now, what does the level of <span class="math-container">$K$</span> do? In some sense, higher values of <span class="math-container">$K$</span> take us on higher indifference curves. It is easy to see that the distance to go from one point on the indifference curve, say with price <span class="math-container">$p$</span>,  to another point, with price <span class="math-container">$p'$</span>, will take more trade in the pool, the larger the value of <span class="math-container">$K$</span>.  If the value of <span class="math-container">$K$</span> is too low, I think prices will be quite volatile as small trades cause large price variation. Big values of <span class="math-container">$K$</span> will demand large amounts of trade to change prices, so prices may be more stable. (see picture below)</p>
<p>However, (from a theoretical point of view) it is not the case that you need to move <span class="math-container">$K$</span> in order to get a price change.</p>
<p><a href="https://i.sstatic.net/AL5YM.png" rel="noreferrer"><img src="https://i.sstatic.net/AL5YM.png" alt="increasing K" /></a></p>

CC BY-SA 4.0
2021-06-19T01:05:36.337Z
Ok, so I guess the question is - to take the bags of rice scenario. You can propose a LP function for say five years of normal market activity. On the sixth year, world production of rice doubles. Does the LP continue pricing the rice effectively, or do you need to adjust K/
dwjohnston
CC BY-SA 4.0
2021-06-19T11:17:13.250Z
@dwjohnston Say that the amount of rice in the world increases and that this leads to a drop of the price in the *real world*. If the price of rice in the liquidity pool is higher than the real price, rational agents should arbitrage. Buy rice in the *real* market, sell this rice to the pool in exchange for dollars and get a sure profit. As such the amount of rice in the pool will increase until it again matches again the price in the real world. There's no need to increase $K$.
tdm
CC BY-SA 4.0
2021-06-18T18:43:35.903Z
2021-06-18T18:43:35.903Z
tdm
<p>First, lets be clear - I'm not pitching a crypto here, and I'm not seriously interested in Safemoon, which seems to be a pyramid scheme.</p>
<p>However, I was investigated Safemoon, and discovered this concept of liquidity pools and decentralised exchanges.</p>
<p>You can see <a href="https://www.youtube.com/watch?v=AHtlcu1zJR4&amp;t=286s" rel="noreferrer">a video here explaining how the LP works</a>.</p>
<p>A liquidity pool is basically a mechanism to price and exchange two commodities, without having a third party manage an order book - like a conventional stock exchange does.</p>
<p><strong>Constant Product Equation</strong></p>
<p>Basically the a LP is created with two different tokens, A and B.</p>
<p>The constant product equation is :</p>
<blockquote>
<p>K = A * B</p>
</blockquote>
<p>As an example:</p>
<p>Say I have I create a LP with 1000 A and 100 B then K = 100,000.</p>
<p>Now someone deposits 100 B into the LP, then in order to keep K constant they will receive 500 A to keep K constant. (500 * 200 = 100,000).</p>
<p>But now if someone deposits another 100 B, they would receive only 167 A (333 * 300 = 100,000).</p>
<p>As the video points out, this causes the price to asymptote as you head towards either extreme of imbalance of the coins, and the video bills this as a good thing.</p>
<p><strong>How good is this system really?</strong></p>
<p>The idea of an algorithmic system, that doesn't require a third party to exchange, I can see the appeal.</p>
<p>To take a real world scenario, you have people with bags of rice, and people with dollars. You could determine the price per bag using an order book.</p>
<p>I wondering if using a liquidity pool just as effectively prices the goods.</p>
<p>My initial thought is that it seems that the initial values of A and B very much 'stick' the price to within a certain band, and the price doesn't have much flexibility in moving beyond there.</p>
<p>I will note that Safemoon does have a mechanism that increases the K value, and that's a whole thing, so I think if the answer is 'Yes the ratio of A:B and the K value generally informs the price, and to move the price you need to adjust the K value, then it becomes a question of 'who/what determines the new ratio and K value?'.</p>

<pricing><cryptocurrency>
Do 'liquidity pools' effectively determine market price?
dwjohnston
# Do 'liquidity pools' effectively determine market price?

(Asked by: username_0 on 2021-06-18)

First, lets be clear - I'm not pitching a crypto here, and I'm not seriously interested in Safemoon, which seems to be a pyramid scheme.

However, I was investigated Safemoon, and discovered this concept of liquidity pools and decentralised exchanges.

You can see [a video here explaining how the LP works](https://www.youtube.com/watch?v=AHtlcu1zJR4&t=286s).

A liquidity pool is basically a mechanism to price and exchange two commodities, without having a third party manage an order book - like a conventional stock exchange does.

**Constant Product Equation**

Basically the a LP is created with two different tokens, A and B.

The constant product equation is :

> K = A \* B

As an example:

Say I have I create a LP with 1000 A and 100 B then K = 100,000.

Now someone deposits 100 B into the LP, then in order to keep K constant they will receive 500 A to keep K constant. (500 \* 200 = 100,000).

But now if someone deposits another 100 B, they would receive only 167 A (333 \* 300 = 100,000).

As the video points out, this causes the price to asymptote as you head towards either extreme of imbalance of the coins, and the video bills this as a good thing.

**How good is this system really?**

The idea of an algorithmic system, that doesn't require a third party to exchange, I can see the appeal.

To take a real world scenario, you have people with bags of rice, and people with dollars. You could determine the price per bag using an order book.

I wondering if using a liquidity pool just as effectively prices the goods.

My initial thought is that it seems that the initial values of A and B very much 'stick' the price to within a certain band, and the price doesn't have much flexibility in moving beyond there.

I will note that Safemoon does have a mechanism that increases the K value, and that's a whole thing, so I think if the answer is 'Yes the ratio of A:B and the K value generally informs the price, and to move the price you need to adjust the K value, then it becomes a question of 'who/what determines the new ratio and K value?'.

**Tags:** pricing, cryptocurrency

---

## 1 answers

### Answer by username_1 on 2021-06-18. Score: 5

I've never heard of this before so I have no idea if this works well. However, In some sense I think the concept is quite interesting.

Let $B$ be the amount of rice in the pool and $A$ the amount of dollars. Let me write the price for 1kg of rice as a function of $A$ and $B$.  
$$
p = f(A,B) \tag{1}
$$
For this to work, we need $f$ to be increasing in $A$ (the more money in the pool the more expensive the rice), we need $f$ to be decreasing in $B$ (the more rice in the pool, the cheaper the rice) and ideally, $p \to 0$ if $A \to 0$, so rice becomes infinitely cheap, and $p \to \infty$ if $B \to 0$, so rice becomes infinitely expensive.

One function that satisfies this is:
$$
p = \frac{A}{B}.
$$
Now consider an exchange in the pool. Assume that I add $dA$ units of money. With this money I get some rice in exchange. Say that the change of rice in the pool resulting from this is $dB$. Notice that $dB< 0$ as I remove rice from the pool. Each unit of rice costs $p$ units so we get the equation:
$$
\begin{align\*}
&dB = -\frac{dA}{p},\\
\to &\frac{dA}{dB} = -p \tag{2}
\end{align\*}
$$
Equating $(1)$ and $(2)$ gives:
$$
\frac{dA}{dB} = -f(A,B).
$$
Let's take the case where $p = \frac{A}{B}$:
$$
\frac{dA}{dB} = -\frac{A}{B}.
$$
This is a differential equation with solution:
$$
AB = K.
$$
Which is the pool equation from the question. However, this is not the only option. Take for example the case where:
$$
\frac{dA}{dB} = -p = \frac{\alpha}{\beta} \frac{A}{B},
$$
with $\alpha, \beta > 0$. A solution for this is:
$$
A^\alpha B^\beta = K,
$$
which gives us a *Cobb-Douglass liquidity pool*.

As another example, consider:
$$
\frac{dA}{dB} = -p = \left(\frac{A}{B}\right)^\sigma
$$
with $\sigma > 0$. Then a solution for this differential equation is:
$$
\frac{A^{1 - \sigma}}{1 - \sigma} + \frac{B^{1-\sigma}}{1 - \sigma} = K
$$
which is a *CES-liquidity pool*.

In general, take any smooth utility function $u(A,B)$ where the marginal rate of substitution varies over $]0, \infty[$ . Then we can set:
$$
U(A,B) = K \to \frac{dA}{dB} = -p = \frac{U\_A}{U\_B}
$$
So price is set by the slope at the indifference curve. By exchanging at this slope, you make sure that the *utility* in the liquidity pool is constant.

Now, what does the level of $K$ do? In some sense, higher values of $K$ take us on higher indifference curves. It is easy to see that the distance to go from one point on the indifference curve, say with price $p$, to another point, with price $p'$, will take more trade in the pool, the larger the value of $K$. If the value of $K$ is too low, I think prices will be quite volatile as small trades cause large price variation. Big values of $K$ will demand large amounts of trade to change prices, so prices may be more stable. (see picture below)

However, (from a theoretical point of view) it is not the case that you need to move $K$ in order to get a price change.

[![increasing K](https://i.sstatic.net/AL5YM.png)](https://i.sstatic.net/AL5YM.png)

> **Comments:**
> **username_0**: Ok, so I guess the question is - to take the bags of rice scenario. You can propose a LP function for say five years of normal market activity. On the sixth year, world production of rice doubles. Does the LP continue pricing the rice effectively, or do you need to adjust K/  
> **username_1**: @dwjohnston Say that the amount of rice in the world increases and that this leads to a drop of the price in the *real world*. If the price of rice in the liquidity pool is higher than the real price, rational agents should arbitrage. Buy rice in the *real* market, sell this rice to the pool in exchange for dollars and get a sure profit. As such the amount of rice in the pool will increase until it again matches again the price in the real world. There's no need to increase $K$.  

---

