6

地址转换错误?数组传参数问题 在研究自动swap相关功能,遇到如下问题: 1、接口的函...

 2 years ago
source link: https://learnblockchain.cn/question/2905
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

地址转换错误?数组传参数问题 在研究自动swap相关功能,遇到如下问题: 1、接口的函数定义:

15 地址转换错误?数组传参数问题 在研究自动swap相关功能,遇到如下问题: 1、接口的函数定义:

image.png

interface IBakerySwapRouter {
	function swapTokensForExactTokens(
	uint256 amountOut,
	uint256 amountInMax,
	address[] calldata path,
	address to,
	uint256 deadline
	) external returns (uint256[] memory amounts);
}
function swapExactTokensForTokens() public onlyOwner returns (uint[] memory) {
        require(getPair() != address(0), "Cannot swapExactTokensForTokens, because the tokenPairAddress is zero");
        (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = getReserves();
        require(reserve0 > 0 && reserve1 > 0, "Cannot swapExactTokensForTokens, because the reserve0 or reserve1 is zero");

        uint amountIn = _totalWBNBBalance;
        uint amountOutMin = _totalWBNBBalance * bnbPrice / tokenPriceUpperLimit / (10 ** 14);
        address[] memory path = new address[](2);
        path[0] = address(wBnbTokenAddress);
        path[1] = address(buyTokenAddress);
        address to = msg.sender;
        uint deadline = now;
        uint[] memory swapResult = pancakeRouterContract.safeSwapExactTokensForTokens(amountIn, amountOutMin, path, to, deadline);
        return swapResult;
    }

最佳答案 15小时前

你可以把接口修改为

interface IBakerySwapRouter {
function swapTokensForExactTokens(
uint256 amountOut,
uint256 amountInMax,
address[] memory path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
}
Tiny熊 - 布道者
擅长:智能合约,以太坊 | 采纳率 41% | 回答于 15小时前

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK