@maplelabs/core-artifacts
Version:
Consist artifacts of the maple protocol
329 lines (328 loc) • 1.29 MB
JSON
{
"id": "438132ea022a1589434948471a655bc5",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.6.11",
"solcLongVersion": "0.6.11+commit.5ef660b1",
"input": {
"language": "Solidity",
"sources": {
"contracts/core/mpl-rewards/v1/MplRewards.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-or-later // hevm: flattened sources of contracts/core/mpl-rewards/v1/MplRewards.sol\npragma solidity =0.6.11 >=0.6.0 <0.8.0 >=0.6.2 <0.8.0;\n\n////// contracts/core/custodial-ownership-token/v1/interfaces/IERC2258.sol\n/* pragma solidity 0.6.11; */\n\n/// @title ERC2258 implements the basic level functionality for a token capable of custodial ownership.\ninterface IERC2258 {\n\n /**\n @dev Emits an event indicating a transfer was performed by a Custodian.\n @param custodian The Custodian performing the transfer.\n @param from The account from which balance is being decremented.\n @param to The account receiving the token.\n @param amount The amount transferred.\n */\n event CustodyTransfer(address custodian, address from, address to, uint256 amount);\n\n /**\n @dev Emits an event indicating that the amount held by `custodian` on behalf of `account` has changed.\n @param account The account to which the token belongs.\n @param custodian The Custodian being entrusted.\n @param oldAllowance The old amount the account has entrusted with `custodian`.\n @param newAllowance The new amount the account has entrusted with `custodian`.\n */\n event CustodyAllowanceChanged(address account, address custodian, uint256 oldAllowance, uint256 newAllowance);\n\n /**\n @param account The account to which some token belongs.\n @param custodian The Custodian being entrusted.\n @return The individual custody limit `account` has entrusted with `custodian`.\n */\n function custodyAllowance(address account, address custodian) external view returns (uint256);\n \n /**\n @param account The account to which some token belongs.\n @return The total custody limit `account` has entrusted with all custodians.\n */\n function totalCustodyAllowance(address account) external view returns (uint256);\n\n /**\n @dev Increase the custody limit of a custodian on behalf of the caller.\n @param custodian The Custodian being entrusted with `amount` additional token.\n @param amount The amount of additional token being entrusted with `custodian`.\n */\n function increaseCustodyAllowance(address custodian, uint256 amount) external;\n\n /**\n @dev Allows a Custodian to exercise their right to transfer custodied tokens.\n @param from The account from which balance is being decremented.\n @param to The account receiving the token.\n @param amount The amount transferred.\n */\n function transferByCustodian(address from, address to, uint256 amount) external;\n\n}\n\n////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n\n////// contracts/core/mpl-rewards/v1/interfaces/IMplRewards.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20 } from \"../../../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\"; */\n\n/* import { IERC2258 } from \"../../../custodial-ownership-token/v1/interfaces/IERC2258.sol\"; */\n\n/// @title MplRewards Synthetix farming contract fork for liquidity mining.\ninterface IMplRewards {\n\n /**\n @dev Emits an event indicating that a reward was added.\n @param reward The amount of the added reward.\n */\n event RewardAdded(uint256 reward);\n\n /**\n @dev Emits an event indicating that an account has staked.\n @param account The address of the account.\n @param amount The amount staked.\n */\n event Staked(address indexed account, uint256 amount);\n\n /**\n @dev Emits an event indicating that reward was withdrawn.\n @param account The address of the account.\n @param amount The amount withdrawn.\n */\n event Withdrawn(address indexed account, uint256 amount);\n\n /**\n @dev Emits an event indicating that some reward was paid to an account.\n @param account The address of the account rewarded.\n @param reward The amount rewarded to `account`.\n */\n event RewardPaid(address indexed account, uint256 reward);\n\n /**\n @dev Emits an event indicating that the duration of the ward period has updated.\n @param newDuration The new duration of the rewards.\n */\n event RewardsDurationUpdated(uint256 newDuration);\n\n /**\n @dev Emits an event indicating that some token was recovered.\n @param token The address of the token recovered.\n @param amount The amount recovered.\n */\n event Recovered(address token, uint256 amount);\n\n /**\n @dev Emits an event indicating that pause state has changed.\n @param isPaused Whether the contract is paused.\n */\n event PauseChanged(bool isPaused);\n\n /**\n @dev The rewards token.\n */\n function rewardsToken() external view returns (IERC20);\n\n /**\n @dev The staking token.\n */\n function stakingToken() external view returns (IERC2258);\n\n /**\n @dev The period finish.\n */\n function periodFinish() external view returns (uint256);\n\n /**\n @dev The rewards rate.\n */\n function rewardRate() external view returns (uint256);\n\n /**\n @dev The rewards duration.\n */\n function rewardsDuration() external view returns (uint256);\n\n /**\n @dev The last update time.\n */\n function lastUpdateTime() external view returns (uint256);\n\n /**\n @dev The reward per token stored.\n */\n function rewardPerTokenStored() external view returns (uint256);\n\n /**\n @dev The last pause time.\n */\n function lastPauseTime() external view returns (uint256);\n\n /**\n @dev Whether the contract is paused.\n */\n function paused() external view returns (bool);\n\n /**\n @param account The address of an account.\n @return The reward per token paid for `account`.\n */\n function userRewardPerTokenPaid(address account) external view returns (uint256);\n\n /**\n @param account The address of an account.\n @return The rewards `account`.\n */\n function rewards(address account) external view returns (uint256);\n\n /**\n @return The total supply.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n @param account The address of an account.\n @return The balance of `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n @return The last time rewards were applicable.\n */\n function lastTimeRewardApplicable() external view returns (uint256);\n\n /**\n @return The reward per token.\n */\n function rewardPerToken() external view returns (uint256);\n\n /**\n @param account The address of an account.\n @return The rewards earned of `account`.\n */\n function earned(address account) external view returns (uint256);\n\n /**\n @return The reward for a duration.\n */\n function getRewardForDuration() external view returns (uint256);\n\n /**\n @dev It emits a `Staked` event.\n @param amount An amount to stake.\n */\n function stake(uint256 amount) external;\n\n /**\n @dev It emits a `Withdrawn` event.\n @param amount An amount to withdraw.\n */\n function withdraw(uint256 amount) external;\n\n /**\n @dev It emits a `RewardPaid` event if any rewards are received.\n */\n function getReward() external;\n\n /**\n @dev Withdraw the entire balance and get the reward.\n */\n function exit() external;\n\n /**\n @dev Only the contract Owner may call this. \n @dev It emits a `RewardAdded` event. \n @param reward A reward amount.\n */\n function notifyRewardAmount(uint256 reward) external;\n\n /**\n @dev End rewards emission earlier. Only the contract Owner may call this.\n @param timestamp A unix timestamp to finish rewards.\n */\n function updatePeriodFinish(uint256 timestamp) external;\n\n /**\n @dev Added to support recovering tokens unintentionally sent to this contract. \n @dev Only the contract Owner may call this. \n @dev It emits a `Recovered` event. \n @param tokenAddress The address of a token to recover.\n @param tokenAmount The amount to recover.\n */\n function recoverERC20(address tokenAddress, uint256 tokenAmount) external;\n\n /**\n @dev Only the contract Owner may call this. \n @dev It emits a `RewardsDurationUpdated` event. \n @param _rewardsDuration The new duration for rewards.\n */\n function setRewardsDuration(uint256 _rewardsDuration) external;\n\n /**\n @dev Change the paused state of the contract. Only the contract Owner may call this. \n @dev It emits a `PauseChanged` event. \n @param _paused Whether to pause the contract.\n */\n function setPaused(bool _paused) external;\n\n}\n\n////// lib/openzeppelin-contracts/contracts/GSN/Context.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n\n////// lib/openzeppelin-contracts/contracts/access/Ownable.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/* import \"../GSN/Context.sol\"; */\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor () internal {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = address(0);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n}\n\n////// lib/openzeppelin-contracts/contracts/math/Math.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a >= b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow, so we distribute\n return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);\n }\n}\n\n////// lib/openzeppelin-contracts/contracts/math/SafeMath.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return mod(a, b, \"SafeMath: modulo by zero\");\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts with custom message when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b != 0, errorMessage);\n return a % b;\n }\n}\n\n////// lib/openzeppelin-contracts/contracts/utils/Address.sol\n/* pragma solidity >=0.6.2 <0.8.0; */\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain`call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\n////// lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/* import \"./IERC20.sol\"; */\n/* import \"../../math/SafeMath.sol\"; */\n/* import \"../../utils/Address.sol\"; */\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using SafeMath for uint256;\n using Address for address;\n\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n // solhint-disable-next-line max-line-length\n require((value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).sub(value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) { // Return data is optional\n // solhint-disable-next-line max-line-length\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n\n////// contracts/core/mpl-rewards/v1/MplRewards.sol\n/* pragma solidity 0.6.11; */\n\n/* import { Ownable } from \"../../../../lib/openzeppelin-contracts/contracts/access/Ownable.sol\"; */\n/* import { Math } from \"../../../../lib/openzeppelin-contracts/contracts/math/Math.sol\"; */\n/* import { SafeMath } from \"../../../../lib/openzeppelin-contracts/contracts/math/SafeMath.sol\"; */\n/* import { IERC20, SafeERC20 } from \"../../../../lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol\"; */\n\n/* import { IERC2258 } from \"../../custodial-ownership-token/v1/interfaces/IERC2258.sol\"; */\n\n/* import { IMplRewards } from \"./interfaces/IMplRewards.sol\"; */\n\n// https://docs.synthetix.io/contracts/source/contracts/stakingrewards\n/// @title MplRewards Synthetix farming contract fork for liquidity mining.\ncontract MplRewards is IMplRewards, Ownable {\n\n using SafeMath for uint256;\n using SafeERC20 for IERC20;\n\n IERC20 public override immutable rewardsToken;\n IERC2258 public override immutable stakingToken;\n\n uint256 public override periodFinish;\n uint256 public override rewardRate;\n uint256 public override rewardsDuration;\n uint256 public override lastUpdateTime;\n uint256 public override rewardPerTokenStored;\n uint256 public override lastPauseTime;\n bool public override paused;\n\n mapping(address => uint256) public override userRewardPerTokenPaid;\n mapping(address => uint256) public override rewards;\n\n uint256 private _totalSupply;\n\n mapping(address => uint256) private _balances;\n\n constructor(address _rewardsToken, address _stakingToken, address _owner) public {\n rewardsToken = IERC20(_rewardsToken);\n stakingToken = IERC2258(_stakingToken);\n rewardsDuration = 7 days;\n transferOwnership(_owner);\n }\n\n function _updateReward(address account) internal {\n uint256 _rewardPerTokenStored = rewardPerToken();\n rewardPerTokenStored = _rewardPerTokenStored;\n lastUpdateTime = lastTimeRewardApplicable();\n\n if (account != address(0)) {\n rewards[account] = earned(account);\n userRewardPerTokenPaid[account] = _rewardPerTokenStored;\n }\n }\n\n function _notPaused() internal view {\n require(!paused, \"R:PAUSED\");\n }\n\n function totalSupply() external override view returns (uint256) {\n return _totalSupply;\n }\n\n function balanceOf(address account) external override view returns (uint256) {\n return _balances[account];\n }\n\n function lastTimeRewardApplicable() public override view returns (uint256) {\n return Math.min(block.timestamp, periodFinish);\n }\n\n function rewardPerToken() public override view returns (uint256) {\n return _totalSupply == 0\n ? rewardPerTokenStored\n : rewardPerTokenStored.add(\n lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)\n );\n }\n\n function earned(address account) public override view returns (uint256) {\n return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);\n }\n\n function getRewardForDuration() external override view returns (uint256) {\n return rewardRate.mul(rewardsDuration);\n }\n\n function stake(uint256 amount) external override {\n _notPaused();\n _updateReward(msg.sender);\n uint256 newBalance = _balances[msg.sender].add(amount);\n require(amount > 0, \"R:ZERO_STAKE\");\n require(stakingToken.custodyAllowance(msg.sender, address(this)) >= newBalance, \"R:INSUF_CUST_ALLOWANCE\");\n _totalSupply = _totalSupply.add(amount);\n _balances[msg.sender] = newBalance;\n emit Staked(msg.sender, amount);\n }\n\n function withdraw(uint256 amount) public override {\n _notPaused();\n _updateReward(msg.sender);\n require(amount > 0, \"R:ZERO_WITHDRAW\");\n _totalSupply = _totalSupply.sub(amount);\n _balances[msg.sender] = _balances[msg.sender].sub(amount);\n stakingToken.transferByCustodian(msg.sender, msg.sender, amount);\n emit Withdrawn(msg.sender, amount);\n }\n\n function getReward() public override {\n _notPaused();\n _updateReward(msg.sender);\n uint256 reward = rewards[msg.sender];\n\n if (reward == uint256(0)) return;\n\n rewards[msg.sender] = uint256(0);\n rewardsToken.safeTransfer(msg.sender, reward);\n emit RewardPaid(msg.sender, reward);\n }\n\n function exit() external override {\n withdraw(_balances[msg.sender]);\n getReward();\n }\n\n function notifyRewardAmount(uint256 reward) external override onlyOwner {\n _updateReward(address(0));\n\n uint256 _rewardRate = block.timestamp >= periodFinish\n ? reward.div(rewardsDuration)\n : reward.add(\n periodFinish.sub(block.timestamp).mul(rewardRate)\n ).div(rewardsDuration);\n\n rewardRate = _rewardRate;\n\n // Ensure the provided reward amount is not more than the balance in the contract.\n // This keeps the reward rate in the right range, preventing overflows due to\n // very high values of rewardRate in the earned and rewardsPerToken functions;\n // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.\n uint256 balance = rewardsToken.balanceOf(address(this));\n require(_rewardRate <= balance.div(rewardsDuration), \"R:REWARD_TOO_HIGH\");\n\n lastUpdateTime = block.timestamp;\n periodFinish = block.timestamp.add(rewardsDuration);\n emit RewardAdded(reward);\n }\n\n function updatePeriodFinish(uint256 timestamp) external override onlyOwner {\n _updateReward(address(0));\n periodFinish = timestamp;\n }\n\n function recoverERC20(address tokenAddress, uint256 tokenAmount) external override onlyOwner {\n IERC20(tokenAddress).safeTransfer(owner(), tokenAmount);\n emit Recovered(tokenAddress, tokenAmount);\n }\n\n function setRewardsDuration(uint256 _rewardsDuration) external override onlyOwner {\n require(block.timestamp > periodFinish, \"R:PERIOD_NOT_FINISHED\");\n rewardsDuration = _rewardsDuration;\n emit RewardsDurationUpdated(rewardsDuration);\n }\n\n function setPaused(bool _paused) external override onlyOwner {\n // Ensure we're actually changing the state before we do anything\n require(_paused != paused, \"R:ALREADY_SET\");\n\n // Set our paused state.\n paused = _paused;\n\n // If applicable, set the last pause time.\n if (_paused) lastPauseTime = block.timestamp;\n\n // Let everyone know that our pause state has changed.\n emit PauseChanged(paused);\n }\n\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers"
],
"": [
"ast"
]
}
}
}
},
"output": {
"contracts": {
"contracts/core/mpl-rewards/v1/MplRewards.sol": {
"Address": {
"abi": [],
"evm": {
"bytecode": {
"linkReferences": {},
"object": "60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204822a19a0ba07d6e626ca3d8ece0f1a330787a14e1c9438985c163540e1a9f8b64736f6c634300060b0033",
"opcodes": "PUSH1 0x56 PUSH1 0x23 PUSH1 0xB DUP3 DUP3 DUP3 CODECOPY DUP1 MLOAD PUSH1 0x0 BYTE PUSH1 0x73 EQ PUSH1 0x16 JUMPI INVALID JUMPDEST ADDRESS PUSH1 0x0 MSTORE PUSH1 0x73 DUP2 MSTORE8 DUP3 DUP2 RETURN INVALID PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 0x48 0x22 LOG1 SWAP11 SIGNEXTEND LOG0 PUSH30 0x6E626CA3D8ECE0F1A330787A14E1C9438985C163540E1A9F8B64736F6C63 NUMBER STOP MOD SIGNEXTEND STOP CALLER ",
"sourceMap": "21131:6704:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;"
},
"deployedBytecode": {
"immutableReferences": {},
"linkReferences": {},
"object": "73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204822a19a0ba07d6e626ca3d8ece0f1a330787a14e1c9438985c163540e1a9f8b64736f6c634300060b0033",
"opcodes": "PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 0x48 0x22 LOG1 SWAP11 SIGNEXTEND LOG0 PUSH30 0x6E626CA3D8ECE0F1A330787A14E1C9438985C163540E1A9F8B64736F6C63 NUMBER STOP MOD SIGNEXTEND STOP CALLER ",
"sourceMap": "21131:6704:0:-:0;;;;;;;;"
},
"methodIdentifiers": {}
}
},
"Context": {
"abi": [],
"evm": {
"bytecode": {
"linkReferences": {},
"object": "",
"opcodes": "",
"sourceMap": ""
},
"deployedBytecode": {
"immutableReferences": {},
"linkReferences": {},
"object": "",
"opcodes": "",
"sourceMap": ""
},
"methodIdentifiers": {}
}
},
"IERC20": {
"abi": [
{
"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": "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": "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": [],
"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"
}
],
"evm": {
"bytecode": {
"linkReferences": {},
"object": "",
"opcodes": "",
"sourceMap": ""
},
"deployedBytecode": {
"immutableReferences": {},
"linkReferences": {},
"object": "",
"opcodes": "",
"sourceMap": ""
},
"methodIdentifiers": {
"allowance(address,address)": "dd62ed3e",
"approve(address,uint256)": "095ea7b3",
"balanceOf(address)": "70a08231",
"totalSupply()": "18160ddd",
"transfer(address,uint256)": "a9059cbb",
"transferFrom(address,address,uint256)": "23b872dd"
}
}
},
"IERC2258": {
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "custodian",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "oldAllowance",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newAllowance",
"type": "uint256"
}
],
"name": "CustodyAllowanceChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "custodian",
"type": "address"
},
{
"indexed": false,
"internalType": "address",