From fd95caea172e577bbb9a3ffcf02bffb5e1d4abda Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Mon, 9 Dec 2019 02:33:18 -0500 Subject: [PATCH] squash errors --- contracts/UniswapV2.sol | 10 +++++----- contracts/UniswapV2Factory.sol | 8 ++++---- contracts/interfaces/IUniswapV2Factory.sol | 4 ++-- test/UniswapV2Factory.spec.ts | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/contracts/UniswapV2.sol b/contracts/UniswapV2.sol index 992c7fa..5aee120 100644 --- a/contracts/UniswapV2.sol +++ b/contracts/UniswapV2.sol @@ -80,10 +80,10 @@ contract UniswapV2 is IUniswapV2, ERC20("Uniswap V2", "UNI-V2", 18, 0), SafeTran } function mintFees() private { - invariant = Math.sqrt(reserve0.mul(reserve1)); - if (invariant > lastInvariant) { + uint invariant = Math.sqrt(uint(reserve0).mul(reserve1)); + if (invariant > invariantLast) { uint numerator = invariant.mul(200); - uint denominator = invariant - (invariant - lastInvariant).mul(200); + uint denominator = invariant - (invariant - invariantLast).mul(200); mint(factory, numerator / denominator - 1); } } @@ -118,7 +118,7 @@ contract UniswapV2 is IUniswapV2, ERC20("Uniswap V2", "UNI-V2", 18, 0), SafeTran mint(recipient, liquidity); update(balance0, balance1); - lastInvariant = Math.sqrt(reserve0.mul(reserve1)); + invariantLast = Math.sqrt(uint(reserve0).mul(reserve1)); emit LiquidityMinted(msg.sender, recipient, amount0, amount1, reserve0, reserve1, liquidity); } @@ -133,7 +133,7 @@ contract UniswapV2 is IUniswapV2, ERC20("Uniswap V2", "UNI-V2", 18, 0), SafeTran safeTransfer(token1, recipient, amount1); update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this))); - lastInvariant = Math.sqrt(reserve0.mul(reserve1)) + invariantLast = Math.sqrt(uint(reserve0).mul(reserve1)); emit LiquidityBurned(msg.sender, recipient, amount0, amount1, reserve0, reserve1, liquidity); } diff --git a/contracts/UniswapV2Factory.sol b/contracts/UniswapV2Factory.sol index 4d0cd1b..2588f89 100644 --- a/contracts/UniswapV2Factory.sol +++ b/contracts/UniswapV2Factory.sol @@ -8,7 +8,7 @@ contract UniswapV2Factory is IUniswapV2Factory { mapping (address => mapping(address => address)) private _getExchange; mapping (address => address[2]) private _getTokens; - address[] public getExchanges; + address[] public exchanges; event ExchangeCreated(address indexed token0, address indexed token1, address exchange, uint exchangeNumber); @@ -30,8 +30,8 @@ contract UniswapV2Factory is IUniswapV2Factory { return (_getTokens[exchange][0], _getTokens[exchange][1]); } - function getExchangesCount() external view returns (uint) { - return getExchanges.length; + function exchangesCount() external view returns (uint) { + return exchanges.length; } function createExchange(address tokenA, address tokenB) external returns (address exchange) { @@ -49,6 +49,6 @@ contract UniswapV2Factory is IUniswapV2Factory { _getExchange[token0][token1] = exchange; _getTokens[exchange] = [token0, token1]; - emit ExchangeCreated(token0, token1, exchange, getExchanges.push(exchange)); + emit ExchangeCreated(token0, token1, exchange, exchanges.push(exchange)); } } diff --git a/contracts/interfaces/IUniswapV2Factory.sol b/contracts/interfaces/IUniswapV2Factory.sol index db1b8cc..9d06c0d 100644 --- a/contracts/interfaces/IUniswapV2Factory.sol +++ b/contracts/interfaces/IUniswapV2Factory.sol @@ -8,8 +8,8 @@ interface IUniswapV2Factory { function sortTokens(address tokenA, address tokenB) external pure returns (address, address); function getExchange(address tokenA, address tokenB) external view returns (address); function getTokens(address exchange) external view returns (address, address); - function getExchanges(uint) external view returns (address); - function getExchangesCount() external view returns (uint); + function exchanges(uint) external view returns (address); + function exchangesCount() external view returns (uint); function createExchange(address tokenA, address tokenB) external returns (address exchange); } diff --git a/test/UniswapV2Factory.spec.ts b/test/UniswapV2Factory.spec.ts index 69f2b23..24c9716 100644 --- a/test/UniswapV2Factory.spec.ts +++ b/test/UniswapV2Factory.spec.ts @@ -32,7 +32,7 @@ describe('UniswapV2Factory', () => { it('exchangeBytecode', async () => { expect(await factory.exchangeBytecode()).to.eq(bytecode) - expect(await factory.getExchangesCount()).to.eq(0) + expect(await factory.exchangesCount()).to.eq(0) }) async function createExchange(tokens: string[]) { @@ -49,8 +49,8 @@ describe('UniswapV2Factory', () => { expect(await factory.getExchange(...tokens)).to.eq(create2Address) expect(await factory.getExchange(...tokens.slice().reverse())).to.eq(create2Address) expect(await factory.getTokens(create2Address)).to.deep.eq([TEST_ADDRESSES.token0, TEST_ADDRESSES.token1]) - expect(await factory.getExchanges(0)).to.eq(create2Address) - expect(await factory.getExchangesCount()).to.eq(1) + expect(await factory.exchanges(0)).to.eq(create2Address) + expect(await factory.exchangesCount()).to.eq(1) const exchange = new Contract(create2Address, JSON.stringify(UniswapV2.abi), provider) expect(await exchange.factory()).to.eq(factory.address)