From 4e0a4b430d83f5302638bd11b4b381cde3d4744b Mon Sep 17 00:00:00 2001 From: Wayne Date: Tue, 14 Nov 2023 16:34:16 -1000 Subject: [PATCH] remove nft quest fee --- .gas-snapshot | 48 +++++++++++++++++++------------------- contracts/Quest.sol | 8 +++---- contracts/Quest1155.sol | 2 -- contracts/QuestFactory.sol | 2 +- test/Quest1155.t.sol | 2 +- test/QuestFactory.t.sol | 4 ++-- 6 files changed, 31 insertions(+), 35 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 6a8dc24e..fb773550 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -16,40 +16,40 @@ ProtocolRewardsTest:test_withdraw() (gas: 34148) ProtocolRewardsTest:test_withdrawFor() (gas: 28858) ProtocolRewardsTest:test_withdrawForFullBalance() (gas: 29017) ProtocolRewardsTest:test_withdrawFullBalance() (gas: 32031) -TestQuest1155:test_RevertIf_initialize_EndTimeInPast() (gas: 2187471) -TestQuest1155:test_RevertIf_initialize_EndTimeLessThanOrEqualToStartTime() (gas: 2185401) +TestQuest1155:test_RevertIf_initialize_EndTimeInPast() (gas: 2177047) +TestQuest1155:test_RevertIf_initialize_EndTimeLessThanOrEqualToStartTime() (gas: 2174977) TestQuest1155:test_RevertIf_not_enough_eth() (gas: 63799) TestQuest1155:test_RevertIf_not_enough_tokens() (gas: 27823) TestQuest1155:test_RevertIf_pause_Unauthorized() (gas: 13520) -TestQuest1155:test_RevertIf_singleClaim_NotQuestFactory() (gas: 82389) +TestQuest1155:test_RevertIf_singleClaim_NotQuestFactory() (gas: 82249) TestQuest1155:test_RevertIf_singleClaim_NotStarted() (gas: 85125) TestQuest1155:test_RevertIf_singleClaim_whenNotPaused() (gas: 105396) TestQuest1155:test_RevertIf_unpause_Unauthorized() (gas: 13517) TestQuest1155:test_RevertIf_withdrawRemainingToken_AlreadyWithdrawn() (gas: 136227) TestQuest1155:test_RevertIf_withdrawRemainingToken_NotEnded() (gas: 91605) -TestQuest1155:test_RevertIf_withdrawRemainingToken_NotQueued() (gas: 21133) +TestQuest1155:test_RevertIf_withdrawRemainingToken_NotQueued() (gas: 21127) TestQuest1155:test_initialize() (gas: 49323) TestQuest1155:test_maxProtocolReward() (gas: 16863) TestQuest1155:test_pause() (gas: 41906) TestQuest1155:test_queue() (gas: 72943) -TestQuest1155:test_singleClaim() (gas: 178257) +TestQuest1155:test_singleClaim() (gas: 141727) TestQuest1155:test_unpause() (gas: 31710) TestQuest1155:test_withdrawRemainingTokens() (gas: 135331) -TestQuest:test_RevertIf_initialize_EndTimeInPast() (gas: 1627078) -TestQuest:test_RevertIf_initialize_EndTimeLessThanOrEqualToStartTime() (gas: 1624465) +TestQuest:test_RevertIf_initialize_EndTimeInPast() (gas: 1605829) +TestQuest:test_RevertIf_initialize_EndTimeLessThanOrEqualToStartTime() (gas: 1603216) TestQuest:test_RevertIf_pause_Unauthorized() (gas: 13586) TestQuest:test_RevertIf_refund_InvalidRefundToken() (gas: 20441) TestQuest:test_RevertIf_refund_Unauthorized() (gas: 15804) -TestQuest:test_RevertIf_singleClaim_NotQuestFactory() (gas: 29685) -TestQuest:test_RevertIf_singleClaim_NotStarted() (gas: 25863) -TestQuest:test_RevertIf_singleClaim_whenNotPaused() (gas: 54588) +TestQuest:test_RevertIf_singleClaim_NotQuestFactory() (gas: 24632) +TestQuest:test_RevertIf_singleClaim_NotStarted() (gas: 25085) +TestQuest:test_RevertIf_singleClaim_whenNotPaused() (gas: 45285) TestQuest:test_RevertIf_unpause_Unauthorized() (gas: 13518) TestQuest:test_RevertIf_withdrawRemainingToken_AlreadyWithdrawn() (gas: 80211) TestQuest:test_RevertIf_withdrawRemainingToken_NotEnded() (gas: 16012) -TestQuest:test_fuzz_protocolFee(uint256) (runs: 256, μ: 56759, ~: 56898) +TestQuest:test_fuzz_protocolFee(uint256) (runs: 256, μ: 56756, ~: 56898) TestQuest:test_fuzz_receiptRedeemers(uint256) (runs: 256, μ: 42665, ~: 43754) -TestQuest:test_fuzz_singleClaim(uint256,uint256,uint256,uint256) (runs: 256, μ: 2573351, ~: 2573889) -TestQuest:test_fuzz_withdrawRemainingTokens(uint16,uint256,uint256,uint16) (runs: 256, μ: 7360502, ~: 7299071) +TestQuest:test_fuzz_singleClaim(uint256,uint256,uint256,uint256) (runs: 256, μ: 2551752, ~: 2552334) +TestQuest:test_fuzz_withdrawRemainingTokens(uint16,uint256,uint256,uint16) (runs: 256, μ: 7299328, ~: 7282240) TestQuest:test_getRewardAmount() (gas: 12406) TestQuest:test_getRewardToken() (gas: 12619) TestQuest:test_initialize() (gas: 66477) @@ -57,30 +57,30 @@ TestQuest:test_maxProtocolReward() (gas: 22294) TestQuest:test_maxTotalRewards() (gas: 16953) TestQuest:test_pause() (gas: 39825) TestQuest:test_refund() (gas: 630202) -TestQuest:test_singleClaim() (gas: 96080) +TestQuest:test_singleClaim() (gas: 93710) TestQuest:test_singleClaim_stream() (gas: 210) TestQuest:test_totalTransferAmount() (gas: 19746) TestQuest:test_unpause() (gas: 29988) TestQuest:test_withdrawRemainingTokens() (gas: 131166) -TestQuestFactory:test_RevertIf_claim_AddressAlreadyMinted() (gas: 754092) +TestQuestFactory:test_RevertIf_claim_AddressAlreadyMinted() (gas: 753722) TestQuestFactory:test_RevertIf_claim_InvalidHash() (gas: 581117) TestQuestFactory:test_RevertIf_claim_InvalidMintFee() (gas: 575729) -TestQuestFactory:test_RevertIf_claim_QuestEnded() (gas: 629507) -TestQuestFactory:test_RevertIf_claim_QuestNotStarted() (gas: 628800) +TestQuestFactory:test_RevertIf_claim_QuestEnded() (gas: 629279) +TestQuestFactory:test_RevertIf_claim_QuestNotStarted() (gas: 628822) TestQuestFactory:test_RevertIf_create1155QuestAndQueue_MsgValueLessThanQuestNFTFee() (gas: 98029) TestQuestFactory:test_RevertIf_createQuestAndQueue_Erc20QuestAddressNotSet() (gas: 88780) TestQuestFactory:test_RevertIf_createQuestAndQueue_QuestIdUsed() (gas: 553462) TestQuestFactory:test_RevertIf_createQuestAndQueue_RewardNotAllowed() (gas: 67273) -TestQuestFactory:test_claim_with_bytes() (gas: 872112) -TestQuestFactory:test_claim_with_bytes_no_referrer() (gas: 826268) -TestQuestFactory:test_claim_with_claim1155Rewards_with_referrer() (gas: 755304) -TestQuestFactory:test_claim_with_claim1155Rewards_without_referrer() (gas: 712093) -TestQuestFactory:test_claim_with_claimRewards_with_referrer() (gas: 786342) -TestQuestFactory:test_claim_with_claimRewards_without_referrer() (gas: 743131) +TestQuestFactory:test_claim_with_bytes() (gas: 871742) +TestQuestFactory:test_claim_with_bytes_no_referrer() (gas: 825898) +TestQuestFactory:test_claim_with_claim1155Rewards_with_referrer() (gas: 747768) +TestQuestFactory:test_claim_with_claim1155Rewards_without_referrer() (gas: 704557) +TestQuestFactory:test_claim_with_claimRewards_with_referrer() (gas: 785972) +TestQuestFactory:test_claim_with_claimRewards_without_referrer() (gas: 742761) TestQuestFactory:test_create1155QuestAndQueue() (gas: 513118) TestQuestFactory:test_createERC20StreamQuest() (gas: 580611) TestQuestFactory:test_createQuestAndQueue() (gas: 558398) -TestQuestFactory:test_fuzz_claim(string,uint256,uint256) (runs: 256, μ: 817532, ~: 806154) +TestQuestFactory:test_fuzz_claim(string,uint256,uint256) (runs: 256, μ: 817197, ~: 805784) TestQuestFactory:test_initialize() (gas: 23408) TestQuestFactory:test_questData() (gas: 568436) TestRabbitHoleTickets:test_RevertIf_mint_OnlyMinter() (gas: 16218) diff --git a/contracts/Quest.sol b/contracts/Quest.sol index 5864b33c..dc6d717f 100644 --- a/contracts/Quest.sol +++ b/contracts/Quest.sol @@ -141,15 +141,13 @@ contract Quest is ReentrancyGuardUpgradeable, PausableUpgradeable, Ownable, IQue function singleClaim(address account_) external virtual - nonReentrant - onlyStarted - whenNotEnded whenNotPaused + whenNotEnded + onlyStarted onlyQuestFactory { - uint256 totalRedeemableRewards = rewardAmountInWei; - _transferRewards(account_, totalRedeemableRewards); redeemedTokens = redeemedTokens + 1; + _transferRewards(account_, rewardAmountInWei); } /// @notice Function to withdraw the remaining tokens in the contract, distributes the protocol fee and returns remaining tokens to owner diff --git a/contracts/Quest1155.sol b/contracts/Quest1155.sol index de3d13c4..cb3722b4 100644 --- a/contracts/Quest1155.sol +++ b/contracts/Quest1155.sol @@ -129,12 +129,10 @@ contract Quest1155 is ERC1155Holder, ReentrancyGuardUpgradeable, PausableUpgrade whenNotPaused whenNotEnded onlyStarted - onlyQueued onlyQuestFactory { redeemedTokens = redeemedTokens + 1; _transferRewards(account_, 1); - if (questFee > 0) protocolFeeRecipient.safeTransferETH(questFee); } /// @notice Unpauses the Quest diff --git a/contracts/QuestFactory.sol b/contracts/QuestFactory.sol index 73793695..33d7bb09 100644 --- a/contracts/QuestFactory.sol +++ b/contracts/QuestFactory.sol @@ -604,7 +604,7 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto IQuestOwnable questContract_ = IQuestOwnable(currentQuest.questAddress); currentQuest.addressMinted[claimData_.claimer] = true; - ++currentQuest.numberMinted; + ++currentQuest.numberMinted; // we can remove this and look at redeemedTokens on the Quest instead questContract_.singleClaim(claimData_.claimer); if (mintFee > 0) { diff --git a/test/Quest1155.t.sol b/test/Quest1155.t.sol index 5299e23a..be250d7a 100644 --- a/test/Quest1155.t.sol +++ b/test/Quest1155.t.sol @@ -177,7 +177,7 @@ contract TestQuest1155 is Test, Errors, Events { assertEq( protocolFeeRecipient.balance, - protocolFeeRecipientOGBalance + QUEST_FEE, + protocolFeeRecipientOGBalance, "participant should have received the reward in ETH" ); assertEq( diff --git a/test/QuestFactory.t.sol b/test/QuestFactory.t.sol index 4fe464cd..506de126 100644 --- a/test/QuestFactory.t.sol +++ b/test/QuestFactory.t.sol @@ -282,7 +282,7 @@ contract TestQuestFactory is Test, Errors, Events, TestUtils { // claim fee & nft quset fee rewards assertEq(questCreator.balance - questCreatorBeforeBalance, MINT_FEE / 3, "questCreator mint fee"); - assertEq(protocolFeeRecipient.balance, (MINT_FEE / 3) + NFT_QUEST_FEE, "protocolFeeRecipient mint fee"); + assertEq(protocolFeeRecipient.balance, (MINT_FEE / 3), "protocolFeeRecipient mint fee"); assertEq(referrer.balance, MINT_FEE / 3, "referrer mint fee"); } @@ -315,7 +315,7 @@ contract TestQuestFactory is Test, Errors, Events, TestUtils { // claim fee & nft quset fee rewards assertEq(questCreator.balance - questCreatorBeforeBalance, MINT_FEE / 3, "questCreator mint fee"); - assertEq(protocolFeeRecipient.balance, (MINT_FEE / 3) * 2 + NFT_QUEST_FEE, "protocolFeeRecipient mint fee"); + assertEq(protocolFeeRecipient.balance, (MINT_FEE / 3) * 2, "protocolFeeRecipient mint fee"); vm.stopPrank(); }