Conversation
| /// @dev The sender must have given enough allowance over vault shares to this bundler. Using max allowance makes sure that this condition is met. | ||
| /// @dev The deallocatedAssets amount is floor(forceWithdrawAssets * WAD / (WAD + penalty)). | ||
| /// @dev Requires Morpho Blue to have more than the deallocated assets in liquidity. | ||
| /// @dev Requires the sender to have enough shares to withdraw ceil(assets * penalty / WAD) and then assets, for each market in the list, where the sum of the assets is equal to deallocatedAssets. |
There was a problem hiding this comment.
there are multiple roundings (up) right? so it could be worse than this I think
There was a problem hiding this comment.
I think it's accurate, it requires to be able to call withdraw twice, which takes into account all the rounding errors that happen inside a given vault interaction
| // Markets not enabled in the vault are skipped. | ||
| if (!IMetaMorpho(vault).config(marketParams.id()).enabled) continue; |
There was a problem hiding this comment.
We don't want the curator to be able to remove it from the list (by calling updateWithdrawQueue, not timelocked) and make the transaction revert. Maybe ok, since the number of markets is limited, but it doesn't cost much to just skip the market here
There was a problem hiding this comment.
it will be very hard to reproduce (only doable once per market). it sounds ok to me
| uint256 assets = UtilsLib.min(availableToWithdraw, assetsToDeallocate); | ||
|
|
||
| IVaultV2(vault).forceDeallocate(adapter, abi.encode(marketParams), assets, msg.sender); | ||
| IVaultV2(vault).withdraw(assets, msg.sender, msg.sender); |
There was a problem hiding this comment.
why not a single withdraw at the end? the deallocated liquidity couldn't be stolen by reentrancy right?
There was a problem hiding this comment.
No strong reason, it was more to align with the other vault v2 function, and the motivation in this message don't hold that well in this case: it's less gas gain, and the rounding that it prevents is not the same as in vault v1.
Maybe still interesting to factorize though, what do you think ?
design
initial thread
follow up thread