From 0afb8d1323d23d3f1f97ced15a6396464e5372c6 Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Thu, 31 Oct 2019 11:16:17 -0400 Subject: [PATCH] tweaks --- contracts/UniswapV2.sol | 5 +++-- contracts/test/Oracle.sol | 2 +- contracts/token/ERC20.sol | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contracts/UniswapV2.sol b/contracts/UniswapV2.sol index 4a457e3..4657695 100644 --- a/contracts/UniswapV2.sol +++ b/contracts/UniswapV2.sol @@ -11,6 +11,7 @@ import "./libraries/SafeMath256.sol"; import "./token/ERC20.sol"; contract UniswapV2 is IUniswapV2, ERC20("Uniswap V2", "UNI-V2", 18, 0) { + using Math for uint256; using SafeMath128 for uint128; using SafeMath256 for uint256; @@ -35,7 +36,7 @@ contract UniswapV2 is IUniswapV2, ERC20("Uniswap V2", "UNI-V2", 18, 0) { } bool private locked; // reentrancy lock - + address public factory; address public token0; address public token1; @@ -66,7 +67,7 @@ contract UniswapV2 is IUniswapV2, ERC20("Uniswap V2", "UNI-V2", 18, 0) { function safeTransfer(address token, address to, uint128 value) private returns (bool result) { IIncompatibleERC20(token).transfer(to, uint256(value)); assembly { - switch returndatasize() + switch returndatasize() case 0 { result := not(0) // for no-bool responses, treat as successful } diff --git a/contracts/test/Oracle.sol b/contracts/test/Oracle.sol index 295fc6f..d0326bd 100644 --- a/contracts/test/Oracle.sol +++ b/contracts/test/Oracle.sol @@ -56,7 +56,7 @@ contract Oracle { token0: deltas.token0 / blocksElapsed, token1: deltas.token1 / blocksElapsed }); - + uint128 timeElapsed = blockTimestamp - lastUpdate.blockTimestamp; _updateCurrentPrice(averages, timeElapsed); } diff --git a/contracts/token/ERC20.sol b/contracts/token/ERC20.sol index 66cf90f..6087c0a 100644 --- a/contracts/token/ERC20.sol +++ b/contracts/token/ERC20.sol @@ -35,7 +35,7 @@ contract ERC20 is IERC20 { require(chainId == 0, "ERC20: ALREADY_INITIALIZED"); chainId = _chainId; } - + function mint(address to, uint256 value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); @@ -110,7 +110,8 @@ contract ERC20 is IERC20 { owner, spender, value, nonce, expiration, chainId )) )); - require(owner == ecrecover(digest, v, r, s), "ERC20: INVALID_SIGNATURE"); // TODO add ECDSA checks? https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/cryptography/ECDSA.sol + // TODO add ECDSA checks? https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/cryptography/ECDSA.sol + require(owner == ecrecover(digest, v, r, s), "ERC20: INVALID_SIGNATURE"); _approve(owner, spender, value); }