sherlock-audit / 2023-01-ajna-judging

1 stars 0 forks source link

Jeiwan - Pools cannot be deployed with the interest rate set to the minimal or the maximal value #153

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

Jeiwan

medium

Pools cannot be deployed with the interest rate set to the minimal or the maximal value

Summary

Pool deployment reverts if the interest rate is the minimal or the maximal one.

Vulnerability Detail

PoolDeployer defines the minimal and maximal interest rates as follows:

uint256 public constant MIN_RATE = 0.01 * 1e18;
uint256 public constant MAX_RATE = 0.1  * 1e18;

However, trying to deploy a pool with MIN_RATE or MAX_RATE will always revert due to this check in the checkDeploy modifier:

if (MIN_RATE >= interestRate_ || interestRate_ >= MAX_RATE)         revert IPoolFactory.PoolInterestRateInvalid();

Impact

Users cannot deploy pools with the minimal or the maximal interest rate.

Code Snippet

PoolDeployer.sol#L13-L14 PoolDeployer.sol#L41

Tool used

Manual Review

Recommendation

Consider this change:

diff --git a/contracts/src/base/PoolDeployer.sol b/contracts/src/base/PoolDeployer.sol
index ffb433a..948c60a 100644
--- a/contracts/src/base/PoolDeployer.sol
+++ b/contracts/src/base/PoolDeployer.sol
@@ -38,7 +38,7 @@ abstract contract PoolDeployer {
     modifier canDeploy(bytes32 subsetHash_, address collateral_, address quote_, uint256 interestRate_) {
         if (collateral_ == address(0) || quote_ == address(0))              revert IPoolFactory.DeployWithZeroAddress();
         if (deployedPools[subsetHash_][collateral_][quote_] != address(0)) revert IPoolFactory.PoolAlreadyExists();
-        if (MIN_RATE >= interestRate_ || interestRate_ >= MAX_RATE)         revert IPoolFactory.PoolInterestRateInvalid();
+        if (MIN_RATE > interestRate_ || interestRate_ > MAX_RATE)         revert IPoolFactory.PoolInterestRateInvalid();
         _;
     }