function _buy(bytes calldata _data) internal {
(
address router,
uint256 amountIn,
uint256 amountOutMin,
address[] memory path
) = abi.decode(_data, (address, uint256, uint256, address[]));
IERC20 fromToken = IERC20(path[0]);
_approve(fromToken, router, amountIn);
IPancakeRouter02(router)
.swapExactTokensForTokensSupportingFeeOnTransferTokens(
amountIn,
amountOutMin,
path,
address(this),
block.timestamp
);
}
This is my code in solidity sometime a frontrunner bot come and my transaction got failed. i want if somebody is front running my transaction so my transaction doesnt perform if it perform and goes failed so the fee should be really low.
I am expecting low transaction on failed transaction via nodejs or inside the solidity.