diff --git a/contracts/QuestFactory.sol b/contracts/QuestFactory.sol index 1741bb26..08b66103 100644 --- a/contracts/QuestFactory.sol +++ b/contracts/QuestFactory.sol @@ -904,18 +904,20 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto function processMintFee(address ref_, address mintFeeRecipient_, string memory questId_) private returns (string memory) { returnChange(); uint256 cachedMintFee = mintFee; - uint256 oneThirdMintfee = cachedMintFee / 3; + require(cachedMintFee > 0, "Zero mint fee"); + + uint256 oneThirdMintfee = (cachedMintFee * 1000) / 3000; // More precise division uint256 protocolPayout; uint256 mintPayout; uint256 referrerPayout; if(ref_ == address(0)){ protocolPayout = oneThirdMintfee * 2; - mintPayout = oneThirdMintfee; + mintPayout = cachedMintFee - protocolPayout; // The remainder goes to mintPayout } else { protocolPayout = oneThirdMintfee; mintPayout = oneThirdMintfee; - referrerPayout = oneThirdMintfee; + referrerPayout = cachedMintFee - (protocolPayout + mintPayout); // The remainder goes to referrerPayout } protocolFeeRecipient.safeTransferETH(protocolPayout); @@ -1019,4 +1021,4 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto // Fallback function to receive ETH when other functions are not available fallback() external payable {} -} \ No newline at end of file +}