I'm implementing my own ERC20 token and trying to figure out best practices by looking at existing implementations. I found that DAI has addition and subtraction functions that appear to prevent integer overflow in the transfer and transferFrom methods.
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x);
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x);
}
Whereas the Consensys reference implementation just subtracts and adds balances without performing any such check.
balances[_to] += _value;
balances[_from] -= _value;
My intuition is that my token doesn't need these methods, as it has a fixed supply far less than MAX_UINT256. Am I missing an attack vector? Is there a more authoritative source to copy?