Skip to content

Commit 97c89a1

Browse files
authored
using solditiy max function to get the max value (#196)
1 parent 404bd9e commit 97c89a1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

contracts/UFragments.sol

Lines changed: 2 additions & 2 deletions
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;

contracts/UFragmentsPolicy.sol

Lines changed: 1 addition & 1 deletion
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)