Hi everybody !
I'm working on a smart contract that aim to sell tokens for a fixed price and convert the benefits into public liquidity (which will be automatically locked by the contract in a second time).
To do this, i've created a standard addliquidity function
function buyPublicLiquidity (uint tokenAmountToSell) private {
IPancakeRouter02 pancakeRouter = IPancakeRouter02 (routerAddress);
pancakeRouter.addLiquidityETH(
tokenAddress,
tokenAmountToSell,
0,
0,
address(this),
block.timestamp + 360
);
called in the buytoken function :
function charityBuyForLiquidity(uint256 numberOfTokens) public payable {
require(msg.value == safeMultiply(numberOfTokens, price));
uint256 scaledAmount = safeMultiply(numberOfTokens,
uint256(10) ** tokenContract.decimals());
require(tokenContract.balanceOf(address(this)) >= scaledAmount);
emit Sold(msg.sender, numberOfTokens);
tokensSold += numberOfTokens;
require(tokenContract.transfer(msg.sender, scaledAmount));
buyPublicLiquidity(tokenForLiquidity);
}
The charityBuyForLiquidity function used to worked before i tried to add the buyPublicLiquidity function inside. With this new version i got an error when trying to buy token :
I only started to code a few weeks ago so maybe i missed something.
The contract is actually deployed on the bsc testnet at this address : 0x2AA6C7aB3FD26aC98f8fe043760BE970e1CF10Ca
Thanks in advance for your help 
