Last active
June 9, 2023 10:36
-
-
Save publu/3707ad4c26eb99cdba104fddb4194c31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.0; | |
| import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
| import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
| import "@openzeppelin/contracts/access/Ownable.sol"; | |
| import "@openzeppelin/contracts/security/Pausable.sol"; | |
| contract TokenWrapper is ERC20, Ownable, Pausable { | |
| IERC20 public constant token; | |
| constructor(IERC20 _token) ERC20("wrappedMAI", "MAI") { | |
| token = _token; | |
| } | |
| function deposit(uint256 amount) public whenNotPaused { | |
| token.transferFrom(_msgSender(), address(this), amount); | |
| _mint(_msgSender(), amount); | |
| } | |
| function withdraw(uint256 amount) public whenNotPaused { | |
| _burn(_msgSender(), amount); | |
| token.transfer(_msgSender(), amount); | |
| } | |
| function pause() public onlyOwner { | |
| _pause(); | |
| } | |
| function unpause() public onlyOwner { | |
| _unpause(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment