// SPDX-License-Identifier: MIT pragma solidity 0.8.19; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "../interfaces/IEsPropel.sol"; import "../interfaces/IPropel.sol"; import "../dependencies/PropelOwnable.sol"; contract EsPropel is ERC20Burnable, PropelOwnable, IEsPropel { address internal deployer; IPropel public propel; address public vest; mapping(address => bool) public senders; mapping(address => bool) public receivers; constructor(IPropelCore _propelCore, address _propel, address _vest) ERC20("Escrow Propel", "esPropel") PropelOwnable(_propelCore) { propel = IPropel(_propel); vest = _vest; _authSender(_vest, true); _authReceiver(_vest, true); } function mint(address account, uint256 amount) external { _requireCallerIsPropel(); _mint(account, amount); } function authAll(address[] memory _callers, bool[] memory _enables) external onlyOwner { _authSenders(_callers, _enables); _authReceivers(_callers, _enables); } function authSenders(address[] memory _senders, bool[] memory _enables) external onlyOwner { _authSenders(_senders, _enables); } function _authSenders(address[] memory _senders, bool[] memory _enables) internal { require(_senders.length == _enables.length, "EsPropel: number of senders must be equal to the number of enables"); for (uint256 i = 0; i < _senders.length; i++) { _authSender(_senders[i], _enables[i]); } } function _authSender(address _sender, bool _enable) internal { senders[_sender] = _enable; emit SenderUpdated(_sender, _enable); } function authReceivers(address[] memory _receivers, bool[] memory _enables) external onlyOwner { _authReceivers(_receivers, _enables); } function _authReceivers(address[] memory _receivers, bool[] memory _enables) internal { require(_receivers.length == _enables.length, "EsPropel: number of receivers must be equal to the number of enables"); for (uint256 i = 0; i < _receivers.length; i++) { _authReceiver(_receivers[i], _enables[i]); } } function _authReceiver(address _receiver, bool _enable) internal { receivers[_receiver] = _enable; emit ReceiverUpdated(_receiver, _enable); } function burnFromPropel(address account, uint256 amount) external override { _requireCallerIsPropel(); _burn(account, amount); } function burn(uint256 amount) public override(ERC20Burnable, IEsPropel) { ERC20Burnable.burn(amount); } function burnFrom(address account, uint256 amount) public override(ERC20Burnable, IEsPropel) { ERC20Burnable.burnFrom(account, amount); } function sendToken(address from, uint256 amount) external override { _requireCallerIsReceiver(); _transfer(from, msg.sender, amount); } function transfer(address to, uint256 amount) public override(IERC20, ERC20) returns (bool) { _requireCallerIsSender(); _transfer(msg.sender, to, amount); return true; } function transferFrom(address from, address to, uint256 amount) public pure override(IERC20, ERC20) returns (bool) { revert("EsPropel: not allowed"); } function _requireCallerIsSender() internal view { require(senders[msg.sender], "EsPropel: invalid sender"); } function _requireCallerIsReceiver() internal view { require(receivers[msg.sender], "EsPropel: invalid receiver"); } function _requireCallerIsPropel() internal view { require(msg.sender == address(propel), "EsPropel: Caller is not Propel"); } }