From 6ae27d92c321ab3454f62b47120746456e59ee45 Mon Sep 17 00:00:00 2001 From: MathisGD Date: Mon, 5 Feb 2024 16:22:18 +0100 Subject: [PATCH] refactor: remove errors from lib --- src/FixedRateIrm.sol | 12 +++++++++--- src/libraries/ErrorsLib.sol | 6 ------ test/forge/FixedRateIrmTest.sol | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/FixedRateIrm.sol b/src/FixedRateIrm.sol index a2dc61e1..1a810224 100644 --- a/src/FixedRateIrm.sol +++ b/src/FixedRateIrm.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.19; import {IIrm} from "../lib/morpho-blue/src/interfaces/IIrm.sol"; import {IFixedRateIrm} from "./interfaces/IFixedRateIrm.sol"; -import {ErrorsLib} from "./libraries/ErrorsLib.sol"; import {MarketParamsLib} from "../lib/morpho-blue/src/libraries/MarketParamsLib.sol"; import {Id, MarketParams, Market} from "../lib/morpho-blue/src/interfaces/IMorpho.sol"; @@ -19,6 +18,13 @@ contract FixedRateIrm is IFixedRateIrm { /// @notice Emitted when a borrow rate is set. event SetBorrowRate(Id indexed id, uint256 newBorrowRate); + /* ERRORS */ + + /// @dev Thrown when the rate is already set for this market. + string public constant RATE_ALREADY_SET = "rate already set"; + /// @dev Thrown when trying to set the rate at zero. + string public constant RATE_ZERO = "rate zero"; + /* STORAGE */ /// @notice Borrow rates. @@ -28,8 +34,8 @@ contract FixedRateIrm is IFixedRateIrm { /// @inheritdoc IFixedRateIrm function setBorrowRate(Id id, uint256 newBorrowRate) external { - require(_borrowRate[id] == 0, ErrorsLib.RATE_ALREADY_SET); - require(newBorrowRate != 0, ErrorsLib.RATE_ZERO); + require(_borrowRate[id] == 0, RATE_ALREADY_SET); + require(newBorrowRate != 0, RATE_ZERO); _borrowRate[id] = newBorrowRate; diff --git a/src/libraries/ErrorsLib.sol b/src/libraries/ErrorsLib.sol index 579edde2..5cb2c632 100644 --- a/src/libraries/ErrorsLib.sol +++ b/src/libraries/ErrorsLib.sol @@ -11,10 +11,4 @@ library ErrorsLib { /// @dev Thrown when the caller is not Morpho. string internal constant NOT_MORPHO = "not Morpho"; - - /// @dev Thrown when the rate is already set for this market. - string internal constant RATE_ALREADY_SET = "rate already set"; - - /// @dev Thrown when trying to set the rate at zero. - string internal constant RATE_ZERO = "rate zero"; } diff --git a/test/forge/FixedRateIrmTest.sol b/test/forge/FixedRateIrmTest.sol index d060afd6..b878a413 100644 --- a/test/forge/FixedRateIrmTest.sol +++ b/test/forge/FixedRateIrmTest.sol @@ -35,12 +35,12 @@ contract FixedRateIrmTest is Test { vm.assume(newBorrowRate1 != 0); vm.assume(newBorrowRate2 != 0); fixedRateIrm.setBorrowRate(id, newBorrowRate1); - vm.expectRevert(bytes(ErrorsLib.RATE_ALREADY_SET)); + vm.expectRevert("rate already set"); fixedRateIrm.setBorrowRate(id, newBorrowRate2); } function testSetBorrowRateRateZero(Id id) external { - vm.expectRevert(bytes(ErrorsLib.RATE_ZERO)); + vm.expectRevert("rate zero"); fixedRateIrm.setBorrowRate(id, 0); }