Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions contracts/src/xYield/xYieldToken.sol
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 {
Comment thread
rymcol marked this conversation as resolved.
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();
Comment thread
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.
}