Skip to content

Commit

Permalink
nit suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshka committed Dec 17, 2023
1 parent d2136b9 commit f55c87e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
21 changes: 8 additions & 13 deletions contracts/modules/SuperMinterV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions tests/modules/SuperMinterV1_1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down

0 comments on commit f55c87e

Please sign in to comment.