我写了一份智能合约,目的是通过 1inch 交易所进行交换。我已经使用 ganache-cli 将合约部署到本地分叉的主网上,并成功地为我的合约预付了资金。但是,在执行交换函数时,事务恢复并显示以下消息:错误:返回错误:VM Exception while processing transaction: revert SafeERC20: low-level call failed。这是我遇到问题的代码:
function swapOnOneInch(
address fromToken,
address toToken,
uint256 originAmount,
uint256 minTargetAmount,
uint256[] memory exchangeDistribution
) internal {
uint minOut = 99 * minTargetAmount / 100;
bytes memory _data = abi.encodeWithSignature(
"swap(address,address,uint256,uint256,uint256[],uint256)",
fromToken,
toToken,
originAmount,
// Set to 99% of the minTargetAmount, to give us a
// 1% price/slippage buffer
minOut,
exchangeDistribution,
0
);
invoke(0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e, _data);
}
我一直在互联网上四处寻找,找不到有用的解决方案。有人知道错误可能在哪里吗?任何帮助深表感谢 :)