From 51a192bb6c70fd217df50a6a8a0bdf2f4f49c74b Mon Sep 17 00:00:00 2001 From: Vectorized Date: Fri, 24 Nov 2023 21:52:47 +0000 Subject: [PATCH] freeMintIncentive -> cheapMintIncentive --- contracts/modules/SuperMinterV1_1.sol | 15 ++++++------ .../modules/interfaces/ISuperMinterV1_1.sol | 17 ++++++++------ tests/modules/SuperMinterV1_1.t.sol | 23 +++++++++++-------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/contracts/modules/SuperMinterV1_1.sol b/contracts/modules/SuperMinterV1_1.sol index cb32709e..eabd7b77 100644 --- a/contracts/modules/SuperMinterV1_1.sol +++ b/contracts/modules/SuperMinterV1_1.sol @@ -354,12 +354,12 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { if (p.affiliate != address(0)) revert InvalidAffiliate(); } - /* --------------------- FREE MINT FEES --------------------- */ + /* -------------------- CHEAP MINT FEES --------------------- */ - if (f.freeMintIncentive != 0 && f.unitPrice == 0) { - l.finalPlatformFee -= f.freeMintIncentive; - l.finalFreeMintFee = f.freeMintIncentive; - l.finalArtistFee += l.finalFreeMintFee; + if (f.cheapMintIncentive != 0 && f.unitPrice <= f.cheapMintIncentiveThreshold) { + l.finalPlatformFee -= f.cheapMintIncentive; + l.finalCheapMintFee = f.cheapMintIncentive; + l.finalArtistFee += l.finalCheapMintFee; } /* ------------------ FIRST COLLECTOR FEES ------------------ */ @@ -968,7 +968,7 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { unchecked { uint256 incentiveSum; incentiveSum += uint256(c.affiliateIncentive); - incentiveSum += uint256(c.freeMintIncentive); + incentiveSum += uint256(c.cheapMintIncentive); incentiveSum += uint256(c.firstCollectorIncentive); if ( LibOps.or( @@ -1139,7 +1139,8 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { f.affiliateFee = LibOps.rawMulDiv(f.subTotal, d.affiliateFeeBPS, BPS_DENOMINATOR); // Calculate the incentives. These may be redirected away from the `platformFee`. f.affiliateIncentive = c.affiliateIncentive * uint256(quantity); - f.freeMintIncentive = c.freeMintIncentive * uint256(quantity); + f.cheapMintIncentive = c.cheapMintIncentive * uint256(quantity); + f.cheapMintIncentiveThreshold = c.cheapMintIncentiveThreshold; f.firstCollectorIncentive = c.firstCollectorIncentive * uint256(quantity); // The total is the final value which the minter has to pay. It includes all fees. f.total = f.subTotal + f.platformFlatFee; diff --git a/contracts/modules/interfaces/ISuperMinterV1_1.sol b/contracts/modules/interfaces/ISuperMinterV1_1.sol index d7ceeae5..7d5cc800 100644 --- a/contracts/modules/interfaces/ISuperMinterV1_1.sol +++ b/contracts/modules/interfaces/ISuperMinterV1_1.sol @@ -114,8 +114,9 @@ interface ISuperMinterV1_1 is IERC165 { uint256 affiliateFee; // The incentive for the affiliate. uint256 affiliateIncentive; - // The incentive for free mints, to be given to the artist. - uint256 freeMintIncentive; + // The incentive for cheap mints, to be given to the artist. + uint256 cheapMintIncentive; + uint256 cheapMintIncentiveThreshold; // The incentive for the first collector. uint256 firstCollectorIncentive; } @@ -150,8 +151,8 @@ interface ISuperMinterV1_1 is IERC165 { uint256 finalPlatformFee; // The total affiliate fee. uint256 finalAffiliateFee; - // The final free mint fee. - uint256 finalFreeMintFee; + // The final cheap mint fee. + uint256 finalCheapMintFee; // The final first collector fee. uint256 finalFirstCollectorFee; } @@ -164,8 +165,10 @@ interface ISuperMinterV1_1 is IERC165 { // to give to the affiliate, if provided. uint96 affiliateIncentive; // The amount of platform per-mint flat fee - // to give to the artist, if the mint is free. - uint96 freeMintIncentive; + // to give to the artist, if the mint is + // less than or equal to `cheapMintIncentiveThreshold`. + uint96 cheapMintIncentive; + uint96 cheapMintIncentiveThreshold; // The amount of platform per-mint flat fee // to give to the first collector. uint96 firstCollectorIncentive; @@ -174,7 +177,7 @@ interface ISuperMinterV1_1 is IERC165 { // The per-token flat fee. // This fee includes: // - `affiliateIncentive`. - // - `freeMintIncentive`. + // - `cheapMintIncentive`. // - `firstCollectorIncentive`. uint96 perMintFlat; // The per-token fee BPS. diff --git a/tests/modules/SuperMinterV1_1.t.sol b/tests/modules/SuperMinterV1_1.t.sol index 14e72455..8e3499eb 100644 --- a/tests/modules/SuperMinterV1_1.t.sol +++ b/tests/modules/SuperMinterV1_1.t.sol @@ -781,9 +781,10 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { pfc.perMintFlat = uint96(_bound(_random(), 0, smc.MAX_PLATFORM_PER_MINT_FLAT_FEE)); pfc.perMintBPS = uint16(_bound(_random(), 0, smc.MAX_PLATFORM_PER_MINT_FEE_BPS)); pfc.affiliateIncentive = uint96(_bound(_random(), 0, pfc.perMintFlat)); - pfc.freeMintIncentive = uint96(_bound(_random(), 0, pfc.perMintFlat - pfc.affiliateIncentive)); + pfc.cheapMintIncentive = uint96(_bound(_random(), 0, pfc.perMintFlat - pfc.affiliateIncentive)); + pfc.cheapMintIncentiveThreshold = uint96(_bound(_random(), 0, pfc.cheapMintIncentive * 2)); pfc.firstCollectorIncentive = uint96( - _bound(_random(), 0, pfc.perMintFlat - pfc.affiliateIncentive - pfc.freeMintIncentive) + _bound(_random(), 0, pfc.perMintFlat - pfc.affiliateIncentive - pfc.cheapMintIncentive) ); pfc.active = true; vm.prank(c.platform); @@ -822,15 +823,16 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { l.affiliated = true; l.requiredEtherValue = tpaf.total; l.unitPrice = tpaf.unitPrice; - uint256 finalFreeMintFee = tpaf.unitPrice == 0 ? tpaf.freeMintIncentive : 0; - l.finalArtistFee = tpaf.total - tpaf.platformFee - tpaf.affiliateFee + finalFreeMintFee; + uint256 finalCheapMintFee; + if (tpaf.unitPrice <= tpaf.cheapMintIncentiveThreshold) finalCheapMintFee = tpaf.cheapMintIncentive; + l.finalArtistFee = tpaf.total - tpaf.platformFee - tpaf.affiliateFee + finalCheapMintFee; l.finalPlatformFee = tpaf.platformFee - tpaf.affiliateIncentive - - finalFreeMintFee - + finalCheapMintFee - tpaf.firstCollectorIncentive; l.finalAffiliateFee = tpaf.affiliateFee + tpaf.affiliateIncentive; - l.finalFreeMintFee = finalFreeMintFee; + l.finalCheapMintFee = finalCheapMintFee; l.finalFirstCollectorFee = tpaf.firstCollectorIncentive; } emit Minted(address(edition), 1, 0, address(this), l, 0); @@ -874,11 +876,12 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { l.affiliated = false; l.requiredEtherValue = tpaf.total; l.unitPrice = tpaf.unitPrice; - uint256 finalFreeMintFee = tpaf.unitPrice == 0 ? tpaf.freeMintIncentive : 0; - l.finalArtistFee = tpaf.total - tpaf.platformFee + finalFreeMintFee; - l.finalPlatformFee = tpaf.platformFee - finalFreeMintFee - tpaf.firstCollectorIncentive; + uint256 finalCheapMintFee; + if (tpaf.unitPrice <= tpaf.cheapMintIncentiveThreshold) finalCheapMintFee = tpaf.cheapMintIncentive; + l.finalArtistFee = tpaf.total - tpaf.platformFee + finalCheapMintFee; + l.finalPlatformFee = tpaf.platformFee - finalCheapMintFee - tpaf.firstCollectorIncentive; l.finalAffiliateFee = 0; - l.finalFreeMintFee = finalFreeMintFee; + l.finalCheapMintFee = finalCheapMintFee; l.finalFirstCollectorFee = tpaf.firstCollectorIncentive; } emit Minted(address(edition), 1, 0, address(this), l, 0);