-
Notifications
You must be signed in to change notification settings - Fork 9
Mintable ERC20 #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Mintable ERC20 #203
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8369e1c
chore: boilerplate copypasta
rymcol 92c75f4
Merge branch 'canary' of github.com:t1protocol/t1 into xYield/erc-20
rymcol a4e3a64
feat: allow minter to be changed
rymcol 0c1fcfe
fix: redundant comment
rymcol 1d97309
fix: forge fmt
rymcol c3c74a3
fix: cleanup linting
rymcol b487c80
fix: cleanup comments
rymcol 6eed846
fix: revert forge fmt for files not touched by this branch
rymcol 7518207
feat: extra comments as nice to have
rymcol 098a368
feat: linter hates me
rymcol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.30; | ||
|
|
||
| import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
|
||
| contract XyieldToken is ERC20 { | ||
| address public minter; | ||
|
|
||
| /// @notice Emitted when the address authorized to mint is updated. | ||
| /// @param oldMinter The formerly authrorized minter | ||
| /// @param newMinter The address now authorized to mint | ||
| event MinterChanged(address indexed oldMinter, address indexed newMinter); | ||
|
|
||
| /// @dev Thrown if the minter would be set to the zero address | ||
| error ZeroAddress(); | ||
| /// @dev Thrown if the minter cannot be set due to an invalid input | ||
| error InvalidMinter(); | ||
| /// @dev Thrown if the caller is not authorized to change the minter | ||
| error NotAuthorized(); | ||
|
|
||
| constructor(address _minter, string memory name, string memory symbol) ERC20(name, symbol) { | ||
| if (_minter == address(0)) revert ZeroAddress(); | ||
| minter = _minter; | ||
| } | ||
|
|
||
| modifier onlyMinter() { | ||
| if (msg.sender != minter) revert NotAuthorized(); | ||
| _; | ||
| } | ||
|
|
||
| /// @notice Updates the minter address | ||
| /// @param newMinter The new minter address | ||
| function updateMinter(address newMinter) external onlyMinter { | ||
| if (newMinter == address(0)) revert ZeroAddress(); | ||
| if (newMinter == minter) revert InvalidMinter(); | ||
|
rymcol marked this conversation as resolved.
|
||
| address oldMinter = minter; | ||
| minter = newMinter; | ||
| emit MinterChanged(oldMinter, newMinter); | ||
| } | ||
|
|
||
| /// @notice Mints new tokens to the specified address | ||
| /// @param to The address to receive the minted tokens | ||
| /// @param amount The amount of tokens to mint | ||
| function mint(address to, uint256 amount) external onlyMinter { | ||
| _mint(to, amount); | ||
| } | ||
|
|
||
| /// @dev The standard burn function is already public and allows any address to burn their own tokens, | ||
| /// emitting a Transfer event to address(0) as the burn signal. Thus, no custom burn event is defined. | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.