diff --git a/contracts/domain/BosonConstants.sol b/contracts/domain/BosonConstants.sol index 157a5324b..00925fd24 100644 --- a/contracts/domain/BosonConstants.sol +++ b/contracts/domain/BosonConstants.sol @@ -11,6 +11,9 @@ bytes32 constant CLIENT = keccak256("CLIENT"); // Role for clients of the Protoc bytes32 constant UPGRADER = keccak256("UPGRADER"); // Role for performing contract and config upgrades bytes32 constant FEE_COLLECTOR = keccak256("FEE_COLLECTOR"); // Role for collecting fees from the protocol +// Generic +uint256 constant HUNDRED_PERCENT = 10000; // 100% in basis points + // Pause Handler uint256 constant ALL_REGIONS_MASK = (1 << (uint256(type(BosonTypes.PausableRegion).max) + 1)) - 1; diff --git a/contracts/protocol/bases/OfferBase.sol b/contracts/protocol/bases/OfferBase.sol index 4332cc416..34df901fa 100644 --- a/contracts/protocol/bases/OfferBase.sol +++ b/contracts/protocol/bases/OfferBase.sol @@ -191,7 +191,7 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents { disputeResolutionTerms.feeAmount = feeAmount; disputeResolutionTerms.buyerEscalationDeposit = (feeAmount * fees.buyerEscalationDepositPercentage) / - 10000; + HUNDRED_PERCENT; } protocolEntities().disputeResolutionTerms[_offer.id] = disputeResolutionTerms; } @@ -236,9 +236,9 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents { uint256 protocolFee = getProtocolFee(_offer.exchangeToken, offerPrice); // Calculate the agent fee amount - uint256 agentFeeAmount = (agent.feePercentage * offerPrice) / 10000; + uint256 agentFeeAmount = (agent.feePercentage * offerPrice) / HUNDRED_PERCENT; - uint256 totalOfferFeeLimit = (limits.maxTotalOfferFeePercentage * offerPrice) / 10000; + uint256 totalOfferFeeLimit = (limits.maxTotalOfferFeePercentage * offerPrice) / HUNDRED_PERCENT; // Sum of agent fee amount and protocol fee amount should be <= offer fee limit and less that fee limit set by seller uint256 totalFeeAmount = agentFeeAmount + protocolFee; diff --git a/contracts/protocol/bases/ProtocolBase.sol b/contracts/protocol/bases/ProtocolBase.sol index 369a3ad25..3ed3ac111 100644 --- a/contracts/protocol/bases/ProtocolBase.sol +++ b/contracts/protocol/bases/ProtocolBase.sol @@ -698,7 +698,7 @@ abstract contract ProtocolBase is PausableBase, ReentrancyGuardBase, BosonErrors return _exchangeToken == protocolAddresses().token ? protocolFees().flatBoson - : (protocolFees().percentage * _price) / 10000; + : (protocolFees().percentage * _price) / HUNDRED_PERCENT; } /** diff --git a/contracts/protocol/clients/voucher/BosonVoucher.sol b/contracts/protocol/clients/voucher/BosonVoucher.sol index f0f2ee8e5..039238e23 100644 --- a/contracts/protocol/clients/voucher/BosonVoucher.sol +++ b/contracts/protocol/clients/voucher/BosonVoucher.sol @@ -634,7 +634,7 @@ contract BosonVoucherBase is IBosonVoucher, BeaconClientBase, OwnableUpgradeable !isPreminted ); - royaltyAmount = (_salePrice * royaltyPercentage) / 10000; + royaltyAmount = (_salePrice * royaltyPercentage) / HUNDRED_PERCENT; } /** diff --git a/contracts/protocol/facets/ConfigHandlerFacet.sol b/contracts/protocol/facets/ConfigHandlerFacet.sol index 53e0d4eb9..d81f736fe 100644 --- a/contracts/protocol/facets/ConfigHandlerFacet.sol +++ b/contracts/protocol/facets/ConfigHandlerFacet.sol @@ -555,6 +555,6 @@ contract ConfigHandlerFacet is IBosonConfigHandler, ProtocolBase { * Reverts if the value more than 10000 */ function checkMaxPercententage(uint256 _percentage) internal pure { - if (_percentage > 10000) revert InvalidFeePercentage(); + if (_percentage > HUNDRED_PERCENT) revert InvalidFeePercentage(); } } diff --git a/contracts/protocol/facets/DisputeHandlerFacet.sol b/contracts/protocol/facets/DisputeHandlerFacet.sol index f84e2a15c..365a915cc 100644 --- a/contracts/protocol/facets/DisputeHandlerFacet.sol +++ b/contracts/protocol/facets/DisputeHandlerFacet.sol @@ -238,7 +238,7 @@ contract DisputeHandlerFacet is DisputeBase, IBosonDisputeHandler { uint8 _sigV ) external override nonReentrant { // buyer should get at most 100% - if (_buyerPercent > 10000) revert InvalidBuyerPercent(); + if (_buyerPercent > HUNDRED_PERCENT) revert InvalidBuyerPercent(); // Get the exchange, should be in disputed state (Exchange storage exchange, ) = getValidExchange(_exchangeId, ExchangeState.Disputed); @@ -340,7 +340,7 @@ contract DisputeHandlerFacet is DisputeBase, IBosonDisputeHandler { */ function decideDispute(uint256 _exchangeId, uint256 _buyerPercent) external override nonReentrant { // Buyer should get at most 100% - if (_buyerPercent > 10000) revert InvalidBuyerPercent(); + if (_buyerPercent > HUNDRED_PERCENT) revert InvalidBuyerPercent(); // Make sure the dispute is valid and the caller is the dispute resolver (Exchange storage exchange, Dispute storage dispute, DisputeDates storage disputeDates) = disputeResolverChecks( diff --git a/contracts/protocol/facets/PriceDiscoveryHandlerFacet.sol b/contracts/protocol/facets/PriceDiscoveryHandlerFacet.sol index b4fc00eaa..9c4ef038d 100644 --- a/contracts/protocol/facets/PriceDiscoveryHandlerFacet.sol +++ b/contracts/protocol/facets/PriceDiscoveryHandlerFacet.sol @@ -122,7 +122,7 @@ contract PriceDiscoveryHandlerFacet is IBosonPriceDiscoveryHandler, PriceDiscove { // Calculate royalties (RoyaltyInfo storage royaltyInfo, uint256 royaltyInfoIndex, ) = fetchRoyalties(offerId, false); - uint256 royaltyAmount = (getTotalRoyaltyPercentage(royaltyInfo.bps) * actualPrice) / 10000; + uint256 royaltyAmount = (getTotalRoyaltyPercentage(royaltyInfo.bps) * actualPrice) / HUNDRED_PERCENT; // Verify that fees and royalties are not higher than the price. if (protocolFeeAmount + royaltyAmount > actualPrice) revert FeeAmountTooHigh(); diff --git a/contracts/protocol/facets/SequentialCommitHandlerFacet.sol b/contracts/protocol/facets/SequentialCommitHandlerFacet.sol index e13b46437..270ab9c73 100644 --- a/contracts/protocol/facets/SequentialCommitHandlerFacet.sol +++ b/contracts/protocol/facets/SequentialCommitHandlerFacet.sol @@ -126,7 +126,7 @@ contract SequentialCommitHandlerFacet is IBosonSequentialCommitHandler, PriceDis (royaltyInfo, exchangeCost.royaltyInfoIndex, ) = fetchRoyalties(offerId, false); exchangeCost.royaltyAmount = (getTotalRoyaltyPercentage(royaltyInfo.bps) * exchangeCost.price) / - 10000; + HUNDRED_PERCENT; } // Verify that fees and royalties are not higher than the price. diff --git a/contracts/protocol/libs/FundsLib.sol b/contracts/protocol/libs/FundsLib.sol index 9c2848fc7..5fbd7738f 100644 --- a/contracts/protocol/libs/FundsLib.sol +++ b/contracts/protocol/libs/FundsLib.sol @@ -175,7 +175,7 @@ library FundsLib { } else { // RESOLVED or DECIDED uint256 pot = price + sellerDeposit + buyerEscalationDeposit; - buyerPayoff = (pot * dispute.buyerPercent) / 10000; + buyerPayoff = (pot * dispute.buyerPercent) / HUNDRED_PERCENT; sellerPayoff = pot - buyerPayoff; } } @@ -257,7 +257,7 @@ library FundsLib { { if (_exchangeState == BosonTypes.ExchangeState.Completed) { // COMPLETED, buyer pays full price - effectivePriceMultiplier = 10000; + effectivePriceMultiplier = HUNDRED_PERCENT; } else if ( _exchangeState == BosonTypes.ExchangeState.Revoked || _exchangeState == BosonTypes.ExchangeState.Canceled @@ -272,13 +272,13 @@ library FundsLib { if (disputeState == BosonTypes.DisputeState.Retracted) { // RETRACTED - same as "COMPLETED" - effectivePriceMultiplier = 10000; + effectivePriceMultiplier = HUNDRED_PERCENT; } else if (disputeState == BosonTypes.DisputeState.Refused) { // REFUSED, buyer pays nothing effectivePriceMultiplier = 0; } else { // RESOLVED or DECIDED - effectivePriceMultiplier = 10000 - dispute.buyerPercent; + effectivePriceMultiplier = HUNDRED_PERCENT - dispute.buyerPercent; } } } @@ -318,9 +318,9 @@ library FundsLib { ( reducedSecondaryPrice > resellerBuyPrice ? effectivePriceMultiplier * (reducedSecondaryPrice - resellerBuyPrice) - : (10000 - effectivePriceMultiplier) * (resellerBuyPrice - reducedSecondaryPrice) + : (HUNDRED_PERCENT - effectivePriceMultiplier) * (resellerBuyPrice - reducedSecondaryPrice) ) / - 10000; + HUNDRED_PERCENT; resellerBuyPrice = price; } @@ -341,7 +341,7 @@ library FundsLib { } // protocolFee and sellerRoyalties can be multiplied by effectivePriceMultiplier just at the end - protocolFee = (protocolFee * effectivePriceMultiplier) / 10000; + protocolFee = (protocolFee * effectivePriceMultiplier) / HUNDRED_PERCENT; } /** @@ -561,10 +561,10 @@ library FundsLib { BosonTypes.RoyaltyInfo storage _royaltyInfo = _offer.royaltyInfo[_royaltyInfoIndex]; uint256 len = _royaltyInfo.recipients.length; uint256 totalAmount; - uint256 effectivePrice = (_price * _effectivePriceMultiplier) / 10000; + uint256 effectivePrice = (_price * _effectivePriceMultiplier) / HUNDRED_PERCENT; for (uint256 i = 0; i < len; ) { address payable recipient = _royaltyInfo.recipients[i]; - uint256 amount = (_royaltyInfo.bps[i] * effectivePrice) / 10000; + uint256 amount = (_royaltyInfo.bps[i] * effectivePrice) / HUNDRED_PERCENT; totalAmount += amount; if (recipient == address(0)) { // goes to seller's treasury @@ -580,6 +580,6 @@ library FundsLib { } // if there is a remainder due to rounding, it goes to the seller's treasury - sellerRoyalties += (_effectivePriceMultiplier * _escrowedRoyaltyAmount) / 10000 - totalAmount; + sellerRoyalties += (_effectivePriceMultiplier * _escrowedRoyaltyAmount) / HUNDRED_PERCENT - totalAmount; } }