Need Help with a function in my token contract

Hello Folks. 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:

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:

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?

if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) This condition implies only selling tokens can trigger token swap. Although 1.1billion has been collected, no single transaction has been made to the pair contract. This can be dangerous, because the one that does go to the trading pair contract may drain liquidity and the transaction may always fail until new and enough liquidity is injected into the pool.

1 Like

So the contract only sells when tokens are sold by holders?

The contract I copied was from a token i had invested in where the contract would sell every 200 million collected and covert it to BNB and then send the bnb to the marketing and airdrop wallet

Didn't go through the entire contract, but based on this condition, yes, that's the case.

In the other example, the trading frequency might be high enough such that in every few transactions, one is for selling, and the swap gets triggered. You won't see it happening if the frequency is too low.

1 Like

Alright. Thank you so much!

So the divisor for airdrop and marketing need not be the same right?

I can have marketing divisor at 5 and airdrop divisor at 3 and the BNB from the sale will get sent in the above ratio to both the wallets once it swaps?

They don't have to the same. Whatever the calculated amounts are would be sent.

1 Like