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

```poolBalance``` is being deducted twice in refinance function

Summary

poolBalance is being deducted twice in refinance function

Vulnerability Details

when calling refinance function the pool balance is updated from old and new once also , but the debt is deducted twice from new poolbalance
first the debt is deducted here:
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L636

_updatePoolBalance(poolId, pools[poolId].poolBalance - debt);

second :
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L698

pools[poolId].poolBalance -= debt;

This will break the ratio between poolbalance and outstandingLoans.

Impact

poolbalance is deducted twice with debt which will cause lender to loose funds from his pool

Tools Used

vs

Recommendations

function should only deduct poolbalance once

Support

FAQs

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