// Returns the amount of Token2 that the user will get when swapping a given amount of Token1 for Token2 function getSwapToken1Estimate(uint256 _amountToken1) public view activePool returns(uint256 amountToken2) { uint256 token1After = totalToken1.add(_amountToken1); uint256 token2After = K.div(token1After); amountToken2 = totalToken2.sub(token2After); // To ensure that Token2's pool is not completely depleted leading to inf:0 ratio if(amountToken2 == totalToken2) amountToken2--; }
0.4.18