5
$\begingroup$

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.

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?'.

$\endgroup$

1 Answer 1

5
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ 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/ $\endgroup$
    – dwjohnston
    Commented Jun 19, 2021 at 1:05
  • $\begingroup$ @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$. $\endgroup$
    – tdm
    Commented Jun 19, 2021 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.