Skip to content

Commit

Permalink
Minor wording fixes ERC4626 contract (#3510)
Browse files Browse the repository at this point in the history
(cherry picked from commit b159b3f)
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
  • Loading branch information
pcaversaccio authored and Amxx committed Jun 28, 2022
1 parent e4748fb commit 0b238a5
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions contracts/token/ERC20/extensions/ERC4626.sol
Expand Up @@ -35,67 +35,67 @@ abstract contract ERC4626 is ERC20, IERC4626 {
_asset = asset_;
}

/** @dev See {IERC4262-asset} */
/** @dev See {IERC4262-asset}. */
function asset() public view virtual override returns (address) {
return address(_asset);
}

/** @dev See {IERC4262-totalAssets} */
/** @dev See {IERC4262-totalAssets}. */
function totalAssets() public view virtual override returns (uint256) {
return _asset.balanceOf(address(this));
}

/** @dev See {IERC4262-convertToShares} */
/** @dev See {IERC4262-convertToShares}. */
function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) {
return _convertToShares(assets, Math.Rounding.Down);
}

/** @dev See {IERC4262-convertToAssets} */
/** @dev See {IERC4262-convertToAssets}. */
function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) {
return _convertToAssets(shares, Math.Rounding.Down);
}

/** @dev See {IERC4262-maxDeposit} */
/** @dev See {IERC4262-maxDeposit}. */
function maxDeposit(address) public view virtual override returns (uint256) {
return _isVaultCollateralized() ? type(uint256).max : 0;
}

/** @dev See {IERC4262-maxMint} */
/** @dev See {IERC4262-maxMint}. */
function maxMint(address) public view virtual override returns (uint256) {
return type(uint256).max;
}

/** @dev See {IERC4262-maxWithdraw} */
/** @dev See {IERC4262-maxWithdraw}. */
function maxWithdraw(address owner) public view virtual override returns (uint256) {
return _convertToAssets(balanceOf(owner), Math.Rounding.Down);
}

/** @dev See {IERC4262-maxRedeem} */
/** @dev See {IERC4262-maxRedeem}. */
function maxRedeem(address owner) public view virtual override returns (uint256) {
return balanceOf(owner);
}

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

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

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

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

/** @dev See {IERC4262-deposit} */
/** @dev See {IERC4262-deposit}. */
function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {
require(assets <= maxDeposit(receiver), "ERC4626: deposit more than max");

Expand All @@ -105,7 +105,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
return shares;
}

/** @dev See {IERC4262-mint} */
/** @dev See {IERC4262-mint}. */
function mint(uint256 shares, address receiver) public virtual override returns (uint256) {
require(shares <= maxMint(receiver), "ERC4626: mint more than max");

Expand All @@ -115,7 +115,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
return assets;
}

/** @dev See {IERC4262-withdraw} */
/** @dev See {IERC4262-withdraw}. */
function withdraw(
uint256 assets,
address receiver,
Expand All @@ -129,7 +129,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
return shares;
}

/** @dev See {IERC4262-redeem} */
/** @dev See {IERC4262-redeem}. */
function redeem(
uint256 shares,
address receiver,
Expand All @@ -144,7 +144,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
}

/**
* @dev Internal convertion function (from assets to shares) with support for rounding direction
* @dev Internal conversion function (from assets to shares) with support for rounding direction.
*
* Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset
* would represent an infinite amout of shares.
Expand All @@ -158,7 +158,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
}

/**
* @dev Internal convertion function (from shares to assets) with support for rounding direction
* @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) {
uint256 supply = totalSupply();
Expand All @@ -169,7 +169,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
}

/**
* @dev Deposit/mint common workflow
* @dev Deposit/mint common workflow.
*/
function _deposit(
address caller,
Expand All @@ -191,7 +191,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
}

/**
* @dev Withdraw/redeem common workflow
* @dev Withdraw/redeem common workflow.
*/
function _withdraw(
address caller,
Expand All @@ -204,7 +204,7 @@ abstract contract ERC4626 is ERC20, IERC4626 {
_spendAllowance(owner, caller, shares);
}

// If _asset is ERC777, `transfer` can trigger trigger a reentrancy AFTER the transfer happens through the
// If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the
// `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,
// calls the vault, which is assumed not malicious.
//
Expand Down

0 comments on commit 0b238a5

Please sign in to comment.