diff --git a/contracts/libraries/Math.sol b/contracts/libraries/Math.sol index d67525a..197d836 100644 --- a/contracts/libraries/Math.sol +++ b/contracts/libraries/Math.sol @@ -7,15 +7,14 @@ library Math { } // based on https://github.com/ethereum/dapp-bin/blob/11f05fc9e3f31a00d57982bc2f65ef2654f1b569/library/math.sol#L28 via https://github.com/ethereum/dapp-bin/pull/50 - function sqrt(uint256 x) internal pure returns (uint256) { + function sqrt(uint256 x) internal pure returns (uint256 y) { if (x == 0) return 0; else if (x <= 3) return 1; uint256 z = (x + 1) / 2; - uint256 y = x; + y = x; while (z < y) { y = z; z = (x / z + z) / 2; } - return y; } } diff --git a/test/UniswapV2.ts b/test/UniswapV2.ts index 729c333..c13da42 100644 --- a/test/UniswapV2.ts +++ b/test/UniswapV2.ts @@ -39,10 +39,10 @@ describe('UniswapV2', () => { }) it('mintLiquidity', async () => { - await token0.transfer(exchange.address, decimalize(1)) + await token0.transfer(exchange.address, decimalize(4)) await token1.transfer(exchange.address, decimalize(1)) await expect(exchange.connect(wallet).mintLiquidity(wallet.address)) .to.emit(exchange, 'LiquidityMinted') - .withArgs(wallet.address, wallet.address, decimalize(1), decimalize(1), decimalize(1)) + .withArgs(wallet.address, wallet.address, decimalize(2), decimalize(4), decimalize(1)) }) })