@@ -46,6 +46,26 @@ import {Math} from "../../../utils/math/Math.sol";
4646 *
4747 * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].
4848 * ====
49+ *
50+ * [NOTE]
51+ * ====
52+ * When overriding this contract, some elements must to be considered:
53+ *
54+ * * When overriding the behavior of the deposit or withdraw mechanisms, it is recommended to override the internal
55+ * functions. Overriding {_deposit} automatically affects both {deposit} and {mint}. Similarly, overriding {_withdraw}
56+ * automatically affects both {withdraw} and {redeem}. Overall it is not recommended to override the public facing
57+ * functions since that could lead to inconsistent behaviors between the {deposit} and {mint} or between {withdraw} and
58+ * {redeem}, which is documented to have lead to loss of funds.
59+ *
60+ * * Overrides to the deposit or withdraw mechanism must be reflected in the preview functions as well.
61+ *
62+ * * {maxWithdraw} depends on {maxRedeem}. Therefore, overriding {maxRedeem} only is enough. On the other hand,
63+ * overriding {maxWithdraw} only would have no effect on {maxRedeem}, and could create an inconsistency between the two
64+ * functions.
65+ *
66+ * * If {previewRedeem} is overridden to revert, {maxWithdraw} must be overridden as necessary to ensure it
67+ * always return successfully.
68+ * ====
4969 */
5070abstract contract ERC4626 is ERC20 , IERC4626 {
5171 using Math for uint256 ;
@@ -142,7 +162,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
142162
143163 /// @inheritdoc IERC4626
144164 function maxWithdraw (address owner ) public view virtual returns (uint256 ) {
145- return _convertToAssets ( balanceOf (owner), Math.Rounding.Floor );
165+ return previewRedeem ( maxRedeem (owner));
146166 }
147167
148168 /// @inheritdoc IERC4626
0 commit comments