Skip to content

Commit

Permalink
Rename _isVaultCollateralized to _isVaultHealthy for clarity (#3796)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx authored Nov 2, 2022
1 parent 7d01fac commit d5ca39e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions contracts/token/ERC20/extensions/ERC4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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}. */
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
}

0 comments on commit d5ca39e

Please sign in to comment.