Skip to content

Commit

Permalink
Merge 51121b8 into 7663fb8
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickGT committed Sep 30, 2021
2 parents 7663fb8 + 51121b8 commit 5ccb533
Show file tree
Hide file tree
Showing 84 changed files with 10,749 additions and 9,103 deletions.
22 changes: 19 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 4
"tabWidth": 4,
"overrides": [
{
"files": "*.*.{ts,js}",
"options": {
"parser": "typescript",
"trailingComma": "all",
"arrowParens": "always",
"singleQuote": true
}
},
{
"files": "*.sol",
"options": {
"bracketSpacing": true,
"explicitTypes": "always"
}
}
]
}
14 changes: 7 additions & 7 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
mocha: { reporter: 'mocha-junit-reporter' },
providerOptions: {
network_id: 1337,
_chainId: 1337,
_chainIdRpc: 1337,
},
skipFiles: ['external', 'test'],
mocha: { reporter: 'mocha-junit-reporter' },
providerOptions: {
network_id: 1337,
_chainId: 1337,
_chainIdRpc: 1337,
},
skipFiles: ['external', 'test'],
};
188 changes: 94 additions & 94 deletions contracts/ControlledToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,103 +8,103 @@ import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "./interfaces/IControlledToken.sol";

/**
* @title PoolTogether V4 Controlled ERC20 Token
* @author PoolTogether Inc Team
* @notice ERC20 Tokens with a controller for minting & burning
*/
* @title PoolTogether V4 Controlled ERC20 Token
* @author PoolTogether Inc Team
* @notice ERC20 Tokens with a controller for minting & burning
*/
contract ControlledToken is ERC20Permit, IControlledToken {
/* ============ Global Variables ============ */

/* ============ Global Variables ============ */

/// @notice Interface to the contract responsible for controlling mint/burn
address public override controller;

/// @notice ERC20 controlled token decimals.
uint8 private immutable _decimals;

/* ============ Events ============ */

/// @dev Emitted when contract is deployed
event Deployed(
string name,
string symbol,
uint8 decimals,
address indexed controller
);

/* ============ Modifiers ============ */

/// @dev Function modifier to ensure that the caller is the controller contract
modifier onlyController {
require(msg.sender == address(controller), "ControlledToken/only-controller");
_;
}

/* ============ Constructor ============ */

/// @notice Deploy the Controlled Token with Token Details and the Controller
/// @param _name The name of the Token
/// @param _symbol The symbol for the Token
/// @param decimals_ The number of decimals for the Token
/// @param _controller Address of the Controller contract for minting & burning
constructor(
string memory _name,
string memory _symbol,
uint8 decimals_,
address _controller
)
ERC20Permit("PoolTogether ControlledToken")
ERC20(_name, _symbol)
{
require(address(_controller) != address(0), "ControlledToken/controller-not-zero-address");
controller = _controller;

require(decimals_ > 0, "ControlledToken/decimals-gt-zero");
_decimals = decimals_;

emit Deployed(
_name,
_symbol,
decimals_,
_controller
);
}

/* ============ External Functions ============ */

/// @notice Allows the controller to mint tokens for a user account
/// @dev May be overridden to provide more granular control over minting
/// @param _user Address of the receiver of the minted tokens
/// @param _amount Amount of tokens to mint
function controllerMint(address _user, uint256 _amount) external virtual override onlyController {
_mint(_user, _amount);
}

/// @notice Allows the controller to burn tokens from a user account
/// @dev May be overridden to provide more granular control over burning
/// @param _user Address of the holder account to burn tokens from
/// @param _amount Amount of tokens to burn
function controllerBurn(address _user, uint256 _amount) external virtual override onlyController {
_burn(_user, _amount);
}

/// @notice Allows an operator via the controller to burn tokens on behalf of a user account
/// @dev May be overridden to provide more granular control over operator-burning
/// @param _operator Address of the operator performing the burn action via the controller contract
/// @param _user Address of the holder account to burn tokens from
/// @param _amount Amount of tokens to burn
function controllerBurnFrom(address _operator, address _user, uint256 _amount) external virtual override onlyController {
if (_operator != _user) {
_approve(_user, _operator, allowance(_user, _operator) - _amount);
/// @notice Interface to the contract responsible for controlling mint/burn
address public override controller;

/// @notice ERC20 controlled token decimals.
uint8 private immutable _decimals;

/* ============ Events ============ */

/// @dev Emitted when contract is deployed
event Deployed(string name, string symbol, uint8 decimals, address indexed controller);

/* ============ Modifiers ============ */

/// @dev Function modifier to ensure that the caller is the controller contract
modifier onlyController() {
require(msg.sender == address(controller), "ControlledToken/only-controller");
_;
}

_burn(_user, _amount);
}
/* ============ Constructor ============ */

/// @notice Deploy the Controlled Token with Token Details and the Controller
/// @param _name The name of the Token
/// @param _symbol The symbol for the Token
/// @param decimals_ The number of decimals for the Token
/// @param _controller Address of the Controller contract for minting & burning
constructor(
string memory _name,
string memory _symbol,
uint8 decimals_,
address _controller
) ERC20Permit("PoolTogether ControlledToken") ERC20(_name, _symbol) {
require(address(_controller) != address(0), "ControlledToken/controller-not-zero-address");
controller = _controller;

require(decimals_ > 0, "ControlledToken/decimals-gt-zero");
_decimals = decimals_;

emit Deployed(_name, _symbol, decimals_, _controller);
}

/// @notice Returns the ERC20 controlled token decimals.
/// @dev This value should be equal to the decimals of the token used to deposit into the pool.
/// @return uint8 decimals.
function decimals() public view virtual override returns (uint8) {
return _decimals;
}
/* ============ External Functions ============ */

/// @notice Allows the controller to mint tokens for a user account
/// @dev May be overridden to provide more granular control over minting
/// @param _user Address of the receiver of the minted tokens
/// @param _amount Amount of tokens to mint
function controllerMint(address _user, uint256 _amount)
external
virtual
override
onlyController
{
_mint(_user, _amount);
}

/// @notice Allows the controller to burn tokens from a user account
/// @dev May be overridden to provide more granular control over burning
/// @param _user Address of the holder account to burn tokens from
/// @param _amount Amount of tokens to burn
function controllerBurn(address _user, uint256 _amount)
external
virtual
override
onlyController
{
_burn(_user, _amount);
}

/// @notice Allows an operator via the controller to burn tokens on behalf of a user account
/// @dev May be overridden to provide more granular control over operator-burning
/// @param _operator Address of the operator performing the burn action via the controller contract
/// @param _user Address of the holder account to burn tokens from
/// @param _amount Amount of tokens to burn
function controllerBurnFrom(
address _operator,
address _user,
uint256 _amount
) external virtual override onlyController {
if (_operator != _user) {
_approve(_user, _operator, allowance(_user, _operator) - _amount);
}

_burn(_user, _amount);
}

/// @notice Returns the ERC20 controlled token decimals.
/// @dev This value should be equal to the decimals of the token used to deposit into the pool.
/// @return uint8 decimals.
function decimals() public view virtual override returns (uint8) {
return _decimals;
}
}
Loading

0 comments on commit 5ccb533

Please sign in to comment.