So far I have tried this:
function swapEthForToken(
address router,
uint256 minAmount,
address _tokenIn,
address _tokenOut
) public payable {
assembly {
let path := mload(0x40)
let deadline := add(timestamp(), 300)
mstore(0x7c, SWAP_ETH_FOR_TOKEN)
mstore(0x80, minAmount)
// mstore(0xA0, path)
mstore(path, 2)
mstore(add(path, 0x20), _tokenIn)
mstore(add(path, 0x40), _tokenOut)
mstore(0xE0, address())
mstore(0x100, deadline)
let s1 := call(gas(), router, callvalue(), 0x7c, 0x100, 0x00, 0x40)
if iszero(s1) {
revert(0x00, 0x40)
}
}
}
function I am trying to call is this:
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);