code-423n4 / 2021-09-wildcredit-findings

0 stars 0 forks source link

Moving checks before other logic can save gas #85

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

0xRajeev

Vulnerability details

Impact

Moving _checkBorrowEnabled and _checkDepositsEnabled checks to before the mint function call will save gas for invalid calls and is also a best practice to move validation checks closest to the interface.

Proof of Concept

https://github.com/code-423n4/2021-09-wildcredit/blob/c48235289a25b2134bb16530185483e8c85507f8/contracts/LendingPair.sol#L538-L542

https://github.com/code-423n4/2021-09-wildcredit/blob/c48235289a25b2134bb16530185483e8c85507f8/contracts/LendingPair.sol#L556-L559

Tools Used

Manual Analysis

Recommended Mitigation Steps

Move _checkBorrowEnabled and _checkDepositsEnabled checks to before the mint function calls.