Created
July 24, 2025 00:09
-
-
Save loon3/3d3d9f8c9821d3e537fd099cf6e8293c to your computer and use it in GitHub Desktop.
PepeUSD
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.20; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; | |
contract PepeUSD is ERC20, ReentrancyGuard { | |
IERC20 public immutable usdc; | |
uint256 public immutable maxSupply; | |
constructor(address _usdc, uint256 _maxSupply) ERC20("PepeUSD", "PEPEUSD") { | |
require(_usdc != address(0), "Invalid USDC address"); | |
usdc = IERC20(_usdc); | |
maxSupply = _maxSupply; | |
} | |
function decimals() public pure override returns (uint8) { | |
return 6; | |
} | |
function mint(uint256 amount) external nonReentrant { | |
require(totalSupply() + amount <= maxSupply, "PepeUSD cap reached"); | |
require(usdc.transferFrom(msg.sender, address(this), amount), "USDC transfer failed"); | |
_mint(msg.sender, amount); | |
} | |
function redeem(uint256 amount) external nonReentrant { | |
_burn(msg.sender, amount); | |
require(usdc.transfer(msg.sender, amount), "USDC redemption failed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment