all files / contracts/ SOLACE.sol

100% Statements 9/9
100% Branches 4/4
100% Functions 6/6
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79                                                                                      625×   616×               53×                 182× 181× 173×                 48× 40×      
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.6;
 
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
import "./utils/Governable.sol";
import "./interfaces/ISOLACE.sol";
 
/**
 * @title Solace Token (SOLACE)
 * @author solace.fi
 * @notice The native governance token of the Solace Coverage Protocol.
 */
contract SOLACE is ISOLACE, ERC20Permit, Governable {
    using SafeERC20 for IERC20;
    using Address for address;
 
    // Minters
    mapping (address => bool) internal _minters;
 
    /**
     * @notice Constructs the Solace Token contract.
     * @param governance_ The address of the [governor](/docs/protocol/governance).
     */
    constructor(address governance_) ERC20("solace", "SOLACE") ERC20Permit("solace") Governable(governance_) { }
 
    /**
     * @notice Returns true if `account` is authorized to mint [**SOLACE**](./SOLACE).
     * @param account Account to query.
     * @return status True if `account` can mint, false otherwise.
     */
    function isMinter(address account) external view override returns (bool status) {
        return _minters[account];
    }
 
    /**
     * @notice Mints new [**SOLACE**](./SOLACE) to the receiver account.
     * Can only be called by authorized minters.
     * @param account The receiver of new tokens.
     * @param amount The number of new tokens.
     */
    function mint(address account, uint256 amount) external override {
        // can only be called by authorized minters
        require(_minters[msg.sender], "!minter");
        // mint
        _mint(account, amount);
    }
 
    /**
     * @notice Burns [**SOLACE**](./SOLACE) from msg.sender.
     * @param amount Amount to burn.
     */
    function burn(uint256 amount) external override {
        _burn(msg.sender, amount);
    }
 
    /**
     * @notice Adds a new minter.
     * Can only be called by the current [**governor**](/docs/protocol/governance).
     * @param minter The new minter.
     */
    function addMinter(address minter) external onlyGovernance override {
        require(minter != address(0x0), "zero address");
        _minters[minter] = true;
        emit MinterAdded(minter);
    }
 
    /**
     * @notice Removes a minter.
     * Can only be called by the current [**governor**](/docs/protocol/governance).
     * @param minter The minter to remove.
     */
    function removeMinter(address minter) external onlyGovernance override {
        _minters[minter] = false;
        emit MinterRemoved(minter);
    }
}