diff --git a/contracts/token/ERC20/extensions/ERC20Wrapper.sol b/contracts/token/ERC20/extensions/ERC20Wrapper.sol index 8b153ffcabd..e1bb2ec2413 100644 --- a/contracts/token/ERC20/extensions/ERC20Wrapper.sol +++ b/contracts/token/ERC20/extensions/ERC20Wrapper.sol @@ -16,28 +16,35 @@ import "../utils/SafeERC20.sol"; * _Available since v4.2._ */ abstract contract ERC20Wrapper is ERC20 { - IERC20 public immutable underlying; + IERC20 immutable _underlying; constructor(IERC20 underlyingToken) { - underlying = underlyingToken; + _underlying = underlyingToken; } /** * @dev See {ERC20-decimals}. */ function decimals() public view virtual override returns (uint8) { - try IERC20Metadata(address(underlying)).decimals() returns (uint8 value) { + try IERC20Metadata(address(_underlying)).decimals() returns (uint8 value) { return value; } catch { return super.decimals(); } } + /** + * @dev Returns the address of the ERC-20 token deployed with ERC20Wrapper.sol + */ + function underlying() public view returns (IERC20) { + return _underlying; + } + /** * @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens. */ function depositFor(address account, uint256 amount) public virtual returns (bool) { - SafeERC20.safeTransferFrom(underlying, _msgSender(), address(this), amount); + SafeERC20.safeTransferFrom(_underlying, _msgSender(), address(this), amount); _mint(account, amount); return true; } @@ -47,7 +54,7 @@ abstract contract ERC20Wrapper is ERC20 { */ function withdrawTo(address account, uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); - SafeERC20.safeTransfer(underlying, account, amount); + SafeERC20.safeTransfer(_underlying, account, amount); return true; } @@ -56,7 +63,7 @@ abstract contract ERC20Wrapper is ERC20 { * function that can be exposed with access control if desired. */ function _recover(address account) internal virtual returns (uint256) { - uint256 value = underlying.balanceOf(address(this)) - totalSupply(); + uint256 value = _underlying.balanceOf(address(this)) - totalSupply(); _mint(account, value); return value; }