feat: lower total shares and supply cap. Also use 18 decimals
@@ -64,16 +64,16 @@ contract UFragments is ERC20Detailed, Ownable {
_;
}
- uint256 private constant DECIMALS = 9;
- uint256 private constant MAX_UINT256 = ~uint256(0);
+ uint256 private constant DECIMALS = 18;
+ uint256 private constant MAX_UINT128 = ~uint128(0);
uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 4000 * 10**DECIMALS;
// TOTAL_SHARES is a multiple of INITIAL_FRAGMENTS_SUPPLY so that _sharesPerFragment is an integer.
- // Use the highest value that fits in a uint256 for max granularity.
- uint256 private constant TOTAL_SHARES = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY);
+ // Use the highest value that fits in a uint128 for sufficient granularity.
+ uint256 private constant TOTAL_SHARES = MAX_UINT128 - (MAX_UINT128 % INITIAL_FRAGMENTS_SUPPLY);
// MAX_SUPPLY = maximum integer < (sqrt(4*TOTAL_SHARES + 1) - 1) / 2
- uint256 private constant MAX_SUPPLY = ~uint128(0); // (2^128) - 1
+ uint256 private constant MAX_SUPPLY = (1 << 64) - 1; // (2^64) - 1
uint256 private _totalSupply;
uint256 public _sharesPerFragment;
@@ -120,9 +120,11 @@ contract UFragments is ERC20Detailed, Ownable {
// This means our applied supplyDelta can deviate from the requested supplyDelta,
// but this deviation is guaranteed to be < (_totalSupply^2)/(TOTAL_SHARES - _totalSupply).
//
- // In the case of _totalSupply <= MAX_UINT128 (our current supply cap), this
+ // In the case of _totalSupply <= MAX_UINT64 (our current supply cap), this
// deviation is guaranteed to be < 1, so we can omit this step. If the supply cap is
// ever increased, it must be re-included.
+ // NB: Digg will likely never reach the total supply cap as the total supply of BTC is
+ // currently 21 million and MAX_UINT64 is many orders of magnitude greater.
// _totalSupply = TOTAL_SHARES.div(_sharesPerFragment)
emit LogRebase(epoch, _totalSupply);
