Skip to content

Instantly share code, notes, and snippets.

@a2468834
Created May 21, 2023 11:12
Show Gist options
  • Save a2468834/274f7495bd6b4544c179e6ac1a820c5c to your computer and use it in GitHub Desktop.
Save a2468834/274f7495bd6b4544c179e6ac1a820c5c to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MTK") {}
function mint(address to, uint256 amount) public {
_mint(to, amount);
}
}
contract RoughVault {
address public underlyingToken;
mapping(address => uint256) balanceOf;
constructor(address _underlyingToken) {
underlyingToken = _underlyingToken;
}
function deposit(uint256 amount) public returns (bool) {
balanceOf[msg.sender] += amount;
ERC20(underlyingToken).transferFrom(msg.sender, address(this), amount);
return true;
}
function withdraw(uint256 amount) public payable {
require(msg.value > 10 gwei, "Give me your money!");
balanceOf[msg.sender] -= amount;
ERC20(underlyingToken).transfer(msg.sender, amount);
}
}
@a2468834
Copy link
Author

This code snippet is just a toy model, so please DO NOT USE it in any of production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment