In refinance logic, debt is moved from old lender pool to new one. So old lender pool balance should be increased and the new lender pool balance is deducted. However, in the implementation, the new lender pool is deducted two times, which causes balance deducted double as expected
Pool balance deducted first time in refinance logic https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L635-L637
Pool balance deducted again here https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L697-L698
POC:
The PoC below is a customized version from origin test function test_refinance() and it does pass
Lender pools balance get deducted and there is no way to recover. It does mean that lenders lost their funds
Foundry
Remove this line https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L697-L698 so that accounting pool balance is correct
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.