From 0d1562d0f1a10f9890beef385edac4dbb55e8e6b Mon Sep 17 00:00:00 2001 From: ernestognw Date: Mon, 29 Jul 2024 12:58:56 -0600 Subject: [PATCH 1/2] Add note to ERC4626Fees --- contracts/mocks/docs/ERC4626Fees.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contracts/mocks/docs/ERC4626Fees.sol b/contracts/mocks/docs/ERC4626Fees.sol index b4baef5b0b7..e390c99b19b 100644 --- a/contracts/mocks/docs/ERC4626Fees.sol +++ b/contracts/mocks/docs/ERC4626Fees.sol @@ -8,6 +8,10 @@ import {SafeERC20} from "../../token/ERC20/utils/SafeERC20.sol"; import {Math} from "../../utils/math/Math.sol"; /// @dev ERC-4626 vault with entry/exit fees expressed in https://en.wikipedia.org/wiki/Basis_point[basis point (bp)]. +/// +/// NOTE: The contract charges fees in terms of assets, not shares. This means that the fees are calculated based on the +/// amount of assets that are being deposited or withdrawn, and not based on the amount of shares that are being minted or +/// redeemed. This is an opinionated design decision that should be taken into account when integrating this contract. abstract contract ERC4626Fees is ERC4626 { using Math for uint256; From 09543b8fbdf5e4d1a018bff8bcb6cb92115551aa Mon Sep 17 00:00:00 2001 From: ernestognw Date: Tue, 30 Jul 2024 15:13:14 -0600 Subject: [PATCH 2/2] Refactor ERC4626Fees example to account for fees in `maxWithdraw` --- contracts/mocks/docs/ERC4626Fees.sol | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contracts/mocks/docs/ERC4626Fees.sol b/contracts/mocks/docs/ERC4626Fees.sol index e390c99b19b..fd62ee2393d 100644 --- a/contracts/mocks/docs/ERC4626Fees.sol +++ b/contracts/mocks/docs/ERC4626Fees.sol @@ -12,6 +12,8 @@ import {Math} from "../../utils/math/Math.sol"; /// NOTE: The contract charges fees in terms of assets, not shares. This means that the fees are calculated based on the /// amount of assets that are being deposited or withdrawn, and not based on the amount of shares that are being minted or /// redeemed. This is an opinionated design decision that should be taken into account when integrating this contract. +/// +/// WARNING: This contract has not been audited and shouldn't be considered production ready. Consider using it with caution. abstract contract ERC4626Fees is ERC4626 { using Math for uint256; @@ -19,6 +21,11 @@ abstract contract ERC4626Fees is ERC4626 { // === Overrides === + /// @dev Maximum amount of the underlying asset that can be withdrawn from the owner's balance. + function maxWithdraw(address owner) public view virtual override returns (uint256) { + return previewRedeem(maxRedeem(owner)); + } + /// @dev Preview taking an entry fee on deposit. See {IERC4626-previewDeposit}. function previewDeposit(uint256 assets) public view virtual override returns (uint256) { uint256 fee = _feeOnTotal(assets, _entryFeeBasisPoints());