Current logic can lead to loss of user funds.
After each deposit, the exchange rate is recalculated. The Exchange rate always increases, but on a deposit the user is minted a number of tokens based on the old exchange rate.
If a user deposits and then immediately withdraws, they will receive more underlying tokens than they deposited. If there are no flash loans or fees generated, this will leave previous users in a position where the contract does not have enough underlying tokens to make them whole on the amount deposited. The console logs will show a profit is realised for user 2.
If you add the following function to the test file, it will fail as there is not sufficient underlying tokens to allow the initial depositor's redemption:
Update exchange rate before minting tokens on deposits
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.