ERC4626 preview functions rounding

Hello guys,

I have some doubts on the rounding mode of previewXXX functions in the ERC4626 smart contract implementation.

What is the purpose of each Rouding mode on each preview function ? Why Rounding.Floor on previewDeposit and previewRedeem, why Rounding.Ceil on previewMint and previewWithdraw ? Is there any math / business model / security concerns on the roundings ?

/** @dev See {IERC4626-previewDeposit}. */
    function previewDeposit(uint256 assets) public view virtual returns (uint256) {
        return _convertToShares(assets, Math.Rounding.Floor);
    }

    /** @dev See {IERC4626-previewMint}. */
    function previewMint(uint256 shares) public view virtual returns (uint256) {
        return _convertToAssets(shares, Math.Rounding.Ceil);
    }

    /** @dev See {IERC4626-previewWithdraw}. */
    function previewWithdraw(uint256 assets) public view virtual returns (uint256) {
        return _convertToShares(assets, Math.Rounding.Ceil);
    }

    /** @dev See {IERC4626-previewRedeem}. */
    function previewRedeem(uint256 shares) public view virtual returns (uint256) {
        return _convertToAssets(shares, Math.Rounding.Floor);
    }

Thanks a lot for the help.

1 Like

Anybody can help please ?