Liquid Pretense: Exposing automatic liquidity generation in Safemoon and similar cryptocurrencies

Cryptogenica
10 min readMay 9, 2021

--

The liquidity function in the Safemoon token contract does not work as advertised. In fact, this function is constantly driving the token price down. In the last 10 days, the liquidity function alone has kept the price down nearly 35%. This is not adequately offset by RFI rewards as the price impact of the liquidity function is currently over 20x greater than the RFI reward impact. In addition to this the liquidity function effectively siphons value from other liquidity providers into the control of the contract owner.

Background

Safemoon has experienced a recent burst in popularity so it is highlighted in this article, but the function at hand really originated with $LIQ which Safemoon incorporated into their smart contract. Due to the recent success of Safemoon, this liquidity function has been copied, forked, and implemented in a wide variety of spinoff cryptocurrencies, so it is now widespread among many ETH and BSC tokens. For the purposes of explaining the topic at hand, I’ll focus on Safemoon, the Binance Smart Chain (BSC), and the primary BSC exchange, PancakeSwap.

Liquidity Pools Explained

If you already understand how liquidity pools work you’ll probably want to skip this section, but for those that don’t, this section is important to understanding the other issues described in this article.

To understand the concern with the automatic liquidity generation function you first have to understand liquidity pools and how they affect the price and volatility of a token. Uniswap and PancakeSwap are decentralized exchanges (DEXs) and are Automated Market Makers (AMMs), meaning instead of pairing buyers with sellers like a traditional exchange, they use liquidity pools to process transactions.

What are Liquidity Pools?

Liquidity pools (LPs) are pairs of tokens. For simplicity sake we’ll only consider the pair BNB and Safemoon. This is the primary pair that the token trades on. The important thing to remember is that BNB is the actual value token that relates to real world value.

Imagine you want to buy Safemoon, how does that work? Well, when you buy Safemoon, you’re essentially putting BNB into the liquidity pool and pulling Safemoon out of the pool. When you sell Safemoon, you’re putting Safemoon coins into the Liquidity Pool and taking BNB out. Simple enough right?

Let’s say for example that the Safemoon LP starts with 100 BNB and 1,000,000 Safemoon coins. If you want to purchase 50,000 Safemoon it will cost about 5.263 BNB. The liquidity pool for that pair will then contain 950,000 Safemoon and 105.263 BNB. So how was that price determined, and how do LPs affect the the price of the token?…

How token prices are determined by liquidity pools

PancakeSwap uses a constant product market maker model. The formula for that looks like: x * y = k. So in our example x and y correspond to the amount of BNB and Safemoon in the liquidity pool. k is always a constant.

Let’s look at the previous example. The LP was created with 100 BNB and 1,000,000 Safemoon, so the formula would look like: 100 x 1,000,000 = k. So in this example k = 100,000,000. So no matter how the quantities of x and y change in the LP due to buying and selling, k will always equal 100,000,000.

The notional price of the token is found by simply dividing the amount of BNB in the LP by the amount of Safemoon in the LP. So the initial price of each Safemoon in this example is 100/1,000,000 or 0.0001 BNB. However, in order to ensure k stays constant, we must really use the constant product formula to determine how many BNB must be added to withdraw 50,000 Safemoon coins. The calculation for that is simply 100,000,000 / 950,000 = 105.263. Therefore the actual cost of 50,000 Safemoon would be 5.263 BNB.

Continuing with that example, here are the prices for some example quantities:

  • 50,000 Safemoon: 5.263 BNB
  • 100,000 Safemoon: 11.11 BNB
  • 200,000 Safemoon: 25 BNB
  • 500,000 Safemoon: 100 BNB
  • 900,000 Safemoon: 900 BNB

As you can see the price is not linear. It increases or decreases to infinity:

This behavior allows the LP and PancakeSwap to be able to support selling any quantity of Safemoon or spending any quantity of BNB to buy Safemoon.

How liquidity pools determine price volatility

Recall that a token price is determined by the amount of that token in the LP divided by the amount of the value token it is paired against. So the price of Safemoon at any given time is the ratio of BNB in the LP to Safemoon in the LP.

When liquidity pools are small the prices will swing wildly with buys and sells because they change that ratio more drastically. The larger the liquidity pool, the lower the impact that any given transaction will have on the overall ratio, thus it will have a lower price impact.

Safemoon Liquidity

One of the common issues with DeFi tokens is obtaining enough liquidity to stabilize token prices. Safemoon advertises that each transaction has a 5% fee that goes towards automatic liquidity generation. This is a massive increase from the 0.17% default for each PancakeSwap transaction. In addition, this applies to every transfer, not just swaps. In terms of liquidity, this sounds great right? Well, maybe not when you really understand how it works and what the impact is.

How Safemoon liquidity generation works

Safemoon takes 5% of each transaction and transfer to support “automatic liquidity generation”. That amount is sent to the contract itself and stored there just like a normal wallet. Once that contract balance reaches a certain threshold, the “swapAndLiquify” function is executed on the next transfer. The steps of that function are described below. In the examples below, the liquidity pool starts with 1,000,000 Safemoon and 100 BNB, and 200,000 Safemoon is the liquidity event threshold.

Note: Round figures are used for the sake of simplicity. In reality there will be minor differences +/- in the values mentioned.

Step 1: Take the accumulated Safemoon balance and split it in half

STEP 1: Contract accumulates Safemoon and splits it in half

Step 2: Sell half of that Safemoon balance for BNB, which results in adding that half of the Safemoon to the LP and extracting 5 BNB.

STEP 2: Contract sells half of the accumulated Safemoon

Step 3: Pair up the remaining Safemoon with the BNB received from the previous step and add it to the existing liquidity pool.

STEP 3: Contract pairs the remaining balances and adds it to liquidity

Recall the discussion earlier about how AMMs work and how liquidity pools support buys and sells. When step 2 executes, it is selling Safemoon, so it is taking BNB out of the existing liquidity pool and inserting half of the accumulated Safemoon. Then when step 3 is executed, it is putting that same BNB back into the pool, except with the additional half of the Safemoon tokens. So the net effect of that transaction is only putting additional Safemoon tokens in the the liquidity pool.

Impact of Automatic Liquidity Generation

There are two significant results of the “swapAndLiquify” function. These are:

  1. Add additional Safemoon to the Liquidity Pool (net effect)
  2. Add new LP tokens to the Safemoon owner wallet

The impact of each of these are described below:

1. Add additional Safemoon to the Liquidity Pool

What is the actual impact of this? That question is the crux of this entire article. This function of Safemoon is often described as “creating liquidity” and “raising the price floor”, but we can see now that the actual effect of it is just adding about 5% of the Safemoon tokens of each transaction to the liquidity pool, so what real impact does that have? Recall that token prices are simply a ratio of existing pairs in the LPs. So one of the primary impacts of this function is to lower the price of the token continually over time.

But how much does this actually affect the price? We can calculate that fairly easily. The % decrease is determined mostly the percentage of the market cap that is backed by BNB. For example, if the market cap is 100,000 BNB, but there is only 1000 BNB in the liquidity pool, then only 1% of the market cap is backed by the liquidity pool. The other factor is the threshold for the liquidity event, or the number of tokens that must be accumulated to trigger a liquidity event. For Safemoon this is 0.05% of the total supply. So the formula for the price decrease for each liquidity event is as follows:

P = % of market cap backed by the liquidity pool

T = The threshold for how many tokens to accumulate for each liquidity event, in % of total supply.

Then the formula for percentage decrease = 1- P/(P+T)

Safemoon Price Decrease

Now lets look at the actual values for Safemoon. As of writing this article the Safemoon liquidity pool backs about 4.28% of the Market Cap. Some sites claim it is double this, but they’re counting both the Safemoon and BNB in the LP. Only the BNB provides any real backing, so 4.28% is the correct figure. Safemoon also uses 0.05% as the amount of the total supply involved in each liquidity event. That comes out to 1.15%. That means every time the Safemoon liquidity event occurs, it lowers the value of everyone's holdings by 1.15%.

2. Add new LP tokens to the Safemoon owner wallet

The secondary effect of the liquidity function is to add LP tokens to the contract owner’s wallet. Just like when you add liquidity for any other pair of tokens, you receive ‘LP’ tokens that correlate to that pair. That allows you to exchange your ‘LP’ tokens for those tokens you staked in the pool (accounting for any impermanent loss).

When the Safemoon liquidity function executes, this same thing occurs. Every time the function executes, additional LP tokens are created and they get sent to the owner’s wallet. Remember that the BNB in the liquidity pool is the real value token. These LP tokens could be exchanged for BNB (in addition to Safemoon).

Recall the discussion and diagram earlier about the net effect of the liquidity function. No additional BNB (and thus value) is added to the liquidity function. So where does the BNB come from that these LP tokens could be exchanged for? It has to come from other liquidity providers. This occurs when the function sells the Safemoon as part of the ‘swapAndLiquify’ function. So ultimately the owners of the contract can do nothing and LP tokens will show up in their wallet that correlate to real value that was siphoned from other liquidity providers including locked liquidity.

What about the Reflect fee? Does that offset the price difference?

Safemoon also has a 5% reflect fee. This is based on the Reflect Finance (RFI) token. This works by taking 5% of every transfer and adding that amount to each holders wallet in proportion to the amount they hold.

So when you consider this with the liquidity function it could make some sense. The liquidity function lowers the value, but the reflect fee adds tokens that could offset it. Does that really work?

Let’s consider the same amount of transactions and fees as the liquidity fee to have an even comparison. When the liquidity function executes, it accumulates up to 0.05% of the total supply. Up until that point the same 0.05% of the total supply would have been transferred to existing holders from the 5% reflect fee in proportion to how much they hold. So how much would that have increased each holder’s value? That math is much easier. It’s simply 0.05%. 0.05% of the total supply distributed evenly to each holder in proportion to how much they own, means everyone sees a 0.05% increase over that period.

Now compare the impact of the liquidity fee to the RFI fee. The liquidity fee drops the price around 1.15% based on today’s numbers and the RFI fee increases it 0.05%. So currently, the liquidity function is about 23 times more damaging to the token value than the RFI function makes up for.

Let’s look at some of the recent liquidity events for Safemoon and see what their impact was. Here’s the latest liquidity event transaction at the time of this article:

That single liquidity event sold $1.7 Million worth of Safemoon. That is happening a little more often than daily right now.

Over the last 10 days (4/29–5/9) there have been 13 liquidity events. The current price of a single Safemoon token is $0.00000691. If those 13 liquidity events had not happened, the current price of Safemoon would be $0.00000932, or about 34.9% higher. Safemoon has obviously been pretty successful despite this issue, so clearly the token value can still go up as long as people are buying faster than the liquidity function is selling. However, this begs the question, how much more successful could Safemoon be if this function weren’t in place?

--

--

Responses (2)