GLMR Price: $0.020771 (-0.40%)

Contract

0xe3947b8e190d77cc3d8F925200283Edd099EBaFD

Overview

GLMR Balance

Moonbeam Chain LogoMoonbeam Chain LogoMoonbeam Chain Logo0 GLMR

GLMR Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Get Reward26849732023-01-08 11:26:001114 days ago1673177160IN
0xe3947b8e...d099EBaFD
0 GLMR0.0785457100
Withdraw All26849612023-01-08 11:23:361114 days ago1673177016IN
0xe3947b8e...d099EBaFD
0 GLMR0.073919100
Get Reward6461582022-03-20 20:56:541408 days ago1647809814IN
0xe3947b8e...d099EBaFD
0 GLMR0.1340574200
Get Reward5893412022-03-12 18:36:541416 days ago1647110214IN
0xe3947b8e...d099EBaFD
0 GLMR0.1376672200
Harvest5893262022-03-12 18:33:481416 days ago1647110028IN
0xe3947b8e...d099EBaFD
0 GLMR0.1138168200
Deposit5425752022-03-06 2:32:421423 days ago1646533962IN
0xe3947b8e...d099EBaFD
0 GLMR0.1680082200
Transfer Ownersh...2781212022-01-26 18:12:061461 days ago1643220726IN
0xe3947b8e...d099EBaFD
0 GLMR0.0025994100
Set Target2781112022-01-26 18:09:481461 days ago1643220588IN
0xe3947b8e...d099EBaFD
0 GLMR0.0233807100

Latest 1 internal transaction

Parent Transaction Hash Block From To
2781072022-01-26 18:09:001461 days ago1643220540
0xe3947b8e...d099EBaFD
 Contract Creation0 GLMR
Cross-Chain Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xC6916ff4...96F8727D9
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
VaultOptimizer

Compiler Version
v0.8.0+commit.c7dfd78e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 32 : VaultOptimizer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "../abstracts/VaultChefWithNovaTargetFlipToFlip.sol";

contract VaultOptimizer is VaultChefWithNovaTargetFlipToFlip {

  /* ========== CONSTRUCTOR ========== */

  constructor(
    address _sToken,
    address _vGovernance,
    address _routerAddress,
    address _mChef,
    uint _chefPid,
    address _vNova,
    address[] memory _rewardToBaseRoute,
    address[] memory _baseToNovaRoute,
    address[] memory _rewardToToken0Route,
    address[] memory _rewardToToken1Route
  ) VaultChefWithNovaTargetFlipToFlip(_sToken, _vGovernance, _routerAddress, _mChef, _chefPid, _vNova, _rewardToBaseRoute, _baseToNovaRoute, _rewardToToken0Route, _rewardToToken1Route) {

  }

}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @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() {
        _setOwner(_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 {
        _setOwner(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");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @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() {
        _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 4 of 32 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^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() {
        _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;
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

// SPDX-License-Identifier: MIT

pragma solidity ^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);
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @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 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'
        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) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _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
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^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;
        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");

        (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");

        (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");

        (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");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^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 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) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^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.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
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) {
        unchecked {
            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) {
        unchecked {
            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) {
        unchecked {
            // 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) {
        unchecked {
            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) {
        unchecked {
            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) {
        return a + b;
    }

    /**
     * @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) {
        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) {
        return a * b;
    }

    /**
     * @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.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        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) {
        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) {
        unchecked {
            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.
     *
     * 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) {
        unchecked {
            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) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IBoringERC20 {
    function mint(address to, uint256 amount) external;

    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function allowance(address owner, address spender)
        external
        view
        returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );

    /// @notice EIP 2612
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IBoringERC20.sol";

interface IComplexRewarder {
    function onNovaReward(
        uint256 pid,
        address user,
        uint256 newLpAmount
    ) external;

    function pendingTokens(uint256 pid, address user)
        external
        view
        returns (uint256 pending);

    function rewardToken() external view returns (IBoringERC20);

    function poolRewardsPerSec(uint256 pid) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IComplexRewarder.sol";
import "./IBoringERC20.sol";

interface IMasterChef {
  function totalAllocPoint() external view returns (uint256);

  function deposit(uint256 _pid, uint256 _amount) external;

  function poolLength() external view returns (uint256);

  function novaPerSec() external view returns (uint256);

  function poolTotalLp(uint256 pid) external view returns (uint256);

  function poolInfo(uint _pid) view external returns (
    address lpToken, // Address of LP token contract.
    uint256 allocPoint, // How many allocation points assigned to this pool. Nova to distribute per block.
    uint256 lastRewardTimestamp, // Last block number that Nova distribution occurs.
    uint256 accNovaPerShare, // Accumulated Nova per share, times 1e18. See below.
    uint16 depositFeeBP, // Deposit fee in basis points
    uint256 harvestInterval, // Harvest interval in seconds
    uint256 totalLp
  );

  function poolRewardsPerSec(uint256 _pid) external view returns (
    address[] memory addresses,
    string[] memory symbols,
    uint256[] memory decimals,
    uint256[] memory rewardsPerSec
  );

  function userInfo(uint _pid, address _account) view external returns (
    uint256 amount, // How many LP tokens the user has provided.
    uint256 rewardDebt, // Reward debt. See explanation below.
    uint256 rewardLockedUp, // Reward locked up.
    uint256 nextHarvestUntil // When can the user harvest again.
  );

  function withdraw(uint256 _pid, uint256 _amount) external;
}

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure 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 DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "./VaultController.sol";
import "../../farm/interfaces/IMasterChef.sol";
import "../interfaces/IVault.sol";
import "../../uniswapv2/interfaces/IUniswapV2Router02.sol";

abstract contract Vault is VaultController, IVault {
  using SafeERC20 for IERC20;
  using SafeMath for uint256;

  /* ========== STATE VARIABLES ========== */

  uint256 public lastHarvest;

  /* ========== CONSTRUCTOR ========== */

  constructor(
    address _sToken,
    address _rToken,
    address _nToken,
    address _vGovernance
  ) VaultController(_sToken, _rToken, _nToken, _vGovernance) {
  }

  /* ========== MUTATIVE FUNCTIONS ========== */

  function deposit(uint _amount) public override {
    _depositTo(_amount, msg.sender);
  }

  function depositAll() external override {
    deposit(_stakingToken.balanceOf(msg.sender));
  }

  function withdrawAll() external override {
    withdraw(balanceOf(msg.sender));
  }

  function harvest() public virtual override {
    _harvest();
    (uint harvested, uint treasuryFeeNova, uint buyBackFeeNova) = getFees();

    depositToken(harvested);

    totalBuyBack = totalBuyBack.add(buyBackFeeNova);
    totalTreasury = totalTreasury.add(treasuryFeeNova);
    totalProfit = totalProfit.add(harvested);

    emit Harvested(harvested, treasuryFeeNova, buyBackFeeNova);

    lastHarvest = block.timestamp;
  }

  function withdraw(uint _amount) public override virtual nonReentrant {
    harvest();

    uint amount = Math.min(_amount, _principal[msg.sender]);
    uint shares = Math.min(amount.mul(totalShares).div(balance()), _shares[msg.sender]);
    totalShares = totalShares.sub(shares);
    _shares[msg.sender] = _shares[msg.sender].sub(shares);
    _principal[msg.sender] = _principal[msg.sender].sub(amount);

    resetShares();

    amount = _withdrawTokenWithCorrection(amount);

    uint withdrawalFee = _vaultGovernance.calculateWithdrawalFee(amount, _depositedAt[msg.sender]);

    if (withdrawalFee > 0) {
      _stakingToken.safeTransfer(_vaultGovernance.treasuryAddress(), withdrawalFee);
      amount = amount.sub(withdrawalFee);
      totalWithdrawalFee = totalWithdrawalFee.add(withdrawalFee);
    }

    _stakingToken.safeTransfer(msg.sender, amount);

    emit Withdrawn(msg.sender, amount, withdrawalFee);
  }

  function getReward() external virtual override nonReentrant {
    harvest();

    uint amount = earned(msg.sender);

    if (amount > 0) {
      amount = _withdrawTokenWithCorrection(amount);
      _stakingToken.safeTransfer(msg.sender, amount);

      totalShares = totalShares.sub(_shares[msg.sender]);

      if (totalShares == 0) {
        _shares[msg.sender] = principalOf(msg.sender);
      } else {
        uint bal = balance().sub(principalOf(msg.sender));
        _shares[msg.sender] = principalOf(msg.sender).mul(totalShares).div(bal);
      }

      totalShares = totalShares.add(_shares[msg.sender]);

      emit RewardsPaid(msg.sender, amount, 0);
    }
  }

  function emergencyWithdraw(uint _amount) override virtual public whenPaused nonReentrant {
    uint amount = Math.min(_amount, _principal[msg.sender]);
    uint shares = Math.min(amount.mul(totalShares).div(balance()), _shares[msg.sender]);
    totalShares = totalShares.sub(shares);
    _shares[msg.sender] = _shares[msg.sender].sub(shares);
    _principal[msg.sender] = _principal[msg.sender].sub(amount);

    resetShares();

    amount = _withdrawTokenWithCorrection(amount);

    _stakingToken.safeTransfer(msg.sender, amount);

    emit Withdrawn(msg.sender, amount, 0);
  }

  /* ========== INTERNAL FUNCTIONS ========== */
  function getFees() internal virtual returns (uint harvested, uint treasuryFeeNova, uint buyBackFeeNova);

  function depositToken(uint _amount) internal virtual;

  function _withdrawTokenWithCorrection(uint amount) internal virtual returns (uint);

  function _harvest() internal virtual {
    depositToken(0);
  }

  function _depositTo(uint _amount, address _to) internal virtual nonReentrant whenNotPaused {
    harvest();

    uint _pool = balance();
    uint _before = _stakingToken.balanceOf(address(this));
    _stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
    uint _after = _stakingToken.balanceOf(address(this));
    _amount = _after.sub(_before);

    uint depositFee = _vaultGovernance.calculateDepositFee(_amount);

    if (depositFee > 0) {
      _stakingToken.safeTransfer(_vaultGovernance.treasuryAddress(), depositFee);
      _amount = _amount.sub(depositFee);
      totalDepositFee = totalDepositFee.add(depositFee);
    }

    uint shares = 0;
    if (totalShares == 0) {
      shares = _amount;
    } else {
      shares = (_amount.mul(totalShares)).div(_pool);
    }

    totalShares = totalShares.add(shares);
    _shares[_to] = _shares[_to].add(shares);
    _principal[_to] = _principal[_to].add(_amount);
    _depositedAt[_to] = block.timestamp;

    depositToken(_amount);

    emit Deposited(_to, _amount, depositFee);
  }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "../../farm/interfaces/IMasterChef.sol";
import "../../uniswapv2/interfaces/IUniswapV2Router02.sol";

import "./Vault.sol";
import "../interfaces/IVaultChef.sol";

abstract contract VaultChef is Vault {
  using SafeERC20 for IERC20;
  using SafeMath for uint256;

  /* ========== STATE VARIABLES ========== */

  IUniswapV2Router02 internal _router;
  IMasterChef internal _masterChef;
  uint internal _pid;

  /* ========== CONSTRUCTOR ========== */

  constructor(
    address _sToken,
    address _rToken,
    address _nToken,
    address _vGovernance,
    address _routerAddress,
    address _mChef,
    uint _chefPid
  ) Vault(_sToken, _rToken, _nToken, _vGovernance) {
    _router = IUniswapV2Router02(_routerAddress);
    _masterChef = IMasterChef(_mChef);
    _pid = _chefPid;
    _stakingToken.safeApprove(address(_masterChef), type(uint256).max);
  }

  /* ========== VIEW FUNCTIONS ========== */

  function chef() external view returns (address) {
    return address(_masterChef);
  }

  function router() external view returns (address) {
    return address(_router);
  }

  function pid() external view returns (uint) {
    return _pid;
  }

  function balance() public view virtual override returns (uint amount) {
    (amount,,,) = _masterChef.userInfo(_pid, address(this));
  }

  /* ========== INTERNAL FUNCTIONS ========== */

  function getFees() internal override virtual returns (uint harvested, uint treasuryFeeNova, uint buyBackFeeNova) {
    uint256 _balance = _rewardsToken.balanceOf(address(this));
    treasuryFeeNova = _vaultGovernance.calculateTreasuryFee(_balance);
    buyBackFeeNova = _vaultGovernance.calculateBuyBackFee(_balance);
    IVaultStrategyReward buyBackAddress = IVaultStrategyReward(_vaultGovernance.buyBackAddress());

    _rewardsToken.safeTransfer(address(buyBackAddress), buyBackFeeNova);
    _rewardsToken.safeTransfer(_vaultGovernance.treasuryAddress(), treasuryFeeNova);

    try buyBackAddress.sendStrategyReward() {} catch {}

    harvested = _rewardsToken.balanceOf(address(this));
  }

  function depositToken(uint _amount) internal virtual override {
    _masterChef.deposit(_pid, _amount);
  }

  function _withdrawTokenWithCorrection(uint amount) internal virtual override returns (uint) {
    uint before = _stakingToken.balanceOf(address(this));
    _masterChef.withdraw(_pid, amount);
    return _stakingToken.balanceOf(address(this)).sub(before);
  }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "./VaultChef.sol";
import "../interfaces/IVaultChefWithNova.sol";

contract VaultChefWithNova is VaultChef {
  using SafeERC20 for IERC20;
  using SafeMath for uint256;

  uint public totalSharesNova;
  IVaultChef _vaultNova;
  uint totalStakedBalance;
  mapping(address => uint) internal _sharesNova;

  /* ========== CONSTRUCTOR ========== */

  constructor(
    address _sToken,
    address _rToken,
    address _vGovernance,
    address _routerAddress,
    address _mChef,
    uint _chefPid,
    address _vNova
  ) VaultChef(_sToken, _rToken, IVaultChef(_vNova).stakingToken(), _vGovernance, _routerAddress, _mChef, _chefPid) {
    _vaultNova = IVaultChef(_vNova);
    _novaToken.safeApprove(address(_vaultNova), type(uint256).max);
  }

  /* ========== VIEW FUNCTIONS ========== */

  function balanceNova() public view returns (uint amount) {
    amount = _vaultNova.balanceOf(address(this));
    amount = amount.add(totalStakedBalance.mul(1e9));
  }

  function balanceOfNova(address account) public view returns (uint) {
    if (totalSharesNova == 0) return 0;
    return balanceNova().mul(sharesOfNova(account)).div(totalSharesNova);
  }

  function sharesOfNova(address account) public view returns (uint) {
    return _sharesNova[account];
  }

  function earnedNova(address account) public view returns (uint) {
    uint staked = principalOf(account).mul(1e9);
    uint bNova = balanceOfNova(account);

    if (bNova >= staked) {
      return bNova.sub(staked);
    } else {
      return 0;
    }
  }

  /* ========== MUTATIVE FUNCTIONS ========== */

  function harvest() public override virtual {
    _harvest();

    (uint harvested, uint treasuryFeeNova, uint buyBackFeeNova) = getFees();

    if (harvested > 0) {
      _vaultNova.deposit(harvested);
    }

    totalBuyBack = totalBuyBack.add(buyBackFeeNova);
    totalTreasury = totalTreasury.add(treasuryFeeNova);
    totalProfit = totalProfit.add(harvested);

    emit Harvested(harvested, treasuryFeeNova, buyBackFeeNova);

    lastHarvest = block.timestamp;
  }

  function getReward() external override virtual nonReentrant {
    harvest();

    uint amount = earned(msg.sender);

    if (amount > 0) {
      amount = _withdrawTokenWithCorrection(amount);
      _stakingToken.safeTransfer(msg.sender, amount);

      totalShares = totalShares.sub(_shares[msg.sender]);

      if (totalShares == 0) {
        _shares[msg.sender] = principalOf(msg.sender);
      } else {
        uint bal = balance().sub(principalOf(msg.sender));
        _shares[msg.sender] = principalOf(msg.sender).mul(totalShares).div(bal);
      }

      totalShares = totalShares.add(_shares[msg.sender]);
    }

    uint amountNova = earnedNova(msg.sender);

    if (amountNova > 0) {
      amountNova = _withdrawNovaTokenWithCorrection(amountNova);
      _novaToken.safeTransfer(msg.sender, amountNova);

      totalSharesNova = totalSharesNova.sub(_sharesNova[msg.sender]);

      if (totalSharesNova == 0) {
        _sharesNova[msg.sender] = principalOf(msg.sender).mul(1e9);
      } else {
        uint bal = balanceNova().sub(principalOf(msg.sender).mul(1e9));
        _sharesNova[msg.sender] = principalOf(msg.sender).mul(1e9).mul(totalSharesNova).div(bal);
      }

      totalSharesNova = totalSharesNova.add(_sharesNova[msg.sender]);
    }

    emit RewardsPaid(msg.sender, amount, amountNova);
  }

  function withdraw(uint _amount) public override virtual nonReentrant {
    harvest();

    uint amount = Math.min(_amount, _principal[msg.sender]);
    uint shares = Math.min(amount.mul(totalShares).div(balance()), _shares[msg.sender]);
    uint sharesNova = Math.min(amount.mul(1e9).mul(totalSharesNova).div(balanceNova()), _sharesNova[msg.sender]);
    totalShares = totalShares.sub(shares);
    totalSharesNova = totalSharesNova.sub(sharesNova);
    _shares[msg.sender] = _shares[msg.sender].sub(shares);
    _sharesNova[msg.sender] = _sharesNova[msg.sender].sub(sharesNova);
    _principal[msg.sender] = _principal[msg.sender].sub(amount);
    totalStakedBalance = totalStakedBalance.sub(amount);

    resetShares();

    amount = _withdrawTokenWithCorrection(amount);

    uint withdrawalFee = _vaultGovernance.calculateWithdrawalFee(amount, _depositedAt[msg.sender]);

    if (withdrawalFee > 0) {
      _stakingToken.safeTransfer(_vaultGovernance.treasuryAddress(), withdrawalFee);
      amount = amount.sub(withdrawalFee);
      totalWithdrawalFee = totalWithdrawalFee.add(withdrawalFee);
    }

    _stakingToken.safeTransfer(msg.sender, amount);
    emit Withdrawn(msg.sender, amount, withdrawalFee);
  }

  function emergencyWithdraw(uint _amount) override virtual public whenPaused nonReentrant {
    uint amount = Math.min(_amount, _principal[msg.sender]);
    uint shares = Math.min(amount.mul(totalShares).div(balance()), _shares[msg.sender]);
    uint sharesNova = Math.min(amount.mul(1e9).mul(totalSharesNova).div(balanceNova()), _sharesNova[msg.sender]);
    totalShares = totalShares.sub(shares);
    totalSharesNova = totalSharesNova.sub(sharesNova);
    _shares[msg.sender] = _shares[msg.sender].sub(shares);
    _sharesNova[msg.sender] = _sharesNova[msg.sender].sub(sharesNova);
    _principal[msg.sender] = _principal[msg.sender].sub(amount);
    totalStakedBalance = totalStakedBalance.sub(amount);

    resetShares();

    amount = _withdrawTokenWithCorrection(amount);

    _stakingToken.safeTransfer(msg.sender, amount);

    emit Withdrawn(msg.sender, amount, 0);
  }

  /* ========== INTERNAL FUNCTIONS ========== */

  function _harvest() override virtual internal {
    _masterChef.deposit(_pid, 0);
    _vaultNova.getReward();

    uint stakedHarvested = _stakingToken.balanceOf(address(this));
    if (stakedHarvested > 0) {
      _masterChef.deposit(_pid, stakedHarvested);
    }
  }

  function _withdrawNovaTokenWithCorrection(uint amount) internal virtual returns (uint) {
    uint before = _novaToken.balanceOf(address(this));
    _vaultNova.withdraw(amount);
    return _novaToken.balanceOf(address(this)).sub(before);
  }

  function _depositTo(uint _amount, address _to) internal override nonReentrant whenNotPaused {
    harvest();

    uint _before = _stakingToken.balanceOf(address(this));
    _stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
    uint _after = _stakingToken.balanceOf(address(this));
    _amount = _after.sub(_before);

    uint depositFee = _vaultGovernance.calculateDepositFee(_amount);

    if (depositFee > 0) {
      _stakingToken.safeTransfer(_vaultGovernance.treasuryAddress(), depositFee);
      _amount = _amount.sub(depositFee);
      totalDepositFee = totalDepositFee.add(depositFee);
    }

    uint shares = 0;
    if (totalShares == 0) {
      shares = _amount;
    } else {
      shares = (_amount.mul(totalShares)).div(balance());
    }

    totalShares = totalShares.add(shares);
    _shares[_to] = _shares[_to].add(shares);
    _principal[_to] = _principal[_to].add(_amount);
    _depositedAt[_to] = block.timestamp;

    uint sharesNova = 0;
    if (totalSharesNova == 0) {
      sharesNova = _amount.mul(1e9);
    } else {
      sharesNova = _amount.mul(1e9).mul(totalSharesNova).div(balanceNova());
    }

    _sharesNova[_to] = _sharesNova[_to].add(sharesNova);
    totalSharesNova = totalSharesNova.add(sharesNova);

    totalStakedBalance = totalStakedBalance.add(_amount);

    depositToken(_amount);

    emit Deposited(_to, _amount, depositFee);
  }

  function resetShares() override virtual internal {
    uint shares = _shares[msg.sender];
    uint sharesNova = _sharesNova[msg.sender];

    if (shares > 0 && shares < 1000) {
      totalShares = totalShares.sub(shares);
      delete _shares[msg.sender];
    }

    if (sharesNova > 0 && sharesNova < 1000) {
      totalSharesNova = totalSharesNova.sub(sharesNova);
      delete _sharesNova[msg.sender];
    }
  }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "./VaultChefWithNova.sol";
import "../interfaces/IVaultChefWithNovaTarget.sol";
import "../resources/TokenTargetChef.sol";

abstract contract VaultChefWithNovaTarget is VaultChefWithNova {
  using SafeERC20 for IERC20;
  using SafeMath for uint256;

  /* ========== STATE VARIABLES ========== */

  IUniswapV2Router02 internal _routerTarget;
  IMasterChef internal _masterChefTarget;
  uint internal _pidTarget;

  IERC20 _tokenTargetChef;

  IERC20 internal _base;

  address[] public rewardToBaseRoute;

  address[] public baseToNovaRoute;

  /* ========== CONSTRUCTOR ========== */

  constructor(
    address _sToken,
    address _vGovernance,
    address _routerAddress,
    address _mChef,
    uint _chefPid,
    address _vNova,
    address[] memory _rewardToBaseRoute,
    address[] memory _baseToNovaRoute
  ) VaultChefWithNova(_sToken, _rewardToBaseRoute[0], _vGovernance, _routerAddress, _mChef, _chefPid, _vNova) {
    _tokenTargetChef = new TokenTargetChef();

    rewardToBaseRoute = _rewardToBaseRoute;
    baseToNovaRoute = _baseToNovaRoute;
    _base = IERC20(baseToNovaRoute[0]);

    require(rewardToBaseRoute[rewardToBaseRoute.length - 1] == baseToNovaRoute[0], "rewardToBaseRoute[last] != baseToNovaRoute[0]");
  }

  function setTarget(address _routerAddressTarget, address _mChefTarget, uint _chefPidTarget) public virtual onlyOwner {
    require(address(_routerTarget) == address(0), 'Target can only be added once');
    _routerTarget = IUniswapV2Router02(_routerAddressTarget);
    _masterChefTarget = IMasterChef(_mChefTarget);
    _pidTarget = _chefPidTarget;
    _tokenTargetChef.safeApprove(address(_masterChefTarget), type(uint256).max);
    _masterChefTarget.deposit(_pidTarget, 1e18);
    _base.safeApprove(address(_routerTarget), type(uint256).max);
  }

  /* ========== VIEW FUNCTIONS ========== */

  function tokenTargetChef() public view returns (address) {
    return address(_tokenTargetChef);
  }

  function base() external view returns (address) {
    return address(_base);
  }

  function chefTarget() external view returns (address) {
    return address(_masterChefTarget);
  }

  function routerTarget() external view returns (address) {
    return address(_routerTarget);
  }

  function pidTarget() external view returns (uint) {
    return _pidTarget;
  }

  function getFees() internal override returns (uint harvested, uint treasuryFeeNova, uint buyBackFeeNova) {
    IVaultStrategyReward buyBackAddress = IVaultStrategyReward(_vaultGovernance.buyBackAddress());
    address treasuryAddress = _vaultGovernance.treasuryAddress();

    uint rewardBalance = _rewardsToken.balanceOf(address(this));

    treasuryFeeNova = 0;
    buyBackFeeNova = 0;
    harvested = 0;

    try _router.swapExactTokensForTokens(rewardBalance, 1, rewardToBaseRoute, address(this), block.timestamp) {
      uint baseBalance = _base.balanceOf(address(this));

      try _routerTarget.swapExactTokensForTokens(baseBalance, 10, baseToNovaRoute, address(this), block.timestamp) {
        uint novaBalance = _novaToken.balanceOf(address(this));

        treasuryFeeNova = _vaultGovernance.calculateNovaFee(novaBalance, 1);
        buyBackFeeNova = _vaultGovernance.calculateNovaFee(novaBalance, 2);

        _novaToken.safeTransfer(treasuryAddress, treasuryFeeNova);
        _novaToken.safeTransfer(address(buyBackAddress), buyBackFeeNova);

        try buyBackAddress.sendStrategyReward() {} catch {}
      } catch {}
    } catch {}
  }

  function _harvest() override internal {
    _masterChef.deposit(_pid, 0);
    _masterChefTarget.deposit(_pidTarget, 0);
    _vaultNova.getReward();
    uint novaHarvested = _novaToken.balanceOf(address(this));
    if (novaHarvested > 0) {
      _vaultNova.deposit(novaHarvested);
    }
  }

}

File 23 of 32 : VaultChefWithNovaTargetFlipToFlip.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "./VaultChefWithNovaTarget.sol";
import "../../uniswapv2/interfaces/IUniswapV2Pair.sol";

abstract contract VaultChefWithNovaTargetFlipToFlip is VaultChefWithNovaTarget {
  using SafeERC20 for IERC20;
  using SafeMath for uint256;

  /* ========== STATE VARIABLES ========== */

  address public token0;
  address public token1;

  address[] public rewardToToken0Route;
  address[] public rewardToToken1Route;

  address[] public token0ToReward;
  address[] public token1ToReward;

  /* ========== CONSTRUCTOR ========== */
  constructor(
    address _sToken,
    address _vGovernance,
    address _routerAddress,
    address _mChef,
    uint _chefPid,
    address _vNova,
    address[] memory _rewardToBaseRoute,
    address[] memory _baseToNovaRoute,
    address[] memory _rewardToToken0Route,
    address[] memory _rewardToToken1Route
  ) VaultChefWithNovaTarget(_sToken, _vGovernance, _routerAddress, _mChef, _chefPid, _vNova, _rewardToBaseRoute, _baseToNovaRoute) {
    rewardToToken0Route = _rewardToToken0Route;
    rewardToToken1Route = _rewardToToken1Route;

    for (uint i = 0; i < rewardToToken0Route.length; i++) {
      token0ToReward.push(rewardToToken0Route[rewardToToken0Route.length - i - 1]);
    }

    for (uint i = 0; i < rewardToToken1Route.length; i++) {
      token1ToReward.push(rewardToToken1Route[rewardToToken1Route.length - i - 1]);
    }

    token0 = IUniswapV2Pair(_sToken).token0();
    token1 = IUniswapV2Pair(_sToken).token1();

    require(rewardToToken0Route[rewardToToken0Route.length - 1] == token0, "rewardToToken0Route[last] != token0");
    require(rewardToToken1Route[rewardToToken1Route.length - 1] == token1, "rewardToToken1Route[last] != token1");
    require(rewardToBaseRoute[0] == _rewardToToken0Route[0], "rewardToBaseRoute[0] != _rewardToToken0Route[0]");
    require(rewardToBaseRoute[0] == _rewardToToken1Route[0], "rewardToBaseRoute[0] != _rewardToToken1Route[0]");

    allowances();
  }

  function allowances() private {
    _rewardsToken.safeApprove(address(_router), type(uint256).max);

    IERC20(token0).safeApprove(address(_router), 0);
    IERC20(token0).safeApprove(address(_router), type(uint256).max);

    IERC20(token1).safeApprove(address(_router), 0);
    IERC20(token1).safeApprove(address(_router), type(uint256).max);
  }

  /* ========== MUTATIVE FUNCTIONS ========== */

  function harvest() public virtual override {
    _harvest();

    uint before = _stakingToken.balanceOf(address(this));
    (, uint treasuryFeeNova, uint buyBackFeeNova) = addLiquidity();
    uint harvested = _stakingToken.balanceOf(address(this)).sub(before);

    _masterChef.deposit(_pid, harvested);

    totalBuyBack = totalBuyBack.add(buyBackFeeNova);
    totalTreasury = totalTreasury.add(treasuryFeeNova);
    totalProfit = totalProfit.add(harvested);

    emit Harvested(harvested, treasuryFeeNova, buyBackFeeNova);

    lastHarvest = block.timestamp;
  }

  function addLiquidity() internal returns (uint liquidity, uint treasuryFee, uint buyBackFee) {
    uint256 balance = _rewardsToken.balanceOf(address(this));
    liquidity = 0;
    treasuryFee = 0;
    buyBackFee = 0;

    if (balance > 0) {
      uint treasuryAmount = _vaultGovernance.calculateTreasuryFee(balance);
      uint buyBackAmount = _vaultGovernance.calculateBuyBackFee(balance);

      uint256 half = balance.sub(treasuryAmount).sub(buyBackAmount).div(2);

      bool existsBuyAmountToken0 = false;
      bool existsBuyAmountToken1 = false;

      if (token0 != address(_rewardsToken)) {
        try _router.getAmountsOut(half, rewardToToken0Route) returns (uint[] memory amounts) {
          if (amounts[rewardToToken0Route.length - 1] > 0) {
            existsBuyAmountToken0 = true;
          }
        } catch {}
      } else {
        existsBuyAmountToken0 = true;
      }

      if (token1 != address(_rewardsToken)) {
        try _router.getAmountsOut(half, rewardToToken1Route) returns (uint[] memory amounts) {
          if (amounts[rewardToToken1Route.length - 1] > 0) {
            existsBuyAmountToken1 = true;
          }
        } catch {}
      } else {
        existsBuyAmountToken1 = true;
      }

      if (existsBuyAmountToken0 && existsBuyAmountToken1) {
        if (token0 != address(_rewardsToken)) {
          try _router.swapExactTokensForTokens(half, 0, rewardToToken0Route, address(this), block.timestamp) {} catch {}
        }

        if (token1 != address(_rewardsToken)) {
          try _router.swapExactTokensForTokens(half, 0, rewardToToken1Route, address(this), block.timestamp) {} catch {}
        }

        uint256 token0Balance = IERC20(token0).balanceOf(address(this));
        uint256 token1Balance = IERC20(token1).balanceOf(address(this));

        try _router.addLiquidity(token0, token1, token0Balance, token1Balance, 1, 1, address(this), block.timestamp) returns (uint, uint, uint x) {
          liquidity = x;
          (,treasuryFee, buyBackFee) = getFees();
        } catch {}

        token0Balance = IERC20(token0).balanceOf(address(this));
        token1Balance = IERC20(token1).balanceOf(address(this));

        if (token0Balance > 0) {
          try _router.swapExactTokensForTokens(token0Balance, 0, token0ToReward, address(this), block.timestamp) {} catch {}
        }

        if (token1Balance > 0) {
          try _router.swapExactTokensForTokens(token1Balance, 0, token1ToReward, address(this), block.timestamp) {} catch {}
        }
      }
    }
  }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

import "../interfaces/IVaultStrategyReward.sol";
import "../interfaces/IVaultGovernance.sol";
import "../interfaces/IVaultController.sol";

abstract contract VaultController is IVaultController, Pausable, ReentrancyGuard, Ownable {
  using SafeERC20 for IERC20;
  using SafeMath for uint256;

  /* ========== STATE VARIABLES ========== */

  IVaultGovernance internal _vaultGovernance;
  IERC20 internal _stakingToken;
  IERC20 internal _rewardsToken;
  IERC20 internal _novaToken;

  uint public totalShares;
  mapping(address => uint) internal _shares;
  mapping(address => uint) internal _principal;
  mapping(address => uint) internal _depositedAt;

  uint public totalBuyBack;
  uint public totalTreasury;
  uint public totalProfit;
  uint public totalDepositFee;
  uint public totalWithdrawalFee;

  /* ========== Event ========== */

  event Recovered(address token, uint amount);

  /* ========== CONSTRUCTOR ========== */

  constructor(address _sToken, address _rToken, address _nToken, address _vGovernance) {
    _stakingToken = IERC20(_sToken);
    _rewardsToken = IERC20(_rToken);
    _novaToken = IERC20(_nToken);
    _vaultGovernance = IVaultGovernance(_vGovernance);
  }

  /* ========== VIEW FUNCTIONS ========== */

  function totalSupply() external view override returns (uint) {
    return totalShares;
  }

  function balance() public view virtual override returns (uint amount) {
    return _stakingToken.balanceOf(address(this));
  }

  function
  balanceOf(address account) public view override returns (uint) {
    if (totalShares == 0) return 0;
    return balance().mul(sharesOf(account)).div(totalShares);
  }

  function sharesOf(address account) public view override returns (uint) {
    return _shares[account];
  }

  function principalOf(address account) public view override returns (uint) {
    return _principal[account];
  }

  function earned(address account) public view virtual override returns (uint) {
    if (balanceOf(account) >= principalOf(account)) {
      return balanceOf(account).sub(principalOf(account));
    } else {
      return 0;
    }
  }

  function depositedAt(address account) external view override returns (uint) {
    return _depositedAt[account];
  }

  function stakingToken() external view override returns (address) {
    return address(_stakingToken);
  }

  function rewardsToken() external view override returns (address) {
    return address(_rewardsToken);
  }

  function novaToken() external view override returns (address) {
    return address(_novaToken);
  }

  function vaultGovernance() external view override returns (address) {
    return address(_vaultGovernance);
  }

  function resetShares() virtual internal {
    uint shares = _shares[msg.sender];
    if (shares > 0 && shares < 1000) {
      totalShares = totalShares.sub(shares);
      delete _shares[msg.sender];
    }
  }

  /* ========== SALVAGE PURPOSE ONLY ========== */

  function emergencyWithdraw(uint _amount) virtual public whenPaused nonReentrant {}

  function recoverToken(address _token, uint amount) virtual external onlyOwner {
    require(_token != address(_stakingToken), 'VaultController: cannot recover staking token');
    IERC20(_token).safeTransfer(owner(), amount);

    emit Recovered(_token, amount);
  }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "./IVaultController.sol";

interface IVault is IVaultController {
  function deposit(uint _amount) external;
  function depositAll() external;
  function withdraw(uint _amount) external;
  function withdrawAll() external;
  function getReward() external;
  function harvest() external;

  event Deposited(address indexed user, uint amount, uint depositFee);
  event Withdrawn(address indexed user, uint amount, uint withdrawalFee);
  event RewardsPaid(address indexed user, uint rewards, uint rewardsNova);
  event Harvested(uint harvested, uint treasuryFeeInNova, uint buyBackInNova);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "./IVault.sol";

interface IVaultChef is IVault {
  function chef() external view returns (address);
  function router() external view returns (address);
  function pid() external view returns (uint);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "./IVaultChef.sol";

interface IVaultChefWithNova is IVaultChef {
  function balanceNova() external view returns (uint amount);

  function balanceOfNova(address account) external view returns (uint);

  function sharesOfNova(address account) external view returns (uint);

  function earnedNova(address account) external view returns (uint);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "./IVaultChefWithNova.sol";

interface IVaultChefWithNovaTarget is IVaultChefWithNova {
  function setTarget(address _routerAddressTarget, address _mChefTarget, uint _chefPidTarget) external;

  /* ========== VIEW FUNCTIONS ========== */

  function tokenTargetChef() external view returns (address);

  function base() external view returns (address);

  function chefTarget() external view returns (address);

  function routerTarget() external view returns (address);

  function pidTarget() external view returns (uint);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

interface IVaultController {
  function totalSupply() external view returns (uint);
  function balance() external view returns (uint);
  function balanceOf(address account) external view returns (uint);
  function principalOf(address account) external view returns (uint);
  function sharesOf(address account) external view returns (uint);
  function earned(address account) external view returns (uint);
  function depositedAt(address account) external view returns (uint);
  function rewardsToken() external view returns (address);
  function stakingToken() external view returns (address);
  function novaToken() external view returns (address);
  function vaultGovernance() external view returns (address);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

interface IVaultGovernance {
  function setWithdrawalFeeFreePeriod(uint _period) external;
  function setWithdrawalFee(uint _fee) external;
  function setDepositFee(uint _fee) external;
  function setTreasuryFee(uint _fee) external;
  function setBuyBackFee(uint _fee) external;
  function setBuyBackAddress(address _buyBackAddress) external;
  function setTreasuryAddress(address _treasuryAddress) external;

  function calculateWithdrawalFee(uint amount, uint depositedAt) external view returns (uint);
  function calculateDepositFee(uint amount) external view returns (uint);
  function calculateTreasuryFee(uint amount) external view returns (uint);
  function calculateBuyBackFee(uint amount) external view returns (uint);
  function calculateNovaFee(uint amount, uint option) external view returns (uint);

  function withdrawalFee() external view returns (uint);
  function withdrawalFeeFreePeriod() external view returns (uint);
  function depositFee() external view returns (uint);
  function treasuryFee() external view returns (uint);
  function buyBackFee() external view returns (uint);
  function buyBackAddress() external view returns (address);
  function treasuryAddress() external view returns (address);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

interface IVaultStrategyReward {
  function totalShares() external view returns (uint256);
  function totalReleased() external view returns (uint256);
  function shares(address account) external view returns (uint256);
  function released(address account) external view returns (uint256);
  function vault(uint256 index) external view returns (address);
  function nova() external view returns (address);
  function sendStrategyReward() external;
  function addPayee(address _vault, uint256 shares_) external;
  function updatePayee(address _vault, uint256 shares_) external;
}

File 32 of 32 : TokenTargetChef.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2021 Novabeam
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract TokenTargetChef is ERC20('Novabeam Yield Optimizer', 'NYL') {

  constructor() {
    _mint(msg.sender, 1e18);
  }
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_sToken","type":"address"},{"internalType":"address","name":"_vGovernance","type":"address"},{"internalType":"address","name":"_routerAddress","type":"address"},{"internalType":"address","name":"_mChef","type":"address"},{"internalType":"uint256","name":"_chefPid","type":"uint256"},{"internalType":"address","name":"_vNova","type":"address"},{"internalType":"address[]","name":"_rewardToBaseRoute","type":"address[]"},{"internalType":"address[]","name":"_baseToNovaRoute","type":"address[]"},{"internalType":"address[]","name":"_rewardToToken0Route","type":"address[]"},{"internalType":"address[]","name":"_rewardToToken1Route","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"depositFee","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"harvested","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"treasuryFeeInNova","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"buyBackInNova","type":"uint256"}],"name":"Harvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardsNova","type":"uint256"}],"name":"RewardsPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawalFee","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balanceNova","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOfNova","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"base","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"baseToNovaRoute","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chef","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chefTarget","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"depositedAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earnedNova","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastHarvest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"novaToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pidTarget","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"principalOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"recoverToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardToBaseRoute","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardToToken0Route","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardToToken1Route","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"routerTarget","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_routerAddressTarget","type":"address"},{"internalType":"address","name":"_mChefTarget","type":"address"},{"internalType":"uint256","name":"_chefPidTarget","type":"uint256"}],"name":"setTarget","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"sharesOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"sharesOfNova","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"token0ToReward","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"token1ToReward","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenTargetChef","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBuyBack","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDepositFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalProfit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSharesNova","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTreasury","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalWithdrawalFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vaultGovernance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"}]

0x60806040523480156200001157600080fd5b50604051620058c8380380620058c8833981016040819052620000349162000db7565b89898989898989898989898989898989898987826000815181106200006957634e487b7160e01b600052603260045260246000fd5b602002602001015188888888888686826001600160a01b03166372f702f36040518163ffffffff1660e01b815260040160206040518083038186803b158015620000b257600080fd5b505afa158015620000c7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000ed919062000d9a565b6000805460ff19169055600180558787878786868686838383836200011b6200011562000834565b62000838565b600480546001600160a01b03199081166001600160a01b03968716179182905560058054821695871695909517909455600680548516938616939093179092556003805484169185169190911790556011805483168b85161790556012805490921689841617918290556013889055620001ae96508216945016915060001990506200088a602090811b6200166417901c565b5050601580546001600160a01b0319166001600160a01b038881169190911791829055600654620001f99750811695501692506000199150506200088a602090811b6200166417901c565b505050505050506040516200020e9062000c49565b604051809103906000f0801580156200022b573d6000803e3d6000fd5b50601b80546001600160a01b0319166001600160a01b039290921691909117905581516200026190601d90602085019062000c57565b5080516200027790601e90602084019062000c57565b50601e6000815481106200029b57634e487b7160e01b600052603260045260246000fd5b6000918252602082200154601c80546001600160a01b0319166001600160a01b03909216919091179055601e8054909190620002e757634e487b7160e01b600052603260045260246000fd5b600091825260209091200154601d80546001600160a01b0390921691620003119060019062001209565b815481106200033057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316146200036e5760405162461bcd60e51b8152600401620003659062000fd9565b60405180910390fd5b505087516200038d965060219550602089019450925062000c57915050565b508051620003a390602290602084019062000c57565b5060005b602154811015620004465760236021600183602180549050620003cb919062001209565b620003d7919062001209565b81548110620003f657634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101548354600181018555938352912090910180546001600160a01b0319166001600160a01b03909216919091179055806200043d8162001256565b915050620003a7565b5060005b602254811015620004e957602460226001836022805490506200046e919062001209565b6200047a919062001209565b815481106200049957634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101548354600181018555938352912090910180546001600160a01b0319166001600160a01b0390921691909117905580620004e08162001256565b9150506200044a565b50896001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b1580156200052457600080fd5b505afa15801562000539573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200055f919062000d9a565b601f60006101000a8154816001600160a01b0302191690836001600160a01b03160217905550896001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015620005bf57600080fd5b505afa158015620005d4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005fa919062000d9a565b602080546001600160a01b0319166001600160a01b03928316179055601f5460218054919092169190620006319060019062001209565b815481106200065057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614620006855760405162461bcd60e51b8152600401620003659062000f96565b602054602280546001600160a01b0390921691620006a69060019062001209565b81548110620006c557634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614620006fa5760405162461bcd60e51b81526004016200036590620011c6565b816000815181106200071c57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316601d6000815481106200075057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614620007855760405162461bcd60e51b815260040162000365906200106c565b80600081518110620007a757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316601d600081548110620007db57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614620008105760405162461bcd60e51b81526004016200036590620010aa565b6200081a62000998565b5050505050505050505050505050505050505050620012a0565b3390565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b801580620009195750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90620008c3903090869060040162000f2e565b60206040518083038186803b158015620008dc57600080fd5b505afa158015620008f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000917919062000ef7565b155b620009385760405162461bcd60e51b8152600401620003659062001169565b620009938363095ea7b360e01b84846040516024016200095a92919062000f48565b60408051808303601f190181529190526020810180516001600160e01b0319939093166001600160e01b039384161790529062000a7b16565b505050565b601154600554620009c5916001600160a01b0391821691166000196200088a602090811b6200166417901c565b601154601f54620009f1916001600160a01b03918216911660006200088a602090811b6200166417901c565b601154601f5462000a1e916001600160a01b0391821691166000196200088a602090811b6200166417901c565b6011546020805462000a4b926001600160a01b0391821692911690600090620016646200088a821b17901c565b6011546020805462000a79926001600160a01b039182169291169060001990620016646200088a821b17901c565b565b600062000ad7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662000b1760201b6200175e179092919060201c565b80519091501562000993578080602001905181019062000af8919062000ed5565b620009935760405162461bcd60e51b815260040162000365906200111f565b606062000b28848460008562000b32565b90505b9392505050565b60608247101562000b575760405162461bcd60e51b8152600401620003659062001026565b62000b628562000c01565b62000b815760405162461bcd60e51b81526004016200036590620010e8565b600080866001600160a01b0316858760405162000b9f919062000f10565b60006040518083038185875af1925050503d806000811462000bde576040519150601f19603f3d011682016040523d82523d6000602084013e62000be3565b606091505b50909250905062000bf682828662000c0b565b979650505050505050565b803b15155b919050565b6060831562000c1c57508162000b2b565b82511562000c2d5782518084602001fd5b8160405162461bcd60e51b815260040162000365919062000f61565b610cb18062004bf783390190565b82805482825590600052602060002090810192821562000caf579160200282015b8281111562000caf57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019062000c78565b5062000cbd92915062000cc1565b5090565b5b8082111562000cbd576000815560010162000cc2565b80516001600160a01b038116811462000c0657600080fd5b600082601f83011262000d01578081fd5b815160206001600160401b038083111562000d205762000d206200128a565b8183026040518382820101818110848211171562000d425762000d426200128a565b6040528481528381019250868401828801850189101562000d61578687fd5b8692505b8583101562000d8e5762000d798162000cd8565b84529284019260019290920191840162000d65565b50979650505050505050565b60006020828403121562000dac578081fd5b62000b2b8262000cd8565b6000806000806000806000806000806101408b8d03121562000dd7578586fd5b62000de28b62000cd8565b995062000df260208c0162000cd8565b985062000e0260408c0162000cd8565b975062000e1260608c0162000cd8565b965060808b0151955062000e2960a08c0162000cd8565b60c08c01519095506001600160401b038082111562000e46578586fd5b62000e548e838f0162000cf0565b955060e08d015191508082111562000e6a578485fd5b62000e788e838f0162000cf0565b94506101008d015191508082111562000e8f578384fd5b62000e9d8e838f0162000cf0565b93506101208d015191508082111562000eb4578283fd5b5062000ec38d828e0162000cf0565b9150509295989b9194979a5092959850565b60006020828403121562000ee7578081fd5b8151801515811462000b2b578182fd5b60006020828403121562000f09578081fd5b5051919050565b6000825162000f2481846020870162001223565b9190910192915050565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b600060208252825180602084015262000f8281604085016020870162001223565b601f01601f19169190910160400192915050565b60208082526023908201527f726577617264546f546f6b656e30526f7574655b6c6173745d20213d20746f6b6040820152620656e360ec1b606082015260800190565b6020808252602d908201527f726577617264546f42617365526f7574655b6c6173745d20213d20626173655460408201526c6f4e6f7661526f7574655b305d60981b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252602f90820152600080516020620058a883398151915260408201526e6f546f6b656e30526f7574655b305d60881b606082015260800190565b6020808252602f90820152600080516020620058a883398151915260408201526e6f546f6b656e31526f7574655b305d60881b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606082015260800190565b60208082526023908201527f726577617264546f546f6b656e31526f7574655b6c6173745d20213d20746f6b604082015262656e3160e81b606082015260800190565b6000828210156200121e576200121e62001274565b500390565b60005b838110156200124057818101518382015260200162001226565b8381111562001250576000848401525b50505050565b60006000198214156200126d576200126d62001274565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b61394780620012b06000396000f3fe608060405234801561001057600080fd5b506004361061030b5760003560e01c806365c6ce281161019d578063c61039f1116100e9578063df3b92aa116100a2578063f2fde38b1161007c578063f2fde38b14610588578063f5eb42dc1461059b578063f887ea40146105ae578063fe255a5e146105b65761030b565b8063df3b92aa14610565578063f106845414610578578063f1a392da146105805761030b565b8063c61039f114610514578063ce91bb9e14610527578063d176e25c1461053a578063d1af0c7d1461054d578063d21220a714610555578063de5f62681461055d5761030b565b80638600151911610156578063916bd71e11610130578063916bd71e146104de578063b29a8140146104e6578063b69ef8a8146104f9578063b6b55f25146105015761030b565b806386001519146104c6578063897534a9146104ce5780638da5cb5b146104d65761030b565b806365c6ce28146104805780636fcfe9001461048857806370a082311461049b578063715018a6146104ae57806372f702f3146104b6578063853828b6146104be5761030b565b80633d18b9121161025c5780635001f3b5116102155780635a94a7a4116101ef5780635a94a7a41461043d5780635acb6da9146104455780635c975abb1461045857806361e20a1c1461046d5761030b565b80635001f3b51461040f5780635312ea8e14610417578063586559d91461042a5761030b565b80633d18b912146103c9578063443d155a146103d15780634641257d146103e45780634665180a146103ec578063467825f7146103ff57806346951239146104075761030b565b80631fc8bc5d116102c957806323ecd50e116102a357806323ecd50e1461039c57806325877eb2146103a45780632e1a7d4d146103ac5780633a98ef39146103c15761030b565b80631fc8bc5d14610379578063208e5acc1461038157806323a904ff146103945761030b565b80628cc262146103105780630dfe168114610339578063104e51421461034e578063163aaff11461035657806316ef4a581461036957806318160ddd14610371575b600080fd5b61032361031e36600461318f565b6105be565b604051610330919061379d565b60405180910390f35b610341610602565b6040516103309190613400565b610341610611565b61032361036436600461318f565b610620565b610323610661565b61032361070c565b610341610712565b61032361038f36600461318f565b610721565b61032361073c565b610323610742565b610341610748565b6103bf6103ba36600461330c565b610757565b005b610323610a88565b6103bf610a8e565b6103416103df36600461330c565b610ccd565b6103bf610cf7565b6103bf6103fa3660046131c7565b610efa565b61032361103c565b610323611042565b610341611048565b6103bf61042536600461330c565b611057565b61034161043836600461330c565b611204565b610341611214565b61032361045336600461318f565b611223565b61046061123e565b60405161033091906134b4565b61032361047b36600461318f565b611247565b610341611262565b61034161049636600461330c565b611271565b6103236104a936600461318f565b611281565b6103bf6112b0565b6103416112fb565b6103bf61130a565b610323611316565b61032361131c565b610341611322565b610323611331565b6103bf6104f4366004613207565b611337565b6103236113fd565b6103bf61050f36600461330c565b61148b565b61034161052236600461330c565b611498565b61032361053536600461318f565b6114a8565b61034161054836600461330c565b6114f0565b610341611500565b61034161150f565b6103bf61151e565b61034161057336600461330c565b6115a1565b6103236115b1565b6103236115b7565b6103bf61059636600461318f565b6115bd565b6103236105a936600461318f565b61162b565b610341611646565b610341611655565b60006105c982611247565b6105d283611281565b106105f9576105f26105e383611247565b6105ec84611281565b90611777565b90506105fd565b5060005b919050565b601f546001600160a01b031681565b6006546001600160a01b031690565b600060145460001415610635575060006105fd565b61065b60145461065561064785611223565b61064f610661565b90611783565b9061178f565b92915050565b6015546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610692903090600401613400565b60206040518083038186803b1580156106aa57600080fd5b505afa1580156106be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e29190613324565b9050610707610700633b9aca0060165461178390919063ffffffff16565b829061179b565b905090565b60075490565b6012546001600160a01b031690565b6001600160a01b03166000908152600a602052604090205490565b601a5490565b600e5481565b601b546001600160a01b031690565b600260015414156107835760405162461bcd60e51b815260040161077a90613710565b60405180910390fd5b6002600155610790610cf7565b336000908152600960205260408120546107ab9083906117a7565b905060006107e06107cb6107bd6113fd565b600754610655908690611783565b336000908152600860205260409020546117a7565b9050600061081c6108076107f2610661565b6014546106559061064f88633b9aca00611783565b336000908152601760205260409020546117a7565b60075490915061082c9083611777565b60075560145461083c9082611777565b601455336000908152600860205260409020546108599083611777565b3360009081526008602090815260408083209390935560179052205461087f9082611777565b336000908152601760209081526040808320939093556009905220546108a59084611777565b336000908152600960205260409020556016546108c29084611777565b6016556108cd6117bd565b6108d68361184a565b600354336000908152600a6020526040808220549051631127bce960e11b815293965090926001600160a01b039092169163224f79d29161091c918891906004016137d6565b60206040518083038186803b15801561093457600080fd5b505afa158015610948573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096c9190613324565b90508015610a23576003546040805163c5f956af60e01b81529051610a05926001600160a01b03169163c5f956af916004808301926020929190829003018186803b1580156109ba57600080fd5b505afa1580156109ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f291906131ab565b6004546001600160a01b03169083611969565b610a0f8482611777565b600f54909450610a1f908261179b565b600f555b600454610a3a906001600160a01b03163386611969565b336001600160a01b03167f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc68583604051610a759291906137d6565b60405180910390a2505060018055505050565b60075481565b60026001541415610ab15760405162461bcd60e51b815260040161077a90613710565b6002600155610abe610cf7565b6000610ac9336105be565b90508015610b9457610ada8161184a565b600454909150610af4906001600160a01b03163383611969565b33600090815260086020526040902054600754610b1091611777565b6007819055610b3757610b2233611247565b33600090815260086020526040902055610b74565b6000610b4d610b4533611247565b6105ec6113fd565b9050610b628161065560075461064f33611247565b33600090815260086020526040902055505b33600090815260086020526040902054600754610b909161179b565b6007555b6000610b9f336114a8565b90508015610c8257610bb081611988565b600654909150610bca906001600160a01b03163383611969565b33600090815260176020526040902054601454610be691611777565b6014819055610c1557610c00633b9aca0061064f33611247565b33600090815260176020526040902055610c62565b6000610c33610c2b633b9aca0061064f33611247565b6105ec610661565b9050610c508161065560145461064f633b9aca0061064f33611247565b33600090815260176020526040902055505b33600090815260176020526040902054601454610c7e9161179b565b6014555b336001600160a01b03167f53195aae24c76f608fd5b9b6ee2da62eb3a6f4e5279d15a8ddfef43199a4b38e8383604051610cbd9291906137d6565b60405180910390a2505060018055565b60228181548110610cdd57600080fd5b6000918252602090912001546001600160a01b0316905081565b610cff611aa6565b600480546040516370a0823160e01b81526000926001600160a01b03909216916370a0823191610d3191309101613400565b60206040518083038186803b158015610d4957600080fd5b505afa158015610d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d819190613324565b9050600080610d8e611cca565b600480546040516370a0823160e01b815293965091945060009350610e1b9287926001600160a01b0316916370a0823191610dcb91309101613400565b60206040518083038186803b158015610de357600080fd5b505afa158015610df7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ec9190613324565b601254601354604051631c57762b60e31b81529293506001600160a01b039091169163e2bbb15891610e519185906004016137d6565b600060405180830381600087803b158015610e6b57600080fd5b505af1158015610e7f573d6000803e3d6000fd5b5050600b54610e91925090508361179b565b600b55600c54610ea1908461179b565b600c55600d54610eb1908261179b565b600d556040517febdd323f18ba49318367d0c92a04d5c51a67f15a60ad50d46523db464661a30290610ee890839086908690613820565b60405180910390a15050426010555050565b610f026125d2565b6001600160a01b0316610f13611322565b6001600160a01b031614610f395760405162461bcd60e51b815260040161077a9061365a565b6018546001600160a01b031615610f625760405162461bcd60e51b815260040161077a906135f9565b601880546001600160a01b038086166001600160a01b0319928316179092556019805485841692169190911790819055601a839055601b54610fab929081169116600019611664565b601954601a54604051631c57762b60e31b81526001600160a01b039092169163e2bbb15891610fe691670de0b6b3a7640000906004016137d6565b600060405180830381600087803b15801561100057600080fd5b505af1158015611014573d6000803e3d6000fd5b5050601854601c5461103793506001600160a01b03908116925016600019611664565b505050565b60145481565b600b5481565b601c546001600160a01b031690565b61105f61123e565b61107b5760405162461bcd60e51b815260040161077a906134f2565b6002600154141561109e5760405162461bcd60e51b815260040161077a90613710565b6002600155336000908152600960205260408120546110be9083906117a7565b905060006110d06107cb6107bd6113fd565b905060006110e26108076107f2610661565b6007549091506110f29083611777565b6007556014546111029082611777565b6014553360009081526008602052604090205461111f9083611777565b336000908152600860209081526040808320939093556017905220546111459082611777565b3360009081526017602090815260408083209390935560099052205461116b9084611777565b336000908152600960205260409020556016546111889084611777565b6016556111936117bd565b61119c8361184a565b6004549093506111b6906001600160a01b03163385611969565b336001600160a01b03167f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc68460006040516111f29291906137d6565b60405180910390a25050600180555050565b60238181548110610cdd57600080fd5b6018546001600160a01b031690565b6001600160a01b031660009081526017602052604090205490565b60005460ff1690565b6001600160a01b031660009081526009602052604090205490565b6019546001600160a01b031690565b601d8181548110610cdd57600080fd5b600060075460001415611296575060006105fd565b61065b6007546106556112a88561162b565b61064f6113fd565b6112b86125d2565b6001600160a01b03166112c9611322565b6001600160a01b0316146112ef5760405162461bcd60e51b815260040161077a9061365a565b6112f960006125d6565b565b6004546001600160a01b031690565b6112f96103ba33611281565b600d5481565b600c5481565b6002546001600160a01b031690565b600f5481565b61133f6125d2565b6001600160a01b0316611350611322565b6001600160a01b0316146113765760405162461bcd60e51b815260040161077a9061365a565b6004546001600160a01b03838116911614156113a45760405162461bcd60e51b815260040161077a90613566565b6113c06113af611322565b6001600160a01b0384169083611969565b7f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa2882826040516113f192919061349b565b60405180910390a15050565b6012546013546040516393f1a40b60e01b81526000926001600160a01b0316916393f1a40b91611432919030906004016137a6565b60806040518083038186803b15801561144a57600080fd5b505afa15801561145e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114829190613369565b50919392505050565b6114958133612628565b50565b60248181548110610cdd57600080fd5b6000806114bc633b9aca0061064f85611247565b905060006114c984610620565b90508181106114e5576114dc8183611777565b925050506105fd565b6000925050506105fd565b601e8181548110610cdd57600080fd5b6005546001600160a01b031690565b6020546001600160a01b031681565b600480546040516370a0823160e01b81526112f9926001600160a01b03909216916370a082319161155191339101613400565b60206040518083038186803b15801561156957600080fd5b505afa15801561157d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050f9190613324565b60218181548110610cdd57600080fd5b60135490565b60105481565b6115c56125d2565b6001600160a01b03166115d6611322565b6001600160a01b0316146115fc5760405162461bcd60e51b815260040161077a9061365a565b6001600160a01b0381166116225760405162461bcd60e51b815260040161077a90613520565b611495816125d6565b6001600160a01b031660009081526008602052604090205490565b6011546001600160a01b031690565b6003546001600160a01b031690565b8015806116ec5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e9061169a9030908690600401613414565b60206040518083038186803b1580156116b257600080fd5b505afa1580156116c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ea9190613324565b155b6117085760405162461bcd60e51b815260040161077a90613747565b6110378363095ea7b360e01b848460405160240161172792919061349b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a49565b606061176d8484600085612ad8565b90505b9392505050565b6000611770828461388d565b6000611770828461386e565b6000611770828461384e565b60006117708284613836565b60008183106117b65781611770565b5090919050565b3360009081526008602090815260408083205460179092529091205481158015906117e957506103e882105b1561180f576007546117fb9083611777565b600755336000908152600860205260408120555b60008111801561182057506103e881105b15611846576014546118329082611777565b601455336000908152601760205260408120555b5050565b600480546040516370a0823160e01b815260009283926001600160a01b0316916370a082319161187c91309101613400565b60206040518083038186803b15801561189457600080fd5b505afa1580156118a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118cc9190613324565b601254601354604051630441a3e760e41b81529293506001600160a01b039091169163441a3e70916119029187906004016137d6565b600060405180830381600087803b15801561191c57600080fd5b505af1158015611930573d6000803e3d6000fd5b5050600480546040516370a0823160e01b815261177094508593506001600160a01b03909116916370a0823191610dcb91309101613400565b6110378363a9059cbb60e01b848460405160240161172792919061349b565b6006546040516370a0823160e01b815260009182916001600160a01b03909116906370a08231906119bd903090600401613400565b60206040518083038186803b1580156119d557600080fd5b505afa1580156119e9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0d9190613324565b601554604051632e1a7d4d60e01b81529192506001600160a01b031690632e1a7d4d90611a3e90869060040161379d565b600060405180830381600087803b158015611a5857600080fd5b505af1158015611a6c573d6000803e3d6000fd5b50506006546040516370a0823160e01b815261177093508492506001600160a01b03909116906370a0823190610dcb903090600401613400565b601254601354604051631c57762b60e31b81526001600160a01b039092169163e2bbb15891611ada916000906004016137d6565b600060405180830381600087803b158015611af457600080fd5b505af1158015611b08573d6000803e3d6000fd5b5050601954601a54604051631c57762b60e31b81526001600160a01b03909216935063e2bbb1589250611b40916000906004016137d6565b600060405180830381600087803b158015611b5a57600080fd5b505af1158015611b6e573d6000803e3d6000fd5b50505050601560009054906101000a90046001600160a01b03166001600160a01b0316633d18b9126040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611bc257600080fd5b505af1158015611bd6573d6000803e3d6000fd5b50506006546040516370a0823160e01b8152600093506001600160a01b0390911691506370a0823190611c0d903090600401613400565b60206040518083038186803b158015611c2557600080fd5b505afa158015611c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5d9190613324565b905080156114955760155460405163b6b55f2560e01b81526001600160a01b039091169063b6b55f2590611c9590849060040161379d565b600060405180830381600087803b158015611caf57600080fd5b505af1158015611cc3573d6000803e3d6000fd5b5050505050565b6005546040516370a0823160e01b81526000918291829182916001600160a01b03909116906370a0823190611d03903090600401613400565b60206040518083038186803b158015611d1b57600080fd5b505afa158015611d2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d539190613324565b60009450849350839250905080156125cc57600354604051634ba71a4b60e01b81526000916001600160a01b031690634ba71a4b90611d9690859060040161379d565b60206040518083038186803b158015611dae57600080fd5b505afa158015611dc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de69190613324565b600354604051633f147d4760e21b81529192506000916001600160a01b039091169063fc51f51c90611e1c90869060040161379d565b60206040518083038186803b158015611e3457600080fd5b505afa158015611e48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6c9190613324565b90506000611e836002610655846105ec8888611777565b600554601f5491925060009182916001600160a01b03918216911614611f785760115460405163d06ca61f60e01b81526001600160a01b039091169063d06ca61f90611ed69086906021906004016137bd565b60006040518083038186803b158015611eee57600080fd5b505afa925050508015611f2357506040513d6000823e601f3d908101601f19168201604052611f209190810190613232565b60015b611f2c57611f73565b6021546000908290611f409060019061388d565b81518110611f5e57634e487b7160e01b600052603260045260246000fd5b60200260200101511115611f7157600192505b505b611f7d565b600191505b6005546020546001600160a01b0390811691161461206a5760115460405163d06ca61f60e01b81526001600160a01b039091169063d06ca61f90611fc89086906022906004016137bd565b60006040518083038186803b158015611fe057600080fd5b505afa92505050801561201557506040513d6000823e601f3d908101601f191682016040526120129190810190613232565b60015b61201e57612065565b60225460009082906120329060019061388d565b8151811061205057634e487b7160e01b600052603260045260246000fd5b6020026020010151111561206357600191505b505b61206e565b5060015b8180156120785750805b156125c657600554601f546001600160a01b03908116911614612129576011546040516338ed173960e01b81526001600160a01b03909116906338ed1739906120cf908690600090602190309042906004016137e4565b600060405180830381600087803b1580156120e957600080fd5b505af192505050801561211e57506040513d6000823e601f3d908101601f1916820160405261211b9190810190613232565b60015b61212757612129565b505b6005546020546001600160a01b039081169116146121d5576011546040516338ed173960e01b81526001600160a01b03909116906338ed17399061217b908690600090602290309042906004016137e4565b600060405180830381600087803b15801561219557600080fd5b505af19250505080156121ca57506040513d6000823e601f3d908101601f191682016040526121c79190810190613232565b60015b6121d3576121d5565b505b601f546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612206903090600401613400565b60206040518083038186803b15801561221e57600080fd5b505afa158015612232573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122569190613324565b6020546040516370a0823160e01b81529192506000916001600160a01b03909116906370a082319061228c903090600401613400565b60206040518083038186803b1580156122a457600080fd5b505afa1580156122b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122dc9190613324565b601154601f5460205460405162e8e33760e81b81529394506001600160a01b039283169363e8e337009361232493811692169087908790600190819030904290600401613452565b606060405180830381600087803b15801561233e57600080fd5b505af192505050801561236e575060408051601f3d908101601f1916820190925261236b9181019061333c565b60015b6123775761238c565b809d50612382612b98565b909e509c50505050505b601f546040516370a0823160e01b81526001600160a01b03909116906370a08231906123bc903090600401613400565b60206040518083038186803b1580156123d457600080fd5b505afa1580156123e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240c9190613324565b6020546040516370a0823160e01b81529193506001600160a01b0316906370a082319061243d903090600401613400565b60206040518083038186803b15801561245557600080fd5b505afa158015612469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248d9190613324565b90508115612529576011546040516338ed173960e01b81526001600160a01b03909116906338ed1739906124cf908590600090602390309042906004016137e4565b600060405180830381600087803b1580156124e957600080fd5b505af192505050801561251e57506040513d6000823e601f3d908101601f1916820160405261251b9190810190613232565b60015b61252757612529565b505b80156125c3576011546040516338ed173960e01b81526001600160a01b03909116906338ed173990612569908490600090602490309042906004016137e4565b600060405180830381600087803b15801561258357600080fd5b505af19250505080156125b857506040513d6000823e601f3d908101601f191682016040526125b59190810190613232565b60015b6125c1576125c3565b505b50505b50505050505b50909192565b3390565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6002600154141561264b5760405162461bcd60e51b815260040161077a90613710565b600260015561265861123e565b156126755760405162461bcd60e51b815260040161077a90613630565b61267d610cf7565b600480546040516370a0823160e01b81526000926001600160a01b03909216916370a08231916126af91309101613400565b60206040518083038186803b1580156126c757600080fd5b505afa1580156126db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ff9190613324565b60045490915061271a906001600160a01b03163330866130f6565b600480546040516370a0823160e01b81526000926001600160a01b03909216916370a082319161274c91309101613400565b60206040518083038186803b15801561276457600080fd5b505afa158015612778573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279c9190613324565b90506127a88183611777565b60035460405163247d284b60e01b81529195506000916001600160a01b039091169063247d284b906127de90889060040161379d565b60206040518083038186803b1580156127f657600080fd5b505afa15801561280a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061282e9190613324565b9050801561289a576003546040805163c5f956af60e01b8152905161287c926001600160a01b03169163c5f956af916004808301926020929190829003018186803b1580156109ba57600080fd5b6128868582611777565b600e54909550612896908261179b565b600e555b6000600754600014156128ae5750846128ca565b6128c76128b96113fd565b600754610655908990611783565b90505b6007546128d7908261179b565b6007556001600160a01b0385166000908152600860205260409020546128fd908261179b565b6001600160a01b03861660009081526008602090815260408083209390935560099052205461292c908761179b565b6001600160a01b038616600090815260096020908152604080832093909355600a90529081204290556014546129715761296a87633b9aca00611783565b9050612994565b61299161297c610661565b6014546106559061064f8b633b9aca00611783565b90505b6001600160a01b0386166000908152601760205260409020546129b7908261179b565b6001600160a01b0387166000908152601760205260409020556014546129dd908261179b565b6014556016546129ed908861179b565b6016556129f98761311d565b856001600160a01b03167f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca8885604051612a349291906137d6565b60405180910390a25050600180555050505050565b6000612a9e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661175e9092919063ffffffff16565b8051909150156110375780806020019051810190612abc91906132ec565b6110375760405162461bcd60e51b815260040161077a906136c6565b606082471015612afa5760405162461bcd60e51b815260040161077a906135b3565b612b0385613150565b612b1f5760405162461bcd60e51b815260040161077a9061368f565b600080866001600160a01b03168587604051612b3b91906133e4565b60006040518083038185875af1925050503d8060008114612b78576040519150601f19603f3d011682016040523d82523d6000602084013e612b7d565b606091505b5091509150612b8d828286613156565b979650505050505050565b600080600080600360009054906101000a90046001600160a01b03166001600160a01b031663783478ad6040518163ffffffff1660e01b815260040160206040518083038186803b158015612bec57600080fd5b505afa158015612c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2491906131ab565b90506000600360009054906101000a90046001600160a01b03166001600160a01b031663c5f956af6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c7657600080fd5b505afa158015612c8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cae91906131ab565b6005546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190612ce4903090600401613400565b60206040518083038186803b158015612cfc57600080fd5b505afa158015612d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d349190613324565b6011546040516338ed173960e01b8152600098508897508796509192506001600160a01b0316906338ed173990612d79908490600190601d90309042906004016137e4565b600060405180830381600087803b158015612d9357600080fd5b505af1925050508015612dc857506040513d6000823e601f3d908101601f19168201604052612dc59190810190613232565b60015b612dd1576130ee565b50601c546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612e03903090600401613400565b60206040518083038186803b158015612e1b57600080fd5b505afa158015612e2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e539190613324565b6018546040516338ed173960e01b81529192506001600160a01b0316906338ed173990612e8e908490600a90601e90309042906004016137e4565b600060405180830381600087803b158015612ea857600080fd5b505af1925050508015612edd57506040513d6000823e601f3d908101601f19168201604052612eda9190810190613232565b60015b612ee6576130ec565b506006546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612f18903090600401613400565b60206040518083038186803b158015612f3057600080fd5b505afa158015612f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f689190613324565b600354604051634952f3c960e11b81529192506001600160a01b0316906392a5e79290612f9c9084906001906004016137d6565b60206040518083038186803b158015612fb457600080fd5b505afa158015612fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fec9190613324565b600354604051634952f3c960e11b81529198506001600160a01b0316906392a5e792906130209084906002906004016137d6565b60206040518083038186803b15801561303857600080fd5b505afa15801561304c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130709190613324565b60065490965061308a906001600160a01b03168589611969565b6006546130a1906001600160a01b03168688611969565b846001600160a01b0316633f556e8e6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156130dc57600080fd5b505af19250505080156125c65750505b505b505050909192565b613117846323b872dd60e01b8585856040516024016117279392919061342e565b50505050565b601254601354604051631c57762b60e31b81526001600160a01b039092169163e2bbb15891611c959185906004016137d6565b3b151590565b60608315613165575081611770565b8251156131755782518084602001fd5b8160405162461bcd60e51b815260040161077a91906134bf565b6000602082840312156131a0578081fd5b8135611770816138fc565b6000602082840312156131bc578081fd5b8151611770816138fc565b6000806000606084860312156131db578182fd5b83356131e6816138fc565b925060208401356131f6816138fc565b929592945050506040919091013590565b60008060408385031215613219578182fd5b8235613224816138fc565b946020939093013593505050565b60006020808385031215613244578182fd5b825167ffffffffffffffff8082111561325b578384fd5b818501915085601f83011261326e578384fd5b815181811115613280576132806138e6565b8381026040518582820101818110858211171561329f5761329f6138e6565b604052828152858101935084860182860187018a10156132bd578788fd5b8795505b838610156132df5780518552600195909501949386019386016132c1565b5098975050505050505050565b6000602082840312156132fd578081fd5b81518015158114611770578182fd5b60006020828403121561331d578081fd5b5035919050565b600060208284031215613335578081fd5b5051919050565b600080600060608486031215613350578283fd5b8351925060208401519150604084015190509250925092565b6000806000806080858703121561337e578081fd5b505082516020840151604085015160609095015191969095509092509050565b6000815480845260208085019450838352808320835b838110156133d95781546001600160a01b0316875295820195600191820191016133b4565b509495945050505050565b600082516133f68184602087016138a4565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039889168152968816602088015260408701959095526060860193909352608085019190915260a084015290921660c082015260e08101919091526101000190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b60006020825282518060208401526134de8160408501602087016138a4565b601f01601f19169190910160400192915050565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252602d908201527f5661756c74436f6e74726f6c6c65723a2063616e6e6f74207265636f7665722060408201526c39ba30b5b4b733903a37b5b2b760991b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601d908201527f5461726765742063616e206f6e6c79206265206164646564206f6e6365000000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b90815260200190565b9182526001600160a01b0316602082015260400190565b60008382526040602083015261176d604083018461339e565b918252602082015260400190565b600086825285602083015260a0604083015261380360a083018661339e565b6001600160a01b0394909416606083015250608001529392505050565b9283526020830191909152604082015260600190565b60008219821115613849576138496138d0565b500190565b60008261386957634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613888576138886138d0565b500290565b60008282101561389f5761389f6138d0565b500390565b60005b838110156138bf5781810151838201526020016138a7565b838111156131175750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461149557600080fdfea26469706673582212204515dc8cda6c4c16eaf86bc919d1c73a928e1570fd47f2bb163c193ad0a278cb64736f6c6343000800003360806040523480156200001157600080fd5b506040518060400160405280601881526020017f4e6f76616265616d205969656c64204f7074696d697a657200000000000000008152506040518060400160405280600381526020016213965360ea1b81525081600390805190602001906200007c9291906200019c565b508051620000929060049060208401906200019c565b505050620000af33670de0b6b3a7640000620000b560201b60201c565b620002e4565b6001600160a01b038216620000e75760405162461bcd60e51b8152600401620000de9062000242565b60405180910390fd5b620000f56000838362000197565b806002600082825462000109919062000282565b90915550506001600160a01b038216600090815260208190526040812080548392906200013890849062000282565b90915550506040516001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906200017d90859062000279565b60405180910390a3620001936000838362000197565b5050565b505050565b828054620001aa90620002a7565b90600052602060002090601f016020900481019282620001ce576000855562000219565b82601f10620001e957805160ff191683800117855562000219565b8280016001018555821562000219579182015b8281111562000219578251825591602001919060010190620001fc565b50620002279291506200022b565b5090565b5b808211156200022757600081556001016200022c565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b60008219821115620002a257634e487b7160e01b81526011600452602481fd5b500190565b600281046001821680620002bc57607f821691505b60208210811415620002de57634e487b7160e01b600052602260045260246000fd5b50919050565b6109bd80620002f46000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461012957806370a082311461013c57806395d89b411461014f578063a457c2d714610157578063a9059cbb1461016a578063dd62ed3e1461017d576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ec57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b6610190565b6040516100c391906106dd565b60405180910390f35b6100df6100da3660046106a9565b610222565b6040516100c391906106d2565b6100f461023f565b6040516100c39190610911565b6100df61010f36600461066e565b610245565b61011c6102de565b6040516100c3919061091a565b6100df6101373660046106a9565b6102e3565b6100f461014a36600461061b565b610337565b6100b6610356565b6100df6101653660046106a9565b610365565b6100df6101783660046106a9565b6103de565b6100f461018b36600461063c565b6103f2565b60606003805461019f9061094c565b80601f01602080910402602001604051908101604052809291908181526020018280546101cb9061094c565b80156102185780601f106101ed57610100808354040283529160200191610218565b820191906000526020600020905b8154815290600101906020018083116101fb57829003601f168201915b5050505050905090565b600061023661022f61041d565b8484610421565b50600192915050565b60025490565b60006102528484846104d5565b6001600160a01b03841660009081526001602052604081208161027361041d565b6001600160a01b03166001600160a01b03168152602001908152602001600020549050828110156102bf5760405162461bcd60e51b81526004016102b6906107fb565b60405180910390fd5b6102d3856102cb61041d565b858403610421565b506001949350505050565b601290565b60006102366102f061041d565b8484600160006102fe61041d565b6001600160a01b03908116825260208083019390935260409182016000908120918b16815292529020546103329190610928565b610421565b6001600160a01b0381166000908152602081905260409020545b919050565b60606004805461019f9061094c565b6000806001600061037461041d565b6001600160a01b03908116825260208083019390935260409182016000908120918816815292529020549050828110156103c05760405162461bcd60e51b81526004016102b6906108cc565b6103d46103cb61041d565b85858403610421565b5060019392505050565b60006102366103eb61041d565b84846104d5565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3390565b6001600160a01b0383166104475760405162461bcd60e51b81526004016102b690610888565b6001600160a01b03821661046d5760405162461bcd60e51b81526004016102b690610773565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906104c8908590610911565b60405180910390a3505050565b6001600160a01b0383166104fb5760405162461bcd60e51b81526004016102b690610843565b6001600160a01b0382166105215760405162461bcd60e51b81526004016102b690610730565b61052c8383836105ff565b6001600160a01b038316600090815260208190526040902054818110156105655760405162461bcd60e51b81526004016102b6906107b5565b6001600160a01b0380851660009081526020819052604080822085850390559185168152908120805484929061059c908490610928565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516105e69190610911565b60405180910390a36105f98484846105ff565b50505050565b505050565b80356001600160a01b038116811461035157600080fd5b60006020828403121561062c578081fd5b61063582610604565b9392505050565b6000806040838503121561064e578081fd5b61065783610604565b915061066560208401610604565b90509250929050565b600080600060608486031215610682578081fd5b61068b84610604565b925061069960208501610604565b9150604084013590509250925092565b600080604083850312156106bb578182fd5b6106c483610604565b946020939093013593505050565b901515815260200190565b6000602080835283518082850152825b81811015610709578581018301518582016040015282016106ed565b8181111561071a5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b60208082526028908201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616040820152676c6c6f77616e636560c01b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b90815260200190565b60ff91909116815260200190565b6000821982111561094757634e487b7160e01b81526011600452602481fd5b500190565b60028104600182168061096057607f821691505b6020821081141561098157634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220926088d6ff0f040dd2f241e655b08578c64272bbd6b9c800564bc561bdfc6bbc64736f6c63430008000033726577617264546f42617365526f7574655b305d20213d205f72657761726454000000000000000000000000fe04b2afba88a2f14c01d1d3c69d4ac095ebb48400000000000000000000000084475eb948c9cf592f1b58ff8fc98c19a4950b17000000000000000000000000d3b02ff30c218c7f7756ba14bca075bf7c2c951e000000000000000000000000995da7dfb96b4dd1e2bd954be384a1e66cbb4b8c0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000c8d13527f8900b7e26bdcfd246ff48993ac256ae000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000e3e43888fa7803cdc7bea478ab327cf1a0dc11a7000000000000000000000000acc15dc74880c9944775448304b263d191c6077f0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000acc15dc74880c9944775448304b263d191c6077f000000000000000000000000ab02ee00148da789d8b48378bb2847cc58ca7e5e0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000e3e43888fa7803cdc7bea478ab327cf1a0dc11a7000000000000000000000000acc15dc74880c9944775448304b263d191c6077f0000000000000000000000008f552a71efe5eefc207bf75485b356a0b3f01ec90000000000000000000000008e70cd5b4ff3f62659049e74b6649c6603a0e5940000000000000000000000000000000000000000000000000000000000000003000000000000000000000000e3e43888fa7803cdc7bea478ab327cf1a0dc11a7000000000000000000000000acc15dc74880c9944775448304b263d191c6077f0000000000000000000000008f552a71efe5eefc207bf75485b356a0b3f01ec9

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061030b5760003560e01c806365c6ce281161019d578063c61039f1116100e9578063df3b92aa116100a2578063f2fde38b1161007c578063f2fde38b14610588578063f5eb42dc1461059b578063f887ea40146105ae578063fe255a5e146105b65761030b565b8063df3b92aa14610565578063f106845414610578578063f1a392da146105805761030b565b8063c61039f114610514578063ce91bb9e14610527578063d176e25c1461053a578063d1af0c7d1461054d578063d21220a714610555578063de5f62681461055d5761030b565b80638600151911610156578063916bd71e11610130578063916bd71e146104de578063b29a8140146104e6578063b69ef8a8146104f9578063b6b55f25146105015761030b565b806386001519146104c6578063897534a9146104ce5780638da5cb5b146104d65761030b565b806365c6ce28146104805780636fcfe9001461048857806370a082311461049b578063715018a6146104ae57806372f702f3146104b6578063853828b6146104be5761030b565b80633d18b9121161025c5780635001f3b5116102155780635a94a7a4116101ef5780635a94a7a41461043d5780635acb6da9146104455780635c975abb1461045857806361e20a1c1461046d5761030b565b80635001f3b51461040f5780635312ea8e14610417578063586559d91461042a5761030b565b80633d18b912146103c9578063443d155a146103d15780634641257d146103e45780634665180a146103ec578063467825f7146103ff57806346951239146104075761030b565b80631fc8bc5d116102c957806323ecd50e116102a357806323ecd50e1461039c57806325877eb2146103a45780632e1a7d4d146103ac5780633a98ef39146103c15761030b565b80631fc8bc5d14610379578063208e5acc1461038157806323a904ff146103945761030b565b80628cc262146103105780630dfe168114610339578063104e51421461034e578063163aaff11461035657806316ef4a581461036957806318160ddd14610371575b600080fd5b61032361031e36600461318f565b6105be565b604051610330919061379d565b60405180910390f35b610341610602565b6040516103309190613400565b610341610611565b61032361036436600461318f565b610620565b610323610661565b61032361070c565b610341610712565b61032361038f36600461318f565b610721565b61032361073c565b610323610742565b610341610748565b6103bf6103ba36600461330c565b610757565b005b610323610a88565b6103bf610a8e565b6103416103df36600461330c565b610ccd565b6103bf610cf7565b6103bf6103fa3660046131c7565b610efa565b61032361103c565b610323611042565b610341611048565b6103bf61042536600461330c565b611057565b61034161043836600461330c565b611204565b610341611214565b61032361045336600461318f565b611223565b61046061123e565b60405161033091906134b4565b61032361047b36600461318f565b611247565b610341611262565b61034161049636600461330c565b611271565b6103236104a936600461318f565b611281565b6103bf6112b0565b6103416112fb565b6103bf61130a565b610323611316565b61032361131c565b610341611322565b610323611331565b6103bf6104f4366004613207565b611337565b6103236113fd565b6103bf61050f36600461330c565b61148b565b61034161052236600461330c565b611498565b61032361053536600461318f565b6114a8565b61034161054836600461330c565b6114f0565b610341611500565b61034161150f565b6103bf61151e565b61034161057336600461330c565b6115a1565b6103236115b1565b6103236115b7565b6103bf61059636600461318f565b6115bd565b6103236105a936600461318f565b61162b565b610341611646565b610341611655565b60006105c982611247565b6105d283611281565b106105f9576105f26105e383611247565b6105ec84611281565b90611777565b90506105fd565b5060005b919050565b601f546001600160a01b031681565b6006546001600160a01b031690565b600060145460001415610635575060006105fd565b61065b60145461065561064785611223565b61064f610661565b90611783565b9061178f565b92915050565b6015546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610692903090600401613400565b60206040518083038186803b1580156106aa57600080fd5b505afa1580156106be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e29190613324565b9050610707610700633b9aca0060165461178390919063ffffffff16565b829061179b565b905090565b60075490565b6012546001600160a01b031690565b6001600160a01b03166000908152600a602052604090205490565b601a5490565b600e5481565b601b546001600160a01b031690565b600260015414156107835760405162461bcd60e51b815260040161077a90613710565b60405180910390fd5b6002600155610790610cf7565b336000908152600960205260408120546107ab9083906117a7565b905060006107e06107cb6107bd6113fd565b600754610655908690611783565b336000908152600860205260409020546117a7565b9050600061081c6108076107f2610661565b6014546106559061064f88633b9aca00611783565b336000908152601760205260409020546117a7565b60075490915061082c9083611777565b60075560145461083c9082611777565b601455336000908152600860205260409020546108599083611777565b3360009081526008602090815260408083209390935560179052205461087f9082611777565b336000908152601760209081526040808320939093556009905220546108a59084611777565b336000908152600960205260409020556016546108c29084611777565b6016556108cd6117bd565b6108d68361184a565b600354336000908152600a6020526040808220549051631127bce960e11b815293965090926001600160a01b039092169163224f79d29161091c918891906004016137d6565b60206040518083038186803b15801561093457600080fd5b505afa158015610948573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096c9190613324565b90508015610a23576003546040805163c5f956af60e01b81529051610a05926001600160a01b03169163c5f956af916004808301926020929190829003018186803b1580156109ba57600080fd5b505afa1580156109ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f291906131ab565b6004546001600160a01b03169083611969565b610a0f8482611777565b600f54909450610a1f908261179b565b600f555b600454610a3a906001600160a01b03163386611969565b336001600160a01b03167f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc68583604051610a759291906137d6565b60405180910390a2505060018055505050565b60075481565b60026001541415610ab15760405162461bcd60e51b815260040161077a90613710565b6002600155610abe610cf7565b6000610ac9336105be565b90508015610b9457610ada8161184a565b600454909150610af4906001600160a01b03163383611969565b33600090815260086020526040902054600754610b1091611777565b6007819055610b3757610b2233611247565b33600090815260086020526040902055610b74565b6000610b4d610b4533611247565b6105ec6113fd565b9050610b628161065560075461064f33611247565b33600090815260086020526040902055505b33600090815260086020526040902054600754610b909161179b565b6007555b6000610b9f336114a8565b90508015610c8257610bb081611988565b600654909150610bca906001600160a01b03163383611969565b33600090815260176020526040902054601454610be691611777565b6014819055610c1557610c00633b9aca0061064f33611247565b33600090815260176020526040902055610c62565b6000610c33610c2b633b9aca0061064f33611247565b6105ec610661565b9050610c508161065560145461064f633b9aca0061064f33611247565b33600090815260176020526040902055505b33600090815260176020526040902054601454610c7e9161179b565b6014555b336001600160a01b03167f53195aae24c76f608fd5b9b6ee2da62eb3a6f4e5279d15a8ddfef43199a4b38e8383604051610cbd9291906137d6565b60405180910390a2505060018055565b60228181548110610cdd57600080fd5b6000918252602090912001546001600160a01b0316905081565b610cff611aa6565b600480546040516370a0823160e01b81526000926001600160a01b03909216916370a0823191610d3191309101613400565b60206040518083038186803b158015610d4957600080fd5b505afa158015610d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d819190613324565b9050600080610d8e611cca565b600480546040516370a0823160e01b815293965091945060009350610e1b9287926001600160a01b0316916370a0823191610dcb91309101613400565b60206040518083038186803b158015610de357600080fd5b505afa158015610df7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ec9190613324565b601254601354604051631c57762b60e31b81529293506001600160a01b039091169163e2bbb15891610e519185906004016137d6565b600060405180830381600087803b158015610e6b57600080fd5b505af1158015610e7f573d6000803e3d6000fd5b5050600b54610e91925090508361179b565b600b55600c54610ea1908461179b565b600c55600d54610eb1908261179b565b600d556040517febdd323f18ba49318367d0c92a04d5c51a67f15a60ad50d46523db464661a30290610ee890839086908690613820565b60405180910390a15050426010555050565b610f026125d2565b6001600160a01b0316610f13611322565b6001600160a01b031614610f395760405162461bcd60e51b815260040161077a9061365a565b6018546001600160a01b031615610f625760405162461bcd60e51b815260040161077a906135f9565b601880546001600160a01b038086166001600160a01b0319928316179092556019805485841692169190911790819055601a839055601b54610fab929081169116600019611664565b601954601a54604051631c57762b60e31b81526001600160a01b039092169163e2bbb15891610fe691670de0b6b3a7640000906004016137d6565b600060405180830381600087803b15801561100057600080fd5b505af1158015611014573d6000803e3d6000fd5b5050601854601c5461103793506001600160a01b03908116925016600019611664565b505050565b60145481565b600b5481565b601c546001600160a01b031690565b61105f61123e565b61107b5760405162461bcd60e51b815260040161077a906134f2565b6002600154141561109e5760405162461bcd60e51b815260040161077a90613710565b6002600155336000908152600960205260408120546110be9083906117a7565b905060006110d06107cb6107bd6113fd565b905060006110e26108076107f2610661565b6007549091506110f29083611777565b6007556014546111029082611777565b6014553360009081526008602052604090205461111f9083611777565b336000908152600860209081526040808320939093556017905220546111459082611777565b3360009081526017602090815260408083209390935560099052205461116b9084611777565b336000908152600960205260409020556016546111889084611777565b6016556111936117bd565b61119c8361184a565b6004549093506111b6906001600160a01b03163385611969565b336001600160a01b03167f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc68460006040516111f29291906137d6565b60405180910390a25050600180555050565b60238181548110610cdd57600080fd5b6018546001600160a01b031690565b6001600160a01b031660009081526017602052604090205490565b60005460ff1690565b6001600160a01b031660009081526009602052604090205490565b6019546001600160a01b031690565b601d8181548110610cdd57600080fd5b600060075460001415611296575060006105fd565b61065b6007546106556112a88561162b565b61064f6113fd565b6112b86125d2565b6001600160a01b03166112c9611322565b6001600160a01b0316146112ef5760405162461bcd60e51b815260040161077a9061365a565b6112f960006125d6565b565b6004546001600160a01b031690565b6112f96103ba33611281565b600d5481565b600c5481565b6002546001600160a01b031690565b600f5481565b61133f6125d2565b6001600160a01b0316611350611322565b6001600160a01b0316146113765760405162461bcd60e51b815260040161077a9061365a565b6004546001600160a01b03838116911614156113a45760405162461bcd60e51b815260040161077a90613566565b6113c06113af611322565b6001600160a01b0384169083611969565b7f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa2882826040516113f192919061349b565b60405180910390a15050565b6012546013546040516393f1a40b60e01b81526000926001600160a01b0316916393f1a40b91611432919030906004016137a6565b60806040518083038186803b15801561144a57600080fd5b505afa15801561145e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114829190613369565b50919392505050565b6114958133612628565b50565b60248181548110610cdd57600080fd5b6000806114bc633b9aca0061064f85611247565b905060006114c984610620565b90508181106114e5576114dc8183611777565b925050506105fd565b6000925050506105fd565b601e8181548110610cdd57600080fd5b6005546001600160a01b031690565b6020546001600160a01b031681565b600480546040516370a0823160e01b81526112f9926001600160a01b03909216916370a082319161155191339101613400565b60206040518083038186803b15801561156957600080fd5b505afa15801561157d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050f9190613324565b60218181548110610cdd57600080fd5b60135490565b60105481565b6115c56125d2565b6001600160a01b03166115d6611322565b6001600160a01b0316146115fc5760405162461bcd60e51b815260040161077a9061365a565b6001600160a01b0381166116225760405162461bcd60e51b815260040161077a90613520565b611495816125d6565b6001600160a01b031660009081526008602052604090205490565b6011546001600160a01b031690565b6003546001600160a01b031690565b8015806116ec5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e9061169a9030908690600401613414565b60206040518083038186803b1580156116b257600080fd5b505afa1580156116c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ea9190613324565b155b6117085760405162461bcd60e51b815260040161077a90613747565b6110378363095ea7b360e01b848460405160240161172792919061349b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a49565b606061176d8484600085612ad8565b90505b9392505050565b6000611770828461388d565b6000611770828461386e565b6000611770828461384e565b60006117708284613836565b60008183106117b65781611770565b5090919050565b3360009081526008602090815260408083205460179092529091205481158015906117e957506103e882105b1561180f576007546117fb9083611777565b600755336000908152600860205260408120555b60008111801561182057506103e881105b15611846576014546118329082611777565b601455336000908152601760205260408120555b5050565b600480546040516370a0823160e01b815260009283926001600160a01b0316916370a082319161187c91309101613400565b60206040518083038186803b15801561189457600080fd5b505afa1580156118a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118cc9190613324565b601254601354604051630441a3e760e41b81529293506001600160a01b039091169163441a3e70916119029187906004016137d6565b600060405180830381600087803b15801561191c57600080fd5b505af1158015611930573d6000803e3d6000fd5b5050600480546040516370a0823160e01b815261177094508593506001600160a01b03909116916370a0823191610dcb91309101613400565b6110378363a9059cbb60e01b848460405160240161172792919061349b565b6006546040516370a0823160e01b815260009182916001600160a01b03909116906370a08231906119bd903090600401613400565b60206040518083038186803b1580156119d557600080fd5b505afa1580156119e9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0d9190613324565b601554604051632e1a7d4d60e01b81529192506001600160a01b031690632e1a7d4d90611a3e90869060040161379d565b600060405180830381600087803b158015611a5857600080fd5b505af1158015611a6c573d6000803e3d6000fd5b50506006546040516370a0823160e01b815261177093508492506001600160a01b03909116906370a0823190610dcb903090600401613400565b601254601354604051631c57762b60e31b81526001600160a01b039092169163e2bbb15891611ada916000906004016137d6565b600060405180830381600087803b158015611af457600080fd5b505af1158015611b08573d6000803e3d6000fd5b5050601954601a54604051631c57762b60e31b81526001600160a01b03909216935063e2bbb1589250611b40916000906004016137d6565b600060405180830381600087803b158015611b5a57600080fd5b505af1158015611b6e573d6000803e3d6000fd5b50505050601560009054906101000a90046001600160a01b03166001600160a01b0316633d18b9126040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611bc257600080fd5b505af1158015611bd6573d6000803e3d6000fd5b50506006546040516370a0823160e01b8152600093506001600160a01b0390911691506370a0823190611c0d903090600401613400565b60206040518083038186803b158015611c2557600080fd5b505afa158015611c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5d9190613324565b905080156114955760155460405163b6b55f2560e01b81526001600160a01b039091169063b6b55f2590611c9590849060040161379d565b600060405180830381600087803b158015611caf57600080fd5b505af1158015611cc3573d6000803e3d6000fd5b5050505050565b6005546040516370a0823160e01b81526000918291829182916001600160a01b03909116906370a0823190611d03903090600401613400565b60206040518083038186803b158015611d1b57600080fd5b505afa158015611d2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d539190613324565b60009450849350839250905080156125cc57600354604051634ba71a4b60e01b81526000916001600160a01b031690634ba71a4b90611d9690859060040161379d565b60206040518083038186803b158015611dae57600080fd5b505afa158015611dc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de69190613324565b600354604051633f147d4760e21b81529192506000916001600160a01b039091169063fc51f51c90611e1c90869060040161379d565b60206040518083038186803b158015611e3457600080fd5b505afa158015611e48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6c9190613324565b90506000611e836002610655846105ec8888611777565b600554601f5491925060009182916001600160a01b03918216911614611f785760115460405163d06ca61f60e01b81526001600160a01b039091169063d06ca61f90611ed69086906021906004016137bd565b60006040518083038186803b158015611eee57600080fd5b505afa925050508015611f2357506040513d6000823e601f3d908101601f19168201604052611f209190810190613232565b60015b611f2c57611f73565b6021546000908290611f409060019061388d565b81518110611f5e57634e487b7160e01b600052603260045260246000fd5b60200260200101511115611f7157600192505b505b611f7d565b600191505b6005546020546001600160a01b0390811691161461206a5760115460405163d06ca61f60e01b81526001600160a01b039091169063d06ca61f90611fc89086906022906004016137bd565b60006040518083038186803b158015611fe057600080fd5b505afa92505050801561201557506040513d6000823e601f3d908101601f191682016040526120129190810190613232565b60015b61201e57612065565b60225460009082906120329060019061388d565b8151811061205057634e487b7160e01b600052603260045260246000fd5b6020026020010151111561206357600191505b505b61206e565b5060015b8180156120785750805b156125c657600554601f546001600160a01b03908116911614612129576011546040516338ed173960e01b81526001600160a01b03909116906338ed1739906120cf908690600090602190309042906004016137e4565b600060405180830381600087803b1580156120e957600080fd5b505af192505050801561211e57506040513d6000823e601f3d908101601f1916820160405261211b9190810190613232565b60015b61212757612129565b505b6005546020546001600160a01b039081169116146121d5576011546040516338ed173960e01b81526001600160a01b03909116906338ed17399061217b908690600090602290309042906004016137e4565b600060405180830381600087803b15801561219557600080fd5b505af19250505080156121ca57506040513d6000823e601f3d908101601f191682016040526121c79190810190613232565b60015b6121d3576121d5565b505b601f546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612206903090600401613400565b60206040518083038186803b15801561221e57600080fd5b505afa158015612232573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122569190613324565b6020546040516370a0823160e01b81529192506000916001600160a01b03909116906370a082319061228c903090600401613400565b60206040518083038186803b1580156122a457600080fd5b505afa1580156122b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122dc9190613324565b601154601f5460205460405162e8e33760e81b81529394506001600160a01b039283169363e8e337009361232493811692169087908790600190819030904290600401613452565b606060405180830381600087803b15801561233e57600080fd5b505af192505050801561236e575060408051601f3d908101601f1916820190925261236b9181019061333c565b60015b6123775761238c565b809d50612382612b98565b909e509c50505050505b601f546040516370a0823160e01b81526001600160a01b03909116906370a08231906123bc903090600401613400565b60206040518083038186803b1580156123d457600080fd5b505afa1580156123e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240c9190613324565b6020546040516370a0823160e01b81529193506001600160a01b0316906370a082319061243d903090600401613400565b60206040518083038186803b15801561245557600080fd5b505afa158015612469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248d9190613324565b90508115612529576011546040516338ed173960e01b81526001600160a01b03909116906338ed1739906124cf908590600090602390309042906004016137e4565b600060405180830381600087803b1580156124e957600080fd5b505af192505050801561251e57506040513d6000823e601f3d908101601f1916820160405261251b9190810190613232565b60015b61252757612529565b505b80156125c3576011546040516338ed173960e01b81526001600160a01b03909116906338ed173990612569908490600090602490309042906004016137e4565b600060405180830381600087803b15801561258357600080fd5b505af19250505080156125b857506040513d6000823e601f3d908101601f191682016040526125b59190810190613232565b60015b6125c1576125c3565b505b50505b50505050505b50909192565b3390565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6002600154141561264b5760405162461bcd60e51b815260040161077a90613710565b600260015561265861123e565b156126755760405162461bcd60e51b815260040161077a90613630565b61267d610cf7565b600480546040516370a0823160e01b81526000926001600160a01b03909216916370a08231916126af91309101613400565b60206040518083038186803b1580156126c757600080fd5b505afa1580156126db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ff9190613324565b60045490915061271a906001600160a01b03163330866130f6565b600480546040516370a0823160e01b81526000926001600160a01b03909216916370a082319161274c91309101613400565b60206040518083038186803b15801561276457600080fd5b505afa158015612778573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279c9190613324565b90506127a88183611777565b60035460405163247d284b60e01b81529195506000916001600160a01b039091169063247d284b906127de90889060040161379d565b60206040518083038186803b1580156127f657600080fd5b505afa15801561280a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061282e9190613324565b9050801561289a576003546040805163c5f956af60e01b8152905161287c926001600160a01b03169163c5f956af916004808301926020929190829003018186803b1580156109ba57600080fd5b6128868582611777565b600e54909550612896908261179b565b600e555b6000600754600014156128ae5750846128ca565b6128c76128b96113fd565b600754610655908990611783565b90505b6007546128d7908261179b565b6007556001600160a01b0385166000908152600860205260409020546128fd908261179b565b6001600160a01b03861660009081526008602090815260408083209390935560099052205461292c908761179b565b6001600160a01b038616600090815260096020908152604080832093909355600a90529081204290556014546129715761296a87633b9aca00611783565b9050612994565b61299161297c610661565b6014546106559061064f8b633b9aca00611783565b90505b6001600160a01b0386166000908152601760205260409020546129b7908261179b565b6001600160a01b0387166000908152601760205260409020556014546129dd908261179b565b6014556016546129ed908861179b565b6016556129f98761311d565b856001600160a01b03167f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca8885604051612a349291906137d6565b60405180910390a25050600180555050505050565b6000612a9e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661175e9092919063ffffffff16565b8051909150156110375780806020019051810190612abc91906132ec565b6110375760405162461bcd60e51b815260040161077a906136c6565b606082471015612afa5760405162461bcd60e51b815260040161077a906135b3565b612b0385613150565b612b1f5760405162461bcd60e51b815260040161077a9061368f565b600080866001600160a01b03168587604051612b3b91906133e4565b60006040518083038185875af1925050503d8060008114612b78576040519150601f19603f3d011682016040523d82523d6000602084013e612b7d565b606091505b5091509150612b8d828286613156565b979650505050505050565b600080600080600360009054906101000a90046001600160a01b03166001600160a01b031663783478ad6040518163ffffffff1660e01b815260040160206040518083038186803b158015612bec57600080fd5b505afa158015612c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2491906131ab565b90506000600360009054906101000a90046001600160a01b03166001600160a01b031663c5f956af6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c7657600080fd5b505afa158015612c8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cae91906131ab565b6005546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190612ce4903090600401613400565b60206040518083038186803b158015612cfc57600080fd5b505afa158015612d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d349190613324565b6011546040516338ed173960e01b8152600098508897508796509192506001600160a01b0316906338ed173990612d79908490600190601d90309042906004016137e4565b600060405180830381600087803b158015612d9357600080fd5b505af1925050508015612dc857506040513d6000823e601f3d908101601f19168201604052612dc59190810190613232565b60015b612dd1576130ee565b50601c546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612e03903090600401613400565b60206040518083038186803b158015612e1b57600080fd5b505afa158015612e2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e539190613324565b6018546040516338ed173960e01b81529192506001600160a01b0316906338ed173990612e8e908490600a90601e90309042906004016137e4565b600060405180830381600087803b158015612ea857600080fd5b505af1925050508015612edd57506040513d6000823e601f3d908101601f19168201604052612eda9190810190613232565b60015b612ee6576130ec565b506006546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612f18903090600401613400565b60206040518083038186803b158015612f3057600080fd5b505afa158015612f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f689190613324565b600354604051634952f3c960e11b81529192506001600160a01b0316906392a5e79290612f9c9084906001906004016137d6565b60206040518083038186803b158015612fb457600080fd5b505afa158015612fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fec9190613324565b600354604051634952f3c960e11b81529198506001600160a01b0316906392a5e792906130209084906002906004016137d6565b60206040518083038186803b15801561303857600080fd5b505afa15801561304c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130709190613324565b60065490965061308a906001600160a01b03168589611969565b6006546130a1906001600160a01b03168688611969565b846001600160a01b0316633f556e8e6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156130dc57600080fd5b505af19250505080156125c65750505b505b505050909192565b613117846323b872dd60e01b8585856040516024016117279392919061342e565b50505050565b601254601354604051631c57762b60e31b81526001600160a01b039092169163e2bbb15891611c959185906004016137d6565b3b151590565b60608315613165575081611770565b8251156131755782518084602001fd5b8160405162461bcd60e51b815260040161077a91906134bf565b6000602082840312156131a0578081fd5b8135611770816138fc565b6000602082840312156131bc578081fd5b8151611770816138fc565b6000806000606084860312156131db578182fd5b83356131e6816138fc565b925060208401356131f6816138fc565b929592945050506040919091013590565b60008060408385031215613219578182fd5b8235613224816138fc565b946020939093013593505050565b60006020808385031215613244578182fd5b825167ffffffffffffffff8082111561325b578384fd5b818501915085601f83011261326e578384fd5b815181811115613280576132806138e6565b8381026040518582820101818110858211171561329f5761329f6138e6565b604052828152858101935084860182860187018a10156132bd578788fd5b8795505b838610156132df5780518552600195909501949386019386016132c1565b5098975050505050505050565b6000602082840312156132fd578081fd5b81518015158114611770578182fd5b60006020828403121561331d578081fd5b5035919050565b600060208284031215613335578081fd5b5051919050565b600080600060608486031215613350578283fd5b8351925060208401519150604084015190509250925092565b6000806000806080858703121561337e578081fd5b505082516020840151604085015160609095015191969095509092509050565b6000815480845260208085019450838352808320835b838110156133d95781546001600160a01b0316875295820195600191820191016133b4565b509495945050505050565b600082516133f68184602087016138a4565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039889168152968816602088015260408701959095526060860193909352608085019190915260a084015290921660c082015260e08101919091526101000190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b60006020825282518060208401526134de8160408501602087016138a4565b601f01601f19169190910160400192915050565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252602d908201527f5661756c74436f6e74726f6c6c65723a2063616e6e6f74207265636f7665722060408201526c39ba30b5b4b733903a37b5b2b760991b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601d908201527f5461726765742063616e206f6e6c79206265206164646564206f6e6365000000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b90815260200190565b9182526001600160a01b0316602082015260400190565b60008382526040602083015261176d604083018461339e565b918252602082015260400190565b600086825285602083015260a0604083015261380360a083018661339e565b6001600160a01b0394909416606083015250608001529392505050565b9283526020830191909152604082015260600190565b60008219821115613849576138496138d0565b500190565b60008261386957634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613888576138886138d0565b500290565b60008282101561389f5761389f6138d0565b500390565b60005b838110156138bf5781810151838201526020016138a7565b838111156131175750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461149557600080fdfea26469706673582212204515dc8cda6c4c16eaf86bc919d1c73a928e1570fd47f2bb163c193ad0a278cb64736f6c63430008000033

Block Transaction Gas Used Reward
view all blocks collator

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.