From d5ca39e9a264ddcadd5742484b6d391ae1647a10 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Wed, 2 Nov 2022 15:46:08 +0100 Subject: [PATCH] Rename `_isVaultCollateralized` to `_isVaultHealthy` for clarity (#3796) --- contracts/token/ERC20/extensions/ERC4626.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/token/ERC20/extensions/ERC4626.sol b/contracts/token/ERC20/extensions/ERC4626.sol index 41ec9d685..6833d43d7 100644 --- a/contracts/token/ERC20/extensions/ERC4626.sol +++ b/contracts/token/ERC20/extensions/ERC4626.sol @@ -75,18 +75,18 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-convertToShares}. */ - function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) { + function convertToShares(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, Math.Rounding.Down); } /** @dev See {IERC4626-convertToAssets}. */ - function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) { + function convertToAssets(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, Math.Rounding.Down); } /** @dev See {IERC4626-maxDeposit}. */ function maxDeposit(address) public view virtual override returns (uint256) { - return _isVaultCollateralized() ? type(uint256).max : 0; + return _isVaultHealthy() ? type(uint256).max : 0; } /** @dev See {IERC4626-maxMint}. */ @@ -178,7 +178,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset * would represent an infinite amount of shares. */ - function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256 shares) { + function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) { uint256 supply = totalSupply(); return (assets == 0 || supply == 0) @@ -201,7 +201,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { /** * @dev Internal conversion function (from shares to assets) with support for rounding direction. */ - function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256 assets) { + function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) { uint256 supply = totalSupply(); return (supply == 0) ? _initialConvertToAssets(shares, rounding) : shares.mulDiv(totalAssets(), supply, rounding); @@ -215,7 +215,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { function _initialConvertToAssets( uint256 shares, Math.Rounding /*rounding*/ - ) internal view virtual returns (uint256 assets) { + ) internal view virtual returns (uint256) { return shares; } @@ -267,7 +267,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { emit Withdraw(caller, receiver, owner, assets, shares); } - function _isVaultCollateralized() private view returns (bool) { + function _isVaultHealthy() private view returns (bool) { return totalAssets() > 0 || totalSupply() == 0; } }