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

`poolBalance` of the new pool has been decreased twice

Summary

In the refinance function, poolBalance of the poolId is being reduced 2 times.

Vulnerability Details

Notice that in the refinance function, when the borrower calls it, it is reducing the poolId's balance twice for the debt amount.

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

https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L636

Then again:

pools[poolId].poolBalance -= debt;

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

Impact

The balance of the new pool will be decreased twice the debt amount.

Tools Used

Manual Review

Recommendations

Remove one of the updates.

Support

FAQs

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