1. I'm a beginner when it comes to solidity. I don't see to defined, do I have to define it? And how to define it without knowing the contract's address? Do I just use something like: to = address(this) or to = address(myContract) ?
 function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
        require(path[path.length - 1] == WETH, 'PancakeRouter: INVALID_PATH');
            path[0], msg.sender, PancakeLibrary.pairFor(factory, path[0], path[1]), amountIn
        _swapSupportingFeeOnTransferTokens(path, address(this));
        uint amountOut = IERC20(WETH).balanceOf(address(this));
        require(amountOut >= amountOutMin, 'PancakeRouter: INSUFFICIENT_OUTPUT_AMOUNT');
        TransferHelper.safeTransferETH(address(this), amountOut);

     function withdraw(uint amount) onlyOwner returns(bool) {
        require(amount <= address(this).balance);
        return true;

This is my code so far - added the withdraw function, modifier so that only I can trade, and now the task of modifying the swap function.

  1. When swapping against the token's smart contract, and against the liquidity pool of let's say CakeLPs - which functions exactly are used in the Router? BSCscan shows only the SwapExactTokens(...) function, but there's usually 2 transfers there amongst 3+ addresses. Does that mean the swap or other functions also get called? Do I have to modify them as well to accomplish my goal?

My guess is - obviously: _swapSupportingFeeOnTransferTokens, and maybe swap function? Please assist me on this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.