Skip to content

Commit

Permalink
THRESHOLD -> MINIMUM_TOTAL_SUPPLY
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahZinsmeister committed Feb 3, 2020
1 parent 0e5d00f commit a1e31c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
26 changes: 11 additions & 15 deletions contracts/UniswapV2ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

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

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IUniswapV2ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/IUniswapV2Exchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a1e31c2

Please sign in to comment.