diff --git a/src/contracts/SafetyNet.sol b/src/contracts/SafetyNet.sol index 9061dbe..6646b50 100644 --- a/src/contracts/SafetyNet.sol +++ b/src/contracts/SafetyNet.sol @@ -279,8 +279,9 @@ contract SafetyNet is ISafetyNet, ReentrancyGuard, OwnableUpgradeable { emit WithdrawalContested(_requestId, _request.owner, block.timestamp); - // Check if consensus on contestation has been reached after this contestation - if (_request.contestCount > memberCount * threshold / PERCENTAGE_BASE) { + // Multiply contestCount by PERCENTAGE_BASE instead of dividing the + // right-hand side, so integer truncation cannot lower the threshold. + if (_request.contestCount * PERCENTAGE_BASE > memberCount * threshold) { isVetoed[_requestId] = true; // Vetoed because more than contestThreshold% of the members have contested emit WithdrawalVetoed(_requestId, _request.owner, block.timestamp); @@ -554,7 +555,7 @@ contract SafetyNet is ISafetyNet, ReentrancyGuard, OwnableUpgradeable { /// @dev Deducts `_amount` from a member’s withdrawable balance and the Safety Net’s total balance. /// Reverts with `NotWithdrawable` if balance is insufficient. - function _deduct(uint256 _safetyNetId, address _member, uint256 _amount) private { + function _deduct(uint256 _safetyNetId, address _member, uint256 _amount) internal { if (memberWithdrawableBalance[_safetyNetId][_member] < _amount) { revert NotWithdrawable(); } diff --git a/src/contracts/modification.txt b/src/contracts/modification.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/interfaces/ISafetyNet.sol b/src/interfaces/ISafetyNet.sol index e65aef2..3dc34d5 100644 --- a/src/interfaces/ISafetyNet.sol +++ b/src/interfaces/ISafetyNet.sol @@ -136,7 +136,7 @@ interface ISafetyNet { /// @notice Thrown when trying to create a duplicate Safety Net error AlreadyExists(); - /// @notice Thrown when a user is trying to contest a request that he has already contested + /// @notice Thrown when a member is trying to contest a request that they have already contested error AlreadyContestedByMember(); /// @notice Thrown when the Safety Net ID is not found @@ -214,7 +214,7 @@ interface ISafetyNet { /// @notice Thrown when epoch duration is invalid error InvalidEpochDuration(); - /// @notice Thrown when redeemeRatio is out of valid range + /// @notice Thrown when redeemRatio is out of valid range error InvalidRatio(); /// @notice Thrown when small withdraws limit is invalid