Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 1cc9798

Browse files
authored
Merge pull request #37 from code-423n4/feature/capMint
Cap minting interval and amount
2 parents 97a9991 + 7a8bc03 commit 1cc9798

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

contracts/ArenaToken.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import "../interfaces/IRevokableTokenLock.sol";
1515
contract ArenaToken is ERC20, ERC20Burnable, Ownable, ERC20Permit, ERC20Votes {
1616
using BitMaps for BitMaps.BitMap;
1717

18+
/// mint cooldown period
19+
uint256 public constant MIN_MINT_INTERVAL = 365 days;
20+
/// maximum tokens allowed per mint
21+
/// 10_000 = 100%
22+
uint256 public constant MINT_CAP = 200; // 2%
23+
1824
bytes32 public merkleRoot;
1925
/// Proportion of airdropped tokens that are immediately claimable
2026
/// 10_000 = 100%
@@ -27,6 +33,8 @@ contract ArenaToken is ERC20, ERC20Burnable, Ownable, ERC20Permit, ERC20Votes {
2733

2834
/// vesting duration
2935
uint256 public vestDuration;
36+
/// timestamp till next mint is allowed
37+
uint256 public nextMint;
3038

3139
event MerkleRootChanged(bytes32 merkleRoot);
3240
event Claim(address indexed claimant, uint256 amount);
@@ -52,6 +60,7 @@ contract ArenaToken is ERC20, ERC20Burnable, Ownable, ERC20Permit, ERC20Votes {
5260
require(_claimPeriodEnds > block.timestamp, "cannot have a backward time");
5361
_mint(msg.sender, _freeSupply);
5462
_mint(address(this), _airdropSupply);
63+
nextMint = block.timestamp + MIN_MINT_INTERVAL;
5564
claimableProportion = _claimableProportion;
5665
claimPeriodEnds = _claimPeriodEnds;
5766
vestDuration = _vestDuration;
@@ -147,6 +156,13 @@ contract ArenaToken is ERC20, ERC20Burnable, Ownable, ERC20Permit, ERC20Votes {
147156
* @param amount The quantity of tokens to mint.
148157
*/
149158
function mint(address dest, uint256 amount) external onlyOwner {
159+
require(
160+
amount <= (totalSupply() * MINT_CAP) / 10_000,
161+
"ArenaToken: Mint exceeds maximum amount"
162+
);
163+
require(block.timestamp >= nextMint, "ArenaToken: Cannot mint yet");
164+
165+
nextMint = block.timestamp + MIN_MINT_INTERVAL;
150166
_mint(dest, amount);
151167
}
152168

test/ArenaToken.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,22 @@ describe('TokenSale', async () => {
8787
);
8888
});
8989

90+
it('should not allow minting until the first mint window', async () => {
91+
await expect(token.connect(admin).mint(user.address, ONE_18)).to.be.revertedWith('ArenaToken: Cannot mint yet');
92+
});
93+
9094
it('should allow owner to mint new tokens', async () => {
95+
await setNextBlockTimeStamp((await token.nextMint()).toNumber());
9196
await token.connect(admin).mint(user.address, ONE_18);
9297
expect(await token.balanceOf(user.address)).to.eq(ONE_18);
9398
});
99+
100+
it('should not allow minting more than the prescribed amount', async () => {
101+
await setNextBlockTimeStamp((await token.nextMint()).toNumber());
102+
await expect(token.mint(user.address, (await token.totalSupply()).div(50).add(1))).to.be.revertedWith(
103+
'ArenaToken: Mint exceeds maximum amount'
104+
);
105+
});
94106
});
95107

96108
describe('#sweep', async () => {

0 commit comments

Comments
 (0)