creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts-upgradeable/math/MathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow, so we distribute\n        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMathUpgradeable {\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        uint256 c = a + b;\n        if (c < a) return (false, 0);\n        return (true, c);\n    }\n\n    /**\n     * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b > a) return (false, 0);\n        return (true, a - b);\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n        if (a == 0) return (true, 0);\n        uint256 c = a * b;\n        if (c / a != b) return (false, 0);\n        return (true, c);\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b == 0) return (false, 0);\n        return (true, a / b);\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b == 0) return (false, 0);\n        return (true, a % b);\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, \"SafeMath: addition overflow\");\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b <= a, \"SafeMath: subtraction overflow\");\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (a == 0) return 0;\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0, \"SafeMath: division by zero\");\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0, \"SafeMath: modulo by zero\");\n        return a % b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {trySub}.\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b <= a, errorMessage);\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryDiv}.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting with custom message when dividing by zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryMod}.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        return a % b;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity >=0.4.24 <0.8.0;\n\nimport \"../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n */\nabstract contract Initializable {\n\n    /**\n     * @dev Indicates that the contract has been initialized.\n     */\n    bool private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Modifier to protect an initializer function from being invoked twice.\n     */\n    modifier initializer() {\n        require(_initializing || _isConstructor() || !_initialized, \"Initializable: contract is already initialized\");\n\n        bool isTopLevelCall = !_initializing;\n        if (isTopLevelCall) {\n            _initializing = true;\n            _initialized = true;\n        }\n\n        _;\n\n        if (isTopLevelCall) {\n            _initializing = false;\n        }\n    }\n\n    /// @dev Returns true if and only if the function is running in the constructor\n    function _isConstructor() private view returns (bool) {\n        return !AddressUpgradeable.isContract(address(this));\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"./IERC20Upgradeable.sol\";\nimport \"../../math/SafeMathUpgradeable.sol\";\nimport \"../../proxy/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {\n    using SafeMathUpgradeable for uint256;\n\n    mapping (address => uint256) private _balances;\n\n    mapping (address => mapping (address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n    uint8 private _decimals;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\n     * a default value of 18.\n     *\n     * To select a different value for {decimals}, use {_setupDecimals}.\n     *\n     * All three of these values are immutable: they can only be set once during\n     * construction.\n     */\n    function __ERC20_init(string memory name_, string memory symbol_) internal initializer {\n        __Context_init_unchained();\n        __ERC20_init_unchained(name_, symbol_);\n    }\n\n    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {\n        _name = name_;\n        _symbol = symbol_;\n        _decimals = 18;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\n     * called.\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual returns (uint8) {\n        return _decimals;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual override returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `recipient` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(_msgSender(), recipient, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        _approve(_msgSender(), spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * Requirements:\n     *\n     * - `sender` and `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``sender``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(sender, recipient, amount);\n        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \"ERC20: transfer amount exceeds allowance\"));\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \"ERC20: decreased allowance below zero\"));\n        return true;\n    }\n\n    /**\n     * @dev Moves tokens `amount` from `sender` to `recipient`.\n     *\n     * This is internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `sender` cannot be the zero address.\n     * - `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     */\n    function _transfer(address sender, address recipient, uint256 amount) internal virtual {\n        require(sender != address(0), \"ERC20: transfer from the zero address\");\n        require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(sender, recipient, amount);\n\n        _balances[sender] = _balances[sender].sub(amount, \"ERC20: transfer amount exceeds balance\");\n        _balances[recipient] = _balances[recipient].add(amount);\n        emit Transfer(sender, recipient, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply = _totalSupply.add(amount);\n        _balances[account] = _balances[account].add(amount);\n        emit Transfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        _balances[account] = _balances[account].sub(amount, \"ERC20: burn amount exceeds balance\");\n        _totalSupply = _totalSupply.sub(amount);\n        emit Transfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(address owner, address spender, uint256 amount) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Sets {decimals} to a value other than the default one of 18.\n     *\n     * WARNING: This function should only be called from the constructor. Most\n     * applications that interact with token contracts will not expect\n     * {decimals} to ever change, and may work incorrectly if it does.\n     */\n    function _setupDecimals(uint8 decimals_) internal virtual {\n        _decimals = decimals_;\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be to transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\n    uint256[44] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"../../math/SafeMathUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n    using SafeMathUpgradeable for uint256;\n    using AddressUpgradeable for address;\n\n    function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        // solhint-disable-next-line max-line-length\n        require((value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n        uint256 newAllowance = token.allowance(address(this), spender).add(value);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n        uint256 newAllowance = token.allowance(address(this), spender).sub(value, \"SafeERC20: decreased allowance below zero\");\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) { // Return data is optional\n            // solhint-disable-next-line max-line-length\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        // solhint-disable-next-line no-inline-assembly\n        assembly { size := extcodesize(account) }\n        return size > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n        (bool success, ) = recipient.call{ value: amount }(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain`call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n      return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.call{ value: value }(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                // solhint-disable-next-line no-inline-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\nimport \"../proxy/Initializable.sol\";\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal initializer {\n        __Context_init_unchained();\n    }\n\n    function __Context_init_unchained() internal initializer {\n    }\n    function _msgSender() internal view virtual returns (address payable) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes memory) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/base/inheritance/ControllableInit.sol": {
        "content": "//SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\nimport \"./GovernableInit.sol\";\n\n// A clone of Governable supporting the Initializable interface and pattern\ncontract ControllableInit is GovernableInit {\n\n  constructor() public {\n  }\n\n  function initialize(address _storage) public override initializer {\n    GovernableInit.initialize(_storage);\n  }\n\n  modifier onlyController() {\n    require(Storage(_storage()).isController(msg.sender), \"Not a controller\");\n    _;\n  }\n\n  modifier onlyControllerOrGovernance(){\n    require((Storage(_storage()).isController(msg.sender) || Storage(_storage()).isGovernance(msg.sender)),\n      \"The caller must be controller or governance\");\n    _;\n  }\n\n  function controller() public view returns (address) {\n    return Storage(_storage()).controller();\n  }\n}\n"
      },
      "contracts/base/inheritance/GovernableInit.sol": {
        "content": "//SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\nimport \"../upgradability/ReentrancyGuardUpgradeable.sol\";\nimport \"./Storage.sol\";\n\n// A clone of Governable supporting the Initializable interface and pattern\ncontract GovernableInit is ReentrancyGuardUpgradeable {\n\n  bytes32 internal constant _STORAGE_SLOT = 0xa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc;\n\n  modifier onlyGovernance() {\n    require(Storage(_storage()).isGovernance(msg.sender), \"Not governance\");\n    _;\n  }\n\n  constructor() public {\n    assert(_STORAGE_SLOT == bytes32(uint256(keccak256(\"eip1967.governableInit.storage\")) - 1));\n  }\n\n  function initialize(address _store) public virtual initializer {\n    _setStorage(_store);\n    ReentrancyGuardUpgradeable.initialize();\n  }\n\n  function _setStorage(address newStorage) private {\n    bytes32 slot = _STORAGE_SLOT;\n    // solhint-disable-next-line no-inline-assembly\n    assembly {\n      sstore(slot, newStorage)\n    }\n  }\n\n  function setStorage(address _store) public onlyGovernance {\n    require(_store != address(0), \"new storage shouldn't be empty\");\n    _setStorage(_store);\n  }\n\n  function _storage() internal view returns (address str) {\n    bytes32 slot = _STORAGE_SLOT;\n    // solhint-disable-next-line no-inline-assembly\n    assembly {\n      str := sload(slot)\n    }\n  }\n\n  function governance() public view returns (address) {\n    return Storage(_storage()).governance();\n  }\n}\n"
      },
      "contracts/base/inheritance/Storage.sol": {
        "content": "//SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\ncontract Storage {\n\n  address public governance;\n  address public controller;\n\n  constructor() public {\n    governance = msg.sender;\n  }\n\n  modifier onlyGovernance() {\n    require(isGovernance(msg.sender), \"Not governance\");\n    _;\n  }\n\n  function setGovernance(address _governance) public onlyGovernance {\n    require(_governance != address(0), \"new governance shouldn't be empty\");\n    governance = _governance;\n  }\n\n  function setController(address _controller) public onlyGovernance {\n    require(_controller != address(0), \"new controller shouldn't be empty\");\n    controller = _controller;\n  }\n\n  function isGovernance(address account) public view returns (bool) {\n    return account == governance;\n  }\n\n  function isController(address account) public view returns (bool) {\n    return account == controller;\n  }\n}\n"
      },
      "contracts/base/interface/IController.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\n\ninterface IController {\n\n    // ========================= Events =========================\n\n    event QueueProfitSharingChange(uint profitSharingNumerator, uint validAtTimestamp);\n    event ConfirmProfitSharingChange(uint profitSharingNumerator);\n\n    event QueueStrategistFeeChange(uint strategistFeeNumerator, uint validAtTimestamp);\n    event ConfirmStrategistFeeChange(uint strategistFeeNumerator);\n\n    event QueuePlatformFeeChange(uint platformFeeNumerator, uint validAtTimestamp);\n    event ConfirmPlatformFeeChange(uint platformFeeNumerator);\n\n    event QueueNextImplementationDelay(uint implementationDelay, uint validAtTimestamp);\n    event ConfirmNextImplementationDelay(uint implementationDelay);\n\n    event AddedStakingContract(address indexed stakingContract);\n    event RemovedStakingContract(address indexed stakingContract);\n\n    event SharePriceChangeLog(\n        address indexed vault,\n        address indexed strategy,\n        uint256 oldSharePrice,\n        uint256 newSharePrice,\n        uint256 timestamp\n    );\n\n    // ==================== Functions ====================\n\n    /**\n     * An EOA can safely interact with the system no matter what. If you're using Metamask, you're using an EOA. Only\n     * smart contracts may be affected by this grey list. This contract will not be able to ban any EOA from the system\n     * even if an EOA is being added to the greyList, he/she will still be able to interact with the whole system as if\n     * nothing happened. Only smart contracts will be affected by being added to the greyList. This grey list is only\n     * used in VaultV3.sol, see the code there for reference\n     */\n    function greyList(address _target) external view returns (bool);\n\n    function addressWhiteList(address _target) external view returns (bool);\n\n    function codeWhiteList(address _target) external view returns (bool);\n\n    function addToWhitelist(address _target) external;\n\n    function addCodeToWhitelist(address _target) external;\n\n    function store() external view returns (address);\n\n    function governance() external view returns (address);\n\n    function doHardWork(address _vault) external;\n\n    function addHardWorker(address _worker) external;\n\n    function removeHardWorker(address _worker) external;\n\n    function salvage(address _token, uint256 amount) external;\n\n    function salvageStrategy(address _strategy, address _token, uint256 amount) external;\n\n    /**\n     * @return The targeted profit token to convert all-non-compounding rewards to. Defaults to WETH.\n     */\n    function targetToken() external view returns (address);\n\n    function setTargetToken(address _targetToken) external;\n\n    function profitSharingReceiver() external view returns (address);\n\n    function setProfitSharingReceiver(address _profitSharingReceiver) external;\n\n    function protocolFeeReceiver() external view returns (address);\n\n    function setProtocolFeeReceiver(address _protocolFeeReceiver) external;\n\n    function rewardForwarder() external view returns (address);\n\n    function setRewardForwarder(address _rewardForwarder) external;\n\n    function universalLiquidator() external view returns (address);\n\n    function setUniversalLiquidator(address _universalLiquidator) external;\n\n    function dolomiteYieldFarmingRouter() external view returns (address);\n\n    function setDolomiteYieldFarmingRouter(address _value) external;\n\n    function nextImplementationDelay() external view returns (uint256);\n\n    function profitSharingNumerator() external view returns (uint256);\n\n    function strategistFeeNumerator() external view returns (uint256);\n\n    function platformFeeNumerator() external view returns (uint256);\n\n    function feeDenominator() external view returns (uint256);\n\n    function setProfitSharingNumerator(uint _profitSharingNumerator) external;\n\n    function confirmSetProfitSharingNumerator() external;\n\n    function setStrategistFeeNumerator(uint _strategistFeeNumerator) external;\n\n    function confirmSetStrategistFeeNumerator() external;\n\n    function setPlatformFeeNumerator(uint _platformFeeNumerator) external;\n\n    function confirmSetPlatformFeeNumerator() external;\n\n    function setNextImplementationDelay(uint256 _nextImplementationDelay) external;\n\n    function confirmNextImplementationDelay() external;\n\n    function nextProfitSharingNumerator() external view returns (uint256);\n\n    function nextProfitSharingNumeratorTimestamp() external view returns (uint256);\n\n    function nextStrategistFeeNumerator() external view returns (uint256);\n\n    function nextStrategistFeeNumeratorTimestamp() external view returns (uint256);\n\n    function nextPlatformFeeNumerator() external view returns (uint256);\n\n    function nextPlatformFeeNumeratorTimestamp() external view returns (uint256);\n\n    function tempNextImplementationDelay() external view returns (uint256);\n\n    function tempNextImplementationDelayTimestamp() external view returns (uint256);\n}\n"
      },
      "contracts/base/interface/IERC4626.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\n\ninterface IERC4626 {\n\n    // ========================= Events =========================\n\n    /**\n     * Caller has exchanged assets for shares, and transferred those shares to owner.\n     *\n     * MUST be emitted when tokens are deposited into the Vault via the mint and deposit methods.\n     */\n    event Deposit(\n        address indexed sender,\n        address indexed receiver,\n        uint256 assets,\n        uint256 shares\n    );\n\n    /**\n     * Caller has exchanged shares, owned by owner, for assets, and transferred those assets to receiver.\n     *\n     * MUST be emitted when shares are withdrawn from the Vault in ERC4626.redeem or ERC4626.withdraw methods.\n     */\n    event Withdraw(\n        address indexed sender,\n        address indexed receiver,\n        address indexed owner,\n        uint256 assets,\n        uint256 shares\n    );\n\n    // ========================= Functions =========================\n\n    /**\n     * @return assetTokenAddress The address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n     */\n    function asset() external view returns (address assetTokenAddress);\n\n    /**\n     * @return  totalManagedAssets Total amount of the underlying asset that is “managed” by Vault. SHOULD include any compounding that\n     *          occurs from yield. MUST be inclusive of any fees that are charged against assets in the Vault.\n     */\n    function totalAssets() external view returns (uint256 totalManagedAssets);\n\n    /**\n     * @return  assetsPerUnitShare The amount of underlying the Vault would exchange for 1 unit of shares, in an ideal scenario where all\n     *          the conditions are met. MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n     *          MUST NOT show any variations depending on the caller. MUST NOT reflect slippage or other on-chain\n     *          conditions, when performing the actual exchange. MUST NOT revert unless due to integer overflow caused\n     *          by an unreasonably large input. MUST round down towards 0. This calculation MAY NOT reflect the\n     *          “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning\n     *          what the average user should expect to see when exchanging to and from. This function should normally\n     *          return more than `10 ** underlying().decimals`.\n     */\n    function assetsPerShare() external view returns (uint256 assetsPerUnitShare);\n\n    /**\n     * @return  assets Total amount of the underlying asset that is “managed” by Vault for the `depositor`. SHOULD include any\n     *          compounding that occurs from yield. MUST be inclusive of any fees that are charged against assets in the\n     *          Vault.\n     */\n    function assetsOf(address depositor) external view returns (uint256 assets);\n\n    /**\n     * Maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit\n     * call. MUST return the maximum amount of assets deposit would allow to be deposited for receiver and not cause a\n     * revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if\n     * necessary). This assumes that the user has infinite assets, i.e. MUST NOT rely on balanceOf of asset. MUST factor\n     * in both global and user-specific limits, like if deposits are entirely disabled (even temporarily) it MUST return\n     * 0. MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n     */\n    function maxDeposit(address caller) external view returns (uint256 maxAssets);\n\n    /**\n     * Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current\n     * on-chain conditions.\n     *\n     * MUST return as close to and no more than the exact amount of Vault shares that would be\n     * minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as\n     * previewDeposit if called in the same transaction. MUST NOT account for deposit limits like those returned from\n     * maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough\n     * tokens approved, etc.\n     *\n     * MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n     *\n     * MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also\n     * cause deposit to revert.\n     *\n     * Note that any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n     */\n    function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n     *\n     * MUST emit the Deposit event.\n     *\n     * MUST support ERC-20 approve / transferFrom on asset as a deposit flow. MAY support an additional flow in which\n     * the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during\n     * deposit.\n     *\n     * MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n     * approving enough underlying tokens to the Vault contract, etc).\n     *\n     * Note that most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n     */\n    function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n    /**\n     * Maximum amount of shares that can be minted from the Vault for the receiver, through a mint call.\n     *\n     * MUST return the maximum amount of shares mint would allow to be deposited to receiver and not cause a revert,\n     * which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).\n     * This assumes that the user has infinite assets, i.e. MUST NOT rely on balanceOf of asset.\n     *\n     * MUST factor in both global and user-specific limits, like if mints are entirely disabled (even temporarily) it\n     * MUST return 0.\n     *\n     * MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n     */\n    function maxMint(address caller) external view returns (uint256 maxShares);\n\n    /**\n     * Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current\n     * on-chain conditions.\n     *\n     * MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in\n     * the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same\n     * transaction.\n     *\n     * MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would\n     * be accepted, regardless if the user has enough tokens approved, etc.\n     *\n     * MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n     *\n     * MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also\n     * cause mint to revert.\n     *\n     * Note that any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by minting.\n     */\n    function previewMint(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n     *\n     * MUST emit the Deposit event.\n     *\n     * MUST support ERC-20 approve / transferFrom on asset as a mint flow. MAY support an additional flow in which the\n     * underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.\n     *\n     * MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n     * approving enough underlying tokens to the Vault contract, etc).\n     *\n     * Note that most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n     */\n    function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n    /**\n     * Maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a\n     * withdraw call.\n     *\n     * MUST return the maximum amount of assets that could be transferred from owner through withdraw and not cause a\n     * revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if\n     * necessary).\n     *\n     * MUST factor in both global and user-specific limits, like if withdrawals are entirely disabled (even temporarily)\n     * it MUST return 0.\n     */\n    function maxWithdraw(address caller) external view returns (uint256 maxAssets);\n\n    /**\n     * Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given\n     * current on-chain conditions.\n     *\n     * MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n     * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called\n     * in the same transaction.\n     *\n     * MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the\n     * withdrawal would be accepted, regardless if the user has enough shares, etc.\n     *\n     * MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n     *\n     * MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also\n     * cause withdraw to revert.\n     *\n     * Note that any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage\n     * in share price or some other type of condition, meaning the depositor will lose assets by depositing.\n     */\n    function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n     *\n     * MUST emit the Withdraw event.\n     *\n     * MUST support a withdraw flow where the shares are burned from owner directly where owner is msg.sender or\n     * msg.sender has ERC-20 approval over the shares of owner. MAY support an additional flow in which the shares are\n     * transferred to the Vault contract before the withdraw execution, and are accounted for during withdraw.\n     *\n     * MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not\n     * having enough shares, etc).\n     *\n     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n     * Those methods should be performed separately.\n     */\n    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\n\n    /**\n     * Maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.\n     *\n     * MUST return the maximum amount of shares that could be transferred from owner through redeem and not cause a\n     * revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if\n     * necessary).\n     *\n     * MUST factor in both global and user-specific limits, like if redemption is entirely disabled (even temporarily)\n     * it MUST return 0.\n     */\n    function maxRedeem(address caller) external view returns (uint256 maxShares);\n\n    /**\n     * Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block, given\n     * current on-chain conditions.\n     *\n     * MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in\n     * the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same\n     * transaction.\n     *\n     * MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n     * redemption would be accepted, regardless if the user has enough shares, etc.\n     *\n     * MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n     *\n     * MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also\n     * cause redeem to revert.\n     *\n     * Note that any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n     */\n    function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n     *\n     * MUST emit the Withdraw event.\n     *\n     * MUST support a redeem flow where the shares are burned from owner directly where owner is msg.sender or\n     * msg.sender has ERC-20 approval over the shares of owner. MAY support an additional flow in which the shares are\n     * transferred to the Vault contract before the redeem execution, and are accounted for during redeem.\n     *\n     * MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not\n     * having enough shares, etc).\n     *\n     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n     * Those methods should be performed separately.\n     */\n    function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\n}\n"
      },
      "contracts/base/interface/IStrategy.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\ninterface IStrategy {\n\n    /// @notice declared as public so child contract can call it\n    function isUnsalvageableToken(address token) external view returns (bool);\n\n    function salvageToken(address recipient, address token, uint amount) external;\n\n    function governance() external view returns (address);\n\n    function controller() external view returns (address);\n\n    function underlying() external view returns (address);\n\n    function vault() external view returns (address);\n\n    function withdrawAllToVault() external;\n\n    function withdrawToVault(uint256 _amount) external;\n\n    function investedUnderlyingBalance() external view returns (uint256);\n\n    function doHardWork() external;\n\n    function depositArbCheck() external view returns (bool);\n\n    function strategist() external view returns (address);\n\n    /**\n     * @return  The value of any accumulated rewards that are under control by the strategy. Each index corresponds with\n     *          the tokens in `rewardTokens`. This function is not a `view`, because some protocols, like Curve, need\n     *          writeable functions to get the # of claimable reward tokens\n     */\n    function getRewardPoolValues() external returns (uint256[] memory);\n}\n"
      },
      "contracts/base/interface/IUpgradeSource.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\n\ninterface IUpgradeSource {\n\n  function shouldUpgrade() external view returns (bool, address);\n\n  function finalizeUpgrade() external;\n}\n"
      },
      "contracts/base/interface/IVault.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\ninterface IVault {\n\n    function initializeVault(\n        address _storage,\n        address _underlying,\n        uint256 _toInvestNumerator,\n        uint256 _toInvestDenominator\n    ) external;\n\n    function balanceOf(address _holder) external view returns (uint256);\n\n    function underlyingBalanceInVault() external view returns (uint256);\n\n    function underlyingBalanceWithInvestment() external view returns (uint256);\n\n    function governance() external view returns (address);\n\n    function controller() external view returns (address);\n\n    function underlying() external view returns (address);\n\n    function underlyingUnit() external view returns (uint);\n\n    function strategy() external view returns (address);\n\n    function setStrategy(address _strategy) external;\n\n    function announceStrategyUpdate(address _strategy) external;\n\n    function setVaultFractionToInvest(uint256 _numerator, uint256 _denominator) external;\n\n    function deposit(uint256 _amount) external;\n    function deposit(uint256 _amount, address _receiver) external;\n\n    function depositFor(uint256 _amount, address _holder) external;\n\n    function withdrawAll() external;\n\n    function withdraw(uint256 _numberOfShares) external;\n\n    function getPricePerFullShare() external view returns (uint256);\n\n    function underlyingBalanceWithInvestmentForHolder(address _holder) view external returns (uint256);\n\n    /**\n     * The total amount available to be deposited from this vault into the strategy, while adhering to the\n     * `vaultFractionToInvestNumerator` and `vaultFractionToInvestDenominator` rules\n     */\n    function availableToInvestOut() external view returns (uint256);\n\n    /**\n     * This should be callable only by the controller (by the hard worker) or by governance\n     */\n    function doHardWork() external;\n}\n"
      },
      "contracts/base/upgradability/ReentrancyGuardUpgradeable.sol": {
        "content": "//SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\n\n/**\n * Same old `ReentrancyGuard`, but can be used by upgradable contracts\n */\ncontract ReentrancyGuardUpgradeable is Initializable {\n\n    bytes32 internal constant _NOT_ENTERED_SLOT = 0x62ae7bf2df4e95c187ea09c8c47c3fc3d9abc36298f5b5b6c5e2e7b4b291fe25;\n\n    modifier nonReentrant() {\n        // On the first call to nonReentrant, _notEntered will be true\n        require(_getNotEntered(_NOT_ENTERED_SLOT), \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _setNotEntered(_NOT_ENTERED_SLOT, false);\n\n        _;\n\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _setNotEntered(_NOT_ENTERED_SLOT, true);\n    }\n\n    constructor() public {\n        assert(_NOT_ENTERED_SLOT == bytes32(uint256(keccak256(\"eip1967.reentrancyGuard.notEntered\")) - 1));\n    }\n\n    function initialize() public initializer {\n        _setNotEntered(_NOT_ENTERED_SLOT, true);\n    }\n\n    function _getNotEntered(bytes32 slot) private view returns (bool) {\n        uint str;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            str := sload(slot)\n        }\n        return str == 1;\n    }\n\n    function _setNotEntered(bytes32 slot, bool _value) private {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            sstore(slot, _value)\n        }\n    }\n\n}\n"
      },
      "contracts/base/VaultStorage.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\n\ncontract VaultStorage is Initializable {\n\n    bytes32 internal constant _STRATEGY_SLOT = 0xf1a169aa0f736c2813818fdfbdc5755c31e0839c8f49831a16543496b28574ea;\n    bytes32 internal constant _UNDERLYING_SLOT = 0x1994607607e11d53306ef62e45e3bd85762c58d9bf38b5578bc4a258a26a7371;\n    bytes32 internal constant _UNDERLYING_UNIT_SLOT = 0xa66bc57d4b4eed7c7687876ca77997588987307cb13ecc23f5e52725192e5fff;\n    bytes32 internal constant _VAULT_FRACTION_TO_INVEST_NUMERATOR_SLOT = 0x39122c9adfb653455d0c05043bd52fcfbc2be864e832efd3abc72ce5a3d7ed5a;\n    bytes32 internal constant _VAULT_FRACTION_TO_INVEST_DENOMINATOR_SLOT = 0x469a3bad2fab7b936c45eecd1f5da52af89cead3e2ed7f732b6f3fc92ed32308;\n    bytes32 internal constant _NEXT_IMPLEMENTATION_SLOT = 0xb1acf527cd7cd1668b30e5a9a1c0d845714604de29ce560150922c9d8c0937df;\n    bytes32 internal constant _NEXT_IMPLEMENTATION_TIMESTAMP_SLOT = 0x3bc747f4b148b37be485de3223c90b4468252967d2ea7f9fcbd8b6e653f434c9;\n    bytes32 internal constant _NEXT_STRATEGY_SLOT = 0xcd7bd9250b0e02f3b13eccf8c73ef5543cb618e0004628f9ca53b65fbdbde2d0;\n    bytes32 internal constant _NEXT_STRATEGY_TIMESTAMP_SLOT = 0x5d2b24811886ad126f78c499d71a932a5435795e4f2f6552f0900f12d663cdcf;\n    bytes32 internal constant _ALLOW_SHARE_PRICE_DECREASE_SLOT = 0x22f7033891e85fc76735ebd320e0d3f546da431c4729c2f6d2613b11923aaaed;\n    bytes32 internal constant _WITHDRAW_BEFORE_REINVESTING_SLOT = 0x4215fbb95dc0890d3e1660fb9089350f2d3f350c0a756934874cae6febf42a79;\n    bytes32 internal constant _PAUSED_SLOT = 0xf1cf856d03630b74791fc293cfafd739932a5a075b02d357fb7a726a38777930;\n\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    constructor() public {\n        assert(_STRATEGY_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.strategy\")) - 1));\n        assert(_UNDERLYING_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.underlying\")) - 1));\n        assert(_UNDERLYING_UNIT_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.underlyingUnit\")) - 1));\n        assert(_VAULT_FRACTION_TO_INVEST_NUMERATOR_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.vaultFractionToInvestNumerator\")) - 1));\n        assert(_VAULT_FRACTION_TO_INVEST_DENOMINATOR_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.vaultFractionToInvestDenominator\")) - 1));\n        assert(_NEXT_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.nextImplementation\")) - 1));\n        assert(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.nextImplementationTimestamp\")) - 1));\n        assert(_NEXT_STRATEGY_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.nextStrategy\")) - 1));\n        assert(_NEXT_STRATEGY_TIMESTAMP_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.nextStrategyTimestamp\")) - 1));\n        assert(_ALLOW_SHARE_PRICE_DECREASE_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.allowSharePriceDecrease\")) - 1));\n        assert(_WITHDRAW_BEFORE_REINVESTING_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.withdrawBeforeReinvesting\")) - 1));\n        assert(_PAUSED_SLOT == bytes32(uint256(keccak256(\"eip1967.vaultStorage.paused\")) - 1));\n    }\n\n    function initialize(\n        address _underlying,\n        uint256 _toInvestNumerator,\n        uint256 _toInvestDenominator,\n        uint256 _underlyingUnit\n    ) public initializer {\n        _setUnderlying(_underlying);\n        _setVaultFractionToInvestNumerator(_toInvestNumerator);\n        _setVaultFractionToInvestDenominator(_toInvestDenominator);\n        _setUnderlyingUnit(_underlyingUnit);\n        _setNextStrategyTimestamp(0);\n        _setNextStrategy(address(0));\n        _setAllowSharePriceDecrease(false);\n        _setWithdrawBeforeReinvesting(false);\n    }\n\n    function _setStrategy(address _address) internal {\n        setAddress(_STRATEGY_SLOT, _address);\n    }\n\n    function _strategy() internal view returns (address) {\n        return getAddress(_STRATEGY_SLOT);\n    }\n\n    function _setUnderlying(address _address) internal {\n        setAddress(_UNDERLYING_SLOT, _address);\n    }\n\n    function _underlying() internal view returns (address) {\n        return getAddress(_UNDERLYING_SLOT);\n    }\n\n    function _setUnderlyingUnit(uint256 _value) internal {\n        setUint256(_UNDERLYING_UNIT_SLOT, _value);\n    }\n\n    function _underlyingUnit() internal view returns (uint256) {\n        return getUint256(_UNDERLYING_UNIT_SLOT);\n    }\n\n    function _setVaultFractionToInvestNumerator(uint256 _value) internal {\n        setUint256(_VAULT_FRACTION_TO_INVEST_NUMERATOR_SLOT, _value);\n    }\n\n    function _vaultFractionToInvestNumerator() internal view returns (uint256) {\n        return getUint256(_VAULT_FRACTION_TO_INVEST_NUMERATOR_SLOT);\n    }\n\n    function _setVaultFractionToInvestDenominator(uint256 _value) internal {\n        setUint256(_VAULT_FRACTION_TO_INVEST_DENOMINATOR_SLOT, _value);\n    }\n\n    function _vaultFractionToInvestDenominator() internal view returns (uint256) {\n        return getUint256(_VAULT_FRACTION_TO_INVEST_DENOMINATOR_SLOT);\n    }\n\n    function _setAllowSharePriceDecrease(bool _value) internal {\n        setBoolean(_ALLOW_SHARE_PRICE_DECREASE_SLOT, _value);\n    }\n\n    function _allowSharePriceDecrease() internal view returns (bool) {\n        return getBoolean(_ALLOW_SHARE_PRICE_DECREASE_SLOT);\n    }\n\n    function _setWithdrawBeforeReinvesting(bool _value) internal {\n        setBoolean(_WITHDRAW_BEFORE_REINVESTING_SLOT, _value);\n    }\n\n    function _withdrawBeforeReinvesting() internal view returns (bool) {\n        return getBoolean(_WITHDRAW_BEFORE_REINVESTING_SLOT);\n    }\n\n    function _setNextImplementation(address _address) internal {\n        setAddress(_NEXT_IMPLEMENTATION_SLOT, _address);\n    }\n\n    function _nextImplementation() internal view returns (address) {\n        return getAddress(_NEXT_IMPLEMENTATION_SLOT);\n    }\n\n    function _setNextImplementationTimestamp(uint256 _value) internal {\n        setUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT, _value);\n    }\n\n    function _nextImplementationTimestamp() internal view returns (uint256) {\n        return getUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT);\n    }\n\n    function _setNextStrategy(address _value) internal {\n        setAddress(_NEXT_STRATEGY_SLOT, _value);\n    }\n\n    function _nextStrategy() internal view returns (address) {\n        return getAddress(_NEXT_STRATEGY_SLOT);\n    }\n\n    function _setNextStrategyTimestamp(uint256 _value) internal {\n        setUint256(_NEXT_STRATEGY_TIMESTAMP_SLOT, _value);\n    }\n\n    function _nextStrategyTimestamp() internal view returns (uint256) {\n        return getUint256(_NEXT_STRATEGY_TIMESTAMP_SLOT);\n    }\n\n    function _implementation() internal view returns (address) {\n        return getAddress(_IMPLEMENTATION_SLOT);\n    }\n\n    function _paused() internal view returns (bool) {\n        return getBoolean(_PAUSED_SLOT);\n    }\n\n    function _setPaused(bool _value) internal {\n        setBoolean(_PAUSED_SLOT, _value);\n    }\n\n    function setBoolean(bytes32 slot, bool _value) internal {\n        setUint256(slot, _value ? 1 : 0);\n    }\n\n    function getBoolean(bytes32 slot) internal view returns (bool) {\n        return (getUint256(slot) == 1);\n    }\n\n    function setAddress(bytes32 slot, address _address) internal {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            sstore(slot, _address)\n        }\n    }\n\n    function setUint256(bytes32 slot, uint256 _value) internal {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            sstore(slot, _value)\n        }\n    }\n\n    function getAddress(bytes32 slot) internal view returns (address str) {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            str := sload(slot)\n        }\n    }\n\n    function getUint256(bytes32 slot) internal view returns (uint256 str) {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            str := sload(slot)\n        }\n    }\n\n    uint256[50] private ______gap;\n}\n"
      },
      "contracts/base/VaultV1.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts-upgradeable/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"./interface/IStrategy.sol\";\nimport \"./interface/IVault.sol\";\nimport \"./interface/IController.sol\";\nimport \"./interface/IUpgradeSource.sol\";\nimport \"./inheritance/ControllableInit.sol\";\nimport \"./VaultStorage.sol\";\n\n\ncontract VaultV1 is ERC20Upgradeable, IUpgradeSource, ControllableInit, VaultStorage {\n  using SafeERC20Upgradeable for IERC20Upgradeable;\n  using AddressUpgradeable for address;\n  using SafeMathUpgradeable for uint256;\n\n  /**\n   * Caller has exchanged assets for shares, and transferred those shares to owner.\n   *\n   * MUST be emitted when tokens are deposited into the Vault via the mint and deposit methods.\n   */\n  event Deposit(\n      address indexed sender,\n      address indexed receiver,\n      uint256 assets,\n      uint256 shares\n  );\n\n  /**\n   * Caller has exchanged shares, owned by owner, for assets, and transferred those assets to receiver.\n   *\n   * MUST be emitted when shares are withdrawn from the Vault in ERC4626.redeem or ERC4626.withdraw methods.\n   */\n  event Withdraw(\n      address indexed sender,\n      address indexed receiver,\n      address indexed owner,\n      uint256 assets,\n      uint256 shares\n  );\n  event Invest(uint256 amount);\n  event StrategyAnnounced(address newStrategy, uint256 time);\n  event StrategyChanged(address newStrategy, address oldStrategy);\n\n\n  constructor() public {\n  }\n\n  // the function is name differently to not cause inheritance clash in truffle and allows tests\n  function initializeVault(\n    address _storage,\n    address _underlying,\n    uint256 _toInvestNumerator,\n    uint256 _toInvestDenominator\n  ) public initializer {\n    require(_toInvestNumerator <= _toInvestDenominator, \"cannot invest more than 100%\");\n    require(_toInvestDenominator != 0, \"cannot divide by 0\");\n\n    __ERC20_init(\n      string(abi.encodePacked(\"FARM_\", ERC20Upgradeable(_underlying).symbol())),\n      string(abi.encodePacked(\"f\", ERC20Upgradeable(_underlying).symbol()))\n    );\n    _setupDecimals(ERC20Upgradeable(_underlying).decimals());\n\n    ControllableInit.initialize(\n      _storage\n    );\n\n    uint256 underlyingUnit = 10 ** uint256(ERC20Upgradeable(address(_underlying)).decimals());\n    VaultStorage.initialize(\n      _underlying,\n      _toInvestNumerator,\n      _toInvestDenominator,\n      underlyingUnit\n    );\n  }\n\n  function strategy() public view returns(address) {\n    return _strategy();\n  }\n\n  function underlying() public view returns(address) {\n    return _underlying();\n  }\n\n  function underlyingUnit() public view returns(uint256) {\n    return _underlyingUnit();\n  }\n\n  function vaultFractionToInvestNumerator() public view returns(uint256) {\n    return _vaultFractionToInvestNumerator();\n  }\n\n  function vaultFractionToInvestDenominator() public view returns(uint256) {\n    return _vaultFractionToInvestDenominator();\n  }\n\n  function nextImplementation() public view returns(address) {\n    return _nextImplementation();\n  }\n\n  function nextImplementationTimestamp() public view returns(uint256) {\n    return _nextImplementationTimestamp();\n  }\n\n  function nextImplementationDelay() public view returns (uint256) {\n    return IController(controller()).nextImplementationDelay();\n  }\n\n  modifier whenStrategyDefined() {\n    require(address(strategy()) != address(0), \"Strategy must be defined\");\n    _;\n  }\n\n  // Only smart contracts will be affected by this modifier\n  modifier defense() {\n    require(\n      (msg.sender == tx.origin) ||                // If it is a normal user and not smart contract,\n                                                  // then the requirement will pass\n      !IController(controller()).greyList(msg.sender), // If it is a smart contract, then\n      \"This smart contract has been grey listed\"  // make sure that it is not on our greyList.\n    );\n    _;\n  }\n\n  /**\n  * Chooses the best strategy and re-invests. If the strategy did not change, it just calls\n  * doHardWork on the current strategy. Call this through controller to claim hard rewards.\n  */\n  function doHardWork() whenStrategyDefined onlyControllerOrGovernance external {\n    // ensure that new funds are invested too\n    invest();\n    IStrategy(strategy()).doHardWork();\n  }\n\n  /*\n  * Returns the cash balance across all users in this contract.\n  */\n  function underlyingBalanceInVault() view public returns (uint256) {\n    return IERC20Upgradeable(underlying()).balanceOf(address(this));\n  }\n\n  /* Returns the current underlying (e.g., DAI's) balance together with\n   * the invested amount (if DAI is invested elsewhere by the strategy).\n  */\n  function underlyingBalanceWithInvestment() view public returns (uint256) {\n    if (address(strategy()) == address(0)) {\n      // initial state, when not set\n      return underlyingBalanceInVault();\n    }\n    return underlyingBalanceInVault().add(IStrategy(strategy()).investedUnderlyingBalance());\n  }\n\n  function getPricePerFullShare() public view returns (uint256) {\n    return totalSupply() == 0\n        ? underlyingUnit()\n        : underlyingUnit().mul(underlyingBalanceWithInvestment()).div(totalSupply());\n  }\n\n  /* get the user's share (in underlying)\n  */\n  function underlyingBalanceWithInvestmentForHolder(address holder) view external returns (uint256) {\n    if (totalSupply() == 0) {\n      return 0;\n    }\n    return underlyingBalanceWithInvestment()\n        .mul(balanceOf(holder))\n        .div(totalSupply());\n  }\n\n  function nextStrategy() public view returns (address) {\n    return _nextStrategy();\n  }\n\n  function nextStrategyTimestamp() public view returns (uint256) {\n    return _nextStrategyTimestamp();\n  }\n\n  function canUpdateStrategy(address _strategy) public view returns (bool) {\n    bool isStrategyNotSetYet = strategy() == address(0);\n    bool hasTimelockPassed = block.timestamp > nextStrategyTimestamp() && nextStrategyTimestamp() != 0;\n    return isStrategyNotSetYet || (_strategy == nextStrategy() && hasTimelockPassed);\n  }\n\n  /**\n  * Indicates that the strategy update will happen in the future\n  */\n  function announceStrategyUpdate(address _strategy) public onlyControllerOrGovernance {\n    // records a new timestamp\n    uint256 when = block.timestamp.add(nextImplementationDelay());\n    _setNextStrategyTimestamp(when);\n    _setNextStrategy(_strategy);\n    emit StrategyAnnounced(_strategy, when);\n  }\n\n  /**\n  * Finalizes (or cancels) the strategy update by resetting the data\n  */\n  function finalizeStrategyUpdate() public onlyControllerOrGovernance {\n    _setNextStrategyTimestamp(0);\n    _setNextStrategy(address(0));\n  }\n\n  function setStrategy(address _strategy) public onlyControllerOrGovernance {\n    require(canUpdateStrategy(_strategy),\n      \"The strategy exists and switch timelock did not elapse yet\");\n    require(_strategy != address(0), \"new _strategy cannot be empty\");\n    require(IStrategy(_strategy).underlying() == address(underlying()), \"Vault underlying must match Strategy underlying\");\n    require(IStrategy(_strategy).vault() == address(this), \"the strategy does not belong to this vault\");\n\n    emit StrategyChanged(_strategy, strategy());\n    if (address(_strategy) != address(strategy())) {\n      if (address(strategy()) != address(0)) { // if the original strategy (no underscore) is defined\n        IERC20Upgradeable(underlying()).safeApprove(address(strategy()), 0);\n        IStrategy(strategy()).withdrawAllToVault();\n      }\n      _setStrategy(_strategy);\n      IERC20Upgradeable(underlying()).safeApprove(address(strategy()), 0);\n      IERC20Upgradeable(underlying()).safeApprove(address(strategy()), uint256(~0));\n    }\n    finalizeStrategyUpdate();\n  }\n\n  function setVaultFractionToInvest(uint256 numerator, uint256 denominator) external onlyGovernance {\n    require(denominator > 0, \"denominator must be greater than 0\");\n    require(numerator <= denominator, \"denominator must be greater than or equal to the numerator\");\n    _setVaultFractionToInvestNumerator(numerator);\n    _setVaultFractionToInvestDenominator(denominator);\n  }\n\n  function rebalance() external onlyControllerOrGovernance {\n    withdrawAll();\n    invest();\n  }\n\n  function availableToInvestOut() public view returns (uint256) {\n    uint256 wantInvestInTotal = underlyingBalanceWithInvestment()\n        .mul(vaultFractionToInvestNumerator())\n        .div(vaultFractionToInvestDenominator());\n    uint256 alreadyInvested = IStrategy(strategy()).investedUnderlyingBalance();\n    if (alreadyInvested >= wantInvestInTotal) {\n      return 0;\n    } else {\n      uint256 remainingToInvest = wantInvestInTotal.sub(alreadyInvested);\n      return remainingToInvest <= underlyingBalanceInVault()\n        // TODO: we think that the \"else\" branch of the ternary operation is not\n        // going to get hit\n        ? remainingToInvest : underlyingBalanceInVault();\n    }\n  }\n\n  function invest() internal whenStrategyDefined {\n    uint256 availableAmount = availableToInvestOut();\n    if (availableAmount > 0) {\n      IERC20Upgradeable(underlying()).safeTransfer(address(strategy()), availableAmount);\n      emit Invest(availableAmount);\n    }\n  }\n\n  /*\n  * Allows for depositing the underlying asset in exchange for shares.\n  * Approval is assumed.\n  */\n  function deposit(uint256 amount) external nonReentrant defense returns (uint256 minted) {\n    minted = _deposit(amount, msg.sender, msg.sender);\n  }\n\n  /*\n  * Allows for depositing the underlying asset in exchange for shares\n  * assigned to the holder.\n  * This facilitates depositing for someone else (using DepositHelper)\n  */\n  function depositFor(uint256 amount, address holder) public nonReentrant defense returns (uint256 minted) {\n    minted = _deposit(amount, msg.sender, holder);\n  }\n\n  function withdraw(uint256 shares) external nonReentrant defense returns (uint256 amtUnderlying) {\n    amtUnderlying = _withdraw(shares, msg.sender, msg.sender);\n  }\n\n  function withdrawAll() public onlyControllerOrGovernance whenStrategyDefined {\n    IStrategy(strategy()).withdrawAllToVault();\n  }\n\n  function _deposit(uint256 amount, address sender, address beneficiary) internal returns (uint256) {\n    require(amount > 0, \"Cannot deposit 0\");\n    require(beneficiary != address(0), \"holder must be defined\");\n\n    if (address(strategy()) != address(0)) {\n      require(IStrategy(strategy()).depositArbCheck(), \"Too much arb\");\n    }\n\n    uint256 toMint = totalSupply() == 0\n        ? amount\n        : amount.mul(totalSupply()).div(underlyingBalanceWithInvestment());\n    _mint(beneficiary, toMint);\n\n    IERC20Upgradeable(underlying()).safeTransferFrom(sender, address(this), amount);\n\n    // update the contribution amount for the beneficiary\n    emit Deposit(sender, beneficiary, amount, toMint);\n    return toMint;\n  }\n\n  function _withdraw(uint256 numberOfShares, address receiver, address owner) internal returns (uint256) {\n    require(totalSupply() > 0, \"Vault has no shares\");\n    require(numberOfShares > 0, \"numberOfShares must be greater than 0\");\n    uint256 totalSupply = totalSupply();\n\n    address sender = msg.sender;\n      if (sender != owner) {\n        uint256 currentAllowance = allowance(owner, sender);\n        if (currentAllowance != uint(-1)) {\n          require(currentAllowance >= numberOfShares, \"ERC20: transfer amount exceeds allowance\");\n          _approve(owner, sender, currentAllowance - numberOfShares);\n        }\n      }\n    _burn(owner, numberOfShares);\n\n    uint256 underlyingAmountToWithdraw = underlyingBalanceWithInvestment()\n        .mul(numberOfShares)\n        .div(totalSupply);\n    if (underlyingAmountToWithdraw > underlyingBalanceInVault()) {\n      // withdraw everything from the strategy to accurately check the share value\n      if (numberOfShares == totalSupply) {\n        IStrategy(strategy()).withdrawAllToVault();\n      } else {\n        uint256 missing = underlyingAmountToWithdraw.sub(underlyingBalanceInVault());\n        IStrategy(strategy()).withdrawToVault(missing);\n      }\n      // recalculate to improve accuracy\n      underlyingAmountToWithdraw = MathUpgradeable.min(underlyingBalanceWithInvestment()\n          .mul(numberOfShares)\n          .div(totalSupply), underlyingBalanceInVault());\n    }\n\n    IERC20Upgradeable(underlying()).safeTransfer(receiver, underlyingAmountToWithdraw);\n\n    // update the withdrawal amount for the holder\n    emit Withdraw(sender, receiver, owner, underlyingAmountToWithdraw, numberOfShares);\n    return underlyingAmountToWithdraw;\n  }\n\n  /**\n  * Schedules an upgrade for this vault's proxy.\n  */\n  function scheduleUpgrade(address impl) public onlyGovernance {\n    _setNextImplementation(impl);\n    _setNextImplementationTimestamp(block.timestamp.add(nextImplementationDelay()));\n  }\n\n  function shouldUpgrade() external view override returns (bool, address) {\n    return (\n      nextImplementationTimestamp() != 0\n        && block.timestamp > nextImplementationTimestamp()\n        && nextImplementation() != address(0),\n      nextImplementation()\n    );\n  }\n\n  function finalizeUpgrade() external override onlyGovernance {\n    _setNextImplementation(address(0));\n    _setNextImplementationTimestamp(0);\n    assembly {\n      sstore(_NOT_ENTERED_SLOT, true)\n    }\n    _setupDecimals(ERC20Upgradeable(underlying()).decimals());\n  }\n}"
      },
      "contracts/base/VaultV2.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity 0.6.12;\n\nimport \"./interface/IERC4626.sol\";\nimport \"./VaultV1.sol\";\n\ncontract VaultV2 is IERC4626, VaultV1 {\n\n    /// By default, the constant `10` is a uint8. This implicitly converts it to `uint256`\n    uint256 public constant TEN = 10;\n\n    function asset() public view override returns (address) {\n        return underlying();\n    }\n\n    function totalAssets() public view override returns (uint256) {\n        return underlyingBalanceWithInvestment();\n    }\n\n    function assetsPerShare() public view override returns (uint256) {\n        return convertToAssets(TEN ** decimals());\n    }\n\n    function assetsOf(address _depositor) public view override returns (uint256) {\n        return totalAssets() * balanceOf(_depositor) / totalSupply();\n    }\n\n    function maxDeposit(address /*caller*/) public view override returns (uint256) {\n        return uint(-1);\n    }\n\n    function previewDeposit(uint256 _assets) public view override returns (uint256) {\n        return convertToShares(_assets);\n    }\n\n    function deposit(uint256 _assets, address _receiver) public override nonReentrant defense returns (uint256) {\n        uint256 shares = _deposit(_assets, msg.sender, _receiver);\n        return shares;\n    }\n\n    function maxMint(address /*caller*/) public view override returns (uint256) {\n        return uint(-1);\n    }\n\n    function previewMint(uint256 _shares) public view override returns (uint256) {\n        return convertToAssets(_shares);\n    }\n\n    function mint(uint256 _shares, address _receiver) public override nonReentrant defense returns (uint256) {\n        uint assets = convertToAssets(_shares);\n        _deposit(assets, msg.sender, _receiver);\n        return assets;\n    }\n\n    function maxWithdraw(address _caller) public view override returns (uint256) {\n        return assetsOf(_caller);\n    }\n\n    function previewWithdraw(uint256 _assets) public view override returns (uint256) {\n        return convertToShares(_assets);\n    }\n\n    function withdraw(\n        uint256 _assets,\n        address _receiver,\n        address _owner\n    )\n    public override\n    nonReentrant\n    defense\n    returns (uint256) {\n        uint256 shares = convertToShares(_assets);\n        _withdraw(shares, _receiver, _owner);\n        return shares;\n    }\n\n    function maxRedeem(address _caller) public view override returns (uint256) {\n        return balanceOf(_caller);\n    }\n\n    function previewRedeem(uint256 _shares) public view override returns (uint256) {\n        return convertToAssets(_shares);\n    }\n\n    function redeem(\n        uint256 _shares,\n        address _receiver,\n        address _owner\n    )\n    public override\n    nonReentrant\n    defense\n    returns (uint256) {\n        uint256 assets = _withdraw(_shares, _receiver, _owner);\n        return assets;\n    }\n\n    // ========================= Conversion Functions =========================\n\n    function convertToAssets(uint256 _shares) public view returns (uint256) {\n        return totalAssets() == 0 || totalSupply() == 0\n            ? _shares * (TEN ** ERC20Upgradeable(underlying()).decimals()) / (TEN ** decimals())\n            : _shares * totalAssets() / totalSupply();\n    }\n\n    function convertToShares(uint256 _assets) public view returns (uint256) {\n        return totalAssets() == 0 || totalSupply() == 0\n            ? _assets * (TEN ** decimals()) / (TEN ** ERC20Upgradeable(underlying()).decimals())\n            : _assets * totalSupply() / totalAssets();\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}