diff --git a/contracts/CToken.sol b/contracts/CToken.sol index 719918e88..6491d1ca4 100644 --- a/contracts/CToken.sol +++ b/contracts/CToken.sol @@ -470,7 +470,7 @@ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew); // Attempt to add interest checkpoint - address(interestRateModel).call(abi.encodeWithSignature("checkpointInterest(uint256)", borrowRateMantissa)); + if (interestRateModelReactive) address(interestRateModel).call(abi.encodeWithSignature("checkpointInterest(uint256)", borrowRateMantissa)); return uint(Error.NO_ERROR); } @@ -1503,10 +1503,11 @@ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel); // Attempt to reset interest checkpoints on old IRM - if (address(oldInterestRateModel) != address(0)) address(oldInterestRateModel).call(abi.encodeWithSignature("resetInterestCheckpoints()")); + if (interestRateModelReactive) address(oldInterestRateModel).call(abi.encodeWithSignature("resetInterestCheckpoints()")); // Attempt to add first interest checkpoint on new IRM - address(newInterestRateModel).call(abi.encodeWithSignature("checkpointInterest()")); + (bool success, ) = address(newInterestRateModel).call(abi.encodeWithSignature("checkpointInterest()")); + interestRateModelReactive = success; return uint(Error.NO_ERROR); } diff --git a/contracts/CTokenInterfaces.sol b/contracts/CTokenInterfaces.sol index 3caeb60be..2b48dfa4a 100644 --- a/contracts/CTokenInterfaces.sol +++ b/contracts/CTokenInterfaces.sol @@ -157,6 +157,16 @@ contract CTokenStorage is CTokenAdminStorage { * @notice Share of seized collateral that is added to reserves */ uint public constant protocolSeizeShareMantissa = 2.8e16; //2.8% + + /** + * @notice Underlying asset for this CToken + */ + address public underlying; + + /** + * @notice Whether or not the interestRateModel is reactive. + */ + bool public interestRateModelReactive; } contract CTokenInterface is CTokenStorage { @@ -284,15 +294,7 @@ contract CTokenInterface is CTokenStorage { function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint); } -contract CErc20Storage { - /** - * @notice Underlying asset for this CToken - */ - address public underlying; -} - -contract CErc20Interface is CErc20Storage { - +contract CErc20Interface { /*** User Interface ***/ function mint(uint mintAmount) external returns (uint); @@ -302,10 +304,9 @@ contract CErc20Interface is CErc20Storage { function repayBorrow(uint repayAmount) external returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint); - } -contract CEtherInterface is CErc20Storage { +contract CEtherInterface { /** * @notice Indicator that this is a CEther contract (for inspection) */