0

I have this solidity function for interacting with Sushiswap:

function swapSingleParamswhitPool(
    uint256 amountIn,
    uint256 amountOutMinimum, 
    address pool, 
    address tokenIn, 
    bytes memory data) public payable {

    ITridentRouter.ExactInputSingleParams memory exactInputSingleParams = ITridentRouter.ExactInputSingleParams(amountIn, amountOutMinimum, pool, tokenIn, data);
    tridentRouter.exactInputSingle{ value: msg.value }(exactInputSingleParams);
}

If I run this function, I always got error:

{ "code": 3, "message": "execution reverted: BentoBox: Transfer not approved", "data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001f42656e746f426f783a205472616e73666572206e6f7420617070726f76656400" }

I set masterContract on BentoBox to approved, tried to approve manually too, but nothing works. Can anyone help me with this? Thank You very much.

1 Answers1

1

i currently faced this issue and solved it in this way:

  1. Set the master contract on BentoBox to approved
IBentoBoxMinimal(bentBox).setMasterContractApproval(
               address(this), //this needs to be the address of your contract or the user if you are not transferring the funds to your contract
               _sushiswapTridentRouterAddress,
               true,
               0,
               0,
               0
           );
  1. Tranfer the tokens from the user to your contract (optional as mentioned above)

  2. Approve the allowance for the tokens to move from the contract/user wallet to the bento box

        IERC20Upgradeable(pool).safeIncreaseAllowance(
            bentBox,
           amountIn
        );
  1. After you can call any method you need from the TridentContract