Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/docs/natspec-in-interface' into …
Browse files Browse the repository at this point in the history
…fix/bound-rate
  • Loading branch information
MathisGD committed Mar 4, 2024
2 parents 3e435cd + 73f9975 commit 9e1c932
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/fixed-rate-irm/FixedRateIrm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,19 @@ string constant RATE_TOO_HIGH = "rate too high";
contract FixedRateIrm is IFixedRateIrm {
using MarketParamsLib for MarketParams;

/* EVENTS */

/// @notice Emitted when a borrow rate is set.
event SetBorrowRate(Id indexed id, uint256 newBorrowRate);

/* CONSTANTS */

/// @notice Max settable borrow rate (800%).
/// @inheritdoc IFixedRateIrm
uint256 public constant MAX_BORROW_RATE = 8.0 ether / uint256(365 days);

/* STORAGE */

/// @notice Borrow rates.
/// @inheritdoc IFixedRateIrm
mapping(Id => uint256) public borrowRateStored;

/* SETTER */

/// @notice Sets the borrow rate for a market.
/// @dev A rate can be set by anybody, but only once.
/// @dev `borrowRate` reverts on rate not set, so the rate needs to be set before the market creation.
/// @dev As interest are rounded down in Morpho, for markets with a low total borrow, setting a rate too low could
/// prevent interest from accruing if interactions are frequent.
/// @inheritdoc IFixedRateIrm
function setBorrowRate(Id id, uint256 newBorrowRate) external {
require(borrowRateStored[id] == 0, RATE_SET);
require(newBorrowRate != 0, RATE_ZERO);
Expand Down
17 changes: 17 additions & 0 deletions src/fixed-rate-irm/interfaces/IFixedRateIrm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ import {Id} from "../../../lib/morpho-blue/src/interfaces/IMorpho.sol";
/// @author Morpho Labs
/// @custom:contact security@morpho.org
interface IFixedRateIrm is IIrm {
/* EVENTS */

/// @notice Emitted when a borrow rate is set.
event SetBorrowRate(Id indexed id, uint256 newBorrowRate);

/* EXTERNAL */

/// @notice Max settable borrow rate (800%).
function MAX_BORROW_RATE() external returns (uint256);

/// @notice Borrow rates.
function borrowRateStored(Id id) external returns (uint256);

/// @notice Sets the borrow rate for a market.
/// @dev A rate can be set by anybody, but only once.
/// @dev `borrowRate` reverts on rate not set, so the rate needs to be set before the market creation.
/// @dev As interest are rounded down in Morpho, for markets with a low total borrow, setting a rate too low could
/// prevent interest from accruing if interactions are frequent.
function setBorrowRate(Id id, uint256 newBorrowRate) external;
}

0 comments on commit 9e1c932

Please sign in to comment.