Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SuperMinterV1_1 et al. #296

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d0e97dc
Prep files
Vectorized Nov 17, 2023
814e6f2
Reinstall multicaller
Vectorized Nov 17, 2023
56ecca9
forge install: multicaller
Vectorized Nov 17, 2023
289f5f5
Add LibMulticaller.senderOrSigner support
Vectorized Nov 17, 2023
767e950
Tidy
Vectorized Nov 17, 2023
51a192b
freeMintIncentive -> cheapMintIncentive
Vectorized Nov 24, 2023
83f02ac
Add comment on the two types of affiliate fees
Vectorized Nov 24, 2023
00273e4
Remove first collector incentives
Vectorized Nov 25, 2023
e993498
Add more comments and use checked math in mintTo
Vectorized Dec 1, 2023
9df9a7a
Add finalAffiliateIncentive to Minted log. Change finalCheapMintFee -…
Vectorized Dec 1, 2023
9d7530b
Add platform airdrop functionality to SuperMinterV1_1 (#298)
Vectorized Dec 15, 2023
ab5d9c3
Create modern-shirts-try.md
vigneshka Dec 15, 2023
9dc3992
pin version for typechain
vigneshka Dec 15, 2023
8e48a58
tweak ci
vigneshka Dec 15, 2023
3e86b2b
more ci tweaks
vigneshka Dec 15, 2023
babe37c
add back foundry
vigneshka Dec 15, 2023
12c912f
Merge branch 'main' of github.com:soundxyz/sound-protocol into vector…
vigneshka Dec 15, 2023
78f8bd9
bump
vigneshka Dec 15, 2023
4abef49
Merge branch 'main' of github.com:soundxyz/sound-protocol into vector…
vigneshka Dec 15, 2023
44373d5
bump typechain
vigneshka Dec 15, 2023
815ce5b
Merge branch 'main' of github.com:soundxyz/sound-protocol into vector…
vigneshka Dec 15, 2023
df00147
Implement fee changes (#299)
Vectorized Dec 18, 2023
30e8987
Update modern-shirts-try.md
vigneshka Dec 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove first collector incentives
  • Loading branch information
Vectorized committed Nov 25, 2023
commit 00273e47f0a69ad947210fbd05b05cc460b74869
33 changes: 0 additions & 33 deletions contracts/modules/SuperMinterV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,6 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 {
*/
mapping(address => uint256) public affiliateFeesAccrued;

/**
* @dev A mapping of `firstCollector` => `feesAccrued`.
*/
mapping(address => uint256) public firstCollectorFeesAccrued;

/**
* @dev The first collector for the edition.
*/
mapping(address => address) public firstCollector;

/**
* @dev A mapping of `platform` => `price`.
*/
Expand Down Expand Up @@ -369,15 +359,6 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 {
l.finalArtistFee += l.finalCheapMintFee;
}

/* ------------------ FIRST COLLECTOR FEES ------------------ */

if (firstCollector[p.edition] == address(0)) firstCollector[p.edition] = p.to;
if (f.firstCollectorIncentive != 0) {
l.finalPlatformFee -= f.firstCollectorIncentive;
l.finalFirstCollectorFee = f.firstCollectorIncentive;
firstCollectorFeesAccrued[firstCollector[p.edition]] += l.finalFirstCollectorFee;
}

platformFeesAccrued[d.platform] += l.finalPlatformFee; // Accrue the platform fee.
}

Expand Down Expand Up @@ -585,18 +566,6 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 {
}
}

/**
* @inheritdoc ISuperMinterV1_1
*/
function withdrawForFirstCollector(address collector) public {
uint256 accrued = firstCollectorFeesAccrued[collector];
if (accrued != 0) {
firstCollectorFeesAccrued[collector] = 0;
SafeTransferLib.forceSafeTransferETH(collector, accrued);
emit FirstCollectorFeesWithdrawn(collector, accrued);
}
}

/**
* @inheritdoc ISuperMinterV1_1
*/
Expand Down Expand Up @@ -976,7 +945,6 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 {
uint256 incentiveSum;
incentiveSum += uint256(c.affiliateIncentive);
incentiveSum += uint256(c.cheapMintIncentive);
incentiveSum += uint256(c.firstCollectorIncentive);
if (
LibOps.or(
c.perTxFlat > MAX_PLATFORM_PER_TX_FLAT_FEE,
Expand Down Expand Up @@ -1148,7 +1116,6 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 {
f.affiliateIncentive = c.affiliateIncentive * 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
21 changes: 0 additions & 21 deletions contracts/modules/interfaces/ISuperMinterV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ interface ISuperMinterV1_1 is IERC165 {
// 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 @@ -153,8 +151,6 @@ interface ISuperMinterV1_1 is IERC165 {
uint256 finalAffiliateFee;
// The final cheap mint fee.
uint256 finalCheapMintFee;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why this is included in the minted struct when other things like affiliateIncentive is not?

Copy link
Collaborator Author

@Vectorized Vectorized Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call out. I added finalAffiliateIncentive to the minted struct and renamed finalCheapMintFee -> finalCheapMintIncentive in the minted struct.

// The final first collector fee.
uint256 finalFirstCollectorFee;
}

/**
Expand All @@ -169,16 +165,12 @@ interface ISuperMinterV1_1 is IERC165 {
// 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;
// The per-transaction flat fee.
uint96 perTxFlat;
// The per-token flat fee.
// This fee includes:
// - `affiliateIncentive`.
// - `cheapMintIncentive`.
// - `firstCollectorIncentive`.
uint96 perMintFlat;
// The per-token fee BPS.
uint16 perMintBPS;
Expand Down Expand Up @@ -368,13 +360,6 @@ interface ISuperMinterV1_1 is IERC165 {
*/
event AffiliateFeesWithdrawn(address indexed affiliate, uint256 accrued);

/**
* @dev Emitted with first collector fees are withdrawn.
* @param collector The first collector.
* @param accrued The amount of Ether accrued and withdrawn.
*/
event FirstCollectorFeesWithdrawn(address indexed collector, uint256 accrued);

/**
* @dev Emitted when platform fees are withdrawn.
* @param platform The platform address.
Expand Down Expand Up @@ -717,12 +702,6 @@ interface ISuperMinterV1_1 is IERC165 {
*/
function withdrawForAffiliate(address affiliate) external;

/**
* @dev Withdraws all accrued fees of the first collector, to the first collector.
* @param collector The first collector.
*/
function withdrawForFirstCollector(address collector) external;

/**
* @dev Withdraws all accrued fees of the platform, to the their fee address.
* @param platform The platform address.
Expand Down
31 changes: 5 additions & 26 deletions tests/modules/SuperMinterV1_1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,6 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 {
pfc.affiliateIncentive = uint96(_bound(_random(), 0, pfc.perMintFlat));
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.cheapMintIncentive)
);
pfc.active = true;
vm.prank(c.platform);
sm.setPlatformFeeConfig(1, pfc);
Expand Down Expand Up @@ -826,22 +823,16 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 {
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 -
finalCheapMintFee -
tpaf.firstCollectorIncentive;
l.finalPlatformFee = tpaf.platformFee - tpaf.affiliateIncentive - finalCheapMintFee;
l.finalAffiliateFee = tpaf.affiliateFee + tpaf.affiliateIncentive;
l.finalCheapMintFee = finalCheapMintFee;
l.finalFirstCollectorFee = tpaf.firstCollectorIncentive;
}
emit Minted(address(edition), 1, 0, address(this), l, 0);

sm.mintTo{ value: tpaf.total }(p);
assertEq(sm.platformFeesAccrued(c.platform), l.finalPlatformFee);
assertEq(sm.affiliateFeesAccrued(p.affiliate), l.finalAffiliateFee);
assertEq(sm.firstCollectorFeesAccrued(p.to), l.finalFirstCollectorFee);
assertEq(address(sm).balance, l.finalPlatformFee + l.finalAffiliateFee + l.finalFirstCollectorFee);
assertEq(address(sm).balance, l.finalPlatformFee + l.finalAffiliateFee);
assertEq(address(edition).balance, l.finalArtistFee);

// Perform the withdrawals and check if the balances tally.
Expand All @@ -852,12 +843,6 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 {
uint256 balanceBefore = address(p.affiliate).balance;
sm.withdrawForAffiliate(p.affiliate);
assertEq(address(p.affiliate).balance, balanceBefore + l.finalAffiliateFee);
assertEq(address(sm).balance, l.finalPlatformFee + l.finalFirstCollectorFee);

balanceBefore = address(p.to).balance;
sm.withdrawForFirstCollector(p.to);
assertEq(address(p.to).balance, balanceBefore + l.finalFirstCollectorFee);
assertEq(address(sm).balance, l.finalPlatformFee);

balanceBefore = address(feeRecipients[0]).balance;
sm.withdrawForPlatform(c.platform);
Expand All @@ -879,29 +864,23 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 {
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.finalPlatformFee = tpaf.platformFee - finalCheapMintFee;
l.finalAffiliateFee = 0;
l.finalCheapMintFee = finalCheapMintFee;
l.finalFirstCollectorFee = tpaf.firstCollectorIncentive;
}
emit Minted(address(edition), 1, 0, address(this), l, 0);

sm.mintTo{ value: tpaf.total }(p);
assertEq(sm.platformFeesAccrued(c.platform), l.finalPlatformFee);
assertEq(address(sm).balance, l.finalPlatformFee + l.finalFirstCollectorFee);
assertEq(address(sm).balance, l.finalPlatformFee);
assertEq(address(edition).balance, l.finalArtistFee);

// Perform the withdrawals and check if the balances tally.
vm.prank(c.platform);
sm.setPlatformFeeAddress(feeRecipients[0]);
assertEq(sm.platformFeeAddress(c.platform), feeRecipients[0]);

uint256 balanceBefore = address(p.to).balance;
sm.withdrawForFirstCollector(p.to);
assertEq(address(p.to).balance, balanceBefore + l.finalFirstCollectorFee);
assertEq(address(sm).balance, l.finalPlatformFee);

balanceBefore = address(feeRecipients[0]).balance;
uint256 balanceBefore = address(feeRecipients[0]).balance;
sm.withdrawForPlatform(c.platform);
assertEq(address(feeRecipients[0]).balance, balanceBefore + l.finalPlatformFee);
assertEq(sm.platformFeeAddress(c.platform), feeRecipients[0]);
Expand Down
Loading