diff --git a/contracts/modules/SuperMinterE.sol b/contracts/modules/SuperMinterE.sol index c5f19da5..d8184e02 100644 --- a/contracts/modules/SuperMinterE.sol +++ b/contracts/modules/SuperMinterE.sol @@ -35,14 +35,14 @@ contract SuperMinterE is ISuperMinterE, EIP712 { struct MintData { // The platform address. address platform; - // The price per token. - uint96 price; // The start time of the mint. uint32 startTime; // The end time of the mint. uint32 endTime; // The maximum number of tokens an account can mint in this mint. uint32 maxMintablePerAccount; + // The price per token. + uint128 price; // The maximum tokens mintable. uint32 maxMintable; // The total number of tokens minted. @@ -94,7 +94,7 @@ contract SuperMinterE is ISuperMinterE, EIP712 { "address to," "uint32 signedQuantity," "uint32 signedClaimTicket," - "uint96 signedPrice," + "uint128 signedPrice," "uint32 signedDeadline," "address affiliate" ")" @@ -160,12 +160,12 @@ contract SuperMinterE is ISuperMinterE, EIP712 { /** * @dev The maximum per-mint reward. Applies to artists, affiliates, platform. */ - uint96 public constant MAX_PER_MINT_REWARD = 0.1 ether; + uint128 public constant MAX_PER_MINT_REWARD = 0.1 ether; /** * @dev The maximum platform per-transaction flat fee. */ - uint96 public constant MAX_PLATFORM_PER_TX_FLAT_FEE = 0.1 ether; + uint128 public constant MAX_PLATFORM_PER_TX_FLAT_FEE = 0.1 ether; /** * @dev The boolean flag on whether the mint has been created. @@ -220,7 +220,7 @@ contract SuperMinterE is ISuperMinterE, EIP712 { /** * @dev A mapping of `platform` => `price`. */ - mapping(address => uint96) public gaPrice; + mapping(address => uint128) public gaPrice; /** * @dev A mapping of `platform` => `platformSigner`. @@ -371,7 +371,7 @@ contract SuperMinterE is ISuperMinterE, EIP712 { // Platform and affilaite fees are accrued mappings. // Artist earnings are directly forwarded to the nft contract in mint call below. - // Overflow not possible since all fees are uint96s. + // Overflow not possible since all fees are uint128s. unchecked { if (l.finalAffiliateFee != 0) { if (l.erc20 == address(0)) { @@ -448,7 +448,7 @@ contract SuperMinterE is ISuperMinterE, EIP712 { address edition, uint8 tier, uint8 scheduleNum, - uint96 price + uint128 price ) public onlyEditionOwnerOrAdmin(edition) { uint256 mintId = LibOps.packId(edition, tier, scheduleNum); MintData storage d = _getMintData(mintId); @@ -689,7 +689,7 @@ contract SuperMinterE is ISuperMinterE, EIP712 { /** * @inheritdoc ISuperMinterE */ - function setGAPrice(uint96 price) public { + function setGAPrice(uint128 price) public { address sender = LibMulticaller.senderOrSigner(); gaPrice[sender] = price; emit GAPriceSet(sender, price); @@ -784,7 +784,7 @@ contract SuperMinterE is ISuperMinterE, EIP712 { uint8 tier, uint8 scheduleNum, uint32 quantity, - uint96 signedPrice, + uint128 signedPrice, bool hasValidAffiliate ) public view returns (TotalPriceAndFees memory) { uint256 mintId = LibOps.packId(edition, tier, scheduleNum); @@ -1214,11 +1214,11 @@ contract SuperMinterE is ISuperMinterE, EIP712 { uint8 tier, MintData storage d, uint32 quantity, - uint96 signedPrice, + uint128 signedPrice, bool hasValidAffiliate ) internal view returns (TotalPriceAndFees memory f) { - // All flat prices are stored as uint96s in storage. - // The quantity is a uint32. Multiplications between a uint96 and uint32 won't overflow. + // All flat prices are stored as uint128s in storage. + // The quantity is a uint32. Multiplications between a uint128 and uint32 won't overflow. unchecked { PlatformFeeConfig memory c = effectivePlatformFeeConfig(d.platform, tier); diff --git a/contracts/modules/interfaces/ISuperMinterE.sol b/contracts/modules/interfaces/ISuperMinterE.sol index a3105444..6df575c1 100644 --- a/contracts/modules/interfaces/ISuperMinterE.sol +++ b/contracts/modules/interfaces/ISuperMinterE.sol @@ -21,7 +21,7 @@ interface ISuperMinterE is IERC165 { // The base price per token. // For `VERIFY_SIGNATURE`, this will be the minimum limit of the signed price. // Will be 0 if the `tier` is `GA_TIER`. - uint96 price; + uint128 price; // The start time of the mint. uint32 startTime; // The end time of the mint. @@ -68,7 +68,7 @@ interface ISuperMinterE is IERC165 { // The allowlist Merkle proof. bytes32[] allowlistProof; // The signed price. Used if `mode` is `VERIFY_SIGNATURE`. - uint96 signedPrice; + uint128 signedPrice; // The signed quantity. Used if `mode` is `VERIFY_SIGNATURE`. uint32 signedQuantity; // The signed claimed ticket. Used if `mode` is `VERIFY_SIGNATURE`. @@ -167,21 +167,21 @@ interface ISuperMinterE is IERC165 { */ struct PlatformFeeConfig { // The amount of reward to give to the artist per mint. - uint96 artistMintReward; + uint128 artistMintReward; // The amount of reward to give to the affiliate per mint. - uint96 affiliateMintReward; + uint128 affiliateMintReward; // The amount of reward to give to the platform per mint. - uint96 platformMintReward; + uint128 platformMintReward; // If the price is greater than this, the rewards will become the threshold variants. - uint96 thresholdPrice; + uint128 thresholdPrice; // The amount of reward to give to the artist (`unitPrice >= thresholdPrice`). - uint96 thresholdArtistMintReward; + uint128 thresholdArtistMintReward; // The amount of reward to give to the affiliate (`unitPrice >= thresholdPrice`). - uint96 thresholdAffiliateMintReward; + uint128 thresholdAffiliateMintReward; // The amount of reward to give to the platform (`unitPrice >= thresholdPrice`). - uint96 thresholdPlatformMintReward; + uint128 thresholdPlatformMintReward; // The per-transaction flat fee. - uint96 platformTxFlatFee; + uint128 platformTxFlatFee; // The per-token fee BPS. uint16 platformMintFeeBPS; // Whether the fees are active. @@ -204,7 +204,7 @@ interface ISuperMinterE is IERC165 { // For `VERIFY_SIGNATURE` this will be the minimum limit of the signed price. // If the `tier` is `GA_TIER`, and the `mode` is NOT `VERIFY_SIGNATURE`, // this value will be the GA price instead. - uint96 price; + uint128 price; // The start time of the mint. uint32 startTime; // The end time of the mint. @@ -270,7 +270,7 @@ interface ISuperMinterE is IERC165 { * @param scheduleNum The edition-tier schedule number. * @param price The base per-token price. */ - event PriceSet(address indexed edition, uint8 tier, uint8 scheduleNum, uint96 price); + event PriceSet(address indexed edition, uint8 tier, uint8 scheduleNum, uint128 price); /** * @dev Emitted when the max mintable per account for a mint is updated. @@ -410,7 +410,7 @@ interface ISuperMinterE is IERC165 { * @param platform The platform address. * @param price The price per token for the GA tier. */ - event GAPriceSet(address indexed platform, uint96 price); + event GAPriceSet(address indexed platform, uint128 price); /** * @dev Emitted when the signer for a platform is set. @@ -604,7 +604,7 @@ interface ISuperMinterE is IERC165 { address edition, uint8 tier, uint8 scheduleNum, - uint96 price + uint128 price ) external; /** @@ -770,7 +770,7 @@ interface ISuperMinterE is IERC165 { * @dev Allows the platform to set the price for the GA tier. * @param price The price per token for the GA tier. */ - function setGAPrice(uint96 price) external; + function setGAPrice(uint128 price) external; /** * @dev Allows the platform to set their signer. @@ -846,13 +846,13 @@ interface ISuperMinterE is IERC165 { * @dev The maximum per-mint reward. Applies to artists, affiliates, platform. * @return The constant value. */ - function MAX_PER_MINT_REWARD() external pure returns (uint96); + function MAX_PER_MINT_REWARD() external pure returns (uint128); /** * @dev The maximum platform per-transaction flat fee. * @return The constant value. */ - function MAX_PLATFORM_PER_TX_FLAT_FEE() external pure returns (uint96); + function MAX_PLATFORM_PER_TX_FLAT_FEE() external pure returns (uint128); /** * @dev Returns the amount of fees accrued by the platform. @@ -921,7 +921,7 @@ interface ISuperMinterE is IERC165 { uint8 tier, uint8 scheduleNum, uint32 quantity, - uint96 signedPrice, + uint128 signedPrice, bool hasValidAffiliate ) external view returns (TotalPriceAndFees memory); @@ -930,7 +930,7 @@ interface ISuperMinterE is IERC165 { * @param platform The platform address. * @return The configured value. */ - function gaPrice(address platform) external view returns (uint96); + function gaPrice(address platform) external view returns (uint128); /** * @dev Returns the signer for the platform. diff --git a/tests/modules/SuperMinterE.t.sol b/tests/modules/SuperMinterE.t.sol index 9fc67e37..dc68b4d2 100644 --- a/tests/modules/SuperMinterE.t.sol +++ b/tests/modules/SuperMinterE.t.sol @@ -27,8 +27,8 @@ contract SuperMinterETests is TestConfigV2_1 { ); struct SuperMinterEConstants { - uint96 MAX_PLATFORM_PER_TX_FLAT_FEE; - uint96 MAX_PER_MINT_REWARD; + uint128 MAX_PLATFORM_PER_TX_FLAT_FEE; + uint128 MAX_PER_MINT_REWARD; uint16 MAX_PLATFORM_PER_MINT_FEE_BPS; uint16 MAX_AFFILIATE_FEE_BPS; } @@ -60,7 +60,7 @@ contract SuperMinterETests is TestConfigV2_1 { function test_createMints() public { uint256 gaPrice = 123 ether; - sm.setGAPrice(uint96(gaPrice)); + sm.setGAPrice(uint128(gaPrice)); assertEq(sm.mintInfoList(address(edition)).length, 0); for (uint256 j; j < 3; ++j) { @@ -70,7 +70,7 @@ contract SuperMinterETests is TestConfigV2_1 { c.platform = address(this); c.edition = address(edition); c.tier = uint8(i * 2); - c.price = uint96(i * 1 ether); + c.price = uint128(i * 1 ether); c.startTime = uint32(block.timestamp + i); c.endTime = uint32(block.timestamp + 1000 + i); c.maxMintablePerAccount = uint32(10 + i); @@ -138,7 +138,7 @@ contract SuperMinterETests is TestConfigV2_1 { c.edition = address(edition); c.tier = uint8(_random() % 2); c.mode = uint8(_random() % 3); - c.price = uint96(_bound(_random(), 0, type(uint96).max)); + c.price = uint128(_bound(_random(), 0, type(uint128).max)); c.startTime = uint32(block.timestamp + _bound(_random(), 0, 1000)); c.endTime = uint32(c.startTime + _bound(_random(), 0, 1000)); c.maxMintablePerAccount = uint32(_bound(_random(), 1, type(uint32).max)); @@ -528,8 +528,8 @@ contract SuperMinterETests is TestConfigV2_1 { function test_platformFeeConfig(uint256) public { SuperMinterEConstants memory smc = _superMinterConstants(); - uint96 perTxFlat = uint96(_bound(_random(), 0, smc.MAX_PLATFORM_PER_TX_FLAT_FEE * 2)); - uint96 platformReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD * 2)); + uint128 perTxFlat = uint128(_bound(_random(), 0, smc.MAX_PLATFORM_PER_TX_FLAT_FEE * 2)); + uint128 platformReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD * 2)); uint16 perMintBPS = uint16(_bound(_random(), 0, smc.MAX_PLATFORM_PER_MINT_FEE_BPS * 2)); uint8 tier = uint8(_random()); @@ -565,8 +565,8 @@ contract SuperMinterETests is TestConfigV2_1 { } function _setDefaultPlatformFeeConfig( - uint96 perTxFlat, - uint96 platformReward, + uint128 perTxFlat, + uint128 platformReward, uint16 perMintBPS, bool active ) internal { @@ -580,8 +580,8 @@ contract SuperMinterETests is TestConfigV2_1 { function _setPlatformFeeConfig( uint8 tier, - uint96 perTxFlat, - uint96 platformReward, + uint128 perTxFlat, + uint128 platformReward, uint16 perMintBPS, bool active ) internal { @@ -594,8 +594,8 @@ contract SuperMinterETests is TestConfigV2_1 { } function _checkDefaultPlatformFeeConfig( - uint96 perTxFlat, - uint96 platformReward, + uint128 perTxFlat, + uint128 platformReward, uint16 perMintBPS, bool active ) internal { @@ -610,8 +610,8 @@ contract SuperMinterETests is TestConfigV2_1 { function _checkEffectivePlatformFeeConfig( uint8 tier, - uint96 perTxFlat, - uint96 platformReward, + uint128 perTxFlat, + uint128 platformReward, uint16 perMintBPS, bool active ) internal { @@ -626,8 +626,8 @@ contract SuperMinterETests is TestConfigV2_1 { function _checkPlatformFeeConfig( ISuperMinterE.PlatformFeeConfig memory result, - uint96 perTxFlat, - uint96 platformReward, + uint128 perTxFlat, + uint128 platformReward, uint16 perMintBPS, bool active ) internal { @@ -646,7 +646,7 @@ contract SuperMinterETests is TestConfigV2_1 { c.edition = address(edition); c.tier = uint8(_random() % 2); c.mode = uint8(_random() % 3); - c.price = uint96(_bound(_random(), 0, type(uint96).max)); + c.price = uint128(_bound(_random(), 0, type(uint128).max)); c.affiliateFeeBPS = uint16(_bound(_random(), 0, smc.MAX_AFFILIATE_FEE_BPS)); c.startTime = 0; c.endTime = uint32(block.timestamp + 1000); @@ -656,12 +656,12 @@ contract SuperMinterETests is TestConfigV2_1 { } assertEq(sm.createEditionMint(c), 0); - uint256 gaPrice = uint96(_bound(_random(), 0, type(uint96).max)); + uint256 gaPrice = uint128(_bound(_random(), 0, type(uint128).max)); vm.prank(c.platform); - sm.setGAPrice(uint96(gaPrice)); + sm.setGAPrice(uint128(gaPrice)); uint32 quantity = uint32(_bound(_random(), 1, type(uint32).max)); - uint96 signedPrice = uint96(_bound(_random(), 1, type(uint96).max)); + uint128 signedPrice = uint128(_bound(_random(), 1, type(uint128).max)); ISuperMinterE.TotalPriceAndFees memory tpaf; if (c.mode == sm.VERIFY_SIGNATURE() && signedPrice < c.price) { vm.expectRevert(ISuperMinterE.SignedPriceTooLow.selector); @@ -696,7 +696,7 @@ contract SuperMinterETests is TestConfigV2_1 { c.platform = _randomNonZeroAddress(); c.edition = address(edition); c.tier = 1; - c.price = uint96(_bound(_random(), 0, type(uint96).max)); + c.price = uint128(_bound(_random(), 0, type(uint128).max)); c.affiliateFeeBPS = uint16(_bound(_random(), 0, smc.MAX_AFFILIATE_FEE_BPS)); c.startTime = 0; c.endTime = uint32(block.timestamp + 1000); @@ -707,18 +707,18 @@ contract SuperMinterETests is TestConfigV2_1 { // Set the tier 1 platform fee config. ISuperMinterE.PlatformFeeConfig memory pfc; { - pfc.platformTxFlatFee = uint96(_bound(_random(), 0, smc.MAX_PLATFORM_PER_TX_FLAT_FEE)); + pfc.platformTxFlatFee = uint128(_bound(_random(), 0, smc.MAX_PLATFORM_PER_TX_FLAT_FEE)); pfc.platformMintFeeBPS = uint16(_bound(_random(), 0, smc.MAX_PLATFORM_PER_MINT_FEE_BPS)); - pfc.artistMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.affiliateMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.platformMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.artistMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.affiliateMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.platformMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.thresholdPrice = uint96(_bound(_random(), 0, type(uint96).max)); + pfc.thresholdPrice = uint128(_bound(_random(), 0, type(uint128).max)); - pfc.thresholdArtistMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.thresholdAffiliateMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.thresholdPlatformMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.thresholdArtistMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.thresholdAffiliateMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.thresholdPlatformMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); pfc.active = true; vm.prank(c.platform); @@ -827,7 +827,7 @@ contract SuperMinterETests is TestConfigV2_1 { c.platform = _randomNonZeroAddress(); c.edition = address(edition); c.tier = 1; - c.price = uint96(_bound(_random(), 0, type(uint96).max)); + c.price = uint128(_bound(_random(), 0, type(uint128).max)); c.affiliateFeeBPS = uint16(_bound(_random(), 0, smc.MAX_AFFILIATE_FEE_BPS)); c.startTime = 0; c.endTime = uint32(block.timestamp + 1000); @@ -839,18 +839,18 @@ contract SuperMinterETests is TestConfigV2_1 { // Set the tier 1 platform fee config. ISuperMinterE.PlatformFeeConfig memory pfc; { - pfc.platformTxFlatFee = uint96(_bound(_random(), 0, smc.MAX_PLATFORM_PER_TX_FLAT_FEE)); + pfc.platformTxFlatFee = uint128(_bound(_random(), 0, smc.MAX_PLATFORM_PER_TX_FLAT_FEE)); pfc.platformMintFeeBPS = uint16(_bound(_random(), 0, smc.MAX_PLATFORM_PER_MINT_FEE_BPS)); - pfc.artistMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.affiliateMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.platformMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.artistMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.affiliateMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.platformMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.thresholdPrice = uint96(_bound(_random(), 0, type(uint96).max)); + pfc.thresholdPrice = uint128(_bound(_random(), 0, type(uint128).max)); - pfc.thresholdArtistMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.thresholdAffiliateMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); - pfc.thresholdPlatformMintReward = uint96(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.thresholdArtistMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.thresholdAffiliateMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); + pfc.thresholdPlatformMintReward = uint128(_bound(_random(), 0, smc.MAX_PER_MINT_REWARD)); pfc.active = true; vm.prank(c.platform); @@ -974,7 +974,7 @@ contract SuperMinterETests is TestConfigV2_1 { p.scheduleNum = 0; p.to = _randomNonZeroAddress(); p.quantity = uint32(_bound(_random(), 1, 16)); - p.signedPrice = uint96(_bound(_random(), 0, type(uint96).max)); + p.signedPrice = uint128(_bound(_random(), 0, type(uint128).max)); p.signedQuantity = uint32(p.quantity + (_random() % 16)); p.signedClaimTicket = uint32(_bound(_random(), 0, type(uint32).max)); p.signedDeadline = type(uint32).max; @@ -1038,9 +1038,9 @@ contract SuperMinterETests is TestConfigV2_1 { c.maxMintablePerAccount = type(uint32).max; assertEq(sm.createEditionMint(c), 0); - uint256 gaPrice = uint96(_bound(_random(), 0, type(uint96).max)); + uint256 gaPrice = uint128(_bound(_random(), 0, type(uint128).max)); vm.prank(c.platform); - sm.setGAPrice(uint96(gaPrice)); + sm.setGAPrice(uint128(gaPrice)); ISuperMinterE.MintTo memory p; p.edition = address(edition);