20,000 USDC
View results
Submission Details
Severity: high
Valid

New pool is double accounted when borrower refinances a loan

Summary

New pool is double accounted when borrower refinances a loan.

Vulnerability Details

When borrower refinances loans, tokens are deducted from the new pool:

// now lets deduct our tokens from the new pool
_updatePoolBalance(poolId, pools[poolId].poolBalance - debt);

However, at the end of the refinancing, new pool balance is updated again:

// update pool balance
pools[poolId].poolBalance -= debt;

Impact

New pool lender suffers a loss.

Tools Used

Mannual Review

Recommendations

New pool balance should only be deducted once.

function refinance(Refinance[] calldata refinances) public {
for (uint256 i = 0; i < refinances.length; i++) {
...
- pools[poolId].poolBalance -= debt;
...
}

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!