Skip to content

Commit

Permalink
fix: check morpho zero address
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed Oct 31, 2023
1 parent a0f0539 commit 60e588a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SpeedJumpIrm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ contract AdaptativeCurveIRM is IIrm {
uint256 targetUtilization,
uint256 initialBaseRate
) {
require(morpho != address(0), ErrorsLib.ZERO_ADDRESS);
require(curveSteepness <= uint256(type(int256).max), ErrorsLib.INPUT_TOO_LARGE);
require(curveSteepness >= WAD, ErrorsLib.INPUT_TOO_SMALL);
require(adjustmentSpeed <= uint256(type(int256).max), ErrorsLib.INPUT_TOO_LARGE);
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/ErrorsLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ library ErrorsLib {

/// @dev Thrown when the input is too small.
string internal constant INPUT_TOO_SMALL = "input too small";

/// @dev Thrown when passing the zero address.
string internal constant ZERO_ADDRESS = "zero address";

/// @dev Thrown when passing the zero input.
string internal constant ZERO_INPUT = "zero input";
Expand Down
5 changes: 5 additions & 0 deletions test/SpeedJumpIrmTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ contract AdaptativeCurveIRMTest is Test {
vm.warp(90 days);
}

function testDeployment() public {
vm.expectRevert(bytes(ErrorsLib.ZERO_ADDRESS));
new AdaptativeCurveIRM(address(0), 0, 0, 0, 0);
}

function testFirstBorrowRateEmptyMarket() public {
Market memory market;
uint256 avgBorrowRate = irm.borrowRate(marketParams, market);
Expand Down

0 comments on commit 60e588a

Please sign in to comment.