From f55c87e6556092b7ec0e61d6eb72811d04658bed Mon Sep 17 00:00:00 2001 From: Vignesh Hirudayakanth Date: Sun, 17 Dec 2023 12:01:09 -0800 Subject: [PATCH] nit suggestion --- contracts/modules/SuperMinterV1_1.sol | 21 ++++++++------------- tests/modules/SuperMinterV1_1.t.sol | 8 ++++---- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/contracts/modules/SuperMinterV1_1.sol b/contracts/modules/SuperMinterV1_1.sol index 1966a2d0..6c00cce5 100644 --- a/contracts/modules/SuperMinterV1_1.sol +++ b/contracts/modules/SuperMinterV1_1.sol @@ -358,8 +358,7 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { // We'll deduct the affiliate BPS fees in the affiliate fees calculation step. l.finalArtistFee = f.subTotal + f.artistReward - f.platformBPSFee; // Initialize to the platform fee. - // (inclusive of `platformTxFlatFee`, `platformBPSFee`, and `platformReward`). - l.finalPlatformFee = f.platformFee; + l.finalPlatformFee = f.platformTxFlatFee + f.platformBPSFee + f.platformReward; // Yeah, we know it's left curved. l.affiliate = p.to == p.affiliate ? address(0) : p.affiliate; @@ -1191,10 +1190,17 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { unitPrice = d.price; // Else, use the `price`. } f.unitPrice = unitPrice; + // The artist will receive the remaining after all BPS fees are deducted from sub total. // The minter will have to pay the sub total plus any flat fees. f.subTotal = unitPrice * uint256(quantity); + // BPS fees are to be deducted from the sub total. + f.platformBPSFee = LibOps.rawMulDiv(f.subTotal, c.perMintBPS, BPS_DENOMINATOR); + f.affiliateBPSFee = LibOps.rawMulDiv(f.subTotal, d.affiliateFeeBPS, BPS_DENOMINATOR); + + // Flat fees, additive to the sub total, include platformTxFlatFee, and rewards + // Set the rewards depending on the `unitPrice`. if (unitPrice <= c.thresholdPrice) { f.artistReward = c.artistReward * uint256(quantity); @@ -1205,18 +1211,7 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { f.affiliateReward = c.thresholdAffiliateReward * uint256(quantity); f.platformReward = c.thresholdPlatformReward * uint256(quantity); } - - // Sum the total flat fees for mints, and the transaction flat fee. f.platformTxFlatFee = c.perTxFlat; - // Platform BPS fees are to be deducted from the sub total. - f.platformBPSFee = LibOps.rawMulDiv(f.subTotal, c.perMintBPS, BPS_DENOMINATOR); - // The platform fee includes BPS fees deducted from sub total, - // and flat fees added to sub total. - f.platformFee = f.platformBPSFee + f.platformTxFlatFee + f.platformReward; - - // Affiliate BPS fee is to be deducted from the sub total. - // Will be conditionally set to zero during mint if not affiliated. - f.affiliateBPSFee = LibOps.rawMulDiv(f.subTotal, d.affiliateFeeBPS, BPS_DENOMINATOR); // The total is the final value which the minter has to pay. It includes all fees. f.total = f.subTotal + f.platformTxFlatFee + f.artistReward + f.affiliateReward + f.platformReward; diff --git a/tests/modules/SuperMinterV1_1.t.sol b/tests/modules/SuperMinterV1_1.t.sol index a2c7ab57..21853e2c 100644 --- a/tests/modules/SuperMinterV1_1.t.sol +++ b/tests/modules/SuperMinterV1_1.t.sol @@ -768,9 +768,9 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { l.affiliated = true; l.requiredEtherValue = tpaf.total; l.unitPrice = tpaf.unitPrice; - l.finalArtistFee = tpaf.total - tpaf.platformFee - tpaf.affiliateBPSFee - tpaf.affiliateReward; + l.finalArtistFee = tpaf.total - tpaf.platformTxFlatFee - tpaf.platformBPSFee - tpaf.affiliateBPSFee - tpaf.platformReward - tpaf.affiliateReward ; l.finalAffiliateFee = tpaf.affiliateBPSFee + tpaf.affiliateReward; - l.finalPlatformFee = tpaf.platformFee; + l.finalPlatformFee = tpaf.platformTxFlatFee + tpaf.platformBPSFee + tpaf.platformReward; emit Minted(address(edition), 1, 0, address(this), l, 0); } else { @@ -784,9 +784,9 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { l.affiliated = false; l.requiredEtherValue = tpaf.total; l.unitPrice = tpaf.unitPrice; - l.finalArtistFee = tpaf.total - tpaf.platformFee - tpaf.affiliateReward; + l.finalArtistFee = tpaf.total - tpaf.platformTxFlatFee - tpaf.platformBPSFee - tpaf.affiliateBPSFee - tpaf.platformReward - tpaf.affiliateReward; l.finalAffiliateFee = 0; - l.finalPlatformFee = tpaf.platformFee + tpaf.affiliateReward; + l.finalPlatformFee = tpaf.platformTxFlatFee + tpaf.platformBPSFee + tpaf.platformReward + tpaf.affiliateReward; emit Minted(address(edition), 1, 0, address(this), l, 0); }