0

I am trying to perform low-level calls (function "Safe_swapV3") within my smart contract. The goal is to perform a transaction even if the sub-function "SwapV3" is reverted. I am testing on Goerli and getting results like this: transaction goes to the blockchain but NO transfer of funds occurs - looking in depth into the transaction, the first internal call results failed - so I believe the problem is the invocation of the Call function. When debugging on Remix I get an empty string as call data result.

enter image description here

Can you please help me debugging the code? Thanks!!

    function SwapV3 (uint Quantity_in, uint Min_quantity, address Address_quote, address Address_token_out, address Recipient) public payable{
        require ((msg.sender==owner) || (msg.sender==address(this)), "Only owner can swap tokens");
        uint256 deadline = block.timestamp;
        address tokenIn = Address_quote;
        address tokenOut = Address_token_out;
        uint24 fee = 3000;
        address recipient = Recipient;
        uint256 amountIn = Quantity_in;
        uint256 amountOutMinimum = Min_quantity;
        uint160 sqrtPriceLimitX96 = 0;
        V3.ExactInputSingleParams memory Parameters = V3.ExactInputSingleParams(tokenIn,tokenOut,fee,recipient,deadline,amountIn,amountOutMinimum,sqrtPriceLimitX96);
        V3(Swapper).exactInputSingle(Parameters); 
    } 

    function Safe_swapV3 (uint Quantity_in, uint Min_quantity, address Address_quote, address Address_token_out, address Recipient) public payable {
        require (msg.sender==owner, "Only owner can swap tokens");
        (bool success, bytes memory result)=address(this).call(abi.encodeWithSignature("SwapV3 (uint,uint,address,address,address)",Quantity_in, Min_quantity, Address_quote, Address_token_out, Recipient));
    }

4

1 Answer 1

0

The function call signature is wrong

"SwapV3(uint256,uint256,address,address,address)"

No white spaces, uint -> uint256. Also check the function name case.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.