Skip to content

Commit

Permalink
Merge remote-tracking branch 'private/main' into add_lavamoat
Browse files Browse the repository at this point in the history
  • Loading branch information
iainnash committed Dec 14, 2023
2 parents 631aa69 + e990b9d commit ea3571b
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 251 deletions.
6 changes: 6 additions & 0 deletions .changeset/stale-ants-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@zoralabs/zora-1155-contracts": minor
"@zoralabs/protocol-rewards": patch
---

Remove platform referral from RewardsSplits, and revert mint fee change to 0.000777 ether. Use new signature for 1155 for `mint` which takes an array of reward recipients
8 changes: 1 addition & 7 deletions packages/1155-contracts/src/nft/ZoraCreator1155Impl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,6 @@ contract ZoraCreator1155Impl is
_requireAdminOrRole(address(minter), tokenId, PERMISSION_BIT_MINTER);

address mintReferral = address(0);
address platformReferral = address(0);

if (rewardsRecipients.length > 1) {
platformReferral = rewardsRecipients[1];
}

if (rewardsRecipients.length > 0) {
mintReferral = rewardsRecipients[0];
Expand All @@ -451,8 +446,7 @@ contract ZoraCreator1155Impl is
getCreatorRewardRecipient(tokenId),
createReferrals[tokenId],
mintReferral,
firstMinters[tokenId],
platformReferral
firstMinters[tokenId]
);

// Execute commands returned from minter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ contract ZoraCreatorFixedPriceSaleStrategyTest is Test {

vm.startPrank(tokenRecipient);

target.mintWithRewards{value: 1.00111 ether}(fixedPrice, newTokenId, 1, abi.encode(tokenRecipient, ""), address(0));
target.mintWithRewards{value: 1.000777 ether}(fixedPrice, newTokenId, 1, abi.encode(tokenRecipient, ""), address(0));

vm.stopPrank();
}
Expand Down
33 changes: 11 additions & 22 deletions packages/1155-contracts/test/nft/ZoraCreator1155.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ contract ZoraCreator1155Test is Test {
address internal mintReferral;
address internal createReferral;
address internal zora;
address internal sourceReferral;
address[] internal rewardsRecipients;

event Purchased(address indexed sender, address indexed minter, uint256 indexed tokenId, uint256 quantity, uint256 value);
Expand All @@ -91,11 +90,9 @@ contract ZoraCreator1155Test is Test {
mintReferral = makeAddr("mintReferral");
createReferral = makeAddr("createReferral");
zora = makeAddr("zora");
sourceReferral = makeAddr("sourceReferral");

rewardsRecipients = new address[](2);
rewardsRecipients = new address[](1);
rewardsRecipients[0] = mintReferral;
rewardsRecipients[1] = sourceReferral;

address adminAddress;
(adminAddress, adminKey) = makeAddrAndKey("admin");
Expand Down Expand Up @@ -709,7 +706,7 @@ contract ZoraCreator1155Test is Test {
}

function test_mintFee_returnsMintFee() public {
assertEq(target.mintFee(), 0.00111 ether);
assertEq(target.mintFee(), 0.000777 ether);
}

function test_FreeMintRewards(uint256 quantity) public {
Expand All @@ -735,10 +732,7 @@ contract ZoraCreator1155Test is Test {

assertEq(protocolRewards.balanceOf(recipient), 0);
assertEq(protocolRewards.balanceOf(fundsRecipient), settings.creatorReward + settings.firstMinterReward);
assertEq(
protocolRewards.balanceOf(zora),
settings.zoraReward + settings.mintReferralReward + settings.createReferralReward + settings.platformReferralReward
);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward + settings.createReferralReward);
}

function test_FreeMintRewardsWithCreateReferral(uint256 quantity) public {
Expand All @@ -765,7 +759,7 @@ contract ZoraCreator1155Test is Test {
assertEq(protocolRewards.balanceOf(recipient), 0);
assertEq(protocolRewards.balanceOf(fundsRecipient), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(createReferral), settings.createReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward + settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward);
}

function test_FreeMintRewardsWithMintReferral(uint256 quantity) public {
Expand All @@ -792,7 +786,7 @@ contract ZoraCreator1155Test is Test {
assertEq(protocolRewards.balanceOf(recipient), 0);
assertEq(protocolRewards.balanceOf(fundsRecipient), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.createReferralReward + settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.createReferralReward);
}

function test_FreeMintRewardsWithCreateAndMintReferral(uint256 quantity) public {
Expand Down Expand Up @@ -820,7 +814,7 @@ contract ZoraCreator1155Test is Test {
assertEq(protocolRewards.balanceOf(fundsRecipient), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(createReferral), settings.createReferralReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward);
}

function testRevert_InsufficientEthForFreeMintRewards(uint256 quantity) public {
Expand Down Expand Up @@ -881,10 +875,7 @@ contract ZoraCreator1155Test is Test {
assertEq(address(target).balance, totalSale);

assertEq(protocolRewards.balanceOf(admin), settings.firstMinterReward);
assertEq(
protocolRewards.balanceOf(zora),
settings.zoraReward + settings.mintReferralReward + settings.createReferralReward + settings.platformReferralReward
);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward + settings.createReferralReward);
}

function test_PaidMintRewardsWithMintReferral(uint256 quantity, uint256 salePrice) public {
Expand Down Expand Up @@ -930,7 +921,7 @@ contract ZoraCreator1155Test is Test {

assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(admin), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.createReferralReward + settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.createReferralReward);
}

function test_PaidMintRewardsWithCreateReferral(uint256 quantity, uint256 salePrice) public {
Expand Down Expand Up @@ -975,7 +966,7 @@ contract ZoraCreator1155Test is Test {
assertEq(address(target).balance, totalSale);
assertEq(protocolRewards.balanceOf(admin), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(createReferral), settings.createReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward + settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward);
}

function test_PaidMintRewardsWithCreateAndMintReferral(uint256 quantity, uint256 salePrice) public {
Expand Down Expand Up @@ -1021,7 +1012,7 @@ contract ZoraCreator1155Test is Test {
assertEq(protocolRewards.balanceOf(admin), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(createReferral), settings.createReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward);
}

function testRevert_InsufficientEthForPaidMintRewards(uint256 quantity, uint256 salePrice) public {
Expand Down Expand Up @@ -1167,7 +1158,7 @@ contract ZoraCreator1155Test is Test {
assertEq(protocolRewards.balanceOf(address(uint160(mintRecipient))), 0);
assertEq(protocolRewards.balanceOf(rewardRecipient), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(fundsRecipient), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.createReferralReward + settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.createReferralReward);
}

function test_SetCreatorRewardRecipientForToken() public {
Expand Down Expand Up @@ -1591,7 +1582,6 @@ contract ZoraCreator1155Test is Test {
assertEq(protocolRewards.balanceOf(recipient), 0);
assertEq(protocolRewards.balanceOf(fundsRecipient), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.createReferralReward);
assertEq(protocolRewards.balanceOf(sourceReferral), settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
}

Expand Down Expand Up @@ -1637,7 +1627,6 @@ contract ZoraCreator1155Test is Test {
assertEq(address(target).balance, totalSale);
assertEq(protocolRewards.balanceOf(admin), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.createReferralReward);
assertEq(protocolRewards.balanceOf(sourceReferral), settings.platformReferralReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract Zora1155PremintExecutorProxyTest is Test, IHasContractName {
address internal zora;
Zora1155Factory internal factoryProxy;
ZoraCreator1155FactoryImpl factoryAtProxy;
uint256 internal mintFeeAmount = 0.00111 ether;
uint256 internal mintFeeAmount = 0.000777 ether;
ZoraCreator1155PremintExecutorImpl preminterAtProxy;

IZoraCreator1155PremintExecutor.MintArguments defaultMintArguments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {Zora1155} from "../../src/proxies/Zora1155.sol";
import {IZoraCreator1155Errors} from "../../src/interfaces/IZoraCreator1155Errors.sol";
import {IZoraCreator1155} from "../../src/interfaces/IZoraCreator1155.sol";
import {IMinter1155} from "../../src/interfaces/IMinter1155.sol";
import {IMinterErrors} from "../../src/interfaces/IMinterErrors.sol";
import {ICreatorRoyaltiesControl} from "../../src/interfaces/ICreatorRoyaltiesControl.sol";
import {ZoraCreatorFixedPriceSaleStrategy} from "../../src/minters/fixed-price/ZoraCreatorFixedPriceSaleStrategy.sol";
import {Zora1155Factory} from "../../src/proxies/Zora1155Factory.sol";
Expand All @@ -33,7 +34,7 @@ contract ZoraCreator1155PreminterTest is Test {
ZoraCreator1155FactoryImpl factory;

ICreatorRoyaltiesControl.RoyaltyConfiguration internal defaultRoyaltyConfig;
uint256 internal mintFeeAmount = 0.00111 ether;
uint256 internal mintFeeAmount = 0.000777 ether;

// setup contract config
uint256 internal creatorPrivateKey;
Expand Down Expand Up @@ -472,45 +473,6 @@ contract ZoraCreator1155PreminterTest is Test {
assertEq(mintReferral.balance, mintReferralReward * quantityToMint);
}

function test_platformReferral_getsMintReferralReward() public {
PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2();

address platformReferral = makeAddr("platformReferral ");

address minter = makeAddr("minter");

ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig();

uint256 quantityToMint = 4;

bytes memory signature = _signPremint(preminter.getContractAddress(contractConfig), premintConfig, creatorPrivateKey, block.chainid);

address[] memory mintRewardsRecipients = new address[](2);
mintRewardsRecipients[1] = platformReferral;

IZoraCreator1155PremintExecutor.MintArguments memory mintArguments = IZoraCreator1155PremintExecutor.MintArguments({
mintRecipient: minter,
mintComment: "",
mintRewardsRecipients: mintRewardsRecipients
});

uint256 mintCost = (mintFeeAmount + premintConfig.tokenConfig.pricePerToken) * quantityToMint;

vm.deal(minter, mintCost);
vm.prank(minter);
preminter.premintV2{value: mintCost}(contractConfig, premintConfig, signature, quantityToMint, mintArguments);

// now get balance of mintReferral in ProtocolRewards - it should be mint referral reward amount * quantityToMint
uint256 platformReferralReward = 0.000111 ether * quantityToMint;

assertEq(rewards.balanceOf(platformReferral), platformReferralReward);

vm.prank(platformReferral);
rewards.withdraw(platformReferral, platformReferralReward);

assertEq(platformReferral.balance, platformReferralReward);
}

function testCreateTokenPerUid() public {
ContractCreationConfig memory contractConfig = makeDefaultContractCreationConfig();
PremintConfigV2 memory premintConfig = makeDefaultPremintConfigV2();
Expand Down Expand Up @@ -967,7 +929,7 @@ contract ZoraCreator1155PreminterTest is Test {

uint256 mintFee = preminter.mintFee(contractAddress);

assertEq(mintFee, 0.00111 ether);
assertEq(mintFee, 0.000777 ether);
}

function test_mintFee_onNewContracts_returnsNewMintFee() external {
Expand All @@ -982,7 +944,7 @@ contract ZoraCreator1155PreminterTest is Test {

uint256 mintFee = preminter.mintFee(contractAddress);

assertEq(mintFee, 0.00111 ether);
assertEq(mintFee, 0.000777 ether);
}

function _signAndExecutePremint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ abstract contract ERC1155Rewards is RewardSplits {
address creator,
address createReferral,
address mintReferral,
address firstMinter,
address platformReferral
address firstMinter
) internal returns (uint256) {
uint256 totalReward = computeTotalReward(numTokens);

Expand All @@ -27,11 +26,11 @@ abstract contract ERC1155Rewards is RewardSplits {
if (msgValue < totalReward) {
revert INVALID_ETH_AMOUNT();
} else if (msgValue == totalReward) {
_depositFreeMintRewards(totalReward, numTokens, creator, createReferral, mintReferral, firstMinter, platformReferral);
_depositFreeMintRewards(totalReward, numTokens, creator, createReferral, mintReferral, firstMinter);

return 0;
} else {
_depositPaidMintRewards(totalReward, numTokens, createReferral, mintReferral, firstMinter, platformReferral);
_depositPaidMintRewards(totalReward, numTokens, createReferral, mintReferral, firstMinter);

unchecked {
return msgValue - totalReward;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ abstract contract ERC721Rewards is RewardSplits {
address creator,
address createReferral,
address mintReferral,
address firstMinter,
address platformReferral
address firstMinter
) internal {
uint256 totalReward = computeTotalReward(numTokens);

Expand All @@ -25,15 +24,15 @@ abstract contract ERC721Rewards is RewardSplits {
revert INVALID_ETH_AMOUNT();
}

_depositFreeMintRewards(totalReward, numTokens, creator, createReferral, mintReferral, firstMinter, platformReferral);
_depositFreeMintRewards(totalReward, numTokens, creator, createReferral, mintReferral, firstMinter);
} else {
uint256 totalSale = numTokens * salePrice;

if (msgValue != (totalReward + totalSale)) {
revert INVALID_ETH_AMOUNT();
}

_depositPaidMintRewards(totalReward, numTokens, createReferral, mintReferral, firstMinter, platformReferral);
_depositPaidMintRewards(totalReward, numTokens, createReferral, mintReferral, firstMinter);
}
}
}
Loading

0 comments on commit ea3571b

Please sign in to comment.