SwapAndLiquify function transferred all my BNB from PancakeSwap to the contract address

I recently set swapandliquify to true and when I tested a transaction after this, all of my liquidity 1.93 BNB from pancakeswap was transferred to my contract address. Is there a way to get this back? Here is the transaction where it occurred https://bscscan.com/tx/0xb56cb68ea096906d4281912f986ea68a72c0a0b8a56e0ce67c0b0ea2c2cc5ffc

Here is my contract address: https://bscscan.com/address/0xdba9b1d91e710b4ac9a1df3a7b3f632f4297f0a3
Any assistance is greatly appreciated, thank you

Tell friend, ok?

Hey friend, for this you need to create a function to remove the bnb from the contract! As you did not write I believe that it is not possible to remove…

Even this is Safemoon’s auditing problem.

create a Whitdraw function.
`` `

function sendContractBalance (address payable to) public onlyOwner {
       require (address (this) .balance> 0, "07");
       to.transfer (address (this) .balance);
}

`` `
** Remembering that you need to deactivate the exchange and liquefy and approve the removal of the bnb from the contract and then write the contract to send the bnb balance to your address **

3 Likes

Any idea why the swapandliquify would do the functionality that it did? Weird it moved all the BNB from pancakeswap LP to the contract address

The SwapandLiquify function does just that! Take half of the tokens and convert them to bnb and send them to the contract.

Analyzing your contract, I saw that it is enabled, you should have selected false, go to write contract and select SwapandLiquify and leave as false.

Another big problem I found in your contract is that you don’t have any function to withdraw tokens, not even withdrawETH(bnb).

1 Like

Is there anyway for the liquidity to be added back to the pancake swap liquidity pool?

From the contract address

Try this! I don’t know if you’ll make it but it’s hard to try…

  1. Go to write contract, and connect with the wallet that owns the contract.
  2. Approve a contract token transfer.


Spender: You put the address you are going to send, try putting the address of the wallet that owns the contract.
Amount: put 1 to see if it goes all bnb.

3)Go to transfer from,
1

Sender: Here you enter the address of your contract.
Recipient: Here you enter the address you approved in the case the wallet that owns the contract.
Amount: 1

Try to do this, if not, repeat the same process for the Transfer function above.

If you can’t let me know.

1 Like

Hi Skynance, thank you for your continued help. It looks like it’s trying to transfer BEP20 token perhaps. Here is the transaction. https://bscscan.com/tx/0xf8f95adeb152150410470f154f0c2e69aefe744dc56fcd8983d5bdacfeb7f08c

The dev who wrote the contract sent this, not sure if this helps:
Capture

I don’t understand what he means by decreasing the number of tokens before the exchange and then selling tokens for swap…

Try to understand this part! I understand that I have to enable swapforliquify again.

1 Like

It seems like @skynance really do a lot, really thanks!

Emmmm, I am not sure, but I think if you set swapAndLiquifyEnabled as false, maybe your token will lose the original intention, but it all depend on you.

Maybe you can add some more tokens( DAPCAT) to this contract, and then when you swap on the pancake, it will consume some BNB, but I do not think this can fundamentally solve your problem, actually, when you add liquidity by swapping on the pancake, in most cases, either token is left, or BNB is left.

Shortly, the current situation just fits with your contract design, and you do not have a function to withdraw BNB directly.

Kind reminder, you should have a test on the testnet before launching on the mainnet, this will decrease bugs.

3 Likes

Hey Skynance. Hope you are well!

I needed a bit of help. I'm launching a token and I've modified a pre existing contract.

Old contract code link: https://bscscan.com/address/0xbddfe03f24c09505fb2db5f9df1589dab17ddaae#code

The contract collects a percentage of tax (6% Liquidity) and then swaps the tokens to bnb and sends them to the marketing wallet and airdrop wallet. Earlier the marketing divisor was 3 and airdrop divisor was 3. And it would Swap the tokens to bnb and then send the bnb in equal parts to the two wallets mentioned above

I then changed the liquidity fee to 8%. And the marketing divisor to 5 and airdrop divisor to 3. While testing the contract on testnet. It doesn't seem to be swapping the tokens collected in the contract to bnb.

New modified contract code (testnet) link: https://testnet.bscscan.com/address/0xcc788bcdb899ef2b11f92ec7315a41e9024c0242#code

The minimum token to swap is set to 100 million and the contract has collected 1.1 billion

Any idea why it's not swapping to bnb?

Where do you change swapAndLiquifyEnabled function to false??

Hi, welcome! :wave:

In dappercats's contract that showed above, he can call this function to set:

sorry to jump in. But i need some help bro.
I have a just created a token on BSC and when I try to add liquidity using pancakeswap i get this error.
""Add liquidity failed: The input token cannot be transferred. There may be an issue with the input token. (TransferHelper: TRANSFER_FROM_FAILED)

for info:
Contract address: 0x6E4Cf2341698F6a8Be1192dF2A6793c0d7E4f7FE