Skip to content

Commit

Permalink
Add one more check
Browse files Browse the repository at this point in the history
  • Loading branch information
aviggiano committed Dec 4, 2023
1 parent 1cb1321 commit 3dc86b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/libraries/LoanLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ library LoanLibrary {
return isFOL(self) ? self.dueDate : loans[self.folId].dueDate;
}

function getFOL(Loan memory self, Loan[] memory loans) public pure returns (Loan memory) {
return isFOL(self) ? self : loans[self.folId];
}

function isOverdue(Loan memory self, Loan[] memory loans) public view returns (bool) {
return block.timestamp >= getDueDate(self, loans);
}
Expand Down Expand Up @@ -100,6 +96,7 @@ library LoanLibrary {
})
);
if (FV > getCredit(fol)) {
// @audit this has 0 coverage, I believe it is already checked by _borrowWithVirtualCollateral & validateExit
revert Errors.NOT_ENOUGH_FREE_CASH(getCredit(fol), FV);
}
fol.amountFVExited += FV;
Expand Down
1 change: 0 additions & 1 deletion test/BorrowAsMarketOrder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ contract BorrowAsMarketOrderTest is BaseTest {
_deposit(alice, usdc, 1000e6);
_deposit(bob, weth, 1e18);
_lendAsLimitOrder(alice, 100e18, 12, 0.03e4, 12);
LoanOffer memory offerBefore = size.getLoanOffer(alice);

_withdraw(alice, usdc, 999e6);

Expand Down
6 changes: 5 additions & 1 deletion test/LendAsLimitOrderValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract LendAsLimitOrderValidationTest is BaseTest {
using OfferLibrary for LoanOffer;

function test_LendAsLimitOrderValidation() public {
_deposit(alice, 100e18, 100e18);
_deposit(alice, address(usdc), 100e6);
uint256 maxAmount = 100e18;
uint256 maxDueDate = 12;
uint256[] memory timeBuckets = new uint256[](2);
Expand All @@ -28,6 +28,7 @@ contract LendAsLimitOrderValidationTest is BaseTest {
uint256[] memory rates1 = new uint256[](1);
rates1[0] = 1.01e4;

vm.startPrank(alice);
vm.expectRevert(abi.encodeWithSelector(Errors.ARRAY_LENGTHS_MISMATCH.selector));
size.lendAsLimitOrder(maxAmount, maxDueDate, timeBuckets, rates1);

Expand All @@ -42,6 +43,9 @@ contract LendAsLimitOrderValidationTest is BaseTest {
vm.expectRevert(abi.encodeWithSelector(Errors.NULL_AMOUNT.selector));
size.lendAsLimitOrder(0, maxDueDate, timeBuckets, rates);

vm.expectRevert(abi.encodeWithSelector(Errors.NOT_ENOUGH_FREE_CASH.selector, 100e18, 100e18 + 1));
size.lendAsLimitOrder(maxAmount + 1, maxDueDate, timeBuckets, rates);

vm.expectRevert(abi.encodeWithSelector(Errors.NULL_MAX_DUE_DATE.selector));
size.lendAsLimitOrder(maxAmount, 0, timeBuckets, rates);

Expand Down

0 comments on commit 3dc86b8

Please sign in to comment.