Skip to content

Commit

Permalink
freeMintIncentive -> cheapMintIncentive
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Nov 24, 2023
1 parent 767e950 commit 51a192b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
15 changes: 8 additions & 7 deletions contracts/modules/SuperMinterV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------ */
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 10 additions & 7 deletions contracts/modules/interfaces/ISuperMinterV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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.
Expand Down
23 changes: 13 additions & 10 deletions tests/modules/SuperMinterV1_1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 51a192b

Please sign in to comment.