Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MezoAllocator Withdrawals Improvements (#717)
Depends on: #716 In this PR we introduce a couple of improvements to the MezoAllocator contract related to withdrawals from the Mezo Portal. ### Check if the withdrawal amount exceeds the deposit balance (1b95419) Here we improve the withdrawal function to check if the withdrawal amount exceeds the deposit balance. If the withdrawal amount exceeds the deposit balance, the function will revert with a custom error message. Before these changes, since the Portal contract changed the handling of partial and full withdrawals the withdrawal function reverted on `depositBalance -= uint96(amount);` with: ``` panic code 0x11 (Arithmetic operation overflowed outside of an unchecked block) ``` ### Include unallocated MezoAllocator balance in `withdraw` and `releaseDeposit` (1b9ba17, 0440580) In bb42bce we included the current balance of the MezoAllocator contract in the `totalAssets` function result. The balance can come from a rewards transfer or any donation. We haven't considered this balance in the `withdraw` function, which could lead to blocking the last user withdrawing the funds, as the balance of assets owned by them calculated based on `totalAssets` function, couldn't be fully withdraw due to unallocated balance being stuck in the `MezoAllocator` contract. In 1b9ba17 we introduce possibility to withdraw funds from the unallocated contract balance. For the `releaseDeposit` function we could face a problem when the Mezo Portal deposit is already released but some tokens were donated to the MezoAllocator contract, since the `Porta.withdraw` function would be reverting as there is no deposit, we won't be able to transfer the unallocated funds in the same call. We fixed it in 0440580. > [!IMPORTANT] > Please ignore failing integration tests, as these will be fixed in #718
- Loading branch information