Add note in ERC20Wrapper about rebasing tokens (#4755)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
pull/4313/merge
Ernesto García 1 year ago committed by GitHub
parent 0b1b5f89ef
commit 769071d473
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      contracts/token/ERC20/extensions/ERC20Wrapper.sol

@ -12,6 +12,11 @@ import {SafeERC20} from "../utils/SafeERC20.sol";
* Users can deposit and withdraw "underlying tokens" and receive a matching number of "wrapped tokens". This is useful
* in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the
* wrapping of an existing "basic" ERC-20 into a governance token.
*
* WARNING: Any mechanism in which the underlying token changes the {balanceOf} of an account without an explicit transfer
* may desynchronize this contract's supply and its underlying balance. Please exercise caution when wrapping tokens that
* may undercollateralize the wrapper (i.e. wrapper's total supply is higher than its underlying balance). See {_recover}
* for recovering value accrued to the wrapper.
*/
abstract contract ERC20Wrapper is ERC20 {
IERC20 private immutable _underlying;
@ -75,8 +80,8 @@ abstract contract ERC20Wrapper is ERC20 {
}
/**
* @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
* function that can be exposed with access control if desired.
* @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake or acquired from
* rebasing mechanisms. Internal 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();

Loading…
Cancel
Save