Skip to content

Instantly share code, notes, and snippets.

@publu
Last active June 9, 2023 10:36
Show Gist options
  • Select an option

  • Save publu/3707ad4c26eb99cdba104fddb4194c31 to your computer and use it in GitHub Desktop.

Select an option

Save publu/3707ad4c26eb99cdba104fddb4194c31 to your computer and use it in GitHub Desktop.
// 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