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

0 stars 0 forks source link

Change unnecessary _borrowBalanceConverted to _debtOf can save gas #31

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

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

uint totalAccountBorrow =
    _borrowBalanceConverted(_account, tokenA, tokenA, priceA, priceA) +
    _borrowBalanceConverted(_account, tokenB, tokenA, priceB, priceA);

Recommendation

Change to:

uint totalAccountBorrow =
    _debtOf(tokenA, _account) +
    _borrowBalanceConverted(_account, tokenB, tokenA, priceB, priceA);