编译器
0.6.12+commit.27d51765
文件 1 的 10:Address.sol
pragma solidity ^0.6.2;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 10:BaseToken.sol
pragma solidity 0.6.12;
import "../libraries/math/SafeMath.sol";
import "../libraries/token/IERC20.sol";
import "../libraries/token/SafeERC20.sol";
import "./interfaces/IYieldTracker.sol";
import "./interfaces/IBaseToken.sol";
contract BaseToken is IERC20, IBaseToken {
using SafeMath for uint256;
using SafeERC20 for IERC20;
string public name;
string public symbol;
uint8 public constant decimals = 18;
uint256 public override totalSupply;
uint256 public nonStakingSupply;
address public gov;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowances;
address[] public yieldTrackers;
mapping (address => bool) public nonStakingAccounts;
mapping (address => bool) public admins;
bool public inPrivateTransferMode;
mapping (address => bool) public isHandler;
modifier onlyGov() {
require(msg.sender == gov, "BaseToken: forbidden");
_;
}
modifier onlyAdmin() {
require(admins[msg.sender], "BaseToken: forbidden");
_;
}
constructor(string memory _name, string memory _symbol, uint256 _initialSupply) public {
name = _name;
symbol = _symbol;
gov = msg.sender;
_mint(msg.sender, _initialSupply);
}
function setGov(address _gov) external onlyGov {
gov = _gov;
}
function setInfo(string memory _name, string memory _symbol) external onlyGov {
name = _name;
symbol = _symbol;
}
function setYieldTrackers(address[] memory _yieldTrackers) external onlyGov {
yieldTrackers = _yieldTrackers;
}
function addAdmin(address _account) external onlyGov {
admins[_account] = true;
}
function removeAdmin(address _account) external override onlyGov {
admins[_account] = false;
}
function withdrawToken(address _token, address _account, uint256 _amount) external override onlyGov {
IERC20(_token).safeTransfer(_account, _amount);
}
function setInPrivateTransferMode(bool _inPrivateTransferMode) external override onlyGov {
inPrivateTransferMode = _inPrivateTransferMode;
}
function setHandler(address _handler, bool _isActive) external onlyGov {
isHandler[_handler] = _isActive;
}
function addNonStakingAccount(address _account) external onlyAdmin {
require(!nonStakingAccounts[_account], "BaseToken: _account already marked");
_updateRewards(_account);
nonStakingAccounts[_account] = true;
nonStakingSupply = nonStakingSupply.add(balances[_account]);
}
function removeNonStakingAccount(address _account) external onlyAdmin {
require(nonStakingAccounts[_account], "BaseToken: _account not marked");
_updateRewards(_account);
nonStakingAccounts[_account] = false;
nonStakingSupply = nonStakingSupply.sub(balances[_account]);
}
function recoverClaim(address _account, address _receiver) external onlyAdmin {
for (uint256 i = 0; i < yieldTrackers.length; i++) {
address yieldTracker = yieldTrackers[i];
IYieldTracker(yieldTracker).claim(_account, _receiver);
}
}
function claim(address _receiver) external {
for (uint256 i = 0; i < yieldTrackers.length; i++) {
address yieldTracker = yieldTrackers[i];
IYieldTracker(yieldTracker).claim(msg.sender, _receiver);
}
}
function totalStaked() external view override returns (uint256) {
return totalSupply.sub(nonStakingSupply);
}
function balanceOf(address _account) external view override returns (uint256) {
return balances[_account];
}
function stakedBalance(address _account) external view override returns (uint256) {
if (nonStakingAccounts[_account]) {
return 0;
}
return balances[_account];
}
function transfer(address _recipient, uint256 _amount) external override returns (bool) {
_transfer(msg.sender, _recipient, _amount);
return true;
}
function allowance(address _owner, address _spender) external view override returns (uint256) {
return allowances[_owner][_spender];
}
function approve(address _spender, uint256 _amount) external override returns (bool) {
_approve(msg.sender, _spender, _amount);
return true;
}
function transferFrom(address _sender, address _recipient, uint256 _amount) external override returns (bool) {
if (isHandler[msg.sender]) {
_transfer(_sender, _recipient, _amount);
return true;
}
uint256 nextAllowance = allowances[_sender][msg.sender].sub(_amount, "BaseToken: transfer amount exceeds allowance");
_approve(_sender, msg.sender, nextAllowance);
_transfer(_sender, _recipient, _amount);
return true;
}
function _mint(address _account, uint256 _amount) internal {
require(_account != address(0), "BaseToken: mint to the zero address");
_updateRewards(_account);
totalSupply = totalSupply.add(_amount);
balances[_account] = balances[_account].add(_amount);
if (nonStakingAccounts[_account]) {
nonStakingSupply = nonStakingSupply.add(_amount);
}
emit Transfer(address(0), _account, _amount);
}
function _burn(address _account, uint256 _amount) internal {
require(_account != address(0), "BaseToken: burn from the zero address");
_updateRewards(_account);
balances[_account] = balances[_account].sub(_amount, "BaseToken: burn amount exceeds balance");
totalSupply = totalSupply.sub(_amount);
if (nonStakingAccounts[_account]) {
nonStakingSupply = nonStakingSupply.sub(_amount);
}
emit Transfer(_account, address(0), _amount);
}
function _transfer(address _sender, address _recipient, uint256 _amount) private {
require(_sender != address(0), "BaseToken: transfer from the zero address");
require(_recipient != address(0), "BaseToken: transfer to the zero address");
if (inPrivateTransferMode) {
require(isHandler[msg.sender], "BaseToken: msg.sender not whitelisted");
}
_updateRewards(_sender);
_updateRewards(_recipient);
balances[_sender] = balances[_sender].sub(_amount, "BaseToken: transfer amount exceeds balance");
balances[_recipient] = balances[_recipient].add(_amount);
if (nonStakingAccounts[_sender]) {
nonStakingSupply = nonStakingSupply.sub(_amount);
}
if (nonStakingAccounts[_recipient]) {
nonStakingSupply = nonStakingSupply.add(_amount);
}
emit Transfer(_sender, _recipient,_amount);
}
function _approve(address _owner, address _spender, uint256 _amount) private {
require(_owner != address(0), "BaseToken: approve from the zero address");
require(_spender != address(0), "BaseToken: approve to the zero address");
allowances[_owner][_spender] = _amount;
emit Approval(_owner, _spender, _amount);
}
function _updateRewards(address _account) private {
for (uint256 i = 0; i < yieldTrackers.length; i++) {
address yieldTracker = yieldTrackers[i];
IYieldTracker(yieldTracker).updateRewards(_account);
}
}
}
文件 3 的 10:EsMOX.sol
pragma solidity 0.6.12;
import "../tokens/MintableBaseToken.sol";
contract EsMOX is MintableBaseToken {
constructor() public MintableBaseToken("Escrowed MOX", "esMOX", 0) {
}
function id() external pure returns (string memory _name) {
return "esMOX";
}
}
文件 4 的 10:IBaseToken.sol
pragma solidity 0.6.12;
interface IBaseToken {
function totalStaked() external view returns (uint256);
function stakedBalance(address _account) external view returns (uint256);
function removeAdmin(address _account) external;
function setInPrivateTransferMode(bool _inPrivateTransferMode) external;
function withdrawToken(address _token, address _account, uint256 _amount) external;
}
文件 5 的 10:IERC20.sol
pragma solidity 0.6.12;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 6 的 10:IMintable.sol
pragma solidity 0.6.12;
interface IMintable {
function isMinter(address _account) external returns (bool);
function setMinter(address _minter, bool _isActive) external;
function mint(address _account, uint256 _amount) external;
function burn(address _account, uint256 _amount) external;
}
文件 7 的 10:IYieldTracker.sol
pragma solidity 0.6.12;
interface IYieldTracker {
function claim(address _account, address _receiver) external returns (uint256);
function updateRewards(address _account) external;
function getTokensPerInterval() external view returns (uint256);
function claimable(address _account) external view returns (uint256);
}
文件 8 的 10:MintableBaseToken.sol
pragma solidity 0.6.12;
import "./BaseToken.sol";
import "./interfaces/IMintable.sol";
contract MintableBaseToken is BaseToken, IMintable {
mapping (address => bool) public override isMinter;
constructor(string memory _name, string memory _symbol, uint256 _initialSupply) public BaseToken(_name, _symbol, _initialSupply) {
}
modifier onlyMinter() {
require(isMinter[msg.sender], "MintableBaseToken: forbidden");
_;
}
function setMinter(address _minter, bool _isActive) external override onlyGov {
isMinter[_minter] = _isActive;
}
function mint(address _account, uint256 _amount) external override onlyMinter {
_mint(_account, _amount);
}
function burn(address _account, uint256 _amount) external override onlyMinter {
_burn(_account, _amount);
}
}
文件 9 的 10:SafeERC20.sol
pragma solidity 0.6.12;
import "./IERC20.sol";
import "../math/SafeMath.sol";
import "../utils/Address.sol";
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
文件 10 的 10:SafeMath.sol
pragma solidity 0.6.12;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
{
"compilationTarget": {
"contracts/mox/EsMOX.sol": "EsMOX"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 10
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"addNonStakingAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"admins","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"id","outputs":[{"internalType":"string","name":"_name","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"inPrivateTransferMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isHandler","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonStakingAccounts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonStakingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"recoverClaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"removeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"removeNonStakingAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_handler","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setHandler","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_inPrivateTransferMode","type":"bool"}],"name":"setInPrivateTransferMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"setInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_yieldTrackers","type":"address[]"}],"name":"setYieldTrackers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"stakedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"yieldTrackers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]