squash errors

This commit is contained in:
Noah Zinsmeister
2019-12-09 02:33:18 -05:00
parent 7fa81c9d6f
commit fd95caea17
4 changed files with 14 additions and 14 deletions

View File

@ -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);
}

View File

@ -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));
}
}

View File

@ -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);
}

View File

@ -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)