Skip to content

Commit

Permalink
chore: Reorder BorrowerOperations require functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bingen committed Sep 3, 2024
1 parent f713a97 commit 5a1eee7
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions contracts/src/BorrowerOperations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1300,49 +1300,6 @@ contract BorrowerOperations is LiquityBase, AddRemoveManagers, IBorrowerOperatio
return batchManager;
}

function _requireOrderedRange(uint256 _minInterestRate, uint256 _maxInterestRate) internal pure {
if (_minInterestRate >= _maxInterestRate) revert MinGeMax();
}

function _requireInterestRateInDelegateRange(uint256 _troveId, uint256 _annualInterestRate) internal view {
InterestIndividualDelegate memory individualDelegate = interestIndividualDelegateOf[_troveId];
if (individualDelegate.account != address(0)) {
_requireInterestRateInRange(
_annualInterestRate, individualDelegate.minInterestRate, individualDelegate.maxInterestRate
);
}
}

function _requireInterestRateInBatchManagerRange(address _interestBatchManagerAddress, uint256 _annualInterestRate)
internal
view
{
InterestBatchManager memory interestBatchManager = interestBatchManagers[_interestBatchManagerAddress];
_requireInterestRateInRange(
_annualInterestRate, interestBatchManager.minInterestRate, interestBatchManager.maxInterestRate
);
}

function _requireInterestRateInRange(
uint256 _annualInterestRate,
uint256 _minInterestRate,
uint256 _maxInterestRate
) internal pure {
if (_minInterestRate > _annualInterestRate || _annualInterestRate > _maxInterestRate) {
revert InterestNotInRange();
}
}

function _requireInterestRateChangePeriodPassed(
address _interestBatchManagerAddress,
uint256 _lastInterestRateAdjTime
) internal view {
InterestBatchManager memory interestBatchManager = interestBatchManagers[_interestBatchManagerAddress];
if (block.timestamp < _lastInterestRateAdjTime + uint256(interestBatchManager.minInterestRateChangePeriod)) {
revert BatchInterestRateChangePeriodNotPassed();
}
}

function _requireTroveIsOpen(ITroveManager _troveManager, uint256 _troveId) internal view {
ITroveManager.Status status = _troveManager.getTroveStatus(_troveId);
if (status != ITroveManager.Status.active && status != ITroveManager.Status.unredeemable) {
Expand Down Expand Up @@ -1479,6 +1436,49 @@ contract BorrowerOperations is LiquityBase, AddRemoveManagers, IBorrowerOperatio
}
}

function _requireOrderedRange(uint256 _minInterestRate, uint256 _maxInterestRate) internal pure {
if (_minInterestRate >= _maxInterestRate) revert MinGeMax();
}

function _requireInterestRateInDelegateRange(uint256 _troveId, uint256 _annualInterestRate) internal view {
InterestIndividualDelegate memory individualDelegate = interestIndividualDelegateOf[_troveId];
if (individualDelegate.account != address(0)) {
_requireInterestRateInRange(
_annualInterestRate, individualDelegate.minInterestRate, individualDelegate.maxInterestRate
);
}
}

function _requireInterestRateInBatchManagerRange(address _interestBatchManagerAddress, uint256 _annualInterestRate)
internal
view
{
InterestBatchManager memory interestBatchManager = interestBatchManagers[_interestBatchManagerAddress];
_requireInterestRateInRange(
_annualInterestRate, interestBatchManager.minInterestRate, interestBatchManager.maxInterestRate
);
}

function _requireInterestRateInRange(
uint256 _annualInterestRate,
uint256 _minInterestRate,
uint256 _maxInterestRate
) internal pure {
if (_minInterestRate > _annualInterestRate || _annualInterestRate > _maxInterestRate) {
revert InterestNotInRange();
}
}

function _requireInterestRateChangePeriodPassed(
address _interestBatchManagerAddress,
uint256 _lastInterestRateAdjTime
) internal view {
InterestBatchManager memory interestBatchManager = interestBatchManagers[_interestBatchManagerAddress];
if (block.timestamp < _lastInterestRateAdjTime + uint256(interestBatchManager.minInterestRateChangePeriod)) {
revert BatchInterestRateChangePeriodNotPassed();
}
}

function _requireValidInterestBatchManager(address _interestBatchManagerAddress) internal view {
if (interestBatchManagers[_interestBatchManagerAddress].maxInterestRate == 0) {
revert InvalidInterestBatchManager();
Expand Down

0 comments on commit 5a1eee7

Please sign in to comment.