- Contract name:
- StakingImp
- Optimization enabled
- false
- Compiler version
- v0.6.12+commit.27d51765
- EVM Version
- default
- Verified at
- 2022-10-25T14:25:04.260638Z
Contract source code
// Sources flattened with hardhat v2.7.0 https://hardhat.org // File @openzeppelin/contracts/math/Math.sol@v3.4.2 pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // File @openzeppelin/contracts/math/SafeMath.sol@v3.4.2 pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ 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; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v3.4.2 pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File @openzeppelin/contracts/utils/Address.sol@v3.4.2 pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ 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"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ 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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (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 { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File @openzeppelin/contracts/token/ERC20/SafeERC20.sol@v3.4.2 pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ 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)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length 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)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File @openzeppelin/contracts/utils/ReentrancyGuard.sol@v3.4.2 pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File contracts/Ownable.sol // P1 - P3: OK pragma solidity ^0.6.0; // Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol + Claimable.sol // Edited by BoringCrypto // T1 - T4: OK contract OwnableData { // V1 - V5: OK address public owner; // V1 - V5: OK address public pendingOwner; } // T1 - T4: OK contract Ownable is OwnableData { // E1: OK event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } // F1 - F9: OK // C1 - C21: OK function transferOwnership(address newOwner, bool direct, bool renounce) public onlyOwner { if (direct) { // Checks require(newOwner != address(0) || renounce, "Ownable: zero address"); // Effects emit OwnershipTransferred(owner, newOwner); owner = newOwner; } else { // Effects pendingOwner = newOwner; } } // F1 - F9: OK // C1 - C21: OK function claimOwnership() public { address _pendingOwner = pendingOwner; // Checks require(msg.sender == _pendingOwner, "Ownable: caller != pending owner"); // Effects emit OwnershipTransferred(owner, _pendingOwner); owner = _pendingOwner; pendingOwner = address(0); } // M1 - M5: OK // C1 - C21: OK modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; } } // File contracts/interfaces/IERC20Burnable.sol pragma solidity >=0.6.0; interface IERC20Burnable { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function burn(uint256 amount) external; function safeTransfer(address to, uint value) external returns (bool); function safeTransferFrom(address from, address to, uint value) external returns (bool); } // File contracts/StakingImp.sol pragma solidity ^0.6.0; contract StakingImp is ReentrancyGuard, Ownable() { using SafeMath for uint256; using SafeERC20 for IERC20; using SafeERC20 for IERC20Burnable; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20Burnable public stakingToken; uint256[] public checkPoints; uint256[] public rewardPerSecond; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; uint public startingCheckPoint; uint public unstakingFeeRatio = 400; uint public newUnstakingFeeRatio; uint public unstakingFeeRatioTimelock; uint public constant unstakingFeeRatioTimelockPeriod = 600; uint public constant unstakingFeeDenominator = 10000; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 public totalStake; mapping(address => uint256) public stakes; bool public feeBurn = false; bool public initialized = false; /* ========== CONSTRUCTOR ========== */ function initialize( address _rewardsToken, address _stakingToken, uint emissionStart, uint firstCheckPoint, uint _rewardPerSecond, address admin, bool _feeBurn, uint _unstakingFeeRatio ) public { require(initialized == false, "StakingImp: contract has already been initialized."); rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20Burnable(_stakingToken); if (checkPoints.length == 0) { checkPoints.push(emissionStart); checkPoints.push(firstCheckPoint); rewardPerSecond.push(_rewardPerSecond); } owner = admin; feeBurn = _feeBurn; unstakingFeeRatio = _unstakingFeeRatio; initialized = true; } function updateSchedule(uint checkPoint, uint _rewardPerSecond) public onlyOwner { require(checkPoint > Math.max(checkPoints[checkPoints.length.sub(1)], block.timestamp), "LM: new checkpoint has to be in the future"); if (block.timestamp > checkPoints[checkPoints.length.sub(1)]) { checkPoints.push(block.timestamp); rewardPerSecond.push(0); } checkPoints.push(checkPoint); rewardPerSecond.push(_rewardPerSecond); } function getCheckPoints() public view returns (uint256[] memory) { return checkPoints; } function getRewardPerSecond() public view returns (uint256[] memory) { return rewardPerSecond; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, checkPoints[checkPoints.length.sub(1)]); } function getTotalEmittedTokens(uint256 _from, uint256 _to, uint256 _startingCheckPoint) public view returns (uint256, uint256) { require(_to >= _from, "StakingImp: _to has to be greater than _from."); uint256 totalEmittedTokens = 0; uint256 workingTime = Math.max(_from, checkPoints[0]); if (_to <= workingTime) { return (0, _startingCheckPoint); } uint checkPointsLength = checkPoints.length; for (uint256 i = _startingCheckPoint + 1; i < checkPointsLength; ++i) { uint256 emissionTime = checkPoints[i]; uint256 emissionRate = rewardPerSecond[i-1]; if (_to < emissionTime) { totalEmittedTokens = totalEmittedTokens.add(_to.sub(workingTime).mul(emissionRate)); return (totalEmittedTokens, i - 1); } else if (workingTime < emissionTime) { totalEmittedTokens = totalEmittedTokens.add(emissionTime.sub(workingTime).mul(emissionRate)); workingTime = emissionTime; } } return (totalEmittedTokens, checkPointsLength.sub(1)); } /* ========== MUTATIVE FUNCTIONS ========== */ function setFeeBurn(bool _feeBurn) public onlyOwner { feeBurn = _feeBurn; } function stake(uint256 amount) external nonReentrant updateReward(msg.sender) { require(amount > 0, "StakingImp: Cannot stake 0"); totalStake = totalStake.add(amount); stakes[msg.sender] = stakes[msg.sender].add(amount); stakingToken.transferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function unstake(uint256 amount, uint maximumFee) public nonReentrant updateReward(msg.sender) { uint unstakingFee = amount.mul(unstakingFeeRatio).div(unstakingFeeDenominator); require(unstakingFee <= maximumFee, "StakingImp: fee too high."); uint amountWithoutFee = amount.sub(unstakingFee); require(stakes[msg.sender] >= amount, "StakingImp: INSUFFICIENT_STAKE"); stakes[msg.sender] = stakes[msg.sender].sub(amount); totalStake = totalStake.sub(amount); stakingToken.transfer(msg.sender, amountWithoutFee); if (feeBurn) { stakingToken.burn(unstakingFee); emit FeeBurned(unstakingFee); } emit Unstaked(msg.sender, amount); } function transferStake(address _recipient, uint _amount) public { require(_amount <= stakes[msg.sender], "StakingImp: not enough stake to transfer"); _updateReward(msg.sender); _updateReward(_recipient); stakes[msg.sender] = stakes[msg.sender].sub(_amount); stakes[_recipient] = stakes[_recipient].add(_amount); emit Unstaked(msg.sender, _amount); emit Staked(_recipient, _amount); } function getRewardThenStake() public nonReentrant updateReward(msg.sender) { require(address(stakingToken) == address(rewardsToken), "StakingImp:only when staking and rewards tokens are the same"); uint256 reward = rewards[msg.sender]; if (reward > 0) { require(reward < stakingToken.balanceOf(address(this)).sub(totalStake), "StakingImp: not enough tokens to pay out reward."); rewards[msg.sender] = 0; stakes[msg.sender] = stakes[msg.sender].add(reward); totalStake = totalStake.add(reward); emit Staked(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function withdrawFee(uint256 amount) public nonReentrant onlyOwner { uint totalFee = stakingToken.balanceOf(address(this)).sub(totalStake); require(amount <= totalFee, "StakingImp: not enough fee."); stakingToken.transfer(owner, amount); emit FeeCollected(amount); } function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.transfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function exit() external { unstake(stakes[msg.sender], uint(-1)); getReward(); } function setNewUnstakingFeeRatio(uint _newUnstakingFeeRatio) public onlyOwner { require(_newUnstakingFeeRatio <= unstakingFeeDenominator, "StakingImp: invalid unstaking fee."); newUnstakingFeeRatio = _newUnstakingFeeRatio; unstakingFeeRatioTimelock = block.timestamp.add(unstakingFeeRatioTimelockPeriod); } function changeUnstakingFeeRatio() public onlyOwner { require(block.timestamp >= unstakingFeeRatioTimelock, "StakingImp: too early to change unstaking fee."); unstakingFeeRatio = newUnstakingFeeRatio; } function showPendingReward(address account) public view returns (uint256) { uint rewardPerTokenStoredActual; if (totalStake != 0) { (uint256 totalEmittedTokensSinceLastUpdate, ) = getTotalEmittedTokens(lastUpdateTime, block.timestamp, startingCheckPoint); rewardPerTokenStoredActual = rewardPerTokenStored.add(totalEmittedTokensSinceLastUpdate.mul(1e18).div(totalStake)); } else { rewardPerTokenStoredActual = rewardPerTokenStored; } return rewards[account].add((rewardPerTokenStoredActual.sub(userRewardPerTokenPaid[account])).mul(stakes[account]).div(1e18)); } function _updateReward(address account) internal { if (totalStake != 0) { (uint256 totalEmittedTokensSinceLastUpdate, uint256 newStartingCheckPoint) = getTotalEmittedTokens(lastUpdateTime, block.timestamp, startingCheckPoint); startingCheckPoint = newStartingCheckPoint; rewardPerTokenStored = rewardPerTokenStored.add(totalEmittedTokensSinceLastUpdate.mul(1e18).div(totalStake)); } lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { uint256 _rewardPerTokenStored = rewardPerTokenStored; rewards[account] = rewards[account].add((_rewardPerTokenStored.sub(userRewardPerTokenPaid[account])).mul(stakes[account]).div(1e18)); userRewardPerTokenPaid[account] = _rewardPerTokenStored; } } modifier updateReward(address account) { _updateReward(account); _; } event Staked(address indexed user, uint256 amount); event Unstaked(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event FeeBurned(uint256 amount); event FeeCollected(uint256 amount); }
Contract ABI
[{"type":"event","name":"FeeBurned","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"FeeCollected","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RewardPaid","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Staked","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unstaked","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeUnstakingFeeRatio","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"checkPoints","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"exit","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"feeBurn","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getCheckPoints","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"getReward","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getRewardPerSecond","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"getRewardThenStake","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTotalEmittedTokens","inputs":[{"type":"uint256","name":"_from","internalType":"uint256"},{"type":"uint256","name":"_to","internalType":"uint256"},{"type":"uint256","name":"_startingCheckPoint","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_rewardsToken","internalType":"address"},{"type":"address","name":"_stakingToken","internalType":"address"},{"type":"uint256","name":"emissionStart","internalType":"uint256"},{"type":"uint256","name":"firstCheckPoint","internalType":"uint256"},{"type":"uint256","name":"_rewardPerSecond","internalType":"uint256"},{"type":"address","name":"admin","internalType":"address"},{"type":"bool","name":"_feeBurn","internalType":"bool"},{"type":"uint256","name":"_unstakingFeeRatio","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"initialized","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastTimeRewardApplicable","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastUpdateTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"newUnstakingFeeRatio","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pendingOwner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerSecond","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerTokenStored","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewards","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"rewardsToken","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFeeBurn","inputs":[{"type":"bool","name":"_feeBurn","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNewUnstakingFeeRatio","inputs":[{"type":"uint256","name":"_newUnstakingFeeRatio","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"showPendingReward","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakes","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20Burnable"}],"name":"stakingToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"startingCheckPoint","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalStake","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"},{"type":"bool","name":"direct","internalType":"bool"},{"type":"bool","name":"renounce","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferStake","inputs":[{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unstake","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"maximumFee","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"unstakingFeeDenominator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"unstakingFeeRatio","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"unstakingFeeRatioTimelock","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"unstakingFeeRatioTimelockPeriod","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateSchedule","inputs":[{"type":"uint256","name":"checkPoint","internalType":"uint256"},{"type":"uint256","name":"_rewardPerSecond","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userRewardPerTokenPaid","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawFee","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]}]
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061023d5760003560e01c80639898545f1161013b578063d1af0c7d116100b8578063e6671f901161007c578063e6671f901461097c578063e69f6332146109b4578063e9fad8ee146109d2578063fd67fd7c146109dc578063fee4f0f514610a1e5761023d565b8063d1af0c7d1461088d578063da5b4ee7146108c1578063df136d6514610920578063e18c07101461093e578063e30c3978146109485761023d565b8063a694fc3a116100ff578063a694fc3a14610718578063be35761614610746578063c204943a14610774578063c7ee9e6b146107b6578063c8f33c911461086f5761023d565b80639898545f146105a85780639e2c8a5b146105d6578063a28f88471461060e578063a5680ed41461065c578063a66ca09e146106bb5761023d565b80635ecbfed4116101c95780638b0e9f3f1161018d5780638b0e9f3f146104c25780638b876347146104e05780638da5cb5b146105385780639001aeb01461056c578063947d8add1461058a5761023d565b80635ecbfed4146103ca57806360593ae3146104225780636341eae21461044057806372f702f31461047057806380faa57d146104a45761023d565b806316934fc41161021057806316934fc41461032057806328153dca146103785780633d18b912146103965780634e71e0c8146103a0578063583fef34146103aa5761023d565b806303ce86f0146102425780630700037d1461024c578063078dfbe7146102a4578063158ef93e14610300575b600080fd5b61024a610a3c565b005b61028e6004803603602081101561026257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ea9565b6040518082815260200191505060405180910390f35b6102fe600480360360608110156102ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190803515159060200190929190505050610ec1565b005b61030861113e565b60405180821515815260200191505060405180910390f35b6103626004803603602081101561033657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611151565b6040518082815260200191505060405180910390f35b610380611169565b6040518082815260200191505060405180910390f35b61039e61116f565b005b6103a86113b6565b005b6103b2611580565b60405180821515815260200191505060405180910390f35b61040c600480360360208110156103e057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611593565b6040518082815260200191505060405180910390f35b61042a61171b565b6040518082815260200191505060405180910390f35b61046e6004803603602081101561045657600080fd5b81019080803515159060200190929190505050611721565b005b610478611801565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104ac611827565b6040518082815260200191505060405180910390f35b6104ca611867565b6040518082815260200191505060405180910390f35b610522600480360360208110156104f657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061186d565b6040518082815260200191505060405180910390f35b610540611885565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105746118ab565b6040518082815260200191505060405180910390f35b6105926118b1565b6040518082815260200191505060405180910390f35b6105d4600480360360208110156105be57600080fd5b81019080803590602001909291905050506118b7565b005b61060c600480360360408110156105ec57600080fd5b8101908080359060200190929190803590602001909291905050506119fa565b005b61065a6004803603604081101561062457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611eaa565b005b61066461211e565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156106a757808201518184015260208101905061068c565b505050509050019250505060405180910390f35b6106fb600480360360608110156106d157600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050612176565b604051808381526020018281526020019250505060405180910390f35b6107446004803603602081101561072e57600080fd5b8101908080359060200190929190505050612331565b005b6107726004803603602081101561075c57600080fd5b8101908080359060200190929190505050612629565b005b6107a06004803603602081101561078a57600080fd5b81019080803590602001909291905050506129f3565b6040518082815260200191505060405180910390f35b61086d60048036036101008110156107cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080351515906020019092919080359060200190929190505050612a14565b005b610877612c13565b6040518082815260200191505060405180910390f35b610895612c19565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6108c9612c3f565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561090c5780820151818401526020810190506108f1565b505050509050019250505060405180910390f35b610928612c97565b6040518082815260200191505060405180910390f35b610946612c9d565b005b610950612dc6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6109b26004803603604081101561099257600080fd5b810190808035906020019092919080359060200190929190505050612dec565b005b6109bc613020565b6040518082815260200191505060405180910390f35b6109da613026565b005b610a08600480360360208110156109f257600080fd5b8101908080359060200190929190505050613099565b6040518082815260200191505060405180910390f35b610a266130ba565b6040518082815260200191505060405180910390f35b60026000541415610ab5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b600260008190555033610ac7816130c0565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b8f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603c815260200180613564603c913960400191505060405180910390fd5b6000600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000811115610e9d57610cb4600f54600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610c6b57600080fd5b505afa158015610c7f573d6000803e3d6000fd5b505050506040513d6020811015610c9557600080fd5b810190808051906020019092919050505061331690919063ffffffff16565b8110610d0b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806135d26030913960400191505060405180910390fd5b6000600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610da281601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461339990919063ffffffff16565b601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610dfa81600f5461339990919063ffffffff16565b600f819055503373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d826040518082815260200191505060405180910390a23373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b50506001600081905550565b600e6020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f84576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b81156110f757600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580610fc35750805b611035576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4f776e61626c653a207a65726f2061646472657373000000000000000000000081525060200191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a382600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611139565b82600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b505050565b601160019054906101000a900460ff1681565b60106020528060005260406000206000915090505481565b600c5481565b600260005414156111e8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600081905550336111fa816130c0565b6000600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111156113aa576000600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561131f57600080fd5b505af1158015611333573d6000803e3d6000fd5b505050506040513d602081101561134957600080fd5b8101908080519060200190929190505050503373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b50506001600081905550565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461147e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c657220213d2070656e64696e67206f776e657281525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b601160009054906101000a900460ff1681565b6000806000600f54146115ff5760006115b160075442600954612176565b5090506115f76115e6600f546115d8670de0b6b3a76400008561342190919063ffffffff16565b6134a790919063ffffffff16565b60085461339990919063ffffffff16565b915050611605565b60085490505b6117136116c5670de0b6b3a76400006116b7601060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a9600d60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548761331690919063ffffffff16565b61342190919063ffffffff16565b6134a790919063ffffffff16565b600e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461339990919063ffffffff16565b915050919050565b61271081565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601160006101000a81548160ff02191690831515021790555050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000611862426005611848600160058054905061331690919063ffffffff16565b8154811061185257fe5b9060005260206000200154613530565b905090565b600f5481565b600d6020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60095481565b600a5481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461197a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6127108111156119d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806136a36022913960400191505060405180910390fd5b80600b819055506119f16102584261339990919063ffffffff16565b600c8190555050565b60026000541415611a73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b600260008190555033611a85816130c0565b6000611ab0612710611aa2600a548761342190919063ffffffff16565b6134a790919063ffffffff16565b905082811115611b28576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f5374616b696e67496d703a2066656520746f6f20686967682e0000000000000081525060200191505060405180910390fd5b6000611b3d828661331690919063ffffffff16565b905084601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611bf4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f5374616b696e67496d703a20494e53554646494349454e545f5354414b45000081525060200191505060405180910390fd5b611c4685601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461331690919063ffffffff16565b601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611c9e85600f5461331690919063ffffffff16565b600f81905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015611d3757600080fd5b505af1158015611d4b573d6000803e3d6000fd5b505050506040513d6020811015611d6157600080fd5b810190808051906020019092919050505050601160009054906101000a900460ff1615611e4d57600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015611dfd57600080fd5b505af1158015611e11573d6000803e3d6000fd5b505050507fa551808c565cfbf20dfffdbcd44c549f835f9d06a82dcd546c61644b2f5ce791826040518082815260200191505060405180910390a15b3373ffffffffffffffffffffffffffffffffffffffff167f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75866040518082815260200191505060405180910390a250505060016000819055505050565b601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811115611f42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602881526020018061362c6028913960400191505060405180910390fd5b611f4b336130c0565b611f54826130c0565b611fa681601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461331690919063ffffffff16565b601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061203b81601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461339990919063ffffffff16565b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75826040518082815260200191505060405180910390a28173ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d826040518082815260200191505060405180910390a25050565b6060600580548060200260200160405190810160405280929190818152602001828054801561216c57602002820191906000526020600020905b815481526020019060010190808311612158575b5050505050905090565b600080848410156121d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d8152602001806136c5602d913960400191505060405180910390fd5b6000806121f78760056000815481106121e757fe5b9060005260206000200154613549565b905080861161220e57600085935093505050612329565b6000600580549050905060006001870190505b8181101561230b5760006005828154811061223857fe5b9060005260206000200154905060006006600184038154811061225757fe5b90600052602060002001549050818a10156122b9576122a361229482612286888e61331690919063ffffffff16565b61342190919063ffffffff16565b8761339990919063ffffffff16565b9550856001840397509750505050505050612329565b818510156122fe576122f86122e9826122db888661331690919063ffffffff16565b61342190919063ffffffff16565b8761339990919063ffffffff16565b95508194505b5050806001019050612221565b508261232160018361331690919063ffffffff16565b945094505050505b935093915050565b600260005414156123aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600081905550336123bc816130c0565b60008211612432576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f5374616b696e67496d703a2043616e6e6f74207374616b65203000000000000081525060200191505060405180910390fd5b61244782600f5461339990919063ffffffff16565b600f8190555061249f82601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461339990919063ffffffff16565b601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561259357600080fd5b505af11580156125a7573d6000803e3d6000fd5b505050506040513d60208110156125bd57600080fd5b8101908080519060200190929190505050503373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d836040518082815260200191505060405180910390a250600160008190555050565b600260005414156126a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600081905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461276d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000612847600f54600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156127fe57600080fd5b505afa158015612812573d6000803e3d6000fd5b505050506040513d602081101561282857600080fd5b810190808051906020019092919050505061331690919063ffffffff16565b9050808211156128bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f5374616b696e67496d703a206e6f7420656e6f756768206665652e000000000081525060200191505060405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561297457600080fd5b505af1158015612988573d6000803e3d6000fd5b505050506040513d602081101561299e57600080fd5b8101908080519060200190929190505050507fc472cb3a7a659a876494d66b3063145f279701771d6150b9329c31611ed6405c826040518082815260200191505060405180910390a150600160008190555050565b60058181548110612a0057fe5b906000526020600020016000915090505481565b60001515601160019054906101000a900460ff16151514612a80576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806135a06032913960400191505060405180910390fd5b87600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555086600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006005805490501415612b8c576005869080600181540180825580915050600190039060005260206000200160009091909190915055600585908060018154018082558091505060019003906000526020600020016000909190919091505560068490806001815401808255809150506001900390600052602060002001600090919091909150555b82600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081601160006101000a81548160ff02191690831515021790555080600a819055506001601160016101000a81548160ff0219169083151502179055505050505050505050565b60075481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60606006805480602002602001604051908101604052809291908181526020018280548015612c8d57602002820191906000526020600020905b815481526020019060010190808311612c79575b5050505050905090565b60085481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612d60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600c54421015612dbb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e815260200180613675602e913960400191505060405180910390fd5b600b54600a81905550565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612eaf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b612ee86005612ecd600160058054905061331690919063ffffffff16565b81548110612ed757fe5b906000526020600020015442613549565b8211612f3f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613602602a913960400191505060405180910390fd5b6005612f5a600160058054905061331690919063ffffffff16565b81548110612f6457fe5b9060005260206000200154421115612fca5760054290806001815401808255809150506001900390600052602060002001600090919091909150556006600090806001815401808255809150506001900390600052602060002001600090919091909150555b600582908060018154018082558091505060019003906000526020600020016000909190919091505560068190806001815401808255809150506001900390600052602060002001600090919091909150555050565b61025881565b61308f601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6119fa565b61309761116f565b565b600681815481106130a657fe5b906000526020600020016000915090505481565b600b5481565b6000600f5414613133576000806130dc60075442600954612176565b915091508060098190555061312a613119600f5461310b670de0b6b3a76400008661342190919063ffffffff16565b6134a790919063ffffffff16565b60085461339990919063ffffffff16565b60088190555050505b61313b611827565b600781905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614613313576000600854905061328a61323c670de0b6b3a764000061322e601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613220600d60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548761331690919063ffffffff16565b61342190919063ffffffff16565b6134a790919063ffffffff16565b600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461339990919063ffffffff16565b600e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505b50565b60008282111561338e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b600080828401905083811015613417576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008083141561343457600090506134a1565b600082840290508284828161344557fe5b041461349c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806136546021913960400191505060405180910390fd5b809150505b92915050565b600080821161351e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b81838161352757fe5b04905092915050565b600081831061353f5781613541565b825b905092915050565b600081831015613559578161355b565b825b90509291505056fe5374616b696e67496d703a6f6e6c79207768656e207374616b696e6720616e64207265776172647320746f6b656e7320617265207468652073616d655374616b696e67496d703a20636f6e74726163742068617320616c7265616479206265656e20696e697469616c697a65642e5374616b696e67496d703a206e6f7420656e6f75676820746f6b656e7320746f20706179206f7574207265776172642e4c4d3a206e657720636865636b706f696e742068617320746f20626520696e20746865206675747572655374616b696e67496d703a206e6f7420656e6f756768207374616b6520746f207472616e73666572536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775374616b696e67496d703a20746f6f206561726c7920746f206368616e676520756e7374616b696e67206665652e5374616b696e67496d703a20696e76616c696420756e7374616b696e67206665652e5374616b696e67496d703a205f746f2068617320746f2062652067726561746572207468616e205f66726f6d2ea2646970667358221220ba004476d34943ec4d0dba0559a9f439befabea77c54d472322ee385996a964b64736f6c634300060c0033