add liquidity complete

This commit is contained in:
Samyak Jain 2019-04-06 16:14:15 +05:30
parent b73037d079
commit 1fe5eb1250

View File

@ -153,8 +153,9 @@ contract InstaUniswapPool is Helper {
function addLiquidity(address token, uint maxDepositedTokens) public payable returns (uint256 tokensMinted) {
address exchangeAddr = getExchangeAddress(token);
(uint exchangeEthBal, uint exchangeTokenBal) = getBal(token, exchangeAddr);
uint tokenToDeposit = msg.value * (exchangeTokenBal/exchangeEthBal);
uint tokenToDeposit = msg.value * exchangeTokenBal / exchangeEthBal + 1;
require(tokenToDeposit < maxDepositedTokens, "Token to deposit is greater than Max token to Deposit");
IERC20(token).transferFrom(msg.sender, address(this), tokenToDeposit);
manageApproval(token, tokenToDeposit);
tokensMinted = UniswapPool(exchangeAddr).addLiquidity.value(msg.value)(
uint(0),
@ -163,4 +164,5 @@ contract InstaUniswapPool is Helper {
);
}
}