As soon as the exchangeRate is updated, functions that depend on the rate will give wrong results.
The exchangeRate is updated by functions ie, deposits and loans. This exchangeRate is used to calculate how much of the underlying assets will be redeemed. If the exchangeRate goes up after deposit, the calculation gives a higher amount. Unfortunately, this calculates to a higher token amount than the contract is holding, meaning that the redeem will fail.
POC. Add this test to test/unit/ThunderLoanTest.t.sol
Users are unable to redeem deposits + yield
Manual review
Looks like a confusion between fee and exchange rate.
Deposits and loans should not update the exchangeRate. Remove src/protocol/ThunderLoan.sol:Ln154-155
and src/protocol/ThunderLoan.sol:Ln195
The exchange rate should not be updated. Instead, the function updateExchangeRate should be updateFee
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.