Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion packages/contracts-bedrock/src/governance/MintManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ contract MintManager is Ownable {
}

/// @notice Only the token owner is allowed to mint a certain amount of the
/// governance token per year.
/// governance token per year. The first mint is uncapped to allow growing
/// the token supply from zero to a non-zero value.
/// @param _account The account receiving minted tokens.
/// @param _amount The amount of tokens to mint.
function mint(address _account, uint256 _amount) public onlyOwner {
Expand Down
46 changes: 23 additions & 23 deletions packages/contracts-bedrock/test/governance/MintManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ contract MintManager_Constructor_Test is MintManager_TestInit {
/// @title MintManager_Mint_Test
/// @notice Tests the `mint` function of the `MintManager` contract.
contract MintManager_Mint_Test is MintManager_TestInit {
/// @notice Tests that the mint function properly mints tokens when called by the owner.
function test_mint_fromOwner_succeeds() external {
// Mint once.
/// @notice Tests that the first mint can be any amount since no cap applies.
function testFuzz_mint_firstMint_succeeds(uint256 _amount) external {
_amount = bound(_amount, 0, type(uint192).max);

vm.prank(owner);
manager.mint(owner, 100);
manager.mint(owner, _amount);

// Token balance increases.
assertEq(gov.balanceOf(owner), 100);
assertEq(gov.balanceOf(owner), _amount);
}

/// @notice Tests that the mint function reverts when called by a non-owner.
Expand All @@ -73,23 +73,23 @@ contract MintManager_Mint_Test is MintManager_TestInit {
manager.mint(owner, 100);
}

/// @notice Tests that the mint function properly mints tokens when called by the owner a
/// second time after the mint period has elapsed.
function test_mint_afterPeriodElapsed_succeeds() external {
// Mint once.
/// @notice Tests that subsequent mints succeed when within cap after period elapsed.
function testFuzz_mint_afterPeriodElapsed_succeeds(uint256 _initialAmount, uint256 _secondAmount) external {
_initialAmount = bound(_initialAmount, 1, type(uint192).max);

vm.prank(owner);
manager.mint(owner, 100);
manager.mint(owner, _initialAmount);

// Token balance increases.
assertEq(gov.balanceOf(owner), 100);
assertEq(gov.balanceOf(owner), _initialAmount);

uint256 maxMint = (_initialAmount * manager.MINT_CAP()) / manager.DENOMINATOR();
_secondAmount = bound(_secondAmount, 0, maxMint);

// Mint again after period elapsed (2% max).
vm.warp(block.timestamp + manager.MINT_PERIOD() + 1);
vm.prank(owner);
manager.mint(owner, 2);
manager.mint(owner, _secondAmount);

// Token balance increases.
assertEq(gov.balanceOf(owner), 102);
assertEq(gov.balanceOf(owner), _initialAmount + _secondAmount);
}

/// @notice Tests that the mint function always reverts when called before the mint period has
Expand Down Expand Up @@ -134,14 +134,14 @@ contract MintManager_Mint_Test is MintManager_TestInit {
/// @title MintManager_Upgrade_Test
/// @notice Tests the `upgrade` function of the `MintManager` contract.
contract MintManager_Upgrade_Test is MintManager_TestInit {
/// @notice Tests that the owner can upgrade the mint manager.
function test_upgrade_fromOwner_succeeds() external {
// Upgrade to new manager.
/// @notice Tests that the owner can upgrade to any non-zero address.
function testFuzz_upgrade_fromOwner_succeeds(address _newManager) external {
vm.assume(_newManager != address(0));

vm.prank(owner);
manager.upgrade(rando);
manager.upgrade(_newManager);

// New manager is rando.
assertEq(gov.owner(), rando);
assertEq(gov.owner(), _newManager);
}

/// @notice Tests that the upgrade function reverts when called by a non-owner.
Expand Down