Skip to content

Commit 6785803

Browse files
authored
Merge branch 'master' into sol-7
2 parents e00e180 + 1a3245b commit 6785803

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

contracts/UFragments.sol

+3-8
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ contract UFragments is ERC20Detailed, Ownable {
5858
}
5959

6060
uint256 private constant DECIMALS = 9;
61-
uint256 private constant MAX_UINT256 = ~uint256(0);
61+
uint256 private constant MAX_UINT256 = type(uint256).max;
6262
uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 50 * 10**6 * 10**DECIMALS;
6363

6464
// TOTAL_GONS is a multiple of INITIAL_FRAGMENTS_SUPPLY so that _gonsPerFragment is an integer.
6565
// Use the highest value that fits in a uint256 for max granularity.
6666
uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY);
6767

6868
// MAX_SUPPLY = maximum integer < (sqrt(4*TOTAL_GONS + 1) - 1) / 2
69-
uint256 private constant MAX_SUPPLY = ~uint128(0); // (2^128) - 1
69+
uint256 private constant MAX_SUPPLY = type(uint128).max; // (2^128) - 1
7070

7171
uint256 private _totalSupply;
7272
uint256 private _gonsPerFragment;
@@ -358,12 +358,7 @@ contract UFragments is ERC20Detailed, Ownable {
358358
*/
359359
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
360360
uint256 oldValue = _allowedFragments[msg.sender][spender];
361-
uint256 newValue;
362-
if (subtractedValue >= oldValue) {
363-
newValue = 0;
364-
} else {
365-
newValue = oldValue.sub(subtractedValue);
366-
}
361+
uint256 newValue = (subtractedValue >= oldValue) ? 0 : oldValue.sub(subtractedValue);
367362

368363
_allowedFragments[msg.sender][spender] = newValue;
369364
emit Approval(msg.sender, spender, newValue);

contracts/UFragmentsPolicy.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ contract UFragmentsPolicy is Ownable {
8383
// Both are 18 decimals fixed point numbers.
8484
uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS;
8585
// MAX_SUPPLY = MAX_INT256 / MAX_RATE
86-
uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;
86+
uint256 public constant MAX_SUPPLY = uint256(type(int256).max) / MAX_RATE;
8787

8888
// This module orchestrates the rebase execution and downstream notification.
8989
address public orchestrator;

0 commit comments

Comments
 (0)