diff --git a/contracts/MaticX.sol b/contracts/MaticX.sol index 8b99da67..e6f16cce 100644 --- a/contracts/MaticX.sol +++ b/contracts/MaticX.sol @@ -26,6 +26,7 @@ contract MaticX is using StringsUpgradeable for string; bytes32 public constant BOT = keccak256("BOT"); + uint256 private constant MAX_FEE_PERCENT = 20; uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; @@ -477,12 +478,15 @@ contract MaticX is /// ------------------------------ Setters --------------------------------- /// @notice Sets a fee percent. - /// @param _feePercent - Fee percent (10 = 10%) + /// @param _feePercent - Fee percent (1 = 1%) // slither-disable-next-line reentrancy-eth function setFeePercent( uint8 _feePercent ) external override nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) { - require(_feePercent <= 100, "Fee percent must not exceed 100"); + require( + _feePercent <= MAX_FEE_PERCENT, + "Fee percent must not exceed 20" + ); uint256[] memory validatorIds = validatorRegistry.getValidators(); uint256 validatorIdCount = validatorIds.length; diff --git a/test/MaticX.spec.ts b/test/MaticX.spec.ts index a10f41fa..5e50db0e 100644 --- a/test/MaticX.spec.ts +++ b/test/MaticX.spec.ts @@ -31,7 +31,7 @@ describe("MaticX", function () { const stakeAmount = ethers.utils.parseUnits("100", 18); const tripleStakeAmount = stakeAmount.mul(3); const version = "2"; - const feePercent = 10; + const feePercent = 20; async function deployFixture(callMaticXInitializeV2 = true) { await reset(providerUrl, envVars.FORKING_BLOCK_NUMBER); @@ -2444,7 +2444,9 @@ describe("MaticX", function () { const { maticX, stakerA, defaultAdminRole } = await loadFixture(deployFixture); - const promise = maticX.connect(stakerA).setFeePercent(100); + const promise = maticX + .connect(stakerA) + .setFeePercent(feePercent); await expect(promise).to.be.revertedWith( `AccessControl: account ${stakerA.address.toLowerCase()} is missing role ${defaultAdminRole}` ); @@ -2453,9 +2455,9 @@ describe("MaticX", function () { it("Should revert with the right error if passing a too high fee percent", async function () { const { maticX, manager } = await loadFixture(deployFixture); - const promise = maticX.connect(manager).setFeePercent(101); + const promise = maticX.connect(manager).setFeePercent(21); await expect(promise).to.be.revertedWith( - "Fee percent must not exceed 100" + "Fee percent must not exceed 20" ); }); });