
13

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

地址转换错误?数组传参数问题 在研究自动swap相关功能,遇到如下问题: 1、接口的函数定义:
15 地址转换错误?数组传参数问题 在研究自动swap相关功能,遇到如下问题: 1、接口的函数定义:
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;
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK