Skip to content

Commit

Permalink
c4-006 DoS in market orders due to incorrect params.amount comparison… (
Browse files Browse the repository at this point in the history
#125)

* c4-006 DoS in market orders due to incorrect params.amount comparison with dust limit when amount represents cash

* Remove params.amount > credit comparison
  • Loading branch information
aviggiano committed Jul 15, 2024
1 parent 6583a50 commit 8447c4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/libraries/actions/BuyCreditMarket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ library BuyCreditMarket {
}

// validate amount
if (params.amount < state.riskConfig.minimumCreditBorrowAToken) {
revert Errors.CREDIT_LOWER_THAN_MINIMUM_CREDIT(params.amount, state.riskConfig.minimumCreditBorrowAToken);
if (params.amount == 0) {
revert Errors.NULL_AMOUNT();
}

// validate deadline
Expand Down
9 changes: 2 additions & 7 deletions src/libraries/actions/SellCreditMarket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,11 @@ library SellCreditMarket {
);
}
tenor = debtPosition.dueDate - block.timestamp; // positive since the credit position is transferrable, so the loan must be ACTIVE

// validate amount
if (params.amount > creditPosition.credit) {
revert Errors.NOT_ENOUGH_CREDIT(params.amount, creditPosition.credit);
}
}

// validate amount
if (params.amount < state.riskConfig.minimumCreditBorrowAToken) {
revert Errors.CREDIT_LOWER_THAN_MINIMUM_CREDIT(params.amount, state.riskConfig.minimumCreditBorrowAToken);
if (params.amount == 0) {
revert Errors.NULL_AMOUNT();
}

// validate tenor
Expand Down

0 comments on commit 8447c4d

Please sign in to comment.