我想通过 web3 使用 pancakeswap testnet contarct 将一些 testnet bep20 令牌交换到 busd(bep20)。我查看了合同,但我无法理解“amountOutMin”和“路径”的含义。我怎样才能用这个合同交换它们?请告诉我例子!
Pancakeswap 测试网合约
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = PancakeLibrary.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'PancakeRouter: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PancakeLibrary.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
谢谢!