Add FV specification for ERC20Wrapper (#4100)

Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
Hadrien Croubois
2023-03-08 23:12:37 +01:00
committed by GitHub
parent 5f7f660c6e
commit 3214f6c256
7 changed files with 249 additions and 7 deletions

View File

@ -19,6 +19,7 @@ abstract contract ERC20Wrapper is ERC20 {
IERC20 private immutable _underlying;
constructor(IERC20 underlyingToken) {
require(underlyingToken != this, "ERC20Wrapper: cannot self wrap");
_underlying = underlyingToken;
}
@ -44,7 +45,9 @@ abstract contract ERC20Wrapper is ERC20 {
* @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);
address sender = _msgSender();
require(sender != address(this), "ERC20Wrapper: wrapper can't deposit");
SafeERC20.safeTransferFrom(_underlying, sender, address(this), amount);
_mint(account, amount);
return true;
}