From 9e0d26f76556e94cbeeab946cba2fb9f16502c5d Mon Sep 17 00:00:00 2001 From: Sergey <2901744+evercoinx@users.noreply.github.com.> Date: Mon, 14 Oct 2024 10:07:31 +0300 Subject: [PATCH] Fix Bailsec Issue_16 --- contracts/MaticX.sol | 8 ++++++-- test/MaticX.spec.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/contracts/MaticX.sol b/contracts/MaticX.sol index 8b99da67..b49a56de 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 = 15; 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 15" + ); uint256[] memory validatorIds = validatorRegistry.getValidators(); uint256 validatorIdCount = validatorIds.length; diff --git a/test/MaticX.spec.ts b/test/MaticX.spec.ts index a10f41fa..ad3b4475 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 = 15; 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(16); await expect(promise).to.be.revertedWith( - "Fee percent must not exceed 100" + "Fee percent must not exceed 15" ); }); });