Smart contract for selling token and buying liquidity - problem on test

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);

        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));

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 :slight_smile:

As I am a new user I couldn't put more than 2 links in the first post so you can find the whole code in Github projet here :

If you are interested in other aspects of the project or if you notice something worth mentioning do not hesitate to contact me !