CoveToken
Inherits: IERC6372, ERC20Votes, AccessControlEnumerable, Pausable, Multicall
ERC20 token with governance features including roles, pausability, and permit functionality.
*This token includes roles for minting and pausing, as well as the ability to set transfer allowances via signatures. It also includes an allowlisting mechanism for:
- Senders: Vesting contracts, treasury multisig, or rewards contracts so CoveToken can be claimed.
- Receivers: For non-tokenized staking contracts like MiniChefV3 to enable staking while it is non-transferrable. It inherits from OpenZeppelin's IERC6372, ERC20Votes, AccessControlEnumerable, Pausable, and Multicall contracts.*
State Variables
_INITIAL_INFLATION_DELAY
Initial delay before inflation starts.
uint256 private constant _INITIAL_INFLATION_DELAY = 3 * 52 weeks;
_INITIAL_SUPPLY
Initial supply of tokens.
uint256 private constant _INITIAL_SUPPLY = 1_000_000_000 ether;
_MIN_MINT_INTERVAL
Minimum time interval between mints.
uint256 private constant _MIN_MINT_INTERVAL = 52 weeks;
_MINT_CAP_NUMERATOR
Numerator for calculating mint cap.
uint256 private constant _MINT_CAP_NUMERATOR = 600;
_MINT_CAP_DENOMINATOR
Denominator for calculating mint cap.
uint256 private constant _MINT_CAP_DENOMINATOR = 10_000;
_MAX_PAUSE_PERIOD
Maximum period the contract can be paused.
uint256 private constant _MAX_PAUSE_PERIOD = 18 * 4 weeks;
_OWNER_PAUSE_PERIOD
Period after which the owner can unpause the contract.
uint256 private constant _OWNER_PAUSE_PERIOD = 6 * 4 weeks;
MINTER_ROLE
Role identifier for minters.
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
TIMELOCK_ROLE
Role identifier for the timelock.
bytes32 public constant TIMELOCK_ROLE = keccak256("TIMELOCK_ROLE");
mintingAllowedAfter
Timestamp after which minting is allowed.
uint256 public mintingAllowedAfter;
OWNER_CAN_UNPAUSE_AFTER
Timestamp after which the owner can unpause the contract.
uint256 public immutable OWNER_CAN_UNPAUSE_AFTER;
ANYONE_CAN_UNPAUSE_AFTER
Timestamp after which anyone can unpause the contract.
uint256 public immutable ANYONE_CAN_UNPAUSE_AFTER;
allowedReceiver
Mapping to track addresses allowed to receive transfers.
mapping(address => bool) public allowedReceiver;
allowedSender
Mapping to track addresses allowed to initiate transfers.
mapping(address => bool) public allowedSender;
_eventId
State variable to make the events orderable for external observers if they are called in the same block.
uint256 private _eventId;
Functions
constructor
Deploys this contract with the initial owner and minting allowed after a specified time.
The contract is paused upon deployment and the initial supply is minted to the owner.
constructor(address owner_) payable ERC20Permit("Cove DAO") ERC20("Cove DAO", "COVE");
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | The address of the initial owner. |
mint
Mints tokens to a specified address.
function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
to | address | The address to mint tokens to. |
amount | uint256 | The amount of tokens to mint. |
unpause
Unpauses the contract.
function unpause() external whenPaused;
addAllowedReceiver
Adds an address to the list of allowed transferees.
function addAllowedReceiver(address target) external onlyRole(TIMELOCK_ROLE);
Parameters
Name | Type | Description |
---|---|---|
target | address | The address to allow. |
removeAllowedReceiver
Removes an address from the list of allowed transferees.
function removeAllowedReceiver(address target) external onlyRole(TIMELOCK_ROLE);
Parameters
Name | Type | Description |
---|---|---|
target | address | The address to disallow. |
addAllowedSender
Adds an address to the list of allowed transferrers.
function addAllowedSender(address target) external onlyRole(TIMELOCK_ROLE);
Parameters
Name | Type | Description |
---|---|---|
target | address | The address to allow. |
removeAllowedSender
Removes an address from the list of allowed transferrers.
function removeAllowedSender(address target) external onlyRole(TIMELOCK_ROLE);
Parameters
Name | Type | Description |
---|---|---|
target | address | The address to disallow. |
availableSupplyToMint
Calculates the available supply that can be minted.
function availableSupplyToMint() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The amount of supply available for minting. |
_addToAllowedReceiver
function _addToAllowedReceiver(address target) internal;
_removeFromAllowedReceiver
function _removeFromAllowedReceiver(address target) internal;
_addToAllowedSender
function _addToAllowedSender(address target) internal;
_removeFromAllowedSender
function _removeFromAllowedSender(address target) internal;
_beforeTokenTransfer
*Hook that is called before any transfer of tokens. This includes minting and burning. It checks if the contract is paused and if so, only allows transfers from allowed transferrers or to allowed transferees (only one inclusion is required). This is meant to support:
- Allowed senders: Vesting, treasury multisig, and rewards contracts so CoveToken can be distributed.
- Allowed receivers: For non-tokenized staking contracts like MiniChefV3 so any address can stake CoveToken while it's non-transferrable.*
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override;
Parameters
Name | Type | Description |
---|---|---|
from | address | The address which is transferring tokens. |
to | address | The address which is receiving tokens. |
amount | uint256 | The amount of tokens being transferred. |
clock
Overrides IERC6372 functions to make the token & governor timestamp-based
function clock() public view override(IERC6372, ERC20Votes) returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public pure override(IERC6372, ERC20Votes) returns (string memory);
Events
SenderAllowed
Emitted when an address is granted permission to initiate transfers.
event SenderAllowed(address indexed target, uint256 eventId);
Parameters
Name | Type | Description |
---|---|---|
target | address | The address that is being allowed to send tokens. |
eventId | uint256 | An identifier for the event to order events within the same block. |
SenderDisallowed
Emitted when an address has its permission to initiate transfers revoked.
event SenderDisallowed(address indexed target, uint256 eventId);
Parameters
Name | Type | Description |
---|---|---|
target | address | The address that is being disallowed from sending tokens. |
eventId | uint256 | An identifier for the event to order events within the same block. |
ReceiverAllowed
Emitted when an address is granted permission to receive transfers.
event ReceiverAllowed(address indexed target, uint256 eventId);
Parameters
Name | Type | Description |
---|---|---|
target | address | The address that is being allowed to receive tokens. |
eventId | uint256 | An identifier for the event to order events within the same block. |
ReceiverDisallowed
Emitted when an address has its permission to receive transfers revoked.
event ReceiverDisallowed(address indexed target, uint256 eventId);
Parameters
Name | Type | Description |
---|---|---|
target | address | The address that is being disallowed from receiving tokens. |
eventId | uint256 | An identifier for the event to order events within the same block. |