From e7461290751eabf78bae4c75f6d3389d58795da8 Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Tue, 6 Feb 2024 10:56:26 -0600 Subject: [PATCH] fix: nit checks (#48) --- src/enforcers/AstariaV1BorrowerEnforcer.sol | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/enforcers/AstariaV1BorrowerEnforcer.sol b/src/enforcers/AstariaV1BorrowerEnforcer.sol index 51478c9..08227ae 100644 --- a/src/enforcers/AstariaV1BorrowerEnforcer.sol +++ b/src/enforcers/AstariaV1BorrowerEnforcer.sol @@ -31,6 +31,8 @@ contract AstariaV1BorrowerEnforcer is CaveatEnforcer { error InvalidAdditionalTransfer(); error LoanAmountOutOfBounds(); error LoanRateExceedsCurrentRate(); + error StartRateExceedsEndRate(); + error MinAmountExceedsMaxAmount(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STRUCTS */ @@ -86,6 +88,10 @@ contract AstariaV1BorrowerEnforcer is CaveatEnforcer { Details memory details = abi.decode(caveatData, (Details)); + if (details.maxAmount < details.minAmount) { + revert MinAmountExceedsMaxAmount(); + } + if (loanAmount < details.minAmount || loanAmount > details.maxAmount) { // Debt amount is less than the current caveat amount revert LoanAmountOutOfBounds(); @@ -125,6 +131,9 @@ contract AstariaV1BorrowerEnforcer is CaveatEnforcer { function _locateCurrentRate(Details memory details) internal view returns (uint256 currentRate) { uint256 endRate = AstariaV1Lib.getBasePricingRate(details.loan.terms.pricingData); + if (endRate < details.startRate) { + revert StartRateExceedsEndRate(); + } // if endRate == startRate, or startTime == endTime, or block.timestamp > endTime if (endRate == details.startRate || details.startTime == details.endTime || block.timestamp > details.endTime) { return endRate;