Skip to content

Instantly share code, notes, and snippets.

@tienshaoku
Last active May 18, 2020 03:52
Show Gist options
  • Save tienshaoku/deb65cd7f2d3c9c2a440216622c0d011 to your computer and use it in GitHub Desktop.
Save tienshaoku/deb65cd7f2d3c9c2a440216622c0d011 to your computer and use it in GitHub Desktop.
function addLiquidity() public payable returns(uint[3] memory) {
require(msg.value == ETHAmount);
require(Dai.transferFrom(msg.sender, address(this), DaiAmount));
// Do remember to approve
Dai.approve(address(uniswapV2Router01), DaiAmount);
(addLiquidityResult[0], addLiquidityResult[1], addLiquidityResult[2]) = uniswapV2Router01.addLiquidityETH{value: ETHAmount}(
DaiAddress, DaiAmount, 0, 0, msg.sender, now + 120);
return addLiquidityResult;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment