Skip to content

Instantly share code, notes, and snippets.

@Hebilicious
Last active April 21, 2021 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hebilicious/f578932146f68ceff1ec650a00b90733 to your computer and use it in GitHub Desktop.
Save Hebilicious/f578932146f68ceff1ec650a00b90733 to your computer and use it in GitHub Desktop.
=
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
owner(),
block.timestamp
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment