PSA Regarding SafeMoon Forks on PancakeSwap - Transfers not working? Read This!

Recently PancakeSwap has migrated to V2.

You can migrate to V2 following the guide.
https://medium.com/beefyfinance/pancakeswap-migration-2d599e262900
The V2 router is now https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e

However if you are already on V1, you will want to stay on V1 if possible because there is a problem with SafeMoon code in that the V1 router for PancakeSwap was hardcoded in.

Line 758 https://bscscan.com/address/0x8076c74c5e3f5852037f31ff0093eeb8c8add8d3#code
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F);

SafeMoon does not allow an update for this. There is not function in the code that will allow you to update this code.

This is important because the Liquification Process will happen to the V1 Router, if you moved to V2 and there is no LP in the V1 router, this will cause errors and you will be unable to swap or transfer your tokens.

If you do move to V2 then
In order to fix this you must set variable swapAndLiquifyEnabled to false.

If you cannot do this because you rejected your ownership of your contract, then you must stay on V1. However you will not get rewards or fees for providing LP.

If you are having trouble removing Liquidity you may need to change your maxTxAmount so that when you remove liquidity it will go through.

7 Likes

Thank you so much, my friend! you helped me a lot!!!
I’m happy to found this group!!! congrats!!

2 Likes

Hey thanks for this PSA.

So if we create a new safemoon fork and update the below to the V2 router does this correct the issue and allow compatibility with Pancakeswap V2 liquidity? i.e. Can we just update the code as follows?

IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ed43c718714eb63d5aa57b78b54704e256024e);

1 Like

Yes, but what if they move to V3 in the future?

You will just end up in the same issue. You should build a function that allows overwriting for this code.

Blockquote Yes, but what if they move to V3 in the future?
You will just end up in the same issue. You should build a function that allows overwriting for this code.

You are right, I did it yesterday!
now I can replace this address, if someone wants it, I can show how I did.

5 Likes

Up for this one. I also wanted to know if this is enough to make safemoon fork work.

Yes, do it and safemoon fork will work.

2 Likes

Aight! Will give it a try! Thank you.

Can you clarify this for me?
I haven't deployed yet - If I update the router address to the V2 address do I need to set the swapAndLiquifyEnabled function to false? I don't believe so since the function will be using the new address.

Also, do you know PacakeSwap V2 address on BSC Testnet?

Hi, it would be great if you could show it, thanks in advance.

Please, before deploy it change router address to the V2.
0x10ed43c718714eb63d5aa57b78b54704e256024e

Thanks for this !

Is there a way to remove liquidity from pancakeswap V2 if we renounce the ownership ? ( lot of bnb locked :dizzy_face: )

1 Like

Trying to do a similar adjust to make the pcs address variable. Can you share your code so I can see your method

Would be interesting to see your approach

Many thanks

2 Likes

Did you try making the router address changeable in the code? I imagine many future PCS releases v3 v4… causing legacy contract issues …

The solution is to write a simple getter/setter of the Router address and for the LP Pair. But no one can change it in their code because they do not use proxies. It would also require the contract to have an owner.

1 Like

I am going to create a function to change Router address. But now the question is:
What I have to do in addition to change the router to an hipotetically v3? It is enought to remove liquidity from v1 and add to v2?

Pancakeswap on testnet is this. No v2 I think
0xD99D1c33F9fC3444f8101754aBC46c52416550D1

you need to update the Router Address and the LP address. When that update happens move your LP to the new address. There are probably better ways to migrate to a new router than manually removing and re-adding. You would have to think up a migration way.

Uniswap might have a way since they created a Migrate from V2 to V3 function.

Ok but should I create a new Pair on new router? Like in the constructor?

I’d love to see how you were able to do this!