github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/src/governance/MintManager.sol (about)

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity 0.8.15;
     3  
     4  import "@openzeppelin/contracts/access/Ownable.sol";
     5  import "./GovernanceToken.sol";
     6  
     7  /// @title MintManager
     8  /// @notice Set as `owner` of the governance token and responsible for the token inflation
     9  ///         schedule. Contract acts as the token "mint manager" with permission to the `mint`
    10  ///         function only. Currently permitted to mint once per year of up to 2% of the total
    11  ///         token supply. Upgradable to allow changes in the inflation schedule.
    12  contract MintManager is Ownable {
    13      /// @notice The GovernanceToken that the MintManager can mint tokens
    14      GovernanceToken public immutable governanceToken;
    15  
    16      /// @notice The amount of tokens that can be minted per year.
    17      ///         The value is a fixed point number with 4 decimals.
    18      uint256 public constant MINT_CAP = 20; // 2%
    19  
    20      /// @notice The number of decimals for the MINT_CAP.
    21      uint256 public constant DENOMINATOR = 1000;
    22  
    23      /// @notice The amount of time that must pass before the MINT_CAP number of tokens can
    24      ///         be minted again.
    25      uint256 public constant MINT_PERIOD = 365 days;
    26  
    27      /// @notice Tracks the time of last mint.
    28      uint256 public mintPermittedAfter;
    29  
    30      /// @notice Constructs the MintManager contract.
    31      /// @param _upgrader        The owner of this contract.
    32      /// @param _governanceToken The governance token this contract can mint tokens of.
    33      constructor(address _upgrader, address _governanceToken) {
    34          transferOwnership(_upgrader);
    35          governanceToken = GovernanceToken(_governanceToken);
    36      }
    37  
    38      /// @notice Only the token owner is allowed to mint a certain amount of the
    39      ///         governance token per year.
    40      /// @param _account The account receiving minted tokens.
    41      /// @param _amount  The amount of tokens to mint.
    42      function mint(address _account, uint256 _amount) public onlyOwner {
    43          if (mintPermittedAfter > 0) {
    44              require(mintPermittedAfter <= block.timestamp, "MintManager: minting not permitted yet");
    45  
    46              require(
    47                  _amount <= (governanceToken.totalSupply() * MINT_CAP) / DENOMINATOR,
    48                  "MintManager: mint amount exceeds cap"
    49              );
    50          }
    51  
    52          mintPermittedAfter = block.timestamp + MINT_PERIOD;
    53          governanceToken.mint(_account, _amount);
    54      }
    55  
    56      /// @notice Upgrade the owner of the governance token to a new MintManager.
    57      /// @param _newMintManager The MintManager to upgrade to.
    58      function upgrade(address _newMintManager) public onlyOwner {
    59          require(_newMintManager != address(0), "MintManager: mint manager cannot be the zero address");
    60  
    61          governanceToken.transferOwnership(_newMintManager);
    62      }
    63  }