Contract Address Details

0xbc149c62EFe8AFC61728fC58b1b66a0661712e76

Contract Name
CraftsmanV2
Creator
0x2b0b98–758b1b at 0xbb8586–14b645
Balance
0 CRO ( )
Tokens
Fetching tokens...
Transactions
423,572 Transactions
Transfers
1,209,737 Transfers
Gas Used
120,191,644,524
Last Balance Update
13643613
Contract name:
CraftsmanV2




Optimization enabled
true
Compiler version
v0.6.12+commit.27d51765




Optimization runs
200
EVM Version
default




Verified at
2022-02-18T01:44:40.575981Z

Constructor Arguments

000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc

Arg [0] (address) : 0xdccd6455ae04b03d785f12196b492b18129564bc

              

Contract source code

// Sources flattened with hardhat v2.6.7 https://hardhat.org

// File @openzeppelin/contracts/math/[email protected]

// SPDX-License-Identifier: MIT

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/[email protected]

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/[email protected]

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/[email protected]

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/[email protected]

pragma solidity >=0.6.0 <0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}


// File @openzeppelin/contracts/access/[email protected]

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}


// File @openzeppelin/contracts/utils/[email protected]

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor () internal {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}


// File contracts/ICraftsman.sol

pragma solidity 0.6.12;

/** 
 * @title ICraftsman
 * @notice It is an interface for Craftsman.sol
 */
interface ICraftsman {
    /**
     * @notice deposit LP tokens for VVS allocation.
     * @param _pid poolId 
     * @param _amount amount of LP token to deposit
     */
    function deposit(uint256 _pid, uint256 _amount) external;

    /**
     * @notice withdraw LP tokens
     * @param _pid poolId 
     * @param _amount amount of LP token to deposit
     */
    function withdraw(uint256 _pid, uint256 _amount) external;

    /**
     * @notice withdraw without caring about rewards. EMERGENCY ONLY.
     * @param _pid poolId 
     */
    function emergencyWithdraw(uint256 _pid) external;

    /**
     * @notice view function to check user pending vvs
     * @param _pid poolId 
     * @param _user address of user 
     */
    function pendingVVS(uint256 _pid, address _user)
        external
        view
        returns (uint256);

    /**
     * @notice view function to check user's deposited LP and rewardDebt
     * @param _pid poolId 
     * @param _user address of user 
     */
    function userInfo(uint256 _pid, address _user)
        external
        view
        returns (uint256 amount, uint256 rewardDebt);

    /**
     * @notice view function to check pool info 
     * @param _pid poolId 
     */
    function poolInfo(uint256 _pid)
        external
        view
        returns (
            address lpToken,
            uint256 allocPoint,
            uint256 lastRewardBlock,
            uint256 accVVSPerShare
        );

    /**
     * @notice view function to check vvs token address registered in craftsman
     */
    function vvs() external view returns (address);
}


// File contracts/CraftsmanV2.sol

pragma solidity 0.6.12;






interface IRewarder {
    function onVVSReward(
        uint256 _pid,
        address _user,
        uint256 _amount
    ) external;

    function pendingToken(uint256 pid, address user) external view returns (address rewardToken, uint256 amount);
}

/// CraftsmanV2 is the new master of VVS.
///
/// Note that it is similar to Craftsman with the ability to attach rewarders (optional)
/// to each pid. User will have to withdraw from Craftsman and redeposit in CraftsmanV2
/// if rewarder is attached to an existing pid such as CRO-BTC
///
/// Have fun reading it. Hopefully it's bug-free. God bless.
contract CraftsmanV2 is Ownable, Pausable {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    /// Info of each user.
    struct UserInfo {
        uint256 amount; // How many LP tokens the user has provided.
        uint256 rewardDebt; // Reward debt - See explaination from Craftsman
    }

    /// Info of each pool.
    struct PoolInfo {
        IERC20 lpToken; // Address of LP token contract.
        IRewarder[] rewarders; // list of rewarder for the pool
        uint256 accVVSPerShare; // Accumulated VVSs per share, times 1e12.
    }

    /// Mapping of pid to poolInfo
    mapping(uint256 => PoolInfo) public poolInfo;

    /// Info of each pool.
    uint256[] public poolIds;

    /// Info of each user that stakes LP tokens.
    mapping(uint256 => mapping(address => UserInfo)) public userInfo;

    ICraftsman public immutable craftsman;

    event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
    event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event SetPid(uint256 indexed pid, address lpToken, IRewarder[] rewarders, bool withUpdate);
    event AddRewarder(uint256 indexed pid, IRewarder rewarder);
    event RemoveRewarder(uint256 indexed pid, IRewarder rewarder);
    event Panic(uint256 pid);

    constructor(ICraftsman _craftsman) public {
        craftsman = _craftsman;
    }

    function deposit(uint256 _pid, uint256 _amount) external whenNotPaused {
        require(_pid != 0, "deposit VVS by Craftsman");

        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];

        updatePool(_pid);

        uint256 pending = user.amount.mul(pool.accVVSPerShare).div(1e12).sub(user.rewardDebt);
        if (pending > 0) {
            safeVVSTransfer(msg.sender, pending);
        }

        // Get rewarder rewards
        uint256 newAmt = user.amount.add(_amount);
        IRewarder[] memory _rewarders = pool.rewarders;
        for (uint256 i = 0; i < _rewarders.length; i++) {
            _rewarders[i].onVVSReward(_pid, msg.sender, newAmt);
        }

        if (_amount > 0) {
            pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
            pool.lpToken.approve(address(craftsman), _amount);
            craftsman.deposit(_pid, _amount);
        }

        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.amount.mul(pool.accVVSPerShare).div(1e12);
        emit Deposit(msg.sender, _pid, _amount);
    }

    function withdraw(uint256 _pid, uint256 _amount) external {
        require(_pid != 0, "withdraw VVS by Craftsman");

        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        require(user.amount >= _amount, "withdraw amount greater than balanace");

        updatePool(_pid);

        uint256 pending = user.amount.mul(pool.accVVSPerShare).div(1e12).sub(user.rewardDebt);
        if (pending > 0) {
            safeVVSTransfer(msg.sender, pending);
        }

        // Get rewarder rewards
        uint256 newAmt = user.amount.sub(_amount);
        IRewarder[] memory rewarders = pool.rewarders;
        for (uint256 i = 0; i < rewarders.length; i++) {
            rewarders[i].onVVSReward(_pid, msg.sender, newAmt);
        }

        if (_amount > 0) {
            user.amount = user.amount.sub(_amount);
            craftsman.withdraw(_pid, _amount);
            pool.lpToken.safeTransfer(address(msg.sender), _amount);
        }

        user.rewardDebt = user.amount.mul(pool.accVVSPerShare).div(1e12);
        emit Withdraw(msg.sender, _pid, _amount);
    }

    /// @notice withdraw without caring about rewards. EMERGENCY ONLY.
    /// @dev if the issue comes from craftsman token, call panic() before asking user to emergencyWithdraw()
    function emergencyWithdraw(uint256 _pid) external {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];

        uint256 amount = user.amount;
        user.amount = 0;
        user.rewardDebt = 0;

        /// Paused implies craftsman is stuck. Owner should have called panic() for all pids
        // and all LP token should be in craftsmanV2, thus skip craftsman.withdraw(_pid, amount)
        if (!paused()) {
            // Not paused implies craftsman is fine while rewarder is stuck. Withdraw from craftsman
            // and split user's pending vvs reward with the remaining stakers. However if user
            // was the only staker, pending vvs will remain with this contract
            uint256 pending = craftsman.pendingVVS(_pid, address(this));
            craftsman.withdraw(_pid, amount);

            (uint256 lpSupply, ) = craftsman.userInfo(_pid, address(this));
            if (pending > 0 && lpSupply > 0) {
                pool.accVVSPerShare = pool.accVVSPerShare.add(pending.mul(1e12).div(lpSupply));
            }
        }

        pool.lpToken.safeTransfer(address(msg.sender), amount);
        emit EmergencyWithdraw(msg.sender, _pid, amount);
    }

    /// @notice pauses deposit and withdraws all fund from craftsman
    /// @dev only call this function if craftsman reward is stuck
    function panic(uint256 _pid) external onlyOwner {
        if (!paused()) {
            _pause();
        }

        craftsman.emergencyWithdraw(_pid);

        emit Panic(_pid);
    }

    /// @dev only unpause if the panic pid has no deposits prior. If the pids had deposits, it
    ///         would mean users cannot call withdraw() as the LP are already withdrawn to craftsmanV2
    function unpause() external onlyOwner {
        _unpause();
    }

    /// @notice Update reward variables for all pools. Be careful of gas spending!
    function massUpdatePools() public {
        uint256 length = poolIds.length;
        for (uint256 pid = 0; pid < length; ++pid) {
            updatePool(pid);
        }
    }

    /// @dev Update pool.accVVSPerShare by claiming any pendingVVS
    function updatePool(uint256 _pid) public {
        (uint256 lpSupply, ) = craftsman.userInfo(_pid, address(this));
        if (lpSupply == 0) {
            return;
        }

        uint256 pending = craftsman.pendingVVS(_pid, address(this));
        craftsman.deposit(_pid, 0); // deposit to triger vvs reward

        PoolInfo storage pool = poolInfo[_pid];
        pool.accVVSPerShare = pool.accVVSPerShare.add(pending.mul(1e12).div(lpSupply));
    }

    /// @notice Add a new pid with rewarder
    /// @dev txn will fail if craftman does not have pool set
    /// @param _pid pid to update
    /// @param _rewarders the list of rewarder to set
    /// @param _withUpdate True if massUpdatePools should be called prior to pool updates.
    function add(
        uint256 _pid,
        IRewarder[] memory _rewarders,
        bool _withUpdate
    ) external onlyOwner {
        require(address(poolInfo[_pid].lpToken) == address(0), "pool has been added");

        if (_withUpdate) {
            massUpdatePools();
        }

        (address lpToken, , , ) = craftsman.poolInfo(_pid);
        poolInfo[_pid].lpToken = IERC20(lpToken);
        poolInfo[_pid].rewarders = _rewarders;

        poolIds.push(_pid);

        emit SetPid(_pid, lpToken, _rewarders, _withUpdate);
    }

    /// @notice add a rewarder to the pid
    /// @param _pid pid to add rewarder
    /// @param _rewarder address of rewarder to add
    function addRewarder(uint256 _pid, IRewarder _rewarder) external onlyOwner {
        (bool found, ) = isRewarderInPool(_pid, _rewarder);
        require(found == false, "Rewarder exist");

        poolInfo[_pid].rewarders.push(_rewarder);
        emit AddRewarder(_pid, _rewarder);
    }

    /// @notice remove a rewarder from the pid, removing rewarder will save gas for user
    /// @dev removing rewarder removes any user unclaimed rewarder reward!
    /// @param _pid pid to remove rewarder
    /// @param _rewarder address of rewarder to remove
    function removeRewarder(uint256 _pid, IRewarder _rewarder) external onlyOwner {
        (bool found, uint256 foundIndex) = isRewarderInPool(_pid, _rewarder);
        require(found, "No rewarder found");

        PoolInfo storage pool = poolInfo[_pid];
        for (uint256 i = foundIndex; i < pool.rewarders.length - 1; i++) {
            pool.rewarders[i] = pool.rewarders[i + 1];
        }

        pool.rewarders.pop();

        emit RemoveRewarder(_pid, _rewarder);
    }

    /// @notice returns all pending token reward for the user
    /// @dev Checks pending token from Craftsman and iterate through each rewarder
    /// @return array of (token address, pending token amount)
    function pendingTokens(uint256 _pid, address _user) external view returns (address[] memory, uint256[] memory) {
        PoolInfo memory pool = poolInfo[_pid];

        // +1 in array to include VVS reward from craftsman
        uint256 rewardLength = pool.rewarders.length;
        address[] memory rewardTokens = new address[](rewardLength + 1);
        uint256[] memory pendingAmounts = new uint256[](rewardLength + 1);

        // Check on VVS reward
        rewardTokens[0] = craftsman.vvs();
        pendingAmounts[0] = pendingVVS(_pid, _user);

        // Check from each rewarder
        IRewarder[] memory rewarders = pool.rewarders;
        for (uint256 i = 0; i < rewarders.length; i++) {
            (address token, uint256 amount) = rewarders[i].pendingToken(_pid, _user);

            rewardTokens[i + 1] = token;
            pendingAmounts[i + 1] = amount;
        }

        return (rewardTokens, pendingAmounts);
    }

    /// @notice check if rewarder is in pool
    /// @return bool if rewarder is found
    /// @return uint256 index of rewarder if found
    function isRewarderInPool(uint256 _pid, IRewarder _rewarder) public view returns (bool, uint256) {
        PoolInfo memory pool = poolInfo[_pid];
        for (uint256 i = 0; i < pool.rewarders.length; i++) {
            if (address(pool.rewarders[i]) == address(_rewarder)) {
                return (true, i);
            }
        }

        return (false, 0);
    }

    function pendingVVS(uint256 _pid, address _user) public view returns (uint256) {
        PoolInfo memory pool = poolInfo[_pid];
        UserInfo memory user = userInfo[_pid][_user];

        uint256 accVVSPerShare = pool.accVVSPerShare;
        (uint256 lpSupply, ) = craftsman.userInfo(_pid, address(this));
        if (lpSupply != 0) {
            uint256 pending = craftsman.pendingVVS(_pid, address(this));
            accVVSPerShare = pool.accVVSPerShare.add(pending.mul(1e12).div(lpSupply));
        }

        uint256 userPendingVVS = user.amount.mul(accVVSPerShare).div(1e12).sub(user.rewardDebt);
        return userPendingVVS;
    }

    /// @param _pid pool to check
    /// @return rewarders for the pool
    function poolRewarders(uint256 _pid) public view returns (IRewarder[] memory) {
        return poolInfo[_pid].rewarders;
    }

    /// Safe vvs transfer function, just in case if rounding error causes pool to not have enough VVSs.
    function safeVVSTransfer(address _to, uint256 _amount) internal {
        IERC20 vvs = IERC20(craftsman.vvs());
        vvs.safeTransfer(_to, _amount);
    }
}
        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_craftsman","internalType":"contract ICraftsman"}]},{"type":"event","name":"AddRewarder","inputs":[{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"address","name":"rewarder","internalType":"contract IRewarder","indexed":false}],"anonymous":false},{"type":"event","name":"Deposit","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"EmergencyWithdraw","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"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":"Panic","inputs":[{"type":"uint256","name":"pid","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"RemoveRewarder","inputs":[{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"address","name":"rewarder","internalType":"contract IRewarder","indexed":false}],"anonymous":false},{"type":"event","name":"SetPid","inputs":[{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"address","name":"lpToken","internalType":"address","indexed":false},{"type":"address[]","name":"rewarders","internalType":"contract IRewarder[]","indexed":false},{"type":"bool","name":"withUpdate","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Withdraw","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"add","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address[]","name":"_rewarders","internalType":"contract IRewarder[]"},{"type":"bool","name":"_withUpdate","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addRewarder","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address","name":"_rewarder","internalType":"contract IRewarder"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ICraftsman"}],"name":"craftsman","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deposit","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"emergencyWithdraw","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"isRewarderInPool","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address","name":"_rewarder","internalType":"contract IRewarder"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"massUpdatePools","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"panic","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"},{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"pendingTokens","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address","name":"_user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"pendingVVS","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address","name":"_user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"poolIds","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"lpToken","internalType":"contract IERC20"},{"type":"uint256","name":"accVVSPerShare","internalType":"uint256"}],"name":"poolInfo","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"contract IRewarder[]"}],"name":"poolRewarders","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeRewarder","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address","name":"_rewarder","internalType":"contract IRewarder"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updatePool","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"rewardDebt","internalType":"uint256"}],"name":"userInfo","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101425760003560e01c806372f40a6b116100b8578063d10522881161007c578063d1052288146103f6578063e2bbb15814610422578063e7a2e3e014610445578063eff8976b14610471578063f2fde38b146104de578063ffcd42631461050457610142565b806372f40a6b146102b45780638da5cb5b146102d157806393f1a40b146102d957806398eff05e1461031e5780639b8379c5146103ca57610142565b80635312ea8e1161010a5780635312ea8e146101f55780635c975abb1461021257806360256d181461022e578063630b5ba11461027557806369883b4e1461027d578063715018a6146102ac57610142565b80631526fe271461014757806327c2bca8146101875780633f4ba83a146101ab578063441a3e70146101b557806351eb05a6146101d8575b600080fd5b6101646004803603602081101561015d57600080fd5b50356105c9565b604080516001600160a01b03909316835260208301919091528051918290030190f35b61018f6105ee565b604080516001600160a01b039092168252519081900360200190f35b6101b3610612565b005b6101b3600480360360408110156101cb57600080fd5b508035906020013561067e565b6101b3600480360360208110156101ee57600080fd5b50356109ad565b6101b36004803603602081101561020b57600080fd5b5035610bbb565b61021a610e50565b604080519115158252519081900360200190f35b61025a6004803603604081101561024457600080fd5b50803590602001356001600160a01b0316610e60565b60408051921515835260208301919091528051918290030190f35b6101b3610f63565b61029a6004803603602081101561029357600080fd5b5035610f86565b60408051918252519081900360200190f35b6101b3610fa4565b6101b3600480360360208110156102ca57600080fd5b5035611050565b61018f61117b565b610305600480360360408110156102ef57600080fd5b50803590602001356001600160a01b031661118a565b6040805192835260208301919091528051918290030190f35b6101b36004803603606081101561033457600080fd5b8135919081019060408101602082013564010000000081111561035657600080fd5b82018360208201111561036857600080fd5b8035906020019184602083028401116401000000008311171561038a57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050505035151590506111ae565b6101b3600480360360408110156103e057600080fd5b50803590602001356001600160a01b031661140f565b61029a6004803603604081101561040c57600080fd5b50803590602001356001600160a01b03166115cb565b6101b36004803603604081101561043857600080fd5b508035906020013561184b565b6101b36004803603604081101561045b57600080fd5b50803590602001356001600160a01b0316611c1d565b61048e6004803603602081101561048757600080fd5b5035611d48565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156104ca5781810151838201526020016104b2565b505050509050019250505060405180910390f35b6101b3600480360360208110156104f457600080fd5b50356001600160a01b0316611db7565b6105306004803603604081101561051a57600080fd5b50803590602001356001600160a01b0316611eb9565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561057457818101518382015260200161055c565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156105b357818101518382015260200161059b565b5050505090500194505050505060405180910390f35b600160205260009081526040902080546002909101546001600160a01b039091169082565b7f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc81565b61061a6121e1565b6001600160a01b031661062b61117b565b6001600160a01b031614610674576040805162461bcd60e51b81526020600482018190526024820152600080516020612a0c833981519152604482015290519081900360640190fd5b61067c6121e5565b565b816106d0576040805162461bcd60e51b815260206004820152601960248201527f776974686472617720565653206279204372616674736d616e00000000000000604482015290519081900360640190fd5b60008281526001602090815260408083206003835281842033855290925290912080548311156107315760405162461bcd60e51b81526004018080602001828103825260258152602001806129c66025913960400191505060405180910390fd5b61073a846109ad565b6000610774826001015461076e64e8d4a510006107688760020154876000015461228890919063ffffffff16565b906122e8565b9061234f565b905080156107865761078633826123ac565b8154600090610795908661234f565b90506060846001018054806020026020016040519081016040528092919081815260200182805480156107f157602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116107d3575b5050505050905060005b815181101561089a5781818151811061081057fe5b60200260200101516001600160a01b0316638b1830408933866040518463ffffffff1660e01b815260040180848152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561087657600080fd5b505af115801561088a573d6000803e3d6000fd5b5050600190920191506107fb9050565b50851561094d5783546108ad908761234f565b845560408051630441a3e760e41b8152600481018990526024810188905290516001600160a01b037f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc169163441a3e7091604480830192600092919082900301818387803b15801561091e57600080fd5b505af1158015610932573d6000803e3d6000fd5b5050865461094d92506001600160a01b03169050338861244e565b600285015484546109689164e8d4a510009161076891612288565b6001850155604080518781529051889133917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689181900360200190a350505050505050565b604080516393f1a40b60e01b81526004810183905230602482015281516000926001600160a01b037f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc16926393f1a40b9260448083019392829003018186803b158015610a1957600080fd5b505afa158015610a2d573d6000803e3d6000fd5b505050506040513d6040811015610a4357600080fd5b5051905080610a525750610bb8565b60007f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc6001600160a01b031663d105228884306040518363ffffffff1660e01b815260040180838152602001826001600160a01b031681526020019250505060206040518083038186803b158015610ac957600080fd5b505afa158015610add573d6000803e3d6000fd5b505050506040513d6020811015610af357600080fd5b505160408051631c57762b60e31b81526004810186905260006024820181905291519293506001600160a01b037f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc169263e2bbb1589260448084019391929182900301818387803b158015610b6757600080fd5b505af1158015610b7b573d6000803e3d6000fd5b50505060008481526001602052604090209050610baf610ba4846107688564e8d4a51000612288565b6002830154906124a0565b60029091015550505b50565b60008181526001602081815260408084206003835281852033865290925283208054848255928101939093559190610bf1610e50565b610dfd5760007f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc6001600160a01b031663d105228886306040518363ffffffff1660e01b815260040180838152602001826001600160a01b031681526020019250505060206040518083038186803b158015610c6c57600080fd5b505afa158015610c80573d6000803e3d6000fd5b505050506040513d6020811015610c9657600080fd5b505160408051630441a3e760e41b8152600481018890526024810185905290519192506001600160a01b037f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc169163441a3e709160448082019260009290919082900301818387803b158015610d0b57600080fd5b505af1158015610d1f573d6000803e3d6000fd5b5050604080516393f1a40b60e01b8152600481018990523060248201528151600094506001600160a01b037f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc1693506393f1a40b92604480840193919291829003018186803b158015610d9157600080fd5b505afa158015610da5573d6000803e3d6000fd5b505050506040513d6040811015610dbb57600080fd5b505190508115801590610dce5750600081115b15610dfa57610df4610de9826107688564e8d4a51000612288565b6002870154906124a0565b60028601555b50505b8254610e13906001600160a01b0316338361244e565b604080518281529051859133917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959181900360200190a350505050565b600054600160a01b900460ff1690565b600080610e6b6128b1565b600085815260016020818152604092839020835160608101855281546001600160a01b0316815292810180548551818502810185019096528086529394919385840193830182828015610ee757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ec9575b50505050508152602001600282015481525050905060005b816020015151811015610f5257846001600160a01b031682602001518281518110610f2657fe5b60200260200101516001600160a01b03161415610f4a57600193509150610f5c9050565b600101610eff565b5060008092509250505b9250929050565b60025460005b81811015610f8257610f7a816109ad565b600101610f69565b5050565b60028181548110610f9357fe5b600091825260209091200154905081565b610fac6121e1565b6001600160a01b0316610fbd61117b565b6001600160a01b031614611006576040805162461bcd60e51b81526020600482018190526024820152600080516020612a0c833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6110586121e1565b6001600160a01b031661106961117b565b6001600160a01b0316146110b2576040805162461bcd60e51b81526020600482018190526024820152600080516020612a0c833981519152604482015290519081900360640190fd5b6110ba610e50565b6110c6576110c66124fa565b7f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc6001600160a01b0316635312ea8e826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561112c57600080fd5b505af1158015611140573d6000803e3d6000fd5b50506040805184815290517f4e487b71539e0164c9d29506cc725e49342bcac15e0927282bf30fedfe1c72689350908190036020019150a150565b6000546001600160a01b031690565b60036020908152600092835260408084209091529082529020805460019091015482565b6111b66121e1565b6001600160a01b03166111c761117b565b6001600160a01b031614611210576040805162461bcd60e51b81526020600482018190526024820152600080516020612a0c833981519152604482015290519081900360640190fd5b6000838152600160205260409020546001600160a01b031615611270576040805162461bcd60e51b81526020600482015260136024820152721c1bdbdb081a185cc81899595b881859191959606a1b604482015290519081900360640190fd5b801561127e5761127e610f63565b60007f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc6001600160a01b0316631526fe27856040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b1580156112e457600080fd5b505afa1580156112f8573d6000803e3d6000fd5b505050506040513d608081101561130e57600080fd5b5051600085815260016020818152604090922080546001600160a01b0319166001600160a01b038516178155865193945061134e939101918601906128db565b506002849080600181540180825580915050600190039060005260206000200160009091909190915055837f89932ef1ddbdefb4ade64ffb3cb5ebf868798d2d6a8bdf55061ab702c0295bde82858560405180846001600160a01b03168152602001806020018315158152602001828103825284818151815260200191508051906020019060200280838360005b838110156113f45781810151838201526020016113dc565b5050505090500194505050505060405180910390a250505050565b6114176121e1565b6001600160a01b031661142861117b565b6001600160a01b031614611471576040805162461bcd60e51b81526020600482018190526024820152600080516020612a0c833981519152604482015290519081900360640190fd5b60008061147e8484610e60565b91509150816114c8576040805162461bcd60e51b8152602060048201526011602482015270139bc81c995dd85c99195c88199bdd5b99607a1b604482015290519081900360640190fd5b6000848152600160205260409020815b600182015460001901811015611553578160010181600101815481106114fa57fe5b6000918252602090912001546001830180546001600160a01b03909216918390811061152257fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790556001016114d8565b508060010180548061156157fe5b6000828152602090819020820160001990810180546001600160a01b0319169055909101909155604080516001600160a01b0387168152905187927fcb84b447f762f6ea5727904c33ecc1a6628dfb39ec6e2db3e0c5b21b400fd769928290030190a25050505050565b60006115d56128b1565b600084815260016020818152604092839020835160608101855281546001600160a01b031681529281018054855181850281018501909652808652939491938584019383018282801561165157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611633575b50505050508152602001600282015481525050905061166e612940565b5060008481526003602090815260408083206001600160a01b0380881685529083528184208251808401845281548152600190910154938101939093528482015182516393f1a40b60e01b8152600481018a905230602482015283519495919491937f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc909316926393f1a40b92604480840193829003018186803b15801561171557600080fd5b505afa158015611729573d6000803e3d6000fd5b505050506040513d604081101561173f57600080fd5b5051905080156118135760007f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc6001600160a01b031663d105228889306040518363ffffffff1660e01b815260040180838152602001826001600160a01b031681526020019250505060206040518083038186803b1580156117c057600080fd5b505afa1580156117d4573d6000803e3d6000fd5b505050506040513d60208110156117ea57600080fd5b5051905061180f611804836107688464e8d4a51000612288565b6040870151906124a0565b9250505b600061183d846020015161076e64e8d4a5100061076887896000015161228890919063ffffffff16565b955050505050505b92915050565b611853610e50565b15611898576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b816118ea576040805162461bcd60e51b815260206004820152601860248201527f6465706f73697420565653206279204372616674736d616e0000000000000000604482015290519081900360640190fd5b600082815260016020908152604080832060038352818420338552909252909120611914846109ad565b6000611942826001015461076e64e8d4a510006107688760020154876000015461228890919063ffffffff16565b905080156119545761195433826123ac565b815460009061196390866124a0565b90506060846001018054806020026020016040519081016040528092919081815260200182805480156119bf57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116119a1575b5050505050905060005b8151811015611a68578181815181106119de57fe5b60200260200101516001600160a01b0316638b1830408933866040518463ffffffff1660e01b815260040180848152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b158015611a4457600080fd5b505af1158015611a58573d6000803e3d6000fd5b5050600190920191506119c99050565b508515611baf578454611a86906001600160a01b0316333089612583565b84546040805163095ea7b360e01b81526001600160a01b037f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc81166004830152602482018a90529151919092169163095ea7b39160448083019260209291908290030181600087803b158015611afb57600080fd5b505af1158015611b0f573d6000803e3d6000fd5b505050506040513d6020811015611b2557600080fd5b505060408051631c57762b60e31b8152600481018990526024810188905290516001600160a01b037f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc169163e2bbb15891604480830192600092919082900301818387803b158015611b9657600080fd5b505af1158015611baa573d6000803e3d6000fd5b505050505b8354611bbb90876124a0565b8085556002860154611bd89164e8d4a51000916107689190612288565b6001850155604080518781529051889133917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159181900360200190a350505050505050565b611c256121e1565b6001600160a01b0316611c3661117b565b6001600160a01b031614611c7f576040805162461bcd60e51b81526020600482018190526024820152600080516020612a0c833981519152604482015290519081900360640190fd5b6000611c8b8383610e60565b5090508015611cd2576040805162461bcd60e51b815260206004820152600e60248201526d14995dd85c99195c88195e1a5cdd60921b604482015290519081900360640190fd5b600083815260016020818152604080842083018054938401815584529281902090910180546001600160a01b0319166001600160a01b0386169081179091558251908152915185927f207d27439436ae9975d3a427dc7bc629ad4a4549b033e591cba0fcf3f9071e2792908290030190a2505050565b600081815260016020818152604092839020909101805483518184028101840190945280845260609392830182828015611dab57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d8d575b50505050509050919050565b611dbf6121e1565b6001600160a01b0316611dd061117b565b6001600160a01b031614611e19576040805162461bcd60e51b81526020600482018190526024820152600080516020612a0c833981519152604482015290519081900360640190fd5b6001600160a01b038116611e5e5760405162461bcd60e51b815260040180806020018281038252602681526020018061297a6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b606080611ec46128b1565b600085815260016020818152604092839020835160608101855281546001600160a01b0316815292810180548551818502810185019096528086529394919385840193830182828015611f4057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611f22575b5050509183525050600291909101546020918201528101515190915060606001820167ffffffffffffffff81118015611f7857600080fd5b50604051908082528060200260200182016040528015611fa2578160200160208202803683370190505b50905060608260010167ffffffffffffffff81118015611fc157600080fd5b50604051908082528060200260200182016040528015611feb578160200160208202803683370190505b5090507f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc6001600160a01b03166308e773446040518163ffffffff1660e01b815260040160206040518083038186803b15801561204757600080fd5b505afa15801561205b573d6000803e3d6000fd5b505050506040513d602081101561207157600080fd5b50518251839060009061208057fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506120aa88886115cb565b816000815181106120b757fe5b60200260200101818152505060608460200151905060005b81518110156121d2576000808383815181106120e757fe5b60200260200101516001600160a01b03166348e43af48d8d6040518363ffffffff1660e01b815260040180838152602001826001600160a01b0316815260200192505050604080518083038186803b15801561214257600080fd5b505afa158015612156573d6000803e3d6000fd5b505050506040513d604081101561216c57600080fd5b50805160209091015187519193509150829087906001860190811061218d57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050808584600101815181106121bd57fe5b602090810291909101015250506001016120cf565b50919890975095505050505050565b3390565b6121ed610e50565b612235576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61226b6121e1565b604080516001600160a01b039092168252519081900360200190a1565b60008261229757506000611845565b828202828482816122a457fe5b04146122e15760405162461bcd60e51b81526004018080602001828103825260218152602001806129eb6021913960400191505060405180910390fd5b9392505050565b600080821161233e576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161234757fe5b049392505050565b6000828211156123a6576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60007f000000000000000000000000dccd6455ae04b03d785f12196b492b18129564bc6001600160a01b03166308e773446040518163ffffffff1660e01b815260040160206040518083038186803b15801561240757600080fd5b505afa15801561241b573d6000803e3d6000fd5b505050506040513d602081101561243157600080fd5b505190506124496001600160a01b038216848461244e565b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526124499084906125e3565b6000828201838110156122e1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b612502610e50565b15612547576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861226b6121e1565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526125dd9085906125e3565b50505050565b6060612638826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126949092919063ffffffff16565b8051909150156124495780806020019051602081101561265757600080fd5b50516124495760405162461bcd60e51b815260040180806020018281038252602a815260200180612a2c602a913960400191505060405180910390fd5b60606126a384846000856126ab565b949350505050565b6060824710156126ec5760405162461bcd60e51b81526004018080602001828103825260268152602001806129a06026913960400191505060405180910390fd5b6126f585612807565b612746576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106127855780518252601f199092019160209182019101612766565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146127e7576040519150601f19603f3d011682016040523d82523d6000602084013e6127ec565b606091505b50915091506127fc82828661280d565b979650505050505050565b3b151590565b6060831561281c5750816122e1565b82511561282c5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561287657818101518382015260200161285e565b50505050905090810190601f1680156128a35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604051806060016040528060006001600160a01b0316815260200160608152602001600081525090565b828054828255906000526020600020908101928215612930579160200282015b8281111561293057825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906128fb565b5061293c92915061295a565b5090565b604051806040016040528060008152602001600081525090565b5b8082111561293c5780546001600160a01b031916815560010161295b56fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c776974686472617720616d6f756e742067726561746572207468616e2062616c616e616365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212209906a065ad9c8cafd007ddcfcbd0f963538bd1aed5940bf3f96c269c88d8ccb964736f6c634300060c0033