Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nit checks #48

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading