Stirring the Liquidity Pool

Keir Finlow-Bates
7 min read5 days ago

(Article 2 in a series on decentralized exchanges and memecoins)

In my previous article, I described how even if a token launch provides 98% of the tokens as liquidity to a decentralized exchange (DEX for short), with only 2% held back for the token launchers, they can still extract half of the DEX value by selling that 2%.

And only holding back 2% of the token in reserve is unheard of. Shockingly, there are coins out there where it’s the other way around: 98% is issued to the project managers and only 2% are made available to the gullible public. Even more shockingly, people are buying them.

There are, however, other ways for unscrupulous token launchers to take advantage of speculators (known derisively as exit liquidity by the scammers), and that is through direct manipulation of the liquidity pool of the DEX.

But before we can understand the mechanics of the scam, we need to understand how liquidity pools work.

How does liquidity work?

For a DEX to function, there has to be a liquidity pool consisting of two amounts of two different tokens. Imagine, for example, we have a token called YOLT (the You Only Live Twice token), and we pair it in a DEX with USDC, which is a stablecoin pegged to the US dollar.

Such a DEX effectively allows people to purchase YOLT with dollars, through the somewhat roundabout method of depositing dollars with an exchange, using them to buy USDC, and then using that USDC to by YOLT.

(Using USDC as the second part of the pair makes things easier to understand, because USDC is pegged to the US dollar. In a future article we will look at what happens when we pair two memecoins.)

In the previous article I wrote that the DEX keeps the amount of the first token (YOLT) times the amount of the second token (USDC) constant. This is not quite true — when more liquidity is added by the same party or other parties, or when liquidity is extracted, the constant has to be recalculated.

To keep track of who owns what proportion of the liquidity pool, the DEX issues liquidity tokens, which you can image as shares in the liquidity pool. I am going to call these lpYOLT (standing for liquidity pool shares in YOLT).

To illustrate, consider the following scenario:

  • I issue 200 of the new YOLT tokens at the start of the project, holding 100 YOLT back under various names for other scams: my personal allocation, a project reserve, some for marketing, then there’s the project treasury, and of course I need some for tokenomic stability purposes.
  • I add 100 YOLT and 100 USDC to the DEX at the start, and receive 100 lpYOLT. The liquidity pool is now 100 YOLT/100 USDC, and the spot price for YOLT is $1.
  • The product of 100 × 100 is 10,000, so that’s the starting constant.
Initial liquidity pool seeding
  • A first speculator pays 50 USDC into the DEX, and the DEX pays out 33.33 YOLT to them to keep the liquidity pool product constant, as 66.67 × 150 = 10,000. After all, they have to get hold of YOLT somehow to be able to add it to the DEX liquidity pool, and the only way for a member of the public to do that is to buy some from the DEX.
  • The new spot price for YOLT is $2.25.
First purchase of YOLT
  • The first speculator wants to pay their newly acquired 33.33 YOLT into the DEX to provide more liquidity.

Question: How much USDC do they need to supply and how many lpYOLT should they receive?

Updating the liquidity pool

The proportion of YOLT to USDC has to stay the same to keep the price per YOLT the same when liquidity is added. That’s the principle idea behind increasing or decreasing the size of the liquidity pool:

The ratio of the two tokens before and after adding to or removing from the liquidity pool must stay the same

Before, we had 66.67 YOLT/150 USDC. After the first speculator adds their 33.33 YOLT, we have 100 YOLT. So the amount of USDC, call it x, that should be in the new liquidity pool to keep the balance is:

66.67/150 = 100/x

x = (100 × 150) / 66.67 = $225

Therefore to match their 33.33 YOLT pay-in, the first speculator has to also add:

$225 — $150 = $75.

You can double-check this: the price per YOLT was $2.25 before the liquidity pool was topped up, and afterward we note that $225/100 also equals $2.25.

Also, the liquidity pool constant has changed. It is now 100 * 225 = 22,500.

Minting more lpYOLT

How many lpYOLT tokens should speculator 1 receive? For that, we can look at either the YOLT balance, or the USDC balance in the liquidity pool. Both will give the same answer, because both allow us to calculate the proportion of the liquidity pool that speculator 1 owns at this point.

Before speculator 1 added their 33.33 YOLT, the pool contained 66.67 YOLT. Afterward it contains 100 YOLT. That means speculator 1 has provided 33.33/100 of the liquidity and should own 33.33% of the lpYOLT tokens in existence.

Now we can’t just take 33.33 lpYOLT tokens from me and move them to speculator 1 — well, technically we could, but that would involve some tricky coding and make lpYOLT token holders unhappy, as psychologically it makes them feel they’ve made a loss. Furthermore, because lpYOLT will typically be an ERC-20 compliant blockchain token and protocol designers like DeFi to work like Lego, there are all sorts of things that can be done with liquidity tokens. They can be traded, swapped, or locked in a yield-bearing contract, for example.

Instead, traditionally we mint more lpYOLT tokens, in this case to speculator 1, so that I end up owning 66.67% of the lpYOLT tokens (remember, I provided the initial liquidity), and speculator 1 ends up holding 33.33%. The DEX needs to perform a calculation to determine exactly how many lpYOLT tokens to issue to speculator 1. We’ll do that manually now.

My 100 lpYOLT represents 66.67% that should exist, so the total amount of lpYOLT should be 100/0.67 = 150. Speculator 1 therefore gets 150–100 = 50 lpYOLT.

Result after speculator 1 adds liquidity to the pool

Yes, this is confusing — we have YOLT and lpYOLT and the liquidity pool values, and numbers moving around everywhere. If you have difficulty following the arithmetic, then my advice is: don’t mess about with decentralized exchanges, and certainly don’t start messing around with DeFi or launching your own token and DEX.

What does lpYOLT give you?

An lpYOLT token represents a claim on some of the liquidity pool. As I said earlier, it is a bit like having shares in the DEX. This means that at any point you can redeem your lpYOLT token for the proportion of the liquidity pool it represents.

For example, continuing the with the above setup for YOLT, what happens if I redeem my 100 lpYOLT tokens for the liquidity pool? They represent 66.7% of the pool, and so I can withdraw two thirds of the YOLT and the associated USDC.

This is excellent for me. I put 100 YOLT and 100 USDC in, got 100 lpYOLT as a receipt for my liquidity pool contribution, and then after some trading on the part of the first speculator, I can withdraw 66.67 YOLT and $150 by redeeming my 100 lpYOLT.

If I don’t care about YOLT, what I’ve done is make a $50 profit. And as a scammer, I don’t care about YOLT. In the long run, I expect it to be worthless.

The liquidity pool exit scam

Back to the original setup in article one, which you really should read if you haven’t already. In that scenario, I added 100 YOLT and 100 USDC to the DEX liquidity pool, and then a hundred speculators each bought $10 worth of YOLT.

We ended up with a DEX containing 9.09 YOLT, and $1,100.

And I own all the lpYOLT tokens so I own all the current liquidity pool contents!

Time to rug — all I do is redeem my lpYOLT for that liquidity.

I get 9.09 YOLT (which I don’t care about) and $1,100. The DEX no longer functions, because it contains no liquidity, and I have made $1,000 in profit from my worthless, scammy tokens.

And if the first speculator owns a third of the liquidity pool tokens? Then I extract my liquidity and use the YOLT it provides me, plus the tokens I held back in reserve to drain all the USDC I can from the remaining liquidity owned by the first speculator.

I win either way, and the memecoin speculators all lose.

Coda

If you found this interesting or useful, you’ll probably enjoy my book, Evil Tokenomics. You can find where to buy a copy by following this link.

--

--

Keir Finlow-Bates
Keir Finlow-Bates

Written by Keir Finlow-Bates

I walk through the woods talking about blockchain

No responses yet