Skip to content

Commit

Permalink
Fix/audit fixes round 8 (#37)
Browse files Browse the repository at this point in the history
* fix: unecessary additonal  assignment in compound interest calculation return

* fix: L-9. recallWindow > 0 isn’t enforced

* fix: reuse error messages

* fix: gas optimizations for assignments
  • Loading branch information
dangerousfood authored Jan 25, 2024
1 parent d760601 commit 5703cd2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lib/AstariaV1Lib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ library AstariaV1Lib {
int256 exponent = int256((rate * baseAdjustment * delta_t) / 365 days);
amount *= baseAdjustment;
uint256 result = amount.mulWad(uint256(exponent.expWad())) - amount;
return result /= baseAdjustment;
return result / baseAdjustment;
}
int256 exponent = int256((rate * delta_t) / 365 days);
return amount.mulWad(uint256(exponent.expWad())) - amount;
Expand Down
5 changes: 2 additions & 3 deletions src/settlement/AstariaV1Settlement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ contract AstariaV1Settlement is DutchAuctionSettlement {

error LoanNotRecalled();
error NoAuction();
error AuctionStartBeforeNow();

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTRUCTOR */
Expand Down Expand Up @@ -139,14 +138,14 @@ contract AstariaV1Settlement is DutchAuctionSettlement {
}

if (recaller == loan.issuer) {
return (new ReceivedItem[](0), recaller);
return (consideration, recaller);
}

start = _getAuctionStart(loan, recallStart);
}

if (block.timestamp < start) {
revert AuctionStartBeforeNow();
revert AuctionNotStarted();
}

Details memory details = abi.decode(loan.terms.settlementData, (Details));
Expand Down
2 changes: 1 addition & 1 deletion src/status/AstariaV1Status.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract AstariaV1Status is BaseStatus, BaseRecall, Ownable {
bool valid = true;
if (
details.recallerRewardRatio > 10 ** pDetails.decimals || details.recallMax > 10 * 10 ** pDetails.decimals
|| !isValidPricing[loan.terms.pricing] || details.recallMax == 0
|| !isValidPricing[loan.terms.pricing] || details.recallMax == 0 || details.recallWindow == 0
) {
valid = false;
}
Expand Down

0 comments on commit 5703cd2

Please sign in to comment.