如何批准在Sushiswap上的Bentobox转移?

发布于 2025-02-13 21:19:38 字数 1339 浏览 0 评论 0原文

我具有与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);
}

如果我运行此功能,我总是会出现错误:

{“代码”:3,“消息”:“ rececution drected:bentobox:bentobox:转移未批准”,“ data”: “ 0x08C379A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Y000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000来; 000000000000000000000000000000000000000000000000000000001F42656E746F426F783A205472616E736666666572206E6E6F742061707070726F766656400 }

我将Bentobox上的Masternarts设置为批准,也试图手动批准,但没有任何效果。谁能帮我吗?非常感谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弥枳 2025-02-20 21:19:38

我目前遇到了这个问题并以这种方式解决了:

  1. 将Bentobox上的总合同设置为批准
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代币从用户到您的合同(如上所述的可选元素)

  2. 将令牌从用户转换为您的
        IERC20Upgradeable(pool).safeIncreaseAllowance(
            bentBox,
           amountIn
        );
  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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文