Skip to content

Commit

Permalink
fix: nit checks (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangerousfood authored Feb 6, 2024
1 parent 0e6a228 commit e746129
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/enforcers/AstariaV1BorrowerEnforcer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ contract AstariaV1BorrowerEnforcer is CaveatEnforcer {
error InvalidAdditionalTransfer();
error LoanAmountOutOfBounds();
error LoanRateExceedsCurrentRate();
error StartRateExceedsEndRate();
error MinAmountExceedsMaxAmount();

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STRUCTS */
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e746129

Please sign in to comment.