What is it about Safemoon SwapandLiquify and numTokensSellToAddToLiquidity

What is it about Safemoon SwapandLiquify and numTokensSellToAddToLiquidity?

There are already many topics about this

1 Like

Although there are many topics, its use has not been clear to me this automatic sale.
If I want to manually add the tokens to the liquidity pool, I don’t need this, not?

Yes right those are used to auto add liquidity

Thanks @FreezyEx

And no its necessary not?

It’s the so-called token killer function.

It’s purpose is to sell that amount of tokens from donation wallet to support liquidity, but not many “devs” seems to understand the function and thus they don’t tell it out public either.

It’s meant to support the LP and balance out swinging chart, but when “investors” aren’t told about that function, they think that the developers are scamming them.

This happened last night to Velorex (VEX).
The function was triggered and panic aroused. All big whales sold their assets and the developer resigned from the team.

It is IMPERATIVE that the function is known and UNDERSTOOD. Otherwise your token will be most likely dead when this hits.

UPDATE:
It has turned out, that this function did’t actually kill VEX, but it was Exploited to rug whole community and create a sob story to cover the tracks.

@Varjokettu Thanks.

Honestly, what has been said is worrying. And since I don’t really understand how it works, I think it will have to be eliminated from my contract so that there are no problems.

At the end of the day, its function is only to send liquidity mechanically. Something that can be perfectly generated manually.
Not?
In what context would it need to be automatic?
High transaction activity?

I’m not 100% sure either, since I’m learning this stuff myself as well.
I thought it’s selling the *tokens from some dedicated wallet, but that’s not actually the case, since there’s no dev wallet or similar in Safemoon where it can sell those…

Only thing I do know is that this function is pretty dangerous if overlooked by developer.
Not in a way that it compromises anything, but in a way that needs to be addressed publicly so that people don’t get scared when it happens.

i repost here for everyone:

The function works in this way:
at each trasnaction a fee is charged and sent to contract balance. When the contract balance reach the numTokensTo… amount, at the next transaction it will call the function swapAndLiquify which divide the contract balance in half. One parte is swapped for wbnb and the second half remain in tokens. These two halves are then paired together and added to liqudiity on pancake

5 Likes

@FreezyEx was kind enough to expain this to me <3

1 Like

This is correct. But the SwapAndLiquify function can look like cheating for new listed token, cos it can be selling at very little time interval thereby dipping price, and making investors be afraid.

Yea.

I think the only way to actually make it legit is to inform the investors.
Or turn off/take out.

I guess only handful of investors actually reads the contract and then when something like this happens, they get scared.
Also unfortunately not even close all investors reads the announcements of the token from TG, Twitter or any other channels and they normally expects the worst.

First I thought that i’d just take that function out completely, but at a second thought, I will just lower the amount substantially and explain everything also in the code, whitepaper, webpage, TG announcements etc.

1 Like

i had to disable it for now for like 2 tokens that I deployed recently.

Will be turned on later.

I wonder if it will create backlog and sell many small portions repeatedly, because the
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
will be filled multiplied if it is turned off.

It won’t sell repeatedly. The function triggers when buy/sell happens, and will happens once, but it will now be on each transfer until the threshold is lesser.

I have a custom code to update the numTokenSell. You can reduce or increase it, depending on what you want. On Safemoon, it is hardcoded, and cannot be changed.

hey, you can’t manually remove token on a contract address, it has to be in the deployed code, else, the token is stucked forever.

Note that, token contract address is different from normal Wallet Address

I performed a study comprised of multiple contracts that utilize the Swap And Liquify function. If anyone would like to know exactly how it works, I wrote a 10 page technical analysis on the Swap and Liquify function.

The long version:

The short version:
The swap and liquify function devalues the token 1-5% each time it is executed. The function is performed automatically when the collected “_taxFee” in the contract hits a certain threshold. During periods of high trade volume, and depending on the specific implementation, the function can execute 1-10 times a day. The real kicker is that no liquidity is actually being added to the pool as these tokens advertise. The added liquidity is 1 sided so it further devalues the token… but the worst part… in a lot of cases the LP tokens are sent to a private unlocked developer wallet. With higher market cap tokens like SafeMoon, some days the dev’s pull in over $25 million worth of LP tokens.

Sorry I didn't understand this part.

The function is advertised as something that adds Liquidity to the pool. This is incorrect because to properly add Liquidity to the pool it must be added in equal value to both sides. If only one token is added to the pool, the value of the token decreases.

2 Likes

Mm I think there is an error. If you look at addLiquidity function you will see that the contract will add both wbnb and tokens.
It takes wbnb trough the swap function. It take his token balance and divid in 2 halves. First half is swapped for wbnb and then paired with remaining tokens.