generated from AngleProtocol/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity ^0.8.7; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
import { IAccessControlManager } from "../../interfaces/IAccessControlManager.sol"; | ||
import "../../utils/Errors.sol"; | ||
|
||
/// @title PointToken | ||
/// @author Angle Labs, Inc. | ||
/// @notice Reference contract for points systems within Merkl | ||
contract PointToken is ERC20 { | ||
mapping(address => bool) public minters; | ||
mapping(address => bool) public whitelistedRecipients; | ||
IAccessControlManager public accessControlManager; | ||
uint8 public allowedTransfers; | ||
|
||
constructor( | ||
string memory name_, | ||
string memory symbol_, | ||
address _minter, | ||
address _accessControlManager | ||
) ERC20(name_, symbol_) { | ||
if (_accessControlManager == address(0) || _minter == address(0)) revert Errors.ZeroAddress(); | ||
accessControlManager = IAccessControlManager(_accessControlManager); | ||
minters[_minter] = true; | ||
} | ||
|
||
modifier onlyGovernorOrGuardian() { | ||
if (!accessControlManager.isGovernorOrGuardian(msg.sender)) revert Errors.NotGovernorOrGuardian(); | ||
_; | ||
} | ||
|
||
modifier onlyMinter() { | ||
if (!minters[msg.sender]) revert Errors.NotTrusted(); | ||
_; | ||
} | ||
|
||
function mint(address account, uint256 amount) external onlyMinter { | ||
_mint(account, amount); | ||
} | ||
|
||
function burn(address account, uint256 amount) external onlyMinter { | ||
_burn(account, amount); | ||
} | ||
|
||
function mintBatch(address[] memory accounts, uint256[] memory amounts) external onlyMinter { | ||
uint256 length = accounts.length; | ||
for (uint256 i = 0; i < length; ++i) { | ||
_mint(accounts[i], amounts[i]); | ||
} | ||
} | ||
|
||
function toggleMinter(address minter) external onlyGovernorOrGuardian { | ||
minters[minter] = !minters[minter]; | ||
} | ||
|
||
function toggleAllowedTransfers() external onlyGovernorOrGuardian { | ||
allowedTransfers = 1 - allowedTransfers; | ||
} | ||
|
||
function toggleWhitelistedRecipient(address recipient) external onlyGovernorOrGuardian { | ||
whitelistedRecipients[recipient] = !whitelistedRecipients[recipient]; | ||
} | ||
|
||
function _beforeTokenTransfer(address from, address to, uint256) internal view override { | ||
if ( | ||
allowedTransfers == 0 && | ||
from != address(0) && | ||
to != address(0) && | ||
!whitelistedRecipients[from] && | ||
!whitelistedRecipients[to] | ||
) revert Errors.NotAllowed(); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.