SafeMoon fork problems with LP

Hello everyone,

First of all I'd like to thank you for providing this opportunity. Maybe there's someone who will help me, and it wouldn't be possible without this platform!

I've merged various forks from popular contracts, most notably SafeMoon, and launched my token through DXSale.

The Token has 4 basic functions: On every transaction, 5% is burnt, 5% is redistributed, and 5% is added to LP. Additionally, the maximum transaction is capped at 5000 Tokens (0.5% of supply)

There is an issue with the 5% going to the PancakeSwap LP, it's not working for some reason, and I'm not sure why.


:computer: Environment
Remix

:memo:Details
I followed DXSale's guide on how to launch SafeMoon forks on their platform, which is this:

If you are yet another copy of SafeMoon please ensure that you do the following to finalize:

  1. setLiquidityFeePercent to 0
  2. setMaxTxPercent to 100
  3. setSwapAndLiquifyEnabled false
  4. setTaxFeePercent 0
  5. Learn to read and understand your own code
  6. Test your code on the test networks provided
  7. Call finalize
  8. setSwapAndLiquifyEnabled true
  9. setLiquidityFeePercent (To your lp tax fee amount)
  10. setTaxFeePercent (To your reflect fee amount)

The launch was successful (the 2nd time around) but I had to disable setSwapAndLiquifyEnabled. This means the 5% to LP is not activated.

I don't have all the exact same functions but they are equivalent in what they do, simple variables changing the fee's values, or the max transaction limit. The one that I do have in common is setSwapAndLiquifyEnabled, which also just changes a boolean from true to false. The part of the code that is relevant to the LP is an exact match with many other popular contracts.

The problem I'm facing is that as soon as setSwapAndLiquifyEnabled is set to true, no one can sell their tokens anymore.

PanCakeSwap error: The transaction cannot succeed due to error: TransferHelper: TRANSFER_FROM_FAILED. This is probably an issue with one of the tokens you are swapping.

I presume this is because of an error in the code, but I can't understand how there's an error if it's exactly the same portion of code as other popular tokens, and as such, I believe it's execution related.

You can see all the current variable values here

:1234: Code to reproduce

Any help is welcome. Thank you so much. :heart:

1 Like

Hey, welcome!

Great!

It seems like you created a deflationary token (burn a percentage on transfer), just like abcoathup mentioned before:

this can cause issues with use in other contracts such as: https://medium.com/balancer-protocol/incident-with-non-standard-erc20-deflationary-tokens-95a0f6d46dea

Also I recommend looking at Points to consider when creating a fungible token (ERC20, ERC777)

A little complex to find out why it does not work.

1 Like

While I can’t say for certainty, when I did a diff on your code and safemoon it looks like you are excluding your custom dead address. This might mess something up in the RFI if/else logic in the _tokenTrasfer function.

I would do some testing and debug down starting from your _transfer function, which is where the swapAndLiquifyEnabled boolean is used. Use the hardhat testing, it makes it easy to trace where things go wrong using console.log.

Hope this can help or get you on the right track.

2 Likes

So, did you find any solution for setSwapAndLiquifyEnabled ?

1 Like

did you initialize the liquidity pool of your token to BNB?

Problems is that you can`t see the reserves in LP. How can I fix this ?
TotalSupply (in Pancake LP) is 0

Hi there, I’m taking a look at your problem now, in the future please create new threads. Do not reply to old ones.

This is your contract, and for whatever reason you can no longer do swaps.

So you need to find your LP Pair and figure out what’s going on with that.

When I go to your LP Token Page, it looks like something is wrong

No balances are shown, it’s as if you didn’t create the initial liquidity.

Can you show me an event or a transaction where you created your LP tokens?

You must create liquidity before you can do swaps.

I made a guide for it over here. Can't add liquidity on PancakeSwap with burnable ERC20 token - #8 by LSparkzwz

(How did you found our contract?)
I don’t know how is possible but someone remove our liquidity today.

The liquidity was here: https://bscscan.com/address/0x2195360493a91677e1211f1f95c458c045523f70

Same things to me
The problem I’m facing is that as soon as setSwapAndLiquifyEnabled is set to true, no one can sell their tokens anymore.
What should I do???

1 Like

Here is the issue the contract code you are using is V1 router address and it doesnt works now. So you need to change the address to v2 if you deploy new and test it. Upon reading i found a guy who also discussed the answer hope it helps. https://ethereum.stackexchange.com/questions/98047/safemoon-fork-lp-stops-working-bep-20

Here is the issue the contract code you are using is V1 router address and it doesnt works now. So you need to change the address to v2 if you deploy new and test it. Upon reading i found a guy who also discussed the answer hope it helps. https://ethereum.stackexchange.com/questions/98047/safemoon-fork-lp-stops-working-bep-20

1 Like

So I can essentially fork the contract
using these steps that were listed at the top

  1. setLiquidityFeePercent to 0
  2. setMaxTxPercent to 100
  3. setSwapAndLiquifyEnabled false
  4. setTaxFeePercent 0
  5. Learn to read and understand your own code
  6. Test your code on the test networks provided
  7. Call finalize
  8. setSwapAndLiquifyEnabled true
  9. setLiquidityFeePercent (To your lp tax fee amount)
  10. setTaxFeePercent (To your reflect fee amount)

and make sure I’m on V2 and I should be good to go??

Can you please help me? I can't remove the Liquidity for some reason.. https://bscscan.com/address/0xA0e49763d4DCAFbb71205d0d7a4eaE88d6FC71dF

Upon looking into your code the router address shows v1 pancakeswap and now it doesn’t work. What u can try now is 1. setSwapAndLiquifyEnabled false in the write section of bscscan and try if it works

I have the same issue as you. After I saw your contract, you managed to remove LP on PancakeSwap, how and how to solve it

can't remove LP in PancakeSwap, please help. I use safemoon fork with smart contract

I know how to solve this problem. I've already removed 10 BNB from one contract and 6 from another.

You can contact me by my telegram so that I can help you:

Did you manage to deploy a token now?