From a1e31c29a6b6810b35e025fc8abbadc6d311d2ae Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Mon, 3 Feb 2020 11:08:22 -0500 Subject: [PATCH] THRESHOLD -> MINIMUM_TOTAL_SUPPLY --- contracts/UniswapV2ERC20.sol | 26 +++++++++------------ contracts/interfaces/IUniswapV2ERC20.sol | 2 +- contracts/interfaces/IUniswapV2Exchange.sol | 1 + 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/contracts/UniswapV2ERC20.sol b/contracts/UniswapV2ERC20.sol index ca6eb5e..056ff71 100644 --- a/contracts/UniswapV2ERC20.sol +++ b/contracts/UniswapV2ERC20.sol @@ -13,7 +13,7 @@ contract UniswapV2ERC20 is IUniswapV2ERC20 { mapping(address => uint) public balanceOf; mapping(address => mapping(address => uint)) public allowance; - uint public constant THRESHOLD = 10**6; + uint public constant MINIMUM_TOTAL_SUPPLY = 10**6; bytes32 public DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; @@ -39,18 +39,18 @@ contract UniswapV2ERC20 is IUniswapV2ERC20 { } function _mint(address to, uint value) internal { - totalSupply = totalSupply.add(value); - uint balance = balanceOf[to].add(value); - require(balance >= THRESHOLD, 'UniswapV2: THRESHOLD'); - balanceOf[to] = balance; + uint _totalSupply = totalSupply.add(value); + require(_totalSupply >= MINIMUM_TOTAL_SUPPLY, 'UniswapV2: MINIMUM_TOTAL_SUPPLY'); + totalSupply = _totalSupply; + balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint value) internal { - uint balance = balanceOf[from].sub(value); - require(balance == 0 || balance >= THRESHOLD, 'UniswapV2: THRESHOLD'); - balanceOf[from] = balance; - totalSupply = totalSupply.sub(value); + uint _totalSupply = totalSupply.sub(value); + require(_totalSupply == 0 || _totalSupply >= MINIMUM_TOTAL_SUPPLY, 'UniswapV2: MINIMUM_TOTAL_SUPPLY'); + balanceOf[from] = balanceOf[from].sub(value); + totalSupply = _totalSupply; emit Transfer(from, address(0), value); } @@ -60,12 +60,8 @@ contract UniswapV2ERC20 is IUniswapV2ERC20 { } function _transfer(address from, address to, uint value) private { - uint balanceFrom = balanceOf[from].sub(value); - uint balanceTo = balanceOf[to].add(value); - require(balanceFrom == 0 || balanceFrom >= THRESHOLD, 'UniswapV2: THRESHOLD'); - require(balanceTo >= THRESHOLD, 'UniswapV2: THRESHOLD'); - balanceOf[from] = balanceFrom; - balanceOf[to] = balanceTo; + balanceOf[from] = balanceOf[from].sub(value); + balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } diff --git a/contracts/interfaces/IUniswapV2ERC20.sol b/contracts/interfaces/IUniswapV2ERC20.sol index 7d4b8ee..1b4e2f5 100644 --- a/contracts/interfaces/IUniswapV2ERC20.sol +++ b/contracts/interfaces/IUniswapV2ERC20.sol @@ -15,7 +15,7 @@ interface IUniswapV2ERC20 { function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); - function THRESHOLD() external pure returns (uint); + function MINIMUM_TOTAL_SUPPLY() external pure returns (uint); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); diff --git a/contracts/interfaces/IUniswapV2Exchange.sol b/contracts/interfaces/IUniswapV2Exchange.sol index 79dbfa5..95f6efe 100644 --- a/contracts/interfaces/IUniswapV2Exchange.sol +++ b/contracts/interfaces/IUniswapV2Exchange.sol @@ -15,6 +15,7 @@ interface IUniswapV2Exchange { function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); + function MINIMUM_TOTAL_SUPPLY() external pure returns (uint); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint);