ETH Price: $3,542.46 (-0.88%)
Gas: 23 Gwei

Contract

0x487187de8d0Ad8Ff2Cd2fc6C2cb64C38EFab48F4
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
0x60806040142425222022-02-20 10:54:59768 days ago1645354499IN
 Create: ConvexBtc
0 ETH0.1672195244.43188326

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ConvexBtc

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 30 runs

Other Settings:
default evmVersion
File 1 of 31 : ConvexBtc.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./CurveBtc.sol";
import "./ConvexBase.sol";

/// @notice Implements the strategy using Convex. The steps are similar to CurveBtc strategy, the main differences are:
///  1) The Curve LP tokens are deposited into Convex Booster contract
///  2) Use the Convex Rewards contract to claim rewards and get both CRV and CVX in return
///  Because of this, the strategy only overrides some of the functions from parent contracts for the different parts.
/// Booster: 0xF403C135812408BFbE8713b5A23a04b3D48AAE31
/// Rewards: 0xeeeCE77e0bc5e59c77fc408789A9A172A504bD2f
/// Pool Id: 20 (This id is used by Convex to look up pool information in the booster)
contract ConvexBtc is CurveBtc, ConvexBase {
  using SafeERC20 for IERC20;

  uint256 private constant POOL_ID = 20;

  constructor(
    address _vault,
    address _proposer,
    address _developer,
    address _keeper,
    address _pool,
    address _booster
  ) CurveBtc(_vault, _proposer, _developer, _keeper, _pool) ConvexBase(POOL_ID, _booster) {}

  function name() external pure override returns (string memory) {
    return "ConvexBTC";
  }

  function protectedTokens() internal view virtual override returns (address[] memory) {
    return _buildProtectedTokens(_getCurveTokenAddress());
  }

  function _approveDex() internal virtual override {
    super._approveDex();
    _approveDexExtra(dex);
  }

  function _balanceOfRewards() internal view virtual override returns (uint256) {
    return _convexRewardsValue(_getCurveTokenAddress(), _getQuoteForTokenToWant);
  }

  function _depositLPTokens() internal virtual override {
    _depositToConvex();
  }

  function _claimRewards() internal virtual override {
    _claimConvexRewards(_getCurveTokenAddress(), _swapToWant);
  }

  function _getLpTokenBalance() internal view virtual override returns (uint256) {
    return _getConvexBalance();
  }

  function _removeLpToken(uint256 _amount) internal virtual override {
    _withdrawFromConvex(_amount);
  }

  // no need to do anything
  function onHarvest() internal virtual override {}
}

File 3 of 31 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 4 of 31 : CurveBtc.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./CurveBase.sol";

/// @notice Implements the strategy using the oBTC/sBTC(renBTC/wBTC/sBTC) pool.
///  The strategy uses the zap depositor(0xd5BCf53e2C81e1991570f33Fa881c49EEa570C8D) for the pool, which will deposit the wBTC token to the 3 BTC pool first, and the deposit the LP tokens to the meta pool.
///  Then the strategy will deposit the LP tokens into the gauge.
///  Input token: WBTC
///  Zap depositor:  0xd5BCf53e2C81e1991570f33Fa881c49EEa570C8D
///  Base pool: 0x7fc77b5c7614e1533320ea6ddc2eb61fa00a9714 (sBTC pool)
///  Meta pool: 0xd81dA8D904b52208541Bade1bD6595D8a251F8dd
///  Gauge: 0x11137B10C210b579405c21A07489e28F3c040AB1
contract CurveBtc is CurveBase {
  using SafeERC20 for IERC20;
  using Address for address;

  address private constant WBTC_TOKEN_ADDRESS = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;
  address private constant CURVE_TBTC_METAPOOL_GAUGE_ADDRESS = 0x11137B10C210b579405c21A07489e28F3c040AB1;
  // the LP (meta token) of the renBtc/sBTc/wBTC curve pool
  address private constant CRV_REN_WS_BTC_TOKEN_ADDRESS = 0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3;
  // 0 - oBTC, 1 - renBTC, 2 - WBTC, 3 - sBTC
  uint256 private constant WBTC_TOKEN_INDEX = 2;
  uint256 private constant NUMBER_OF_COINS = 4;

  /* solhint-disable  no-empty-blocks */
  /// @dev the _pool here is a zap depositor, which will automatically add/remove liquidity to/from the base and meta pool
  constructor(
    address _vault,
    address _proposer,
    address _developer,
    address _keeper,
    address _pool
  ) CurveBase(_vault, _proposer, _developer, _keeper, _pool) {}

  /* solhint-enable */

  function name() external view virtual override returns (string memory) {
    return "CurveWBTC";
  }

  function checkWantToken() internal view virtual override {
    require(address(want) == _getWTBCTokenAddress(), "wrong vault token");
  }

  function _approveBasic() internal override {
    super._approveBasic();
    // the zap depositor pool needs this to add liquidity to the base pool
    IERC20(_getWTBCTokenAddress()).safeApprove(address(curvePool), type(uint256).max);
    // the zap depositor pool needs this to remove LP tokens when remove liquidity
    IERC20(curveGauge.lp_token()).safeApprove(address(curvePool), type(uint256).max);
  }

  function _getWTBCTokenAddress() internal view virtual returns (address) {
    return WBTC_TOKEN_ADDRESS;
  }

  function _getWantTokenIndex() internal pure override returns (uint256) {
    return WBTC_TOKEN_INDEX;
  }

  function _getCoinsCount() internal pure override returns (uint256) {
    return NUMBER_OF_COINS;
  }

  function _addLiquidityToCurvePool() internal virtual override {
    uint256 balance = _balanceOfWant();
    if (balance > 0) {
      uint256[4] memory params;
      params[WBTC_TOKEN_INDEX] = balance;
      curvePool.add_liquidity(params, 0);
    }
  }

  function _getCurvePoolGaugeAddress() internal view virtual override returns (address) {
    return CURVE_TBTC_METAPOOL_GAUGE_ADDRESS;
  }
}

File 5 of 31 : ConvexBase.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../interfaces/convex/IConvexDeposit.sol";
import "../interfaces/convex/IConvexRewards.sol";

/// @notice This contract provides common functions that will be used by all Convex strategies.
contract ConvexBase {
  using SafeERC20 for IERC20;

  address private constant CONVEX_TOKEN_ADDRESS = 0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B;

  // The pool id. This is unique for each Curve pool.
  uint256 public poolId;
  // The address of the Convex booster contract
  address public convexBooster;
  // The address of the Rewards contract for the pool. Different for each pool
  address public cvxRewards;
  // The address of the LP token that the booster contract will accept for a pool
  address public lpToken;
  // Store dex approval status to avoid excessive approvals
  mapping(address => bool) internal cvxDexApprovals;

  /// @param _pooId the id of the pool
  /// @param _booster the address of the booster contract
  constructor(uint256 _pooId, address _booster) {
    require(_booster != address(0), "invalid booster address");
    poolId = _pooId;
    convexBooster = _booster;
    (lpToken, , , cvxRewards, , ) = IConvexDeposit(convexBooster).poolInfo(poolId);
    _approveConvexExtra();
  }

  // Need to allow booster to access the lp tokens for deposit
  function _approveConvexExtra() internal virtual {
    IERC20(lpToken).safeApprove(convexBooster, type(uint256).max);
  }

  // Need to allow dex to access the Convex tokens for swaps
  function _approveDexExtra(address _dex) internal {
    if (!cvxDexApprovals[_dex]) {
      cvxDexApprovals[_dex] = true;
      IERC20(_getConvexTokenAddress()).safeApprove(_dex, type(uint256).max);
    }
  }

  // Keep CRV, CVX and the pool lp tokens in the strategy. Everything else can be sent to somewhere else.
  function _buildProtectedTokens(address _curveToken) internal view returns (address[] memory) {
    address[] memory protected = new address[](3);
    protected[0] = _curveToken;
    protected[1] = _getConvexTokenAddress();
    protected[2] = lpToken;
    return protected;
  }

  /// @dev Add Curve LP tokens to Convex booster
  function _depositToConvex() internal {
    uint256 balance = IERC20(lpToken).balanceOf(address(this));
    if (balance > 0) {
      IConvexDeposit(convexBooster).depositAll(poolId, true);
    }
  }

  /// @dev Return the amount of Curve LP tokens.
  ///  The Curve LP tokens are eventually deposited into the Rewards contract, and we can query it to get the balance.
  function _getConvexBalance() internal view returns (uint256) {
    return IConvexRewards(cvxRewards).balanceOf(address(this));
  }

  /// @dev When withdraw, withdraw the LP tokens from the Rewards contract and claim rewards. Unwrap these to Curve LP tokens.
  /// @param _amount The amount of rewards (1:1 to LP tokens) to withdraw.
  function _withdrawFromConvex(uint256 _amount) internal {
    IConvexRewards(cvxRewards).withdrawAndUnwrap(_amount, true);
  }

  function _getConvexTokenAddress() internal view virtual returns (address) {
    return CONVEX_TOKEN_ADDRESS;
  }

  /// @dev Get the rewards (CRV and CVX) from Convex, and swap them for the `want` tokens.
  function _claimConvexRewards(address _curveTokenAddress, function(address, uint256) returns (uint256) _swapFunc)
    internal
    virtual
  {
    IConvexRewards(cvxRewards).getReward(address(this), true);
    uint256 crvBalance = IERC20(_curveTokenAddress).balanceOf(address(this));
    uint256 convexBalance = IERC20(_getConvexTokenAddress()).balanceOf(address(this));
    _swapFunc(_curveTokenAddress, crvBalance);
    _swapFunc(_getConvexTokenAddress(), convexBalance);
  }

  /// @dev calculate the value of the convex rewards in want token.
  ///  It will calculate how many CVX tokens can be claimed based on the _crv amount and then swap them to want
  function _convexRewardsValue(address _curveTokenAddress, function(address, uint256) view returns (uint256) _quoteFunc)
    internal
    view
    returns (uint256)
  {
    uint256 _crv = IConvexRewards(cvxRewards).earned(address(this));
    if (_crv > 0) {
      // calculations pulled directly from CVX's contract for minting CVX per CRV claimed
      uint256 totalCliffs = 1000;
      uint256 maxSupply = 1e8 * 1e18; // 100m
      uint256 reductionPerCliff = 1e5 * 1e18; // 100k
      uint256 supply = IERC20(_getConvexTokenAddress()).totalSupply();
      uint256 _cvx;

      uint256 cliff = supply / reductionPerCliff;
      // mint if below total cliffs
      if (cliff < totalCliffs) {
        // for reduction% take inverse of current cliff
        uint256 reduction = totalCliffs - cliff;
        // reduce
        _cvx = (_crv * reduction) / totalCliffs;

        // supply cap check
        uint256 amtTillMax = maxSupply - supply;
        if (_cvx > amtTillMax) {
          _cvx = amtTillMax;
        }
      }
      uint256 rewardsValue;

      rewardsValue += _quoteFunc(_curveTokenAddress, _crv);
      if (_cvx > 0) {
        rewardsValue += _quoteFunc(_getConvexTokenAddress(), _cvx);
      }
      return rewardsValue;
    }
    return 0;
  }
}

File 6 of 31 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 7 of 31 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

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

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 8 of 31 : CurveBase.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

import "@openzeppelin/contracts/utils/math/Math.sol";
import "./BaseStrategy.sol";
import "../interfaces/curve/ICurveGauge.sol";
import "../interfaces/curve/ICurveMinter.sol";
import "../interfaces/curve/ICurveRegistry.sol";
import "../interfaces/curve/ICurveDeposit.sol";
import "../interfaces/curve/ICurveAddressProvider.sol";
import "../interfaces/sushiswap/IUniswapV2Router.sol";

/// @dev The base implementation for all Curve strategies. All strategies will add liquidity to a Curve pool (could be a plain or meta pool), and then deposit the LP tokens to the corresponding gauge to earn Curve tokens.
///  When it comes to harvest time, the Curve tokens will be minted and sold, and the profit will be reported and moved back to the vault.
///  The next time when harvest is called again, the profits from previous harvests will be invested again (if they haven't been withdrawn from the vault).
///  The Convex strategies are pretty much the same as the Curve ones, the only different is that the LP tokens are deposited into Convex instead, and it will take rewards from both Curve and Convex.
abstract contract CurveBase is BaseStrategy {
  using SafeERC20 for IERC20;
  using Address for address;

  // The address of the curve address provider. This address will never change is is the recommended way to get the address of their registry.
  // See https://curve.readthedocs.io/registry-address-provider.html#
  address private constant CURVE_ADDRESS_PROVIDER_ADDRESS = 0x0000000022D53366457F9d5E68Ec105046FC4383;
  // Minter contract address will never change either. See https://curve.readthedocs.io/dao-gauges.html#minter
  address private constant CURVE_MINTER_ADDRESS = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0;
  address private constant CRV_TOKEN_ADDRESS = 0xD533a949740bb3306d119CC777fa900bA034cd52;
  address private constant SUSHISWAP_ADDRESS = 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F;
  address private constant UNISWAP_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
  address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

  // Curve token minter
  ICurveMinter public curveMinter;
  // Curve address provider, where we can query for the address of the registry
  ICurveAddressProvider public curveAddressProvider;
  // Curve pool. Can be either a plain pool, or meta pool, or Curve zap depositor (automatically add liquidity to base pool and then meta pool).
  ICurveDeposit public curvePool;
  // The Curve gauge corresponding to the Curve pool
  ICurveGauge public curveGauge;
  // Dex address for token swaps.
  address public dex;
  // Store dex approval status to avoid excessive approvals
  mapping(address => bool) internal dexApprovals;

  /// @param _vault The address of the vault. The underlying token should match the `want` token of the strategy.
  /// @param _proposer The address of the strategy proposer
  /// @param _developer The address of the strategy developer
  /// @param _keeper The address of the keeper of the strategy.
  /// @param _pool The address of the Curve pool
  constructor(
    address _vault,
    address _proposer,
    address _developer,
    address _keeper,
    address _pool
  ) BaseStrategy(_vault, _proposer, _developer, _keeper) {
    require(_pool != address(0), "invalid pool address");
    minReportDelay = 43_200; // 12hr
    maxReportDelay = 259_200; // 72hr
    profitFactor = 1000;
    debtThreshold = 1e24;
    dex = SUSHISWAP_ADDRESS;
    _initCurvePool(_pool);
    _approveOnInit();
  }

  /// @notice Approves pools/dexes to be spenders of the tokens of this strategy
  function approveAll() external onlyAuthorized {
    _approveBasic();
    _approveDex();
  }

  /// @notice Changes the dex to use when swap tokens
  /// @param _isUniswap If true, uses Uniswap, otherwise uses Sushiswap
  function switchDex(bool _isUniswap) external onlyAuthorized {
    if (_isUniswap) {
      dex = UNISWAP_ADDRESS;
    } else {
      dex = SUSHISWAP_ADDRESS;
    }
    _approveDex();
  }

  /// @notice Returns the total value of assets in want tokens
  /// @dev it should include the current balance of want tokens, the assets that are deployed and value of rewards so far
  function estimatedTotalAssets() public view virtual override returns (uint256) {
    return _balanceOfWant() + _balanceOfPool() + _balanceOfRewards();
  }

  /// @dev Before migration, we will claim all rewards and remove all liquidity.
  function prepareMigration(address) internal override {
    // mint all the CRV tokens
    _claimRewards();
    _removeLiquidity(_getLpTokenBalance());
  }

  // solhint-disable-next-line no-unused-vars
  /// @dev This will perform the actual invest steps.
  ///   For both Curve & Convex, it will add liquidity to Curve pool(s) first, and then deposit the LP tokens to either Curve gauges or Convex booster.
  function adjustPosition(uint256) internal virtual override {
    if (emergencyExit) {
      return;
    }
    _addLiquidityToCurvePool();
    _depositLPTokens();
  }

  /// @dev This will claim the rewards from either Curve or Convex, swap them to want tokens and calculate the profit/loss.
  function prepareReturn(uint256 _debtOutstanding)
    internal
    virtual
    override
    returns (
      uint256 _profit,
      uint256 _loss,
      uint256 _debtPayment
    )
  {
    uint256 wantBefore = _balanceOfWant();
    _claimRewards();
    uint256 wantNow = _balanceOfWant();
    _profit = wantNow - wantBefore;

    uint256 _total = estimatedTotalAssets();
    uint256 _debt = IVault(vault).strategy(address(this)).totalDebt;

    if (_total < _debt) {
      _loss = _debt - _total;
      _profit = 0;
    }

    if (_debtOutstanding > 0) {
      _withdrawSome(_debtOutstanding);
      _debtPayment = Math.min(_debtOutstanding, _balanceOfWant() - _profit);
    }
  }

  /// @dev Liquidates the positions from either Curve or Convex.
  function liquidatePosition(uint256 _amountNeeded)
    internal
    virtual
    override
    returns (uint256 _liquidatedAmount, uint256 _loss)
  {
    // cash out all the rewards first
    _claimRewards();
    uint256 _balance = _balanceOfWant();
    if (_balance < _amountNeeded) {
      _liquidatedAmount = _withdrawSome(_amountNeeded - _balance);
      _liquidatedAmount = _liquidatedAmount + _balance;
      _loss = _amountNeeded - _liquidatedAmount; // this should be 0. o/w there must be an error
    } else {
      _liquidatedAmount = _amountNeeded;
    }
  }

  function protectedTokens() internal view virtual override returns (address[] memory) {
    address[] memory protected = new address[](2);
    protected[0] = _getCurveTokenAddress();
    protected[1] = curveGauge.lp_token();
    return protected;
  }

  /// @dev Can be used to perform some actions by the strategy, before the rewards are claimed (like call the checkpoint to update user rewards).
  function onHarvest() internal virtual override {
    // make sure the claimable rewards record is up to date
    curveGauge.user_checkpoint(address(this));
  }

  /// @dev Initialises the state variables. Put them in a function to allow for testing. Testing contracts can override these.
  function _initCurvePool(address _pool) internal virtual {
    curveAddressProvider = ICurveAddressProvider(CURVE_ADDRESS_PROVIDER_ADDRESS);
    curveMinter = ICurveMinter(CURVE_MINTER_ADDRESS);
    curvePool = ICurveDeposit(_pool);
    curveGauge = ICurveGauge(_getCurvePoolGaugeAddress());
  }

  function _approveOnInit() internal virtual {
    _approveBasic();
    _approveDex();
  }

  /// @dev Returns the balance of the `want` token.
  function _balanceOfWant() internal view returns (uint256) {
    return want.balanceOf(address(this));
  }

  /// @dev Returns total liquidity provided to Curve pools.
  ///  Can be overridden if the strategy has a different way to get the value of the pool.
  function _balanceOfPool() internal view virtual returns (uint256) {
    uint256 lpTokenAmount = _getLpTokenBalance();
    if (lpTokenAmount > 0) {
      uint256 outputAmount = curvePool.calc_withdraw_one_coin(lpTokenAmount, _int128(_getWantTokenIndex()));
      return outputAmount;
    }
    return 0;
  }

  /// @dev Returns the estimated value of the unclaimed rewards.
  function _balanceOfRewards() internal view virtual returns (uint256) {
    uint256 totalClaimableCRV = curveGauge.integrate_fraction(address(this));
    uint256 mintedCRV = curveMinter.minted(address(this), address(curveGauge));
    uint256 remainingCRV = totalClaimableCRV - mintedCRV;

    if (remainingCRV > 0) {
      return _getQuoteForTokenToWant(_getCurveTokenAddress(), remainingCRV);
    }
    return 0;
  }

  /// @dev Swaps the `_from` token to the want token using either Uniswap or Sushiswap
  function _swapToWant(address _from, uint256 _fromAmount) internal virtual returns (uint256) {
    if (_fromAmount > 0) {
      address[] memory path;
      if (address(want) == _getWETHTokenAddress()) {
        path = new address[](2);
        path[0] = _from;
        path[1] = address(want);
      } else {
        path = new address[](3);
        path[0] = _from;
        path[1] = address(_getWETHTokenAddress());
        path[2] = address(want);
      }
      /* solhint-disable  not-rely-on-time */
      uint256[] memory amountOut = IUniswapV2Router(dex).swapExactTokensForTokens(
        _fromAmount,
        uint256(0),
        path,
        address(this),
        block.timestamp
      );
      /* solhint-enable */
      return amountOut[path.length - 1];
    }
    return 0;
  }

  /// @dev Deposits the LP tokens to Curve gauge.
  function _depositLPTokens() internal virtual {
    address poolLPToken = curveGauge.lp_token();
    uint256 balance = IERC20(poolLPToken).balanceOf(address(this));
    if (balance > 0) {
      curveGauge.deposit(balance);
    }
  }

  /// @dev Withdraws the given amount of want tokens from the Curve pools.
  /// @param _amount The amount of *want* tokens (not LP token).
  function _withdrawSome(uint256 _amount) internal virtual returns (uint256) {
    uint256 requiredLPTokenAmount;
    // check how many LP tokens we will need for the given want _amount
    // not great, but can't find a better way to define the params dynamically based on the coins count
    if (_getCoinsCount() == 2) {
      uint256[2] memory params;
      params[_getWantTokenIndex()] = _amount;
      requiredLPTokenAmount = (curvePool.calc_token_amount(params, true) * 10200) / 10000; // adding 2% padding
    } else if (_getCoinsCount() == 3) {
      uint256[3] memory params;
      params[_getWantTokenIndex()] = _amount;
      requiredLPTokenAmount = (curvePool.calc_token_amount(params, true) * 10200) / 10000; // adding 2% padding
    } else if (_getCoinsCount() == 4) {
      uint256[4] memory params;
      params[_getWantTokenIndex()] = _amount;
      requiredLPTokenAmount = (curvePool.calc_token_amount(params, true) * 10200) / 10000; // adding 2% padding
    } else {
      revert("Invalid number of LP tokens");
    }
    // decide how many LP tokens we can actually withdraw
    return _removeLiquidity(requiredLPTokenAmount);
  }

  /// @dev Removes the liquidity by the LP token amount
  /// @param _amount The amount of LP token (not want token)
  function _removeLiquidity(uint256 _amount) internal virtual returns (uint256) {
    uint256 balance = _getLpTokenBalance();
    uint256 withdrawAmount = Math.min(_amount, balance);
    // withdraw this amount of token from the gauge first
    _removeLpToken(withdrawAmount);
    // then remove the liqudity from the pool, will get eth back
    uint256 amount = curvePool.remove_liquidity_one_coin(withdrawAmount, _int128(_getWantTokenIndex()), 0);
    return amount;
  }

  /// @dev Returns the total amount of Curve LP tokens the strategy has
  function _getLpTokenBalance() internal view virtual returns (uint256) {
    return curveGauge.balanceOf(address(this));
  }

  /// @dev Withdraws the given amount of LP tokens from Curve gauge
  /// @param _amount The amount of LP tokens to withdraw
  function _removeLpToken(uint256 _amount) internal virtual {
    curveGauge.withdraw(_amount);
  }

  /// @dev Claims the curve rewards tokens and swap them to want tokens
  function _claimRewards() internal virtual {
    curveMinter.mint(address(curveGauge));
    uint256 crvBalance = IERC20(_getCurveTokenAddress()).balanceOf(address(this));
    _swapToWant(_getCurveTokenAddress(), crvBalance);
  }

  /// @dev Returns the address of the pool LP token. Use a function to allow override in sub contracts to allow for unit testing.
  function _getPoolLPTokenAddress(address _pool) internal virtual returns (address) {
    require(_pool != address(0), "invalid pool address");
    address registry = curveAddressProvider.get_registry();
    return ICurveRegistry(registry).get_lp_token(address(_pool));
  }

  /// @dev Returns the address of the curve gauge. It will use the Curve registry to look up the gauge for a Curve pool.
  ///  Use a function to allow override in sub contracts to allow for unit testing.
  function _getCurvePoolGaugeAddress() internal view virtual returns (address) {
    address registry = curveAddressProvider.get_registry();
    (address[10] memory gauges, ) = ICurveRegistry(registry).get_gauges(address(curvePool));
    // This only usese the first gauge of the pool. Should be enough for most cases, however, if this is not the case, then this method should be overriden

    return gauges[0];
  }

  /// @dev Returns the address of the Curve token. Use a function to allow override in sub contracts to allow for unit testing.
  function _getCurveTokenAddress() internal view virtual returns (address) {
    return CRV_TOKEN_ADDRESS;
  }

  /// @dev Returns the address of the WETH token. Use a function to allow override in sub contracts to allow for unit testing.
  function _getWETHTokenAddress() internal view virtual returns (address) {
    return WETH_ADDRESS;
  }

  /// @dev Gets an estimate value in want token for the given amount of given token using the dex.
  function _getQuoteForTokenToWant(address _from, uint256 _fromAmount) internal view virtual returns (uint256) {
    if (_fromAmount > 0) {
      address[] memory path;
      if (address(want) == _getWETHTokenAddress()) {
        path = new address[](2);
        path[0] = _from;
        path[1] = address(want);
      } else {
        path = new address[](3);
        path[0] = _from;
        path[1] = address(_getWETHTokenAddress());
        path[2] = address(want);
      }
      uint256[] memory amountOut = IUniswapV2Router(dex).getAmountsOut(_fromAmount, path);
      return amountOut[path.length - 1];
    }
    return 0;
  }

  /// @dev Approves Curve pools/gauges/rewards contracts to access the tokens in the strategy
  function _approveBasic() internal virtual {
    IERC20(curveGauge.lp_token()).safeApprove(address(curveGauge), type(uint256).max);
  }

  /// @dev Approves dex to access tokens in the strategy for swaps
  function _approveDex() internal virtual {
    if (!dexApprovals[dex]) {
      dexApprovals[dex] = true;
      IERC20(_getCurveTokenAddress()).safeApprove(dex, type(uint256).max);
    }
  }

  // does not deal with over/under flow
  function _int128(uint256 _val) internal pure returns (int128) {
    return int128(uint128(_val));
  }

  /// @dev This needs to be overridden by the concrete strategyto implement how liquidity will be added to Curve pools
  function _addLiquidityToCurvePool() internal virtual;

  /// @dev Returns the index of the want token for a Curve pool
  function _getWantTokenIndex() internal view virtual returns (uint256);

  /// @dev Returns the total number of coins the Curve pool supports
  function _getCoinsCount() internal view virtual returns (uint256);
}

File 9 of 31 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

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

File 10 of 31 : BaseStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "../interfaces/IVault.sol";
import "../interfaces/IStrategy.sol";

/**
 *
 * @notice
 *  BaseStrategy implements all of the required functionality to interoperate
 *  closely with the Vault contract. This contract should be inherited and the
 *  abstract methods implemented to adapt the Strategy to the particular needs
 *  it has to create a return.
 *
 *  Of special interest is the relationship between `harvest()` and
 *  `vault.report()'. `harvest()` may be called simply because enough time has
 *  elapsed since the last report, and not because any funds need to be moved
 *  or positions adjusted. This is critical so that the Vault may maintain an
 *  accurate picture of the Strategy's performance. See  `vault.report()`,
 *  `harvest()`, and `harvestTrigger()` for further details.
 */

abstract contract BaseStrategy is IStrategy, ERC165 {
  using SafeMath for uint256;
  using SafeERC20 for IERC20;
  string public metadataURI;

  /**
   * @notice
   *  Used to track which version of `StrategyAPI` this Strategy
   *  implements.
   * @dev The Strategy's version must match the Vault's `API_VERSION`.
   * @return A string which holds the current API version of this contract.
   */
  function apiVersion() public pure returns (string memory) {
    return "0.0.1";
  }

  /**
   * @notice This Strategy's name.
   * @dev
   *  You can use this field to manage the "version" of this Strategy, e.g.
   *  `StrategySomethingOrOtherV1`. However, "API Version" is managed by
   *  `apiVersion()` function above.
   * @return This Strategy's name.
   */
  function name() external view virtual returns (string memory);

  /**
   * @notice
   *  The amount (priced in want) of the total assets managed by this strategy should not count
   *  towards Yearn's TVL calculations.
   * @dev
   *  You can override this field to set it to a non-zero value if some of the assets of this
   *  Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault.
   *  Note that this value must be strictly less than or equal to the amount provided by
   *  `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets.
   *  Also note that this value is used to determine the total assets under management by this
   *  strategy, for the purposes of computing the management fee in `Vault`
   * @return
   *  The amount of assets this strategy manages that should not be included in Yearn's Total Value
   *  Locked (TVL) calculation across it's ecosystem.
   */
  function delegatedAssets() external view virtual returns (uint256) {
    return 0;
  }

  address public vault;
  address public strategyProposer;
  address public strategyDeveloper;
  address public rewards;
  address public harvester;
  IERC20 public want;

  // So indexers can keep track of this

  event UpdatedStrategyProposer(address strategyProposer);

  event UpdatedStrategyDeveloper(address strategyDeveloper);

  event UpdatedHarvester(address newHarvester);

  event UpdatedVault(address vault);

  event UpdatedMinReportDelay(uint256 delay);

  event UpdatedMaxReportDelay(uint256 delay);

  event UpdatedProfitFactor(uint256 profitFactor);

  event UpdatedDebtThreshold(uint256 debtThreshold);

  event UpdatedMetadataURI(string metadataURI);

  // The minimum number of seconds between harvest calls. See
  // `setMinReportDelay()` for more details.
  uint256 public minReportDelay;

  // The maximum number of seconds between harvest calls. See
  // `setMaxReportDelay()` for more details.
  uint256 public maxReportDelay;

  // The minimum multiple that `callCost` must be above the credit/profit to
  // be "justifiable". See `setProfitFactor()` for more details.
  uint256 public profitFactor;

  // Use this to adjust the threshold at which running a debt causes a
  // harvest trigger. See `setDebtThreshold()` for more details.
  uint256 public debtThreshold;

  // See note on `setEmergencyExit()`.
  bool public emergencyExit;

  // modifiers
  modifier onlyAuthorized() {
    require(
      msg.sender == strategyProposer || msg.sender == strategyDeveloper || msg.sender == governance(),
      "!authorized"
    );
    _;
  }

  modifier onlyStrategist() {
    require(msg.sender == strategyProposer || msg.sender == strategyDeveloper, "!strategist");
    _;
  }

  modifier onlyGovernance() {
    require(msg.sender == governance(), "!authorized");
    _;
  }

  modifier onlyKeepers() {
    require(
      msg.sender == harvester ||
        msg.sender == strategyProposer ||
        msg.sender == strategyDeveloper ||
        msg.sender == governance(),
      "!authorized"
    );
    _;
  }

  constructor(
    address _vault,
    address _strategyProposer,
    address _strategyDeveloper,
    address _harvester
  ) {
    _initialize(_vault, _strategyProposer, _strategyDeveloper, _harvester);
  }

  /**
   * @notice
   *  Initializes the Strategy, this is called only once, when the
   *  contract is deployed.
   * @dev `_vault` should implement `VaultAPI`.
   * @param _vault The address of the Vault responsible for this Strategy.
   */
  function _initialize(
    address _vault,
    address _strategyProposer,
    address _strategyDeveloper,
    address _harvester
  ) internal {
    require(address(want) == address(0), "Strategy already initialized");

    vault = _vault;
    want = IERC20(IVault(vault).token());
    checkWantToken();
    want.safeApprove(_vault, type(uint256).max); // Give Vault unlimited access (might save gas)
    strategyProposer = _strategyProposer;
    strategyDeveloper = _strategyDeveloper;
    harvester = _harvester;

    // initialize variables
    minReportDelay = 0;
    maxReportDelay = 86400;
    profitFactor = 100;
    debtThreshold = 0;
  }

  /**
   * @notice
   *  Used to change `_strategyProposer`.
   *
   *  This may only be called by governance or the existing strategist.
   * @param _strategyProposer The new address to assign as `strategist`.
   */
  function setStrategyProposer(address _strategyProposer) external onlyAuthorized {
    require(_strategyProposer != address(0), "! address 0");
    strategyProposer = _strategyProposer;
    emit UpdatedStrategyProposer(_strategyProposer);
  }

  function setStrategyDeveloper(address _strategyDeveloper) external onlyAuthorized {
    require(_strategyDeveloper != address(0), "! address 0");
    strategyDeveloper = _strategyDeveloper;
    emit UpdatedStrategyDeveloper(_strategyDeveloper);
  }

  /**
   * @notice
   *  Used to change `harvester`.
   *
   *  `harvester` is the only address that may call `tend()` or `harvest()`,
   *  other than `governance()` or `strategist`. However, unlike
   *  `governance()` or `strategist`, `harvester` may *only* call `tend()`
   *  and `harvest()`, and no other authorized functions, following the
   *  principle of least privilege.
   *
   *  This may only be called by governance or the strategist.
   * @param _harvester The new address to assign as `keeper`.
   */
  function setHarvester(address _harvester) external onlyAuthorized {
    require(_harvester != address(0), "! address 0");
    harvester = _harvester;
    emit UpdatedHarvester(_harvester);
  }

  function setVault(address _vault) external onlyAuthorized {
    require(_vault != address(0), "! address 0");
    vault = _vault;
    emit UpdatedVault(_vault);
  }

  /**
   * @notice
   *  Used to change `minReportDelay`. `minReportDelay` is the minimum number
   *  of blocks that should pass for `harvest()` to be called.
   *
   *  For external keepers (such as the Keep3r network), this is the minimum
   *  time between jobs to wait. (see `harvestTrigger()`
   *  for more details.)
   *
   *  This may only be called by governance or the strategist.
   * @param _delay The minimum number of seconds to wait between harvests.
   */
  function setMinReportDelay(uint256 _delay) external onlyAuthorized {
    minReportDelay = _delay;
    emit UpdatedMinReportDelay(_delay);
  }

  /**
   * @notice
   *  Used to change `maxReportDelay`. `maxReportDelay` is the maximum number
   *  of blocks that should pass for `harvest()` to be called.
   *
   *  For external keepers (such as the Keep3r network), this is the maximum
   *  time between jobs to wait. (see `harvestTrigger()`
   *  for more details.)
   *
   *  This may only be called by governance or the strategist.
   * @param _delay The maximum number of seconds to wait between harvests.
   */
  function setMaxReportDelay(uint256 _delay) external onlyAuthorized {
    maxReportDelay = _delay;
    emit UpdatedMaxReportDelay(_delay);
  }

  /**
   * @notice
   *  Used to change `profitFactor`. `profitFactor` is used to determine
   *  if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()`
   *  for more details.)
   *
   *  This may only be called by governance or the strategist.
   * @param _profitFactor A ratio to multiply anticipated
   * `harvest()` gas cost against.
   */
  function setProfitFactor(uint256 _profitFactor) external onlyAuthorized {
    profitFactor = _profitFactor;
    emit UpdatedProfitFactor(_profitFactor);
  }

  /**
   * @notice
   *  Sets how far the Strategy can go into loss without a harvest and report
   *  being required.
   *
   *  By default this is 0, meaning any losses would cause a harvest which
   *  will subsequently report the loss to the Vault for tracking. (See
   *  `harvestTrigger()` for more details.)
   *
   *  This may only be called by governance or the strategist.
   * @param _debtThreshold How big of a loss this Strategy may carry without
   * being required to report to the Vault.
   */
  function setDebtThreshold(uint256 _debtThreshold) external onlyAuthorized {
    debtThreshold = _debtThreshold;
    emit UpdatedDebtThreshold(_debtThreshold);
  }

  /**
   * @notice
   *  Used to change `metadataURI`. `metadataURI` is used to store the URI
   * of the file describing the strategy.
   *
   *  This may only be called by governance or the strategist.
   * @param _metadataURI The URI that describe the strategy.
   */
  function setMetadataURI(string calldata _metadataURI) external onlyAuthorized {
    metadataURI = _metadataURI;
    emit UpdatedMetadataURI(_metadataURI);
  }

  /**
   * Resolve governance address from Vault contract, used to make assertions
   * on protected functions in the Strategy.
   */
  function governance() internal view returns (address) {
    return IVault(vault).governance();
  }

  /**
   * @notice
   *  Provide an accurate estimate for the total amount of assets
   *  (principle + return) that this Strategy is currently managing,
   *  denominated in terms of `want` tokens.
   *
   *  This total should be "realizable" e.g. the total value that could
   *  *actually* be obtained from this Strategy if it were to divest its
   *  entire position based on current on-chain conditions.
   * @dev
   *  Care must be taken in using this function, since it relies on external
   *  systems, which could be manipulated by the attacker to give an inflated
   *  (or reduced) value produced by this function, based on current on-chain
   *  conditions (e.g. this function is possible to influence through
   *  flashloan attacks, oracle manipulations, or other DeFi attack
   *  mechanisms).
   *
   *  It is up to governance to use this function to correctly order this
   *  Strategy relative to its peers in the withdrawal queue to minimize
   *  losses for the Vault based on sudden withdrawals. This value should be
   *  higher than the total debt of the Strategy and higher than its expected
   *  value to be "safe".
   * @return The estimated total assets in this Strategy.
   */
  function estimatedTotalAssets() public view virtual returns (uint256);

  /*
   * @notice
   *  Provide an indication of whether this strategy is currently "active"
   *  in that it is managing an active position, or will manage a position in
   *  the future. This should correlate to `harvest()` activity, so that Harvest
   *  events can be tracked externally by indexing agents.
   * @return True if the strategy is actively managing a position.
   */
  function isActive() public view returns (bool) {
    return IVault(vault).strategyDebtRatio(address(this)) > 0 || estimatedTotalAssets() > 0;
  }

  /*
   * @notice
   *  Support ERC165 spec to allow other contracts to query if a strategy has implemented IStrategy interface
   */
  function supportsInterface(bytes4 _interfaceId) public view virtual override returns (bool) {
    return _interfaceId == type(IStrategy).interfaceId || super.supportsInterface(_interfaceId);
  }

  /// @notice check the want token to make sure it is the token that the strategy is expecting
  // solhint-disable-next-line no-empty-blocks
  function checkWantToken() internal view virtual {
    // by default this will do nothing. But child strategies can override this and validate the want token
  }

  /**
   * Perform any Strategy unwinding or other calls necessary to capture the
   * "free return" this Strategy has generated since the last time its core
   * position(s) were adjusted. Examples include unwrapping extra rewards.
   * This call is only used during "normal operation" of a Strategy, and
   * should be optimized to minimize losses as much as possible.
   *
   * This method returns any realized profits and/or realized losses
   * incurred, and should return the total amounts of profits/losses/debt
   * payments (in `want` tokens) for the Vault's accounting (e.g.
   * `want.balanceOf(this) >= _debtPayment + _profit - _loss`).
   *
   * `_debtOutstanding` will be 0 if the Strategy is not past the configured
   * debt limit, otherwise its value will be how far past the debt limit
   * the Strategy is. The Strategy's debt limit is configured in the Vault.
   *
   * NOTE: `_debtPayment` should be less than or equal to `_debtOutstanding`.
   *       It is okay for it to be less than `_debtOutstanding`, as that
   *       should only used as a guide for how much is left to pay back.
   *       Payments should be made to minimize loss from slippage, debt,
   *       withdrawal fees, etc.
   *
   * See `vault.debtOutstanding()`.
   */
  function prepareReturn(uint256 _debtOutstanding)
    internal
    virtual
    returns (
      uint256 _profit,
      uint256 _loss,
      uint256 _debtPayment
    );

  /**
   * Perform any adjustments to the core position(s) of this Strategy given
   * what change the Vault made in the "investable capital" available to the
   * Strategy. Note that all "free capital" in the Strategy after the report
   * was made is available for reinvestment. Also note that this number
   * could be 0, and you should handle that scenario accordingly.
   *
   * See comments regarding `_debtOutstanding` on `prepareReturn()`.
   */
  function adjustPosition(uint256 _debtOutstanding) internal virtual;

  /**
   * Liquidate up to `_amountNeeded` of `want` of this strategy's positions,
   * irregardless of slippage. Any excess will be re-invested with `adjustPosition()`.
   * This function should return the amount of `want` tokens made available by the
   * liquidation. If there is a difference between them, `_loss` indicates whether the
   * difference is due to a realized loss, or if there is some other situation at play
   * (e.g. locked funds) where the amount made available is less than what is needed.
   * This function is used during emergency exit instead of `prepareReturn()` to
   * liquidate all of the Strategy's positions back to the Vault.
   *
   * NOTE: The invariant `_liquidatedAmount + _loss <= _amountNeeded` should always be maintained
   */
  function liquidatePosition(uint256 _amountNeeded) internal virtual returns (uint256 _liquidatedAmount, uint256 _loss);

  /**
   * @notice
   *  Provide a signal to the keeper that `tend()` should be called. The
   *  keeper will provide the estimated gas cost that they would pay to call
   *  `tend()`, and this function should use that estimate to make a
   *  determination if calling it is "worth it" for the keeper. This is not
   *  the only consideration into issuing this trigger, for example if the
   *  position would be negatively affected if `tend()` is not called
   *  shortly, then this can return `true` even if the keeper might be
   *  "at a loss" (keepers are always reimbursed by Yearn).
   * @dev
   *  `callCost` must be priced in terms of `want`.
   *
   *  This call and `harvestTrigger()` should never return `true` at the same
   *  time.
   * @return `true` if `tend()` should be called, `false` otherwise.
   */
  // solhint-disable-next-line no-unused-vars
  function tendTrigger(uint256) public view virtual returns (bool) {
    // We usually don't need tend, but if there are positions that need
    // active maintenance, overriding this function is how you would
    // signal for that.
    return false;
  }

  /**
   * @notice
   *  Adjust the Strategy's position. The purpose of tending isn't to
   *  realize gains, but to maximize yield by reinvesting any returns.
   *
   *  See comments on `adjustPosition()`.
   *
   *  This may only be called by governance, the strategist, or the keeper.
   */
  function tend() external onlyKeepers {
    // Don't take profits with this call, but adjust for better gains
    adjustPosition(IVault(vault).debtOutstanding(address(this)));
  }

  /**
   * @notice
   *  Provide a signal to the keeper that `harvest()` should be called. The
   *  keeper will provide the estimated gas cost that they would pay to call
   *  `harvest()`, and this function should use that estimate to make a
   *  determination if calling it is "worth it" for the keeper. This is not
   *  the only consideration into issuing this trigger, for example if the
   *  position would be negatively affected if `harvest()` is not called
   *  shortly, then this can return `true` even if the keeper might be "at a
   *  loss" (keepers are always reimbursed by Yearn).
   * @dev
   *  `callCost` must be priced in terms of `want`.
   *
   *  This call and `tendTrigger` should never return `true` at the
   *  same time.
   *
   *  See `min/maxReportDelay`, `profitFactor`, `debtThreshold` to adjust the
   *  strategist-controlled parameters that will influence whether this call
   *  returns `true` or not. These parameters will be used in conjunction
   *  with the parameters reported to the Vault (see `params`) to determine
   *  if calling `harvest()` is merited.
   *
   *  It is expected that an external system will check `harvestTrigger()`.
   *  This could be a script run off a desktop or cloud bot (e.g.
   *  https://github.com/iearn-finance/yearn-vaults/blob/master/scripts/keep.py),
   *  or via an integration with the Keep3r network (e.g.
   *  https://github.com/Macarse/GenericKeep3rV2/blob/master/contracts/keep3r/GenericKeep3rV2.sol).
   * @param callCost The keeper's estimated cast cost to call `harvest()`.
   * @return `true` if `harvest()` should be called, `false` otherwise.
   */
  function harvestTrigger(uint256 callCost) public view virtual returns (bool) {
    StrategyInfo memory params = IVault(vault).strategy(address(this));

    // Should not trigger if Strategy is not activated
    if (params.activation == 0) return false;

    // Should not trigger if we haven't waited long enough since previous harvest
    if (timestamp().sub(params.lastReport) < minReportDelay) return false;

    // Should trigger if hasn't been called in a while
    if (timestamp().sub(params.lastReport) >= maxReportDelay) return true;

    // If some amount is owed, pay it back
    // NOTE: Since debt is based on deposits, it makes sense to guard against large
    //       changes to the value from triggering a harvest directly through user
    //       behavior. This should ensure reasonable resistance to manipulation
    //       from user-initiated withdrawals as the outstanding debt fluctuates.
    uint256 outstanding = IVault(vault).debtOutstanding(address(this));
    if (outstanding > debtThreshold) return true;

    // Check for profits and losses
    uint256 total = estimatedTotalAssets();
    // Trigger if we have a loss to report
    if (total.add(debtThreshold) < params.totalDebt) return true;

    uint256 profit = 0;
    if (total > params.totalDebt) profit = total.sub(params.totalDebt); // We've earned a profit!

    // Otherwise, only trigger if it "makes sense" economically (gas cost
    // is <N% of value moved)
    uint256 credit = IVault(vault).creditAvailable(address(this));
    return (profitFactor.mul(callCost) < credit.add(profit));
  }

  /**
   * @notice All the strategy to do something when harvest is called.
   */
  // solhint-disable-next-line no-empty-blocks
  function onHarvest() internal virtual {}

  /**
   * @notice
   *  Harvests the Strategy, recognizing any profits or losses and adjusting
   *  the Strategy's position.
   *
   *  In the rare case the Strategy is in emergency shutdown, this will exit
   *  the Strategy's position.
   *
   *  This may only be called by governance, the strategist, or the keeper.
   * @dev
   *  When `harvest()` is called, the Strategy reports to the Vault (via
   *  `vault.report()`), so in some cases `harvest()` must be called in order
   *  to take in profits, to borrow newly available funds from the Vault, or
   *  otherwise adjust its position. In other cases `harvest()` must be
   *  called to report to the Vault on the Strategy's position, especially if
   *  any losses have occurred.
   */
  function harvest() external onlyKeepers {
    uint256 profit = 0;
    uint256 loss = 0;
    uint256 debtOutstanding = IVault(vault).debtOutstanding(address(this));
    uint256 debtPayment = 0;
    onHarvest();
    if (emergencyExit) {
      // Free up as much capital as possible
      uint256 totalAssets = estimatedTotalAssets();
      // NOTE: use the larger of total assets or debt outstanding to book losses properly
      (debtPayment, loss) = liquidatePosition(totalAssets > debtOutstanding ? totalAssets : debtOutstanding);
      // NOTE: take up any remainder here as profit
      if (debtPayment > debtOutstanding) {
        profit = debtPayment.sub(debtOutstanding);
        debtPayment = debtOutstanding;
      }
    } else {
      // Free up returns for Vault to pull
      (profit, loss, debtPayment) = prepareReturn(debtOutstanding);
    }

    // Allow Vault to take up to the "harvested" balance of this contract,
    // which is the amount it has earned since the last time it reported to
    // the Vault.
    debtOutstanding = IVault(vault).report(profit, loss, debtPayment);

    // Check if free returns are left, and re-invest them
    adjustPosition(debtOutstanding);

    emit Harvested(profit, loss, debtPayment, debtOutstanding);
  }

  /**
   * @notice
   *  Withdraws `_amountNeeded` to `vault`.
   *
   *  This may only be called by the Vault.
   * @param _amountNeeded How much `want` to withdraw.
   * @return _loss Any realized losses
   */
  function withdraw(uint256 _amountNeeded) external returns (uint256 _loss) {
    require(msg.sender == address(vault), "!vault");
    // Liquidate as much as possible to `want`, up to `_amountNeeded`
    uint256 amountFreed;
    (amountFreed, _loss) = liquidatePosition(_amountNeeded);
    // Send it directly back (NOTE: Using `msg.sender` saves some gas here)
    want.safeTransfer(msg.sender, amountFreed);
    // NOTE: Reinvest anything leftover on next `tend`/`harvest`
  }

  /**
   * Do anything necessary to prepare this Strategy for migration, such as
   * transferring any reserve or LP tokens, CDPs, or other tokens or stores of
   * value.
   */
  function prepareMigration(address _newStrategy) internal virtual;

  /**
   * @notice
   *  Transfers all `want` from this Strategy to `_newStrategy`.
   *
   *  This may only be called by governance or the Vault.
   * @dev
   *  The new Strategy's Vault must be the same as this Strategy's Vault.
   * @param _newStrategy The Strategy to migrate to.
   */
  function migrate(address _newStrategy) external {
    require(msg.sender == address(vault) || msg.sender == governance(), "!authorised");
    require(BaseStrategy(_newStrategy).vault() == vault, "invalid vault");
    prepareMigration(_newStrategy);
    want.safeTransfer(_newStrategy, want.balanceOf(address(this)));
  }

  /**
   * @notice
   *  Activates emergency exit. Once activated, the Strategy will exit its
   *  position upon the next harvest, depositing all funds into the Vault as
   *  quickly as is reasonable given on-chain conditions.
   *
   *  This may only be called by governance or the strategist.
   * @dev
   *  See `vault.setEmergencyShutdown()` and `harvest()` for further details.
   */
  function setEmergencyExit() external onlyAuthorized {
    emergencyExit = true;
    IVault(vault).revokeStrategy();

    emit EmergencyExitEnabled();
  }

  /**
   * Override this to add all tokens/tokenized positions this contract
   * manages on a *persistent* basis (e.g. not just for swapping back to
   * want ephemerally).
   *
   * NOTE: Do *not* include `want`, already included in `sweep` below.
   *
   * Example:
   *
   *    function protectedTokens() internal override view returns (address[] memory) {
   *      address[] memory protected = new address[](3);
   *      protected[0] = tokenA;
   *      protected[1] = tokenB;
   *      protected[2] = tokenC;
   *      return protected;
   *    }
   */
  function protectedTokens() internal view virtual returns (address[] memory);

  /**
   * @notice
   *  Removes tokens from this Strategy that are not the type of tokens
   *  managed by this Strategy. This may be used in case of accidentally
   *  sending the wrong kind of token to this Strategy.
   *
   *  Tokens will be sent to `governance()`.
   *
   *  This will fail if an attempt is made to sweep `want`, or any tokens
   *  that are protected by this Strategy.
   *
   *  This may only be called by governance.
   * @dev
   *  Implement `protectedTokens()` to specify any additional tokens that
   *  should be protected from sweeping in addition to `want`.
   * @param _token The token to transfer out of this vault.
   */
  function sweep(address _token) external onlyGovernance {
    require(_token != address(want), "!want");
    require(_token != address(vault), "!shares");

    address[] memory _protectedTokens = protectedTokens();
    for (uint256 i; i < _protectedTokens.length; i++) {
      require(_token != _protectedTokens[i], "!protected");
    }

    IERC20(_token).safeTransfer(governance(), IERC20(_token).balanceOf(address(this)));
  }

  function timestamp() internal view virtual returns (uint256) {
    // solhint-disable-next-line not-rely-on-time
    return block.timestamp;
  }
}

File 11 of 31 : ICurveGauge.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

interface ICurveGauge {
  function deposit(uint256 _value) external;

  function integrate_fraction(address arg0) external view returns (uint256);

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

  function claimable_tokens(address arg0) external returns (uint256);

  function withdraw(uint256 _value) external;

  /// @dev The address of the LP token that may be deposited into the gauge.
  function lp_token() external view returns (address);

  function user_checkpoint(address _user) external returns (bool);
}

File 12 of 31 : ICurveMinter.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

// so
interface ICurveMinter {
  function mint(address gauge_addr) external;

  function minted(address arg0, address arg1) external view returns (uint256);
}

File 13 of 31 : ICurveRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

interface ICurveRegistry {
  function get_lp_token(address _pool) external view returns (address);

  function get_gauges(address _pool) external view returns (address[10] memory, address[10] memory);
}

File 14 of 31 : ICurveDeposit.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

interface ICurveDeposit {
  // 3 coin
  function add_liquidity(uint256[1] memory amounts, uint256 min_mint_amount) external;

  function add_liquidity(uint256[2] memory amounts, uint256 min_mint_amount) external payable returns (uint256);

  function add_liquidity(uint256[3] memory amounts, uint256 min_mint_amount) external;

  function add_liquidity(uint256[4] calldata amounts, uint256 min_mint_amount) external;

  function add_liquidity(
    uint256[3] memory amounts,
    uint256 min_mint_amount,
    bool _use_underlying
  ) external;

  function coins(uint256 arg0) external view returns (address);

  function calc_withdraw_one_coin(uint256 _token_amount, int128 i) external view returns (uint256);

  function calc_token_amount(uint256[4] memory amounts, bool is_deposit) external view returns (uint256);

  function calc_token_amount(uint256[3] memory amounts, bool is_deposit) external view returns (uint256);

  function calc_token_amount(uint256[2] memory amounts, bool is_deposit) external view returns (uint256);

  /// @notice Withdraw and unwrap a single coin from the pool
  /// @param _token_amount Amount of LP tokens to burn in the withdrawal
  /// @param i Index value of the coin to withdraw, 0-Dai, 1-USDC, 2-USDT
  /// @param _min_amount Minimum amount of underlying coin to receive
  //
  function remove_liquidity_one_coin(
    uint256 _token_amount,
    int128 i,
    uint256 _min_amount
  ) external returns (uint256);
}

interface ICurveDepositTrio {
  function remove_liquidity_one_coin(
    uint256 _token_amount,
    int128 i,
    uint256 _min_amount
  ) external;
}

File 15 of 31 : ICurveAddressProvider.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

interface ICurveAddressProvider {
  function get_registry() external view returns (address);
}

File 16 of 31 : IUniswapV2Router.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

interface IUniswapV2Router {
  function swapExactTokensForTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
  ) external returns (uint256[] memory amounts);

  function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);

  function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);
}

// interface GeneratedInterface {
//   function WETH() external view returns (address);

//   function addLiquidity(
//     address tokenA,
//     address tokenB,
//     uint256 amountADesired,
//     uint256 amountBDesired,
//     uint256 amountAMin,
//     uint256 amountBMin,
//     address to,
//     uint256 deadline
//   )
//     external
//     returns (
//       uint256 amountA,
//       uint256 amountB,
//       uint256 liquidity
//     );

//   function addLiquidityETH(
//     address token,
//     uint256 amountTokenDesired,
//     uint256 amountTokenMin,
//     uint256 amountETHMin,
//     address to,
//     uint256 deadline
//   )
//     external
//     returns (
//       uint256 amountToken,
//       uint256 amountETH,
//       uint256 liquidity
//     );

//   function factory() external view returns (address);

//   function getAmountIn(
//     uint256 amountOut,
//     uint256 reserveIn,
//     uint256 reserveOut
//   ) external pure returns (uint256 amountIn);

//   function getAmountOut(
//     uint256 amountIn,
//     uint256 reserveIn,
//     uint256 reserveOut
//   ) external pure returns (uint256 amountOut);

//   function getAmountsIn(uint256 amountOut, address[] path) external view returns (uint256[] amounts);

//   function getAmountsOut(uint256 amountIn, address[] path) external view returns (uint256[] amounts);

//   function quote(
//     uint256 amountA,
//     uint256 reserveA,
//     uint256 reserveB
//   ) external pure returns (uint256 amountB);

//   function removeLiquidity(
//     address tokenA,
//     address tokenB,
//     uint256 liquidity,
//     uint256 amountAMin,
//     uint256 amountBMin,
//     address to,
//     uint256 deadline
//   ) external returns (uint256 amountA, uint256 amountB);

//   function removeLiquidityETH(
//     address token,
//     uint256 liquidity,
//     uint256 amountTokenMin,
//     uint256 amountETHMin,
//     address to,
//     uint256 deadline
//   ) external returns (uint256 amountToken, uint256 amountETH);

//   function removeLiquidityETHSupportingFeeOnTransferTokens(
//     address token,
//     uint256 liquidity,
//     uint256 amountTokenMin,
//     uint256 amountETHMin,
//     address to,
//     uint256 deadline
//   ) external returns (uint256 amountETH);

//   function removeLiquidityETHWithPermit(
//     address token,
//     uint256 liquidity,
//     uint256 amountTokenMin,
//     uint256 amountETHMin,
//     address to,
//     uint256 deadline,
//     bool approveMax,
//     uint8 v,
//     bytes32 r,
//     bytes32 s
//   ) external returns (uint256 amountToken, uint256 amountETH);

//   function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
//     address token,
//     uint256 liquidity,
//     uint256 amountTokenMin,
//     uint256 amountETHMin,
//     address to,
//     uint256 deadline,
//     bool approveMax,
//     uint8 v,
//     bytes32 r,
//     bytes32 s
//   ) external returns (uint256 amountETH);

//   function removeLiquidityWithPermit(
//     address tokenA,
//     address tokenB,
//     uint256 liquidity,
//     uint256 amountAMin,
//     uint256 amountBMin,
//     address to,
//     uint256 deadline,
//     bool approveMax,
//     uint8 v,
//     bytes32 r,
//     bytes32 s
//   ) external returns (uint256 amountA, uint256 amountB);

//   function swapETHForExactTokens(
//     uint256 amountOut,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external returns (uint256[] amounts);

//   function swapExactETHForTokens(
//     uint256 amountOutMin,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external returns (uint256[] amounts);

//   function swapExactETHForTokensSupportingFeeOnTransferTokens(
//     uint256 amountOutMin,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external;

//   function swapExactTokensForETH(
//     uint256 amountIn,
//     uint256 amountOutMin,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external returns (uint256[] amounts);

//   function swapExactTokensForETHSupportingFeeOnTransferTokens(
//     uint256 amountIn,
//     uint256 amountOutMin,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external;

//   function swapExactTokensForTokens(
//     uint256 amountIn,
//     uint256 amountOutMin,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external returns (uint256[] amounts);

//   function swapExactTokensForTokensSupportingFeeOnTransferTokens(
//     uint256 amountIn,
//     uint256 amountOutMin,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external;

//   function swapTokensForExactETH(
//     uint256 amountOut,
//     uint256 amountInMax,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external returns (uint256[] amounts);

//   function swapTokensForExactTokens(
//     uint256 amountOut,
//     uint256 amountInMax,
//     address[] path,
//     address to,
//     uint256 deadline
//   ) external returns (uint256[] amounts);
// }

File 17 of 31 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 18 of 31 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 19 of 31 : IVault.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";

struct StrategyInfo {
  uint256 activation;
  uint256 lastReport;
  uint256 totalDebt;
  uint256 totalGain;
  uint256 totalLoss;
}

interface IVault is IERC20, IERC20Permit {
  function name() external view returns (string memory);

  function symbol() external view returns (string memory);

  function decimals() external view returns (uint256);

  function activation() external view returns (uint256);

  function rewards() external view returns (address);

  function managementFee() external view returns (uint256);

  function gatekeeper() external view returns (address);

  function governance() external view returns (address);

  function creator() external view returns (address);

  function strategyDataStore() external view returns (address);

  function healthCheck() external view returns (address);

  function emergencyShutdown() external view returns (bool);

  function lockedProfitDegradation() external view returns (uint256);

  function depositLimit() external view returns (uint256);

  function lastReport() external view returns (uint256);

  function lockedProfit() external view returns (uint256);

  function totalDebt() external view returns (uint256);

  function token() external view returns (address);

  function totalAsset() external view returns (uint256);

  function availableDepositLimit() external view returns (uint256);

  function maxAvailableShares() external view returns (uint256);

  function pricePerShare() external view returns (uint256);

  function debtOutstanding(address _strategy) external view returns (uint256);

  function creditAvailable(address _strategy) external view returns (uint256);

  function expectedReturn(address _strategy) external view returns (uint256);

  function strategy(address _strategy) external view returns (StrategyInfo memory);

  function strategyDebtRatio(address _strategy) external view returns (uint256);

  function setRewards(address _rewards) external;

  function setManagementFee(uint256 _managementFee) external;

  function setGatekeeper(address _gatekeeper) external;

  function setStrategyDataStore(address _strategyDataStoreContract) external;

  function setHealthCheck(address _healthCheck) external;

  function setVaultEmergencyShutdown(bool _active) external;

  function setLockedProfileDegradation(uint256 _degradation) external;

  function setDepositLimit(uint256 _limit) external;

  function sweep(address _token, uint256 _amount) external;

  function addStrategy(address _strategy) external returns (bool);

  function migrateStrategy(address _oldVersion, address _newVersion) external returns (bool);

  function revokeStrategy() external;

  /// @notice deposit the given amount into the vault, and return the number of shares
  function deposit(uint256 _amount, address _recipient) external returns (uint256);

  /// @notice burn the given amount of shares from the vault, and return the number of underlying tokens recovered
  function withdraw(
    uint256 _shares,
    address _recipient,
    uint256 _maxLoss
  ) external returns (uint256);

  function report(
    uint256 _gain,
    uint256 _loss,
    uint256 _debtPayment
  ) external returns (uint256);
}

File 20 of 31 : IStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

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

interface IStrategy {
  // *** Events *** //
  event Harvested(uint256 _profit, uint256 _loss, uint256 _debtPayment, uint256 _debtOutstanding);
  event StrategistUpdated(address _newStrategist);
  event KeeperUpdated(address _newKeeper);
  event MinReportDelayUpdated(uint256 _delay);
  event MaxReportDelayUpdated(uint256 _delay);
  event ProfitFactorUpdated(uint256 _profitFactor);
  event DebtThresholdUpdated(uint256 _debtThreshold);
  event EmergencyExitEnabled();

  // *** The following functions are used by the Vault *** //
  /// @notice returns the address of the token that the strategy wants
  function want() external view returns (IERC20);

  /// @notice the address of the Vault that the strategy belongs to
  function vault() external view returns (address);

  /// @notice if the strategy is active
  function isActive() external view returns (bool);

  /// @notice migrate the strategy to the new one
  function migrate(address _newStrategy) external;

  /// @notice withdraw the amount from the strategy
  function withdraw(uint256 _amount) external returns (uint256);

  /// @notice the amount of total assets managed by this strategy that should not account towards the TVL of the strategy
  function delegatedAssets() external view returns (uint256);

  /// @notice the total assets that the strategy is managing
  function estimatedTotalAssets() external view returns (uint256);

  // *** public read functions that can be called by anyone *** //
  function name() external view returns (string memory);

  function harvester() external view returns (address);

  function strategyProposer() external view returns (address);

  function strategyDeveloper() external view returns (address);

  function tendTrigger(uint256 _callCost) external view returns (bool);

  function harvestTrigger(uint256 _callCost) external view returns (bool);

  // *** write functions that can be called by the governance, the strategist or the keeper *** //
  function tend() external;

  function harvest() external;

  // *** write functions that can be called by the governance or the strategist ***//

  function setHarvester(address _havester) external;

  function setVault(address _vault) external;

  /// @notice `minReportDelay` is the minimum number of blocks that should pass for `harvest()` to be called.
  function setMinReportDelay(uint256 _delay) external;

  function setMaxReportDelay(uint256 _delay) external;

  /// @notice `profitFactor` is used to determine if it's worthwhile to harvest, given gas costs.
  function setProfitFactor(uint256 _profitFactor) external;

  /// @notice Sets how far the Strategy can go into loss without a harvest and report being required.
  function setDebtThreshold(uint256 _debtThreshold) external;

  // *** write functions that can be called by the governance, or the strategist, or the guardian, or the management *** //
  function setEmergencyExit() external;
}

File 21 of 31 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 22 of 31 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 23 of 31 : draft-ERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol)

pragma solidity ^0.8.0;

import "./draft-IERC20Permit.sol";
import "../ERC20.sol";
import "../../../utils/cryptography/draft-EIP712.sol";
import "../../../utils/cryptography/ECDSA.sol";
import "../../../utils/Counters.sol";

/**
 * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * _Available since v3.4._
 */
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
    using Counters for Counters.Counter;

    mapping(address => Counters.Counter) private _nonces;

    // solhint-disable-next-line var-name-mixedcase
    bytes32 private immutable _PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

    /**
     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
     *
     * It's a good idea to use the same `name` that is defined as the ERC20 token name.
     */
    constructor(string memory name) EIP712(name, "1") {}

    /**
     * @dev See {IERC20Permit-permit}.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual override {
        require(block.timestamp <= deadline, "ERC20Permit: expired deadline");

        bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSA.recover(hash, v, r, s);
        require(signer == owner, "ERC20Permit: invalid signature");

        _approve(owner, spender, value);
    }

    /**
     * @dev See {IERC20Permit-nonces}.
     */
    function nonces(address owner) public view virtual override returns (uint256) {
        return _nonces[owner].current();
    }

    /**
     * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view override returns (bytes32) {
        return _domainSeparatorV4();
    }

    /**
     * @dev "Consume a nonce": return the current value and increment.
     *
     * _Available since v4.1._
     */
    function _useNonce(address owner) internal virtual returns (uint256 current) {
        Counters.Counter storage nonce = _nonces[owner];
        current = nonce.current();
        nonce.increment();
    }
}

File 24 of 31 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

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

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

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

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 25 of 31 : draft-EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;
    address private immutable _CACHED_THIS;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}

File 26 of 31 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 27 of 31 : Counters.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 28 of 31 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

File 29 of 31 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 30 of 31 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 31 of 31 : IConvexDeposit.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

interface IConvexDeposit {
  struct PoolInfo {
    address lptoken;
    address token;
    address gauge;
    address crvRewards;
    address stash;
    bool shutdown;
  }

  function poolInfo(uint256)
    external
    view
    returns (
      address,
      address,
      address,
      address,
      address,
      bool
    );

  // deposit lp tokens and stake
  function deposit(
    uint256 _pid,
    uint256 _amount,
    bool _stake
  ) external returns (bool);

  // deposit all lp tokens and stake
  function depositAll(uint256 _pid, bool _stake) external returns (bool);

  function poolLength() external view returns (uint256);

  // withdraw lp tokens
  function withdraw(uint256 _pid, uint256 _amount) external returns (bool);

  // withdraw all lp tokens
  function withdrawAll(uint256 _pid) external returns (bool);

  // claim crv + extra rewards
  function earmarkRewards(uint256 _pid) external returns (bool);

  // claim  rewards on stash (msg.sender == stash)
  function claimRewards(uint256 _pid, address _gauge) external returns (bool);

  // delegate address votes on dao (needs to be voteDelegate)
  function vote(
    uint256 _voteId,
    address _votingAddress,
    bool _support
  ) external returns (bool);

  function voteGaugeWeight(address[] calldata _gauge, uint256[] calldata _weight) external returns (bool);
}

File 32 of 31 : IConvexRewards.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.9;

interface IConvexRewards {
  // strategy's staked balance in the synthetix staking contract
  function balanceOf(address account) external view returns (uint256);

  // read how much claimable CRV a strategy has
  function earned(address account) external view returns (uint256);

  // stake a convex tokenized deposit
  function stake(uint256 _amount) external returns (bool);

  // withdraw to a convex tokenized deposit, probably never need to use this
  function withdraw(uint256 _amount, bool _claim) external returns (bool);

  // withdraw directly to curve LP token, this is what we primarily use
  function withdrawAndUnwrap(uint256 _amount, bool _claim) external returns (bool);

  // claim rewards, with an option to claim extra rewards or not
  function getReward(address _account, bool _claimExtras) external returns (bool);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 30
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_vault","type":"address"},{"internalType":"address","name":"_proposer","type":"address"},{"internalType":"address","name":"_developer","type":"address"},{"internalType":"address","name":"_keeper","type":"address"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"address","name":"_booster","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_debtThreshold","type":"uint256"}],"name":"DebtThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"EmergencyExitEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_profit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_loss","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_debtPayment","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_debtOutstanding","type":"uint256"}],"name":"Harvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_newKeeper","type":"address"}],"name":"KeeperUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_delay","type":"uint256"}],"name":"MaxReportDelayUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_delay","type":"uint256"}],"name":"MinReportDelayUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_profitFactor","type":"uint256"}],"name":"ProfitFactorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_newStrategist","type":"address"}],"name":"StrategistUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"debtThreshold","type":"uint256"}],"name":"UpdatedDebtThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newHarvester","type":"address"}],"name":"UpdatedHarvester","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"delay","type":"uint256"}],"name":"UpdatedMaxReportDelay","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"metadataURI","type":"string"}],"name":"UpdatedMetadataURI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"delay","type":"uint256"}],"name":"UpdatedMinReportDelay","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"profitFactor","type":"uint256"}],"name":"UpdatedProfitFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"strategyDeveloper","type":"address"}],"name":"UpdatedStrategyDeveloper","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"strategyProposer","type":"address"}],"name":"UpdatedStrategyProposer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vault","type":"address"}],"name":"UpdatedVault","type":"event"},{"inputs":[],"name":"apiVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"approveAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"convexBooster","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveAddressProvider","outputs":[{"internalType":"contract ICurveAddressProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveGauge","outputs":[{"internalType":"contract ICurveGauge","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveMinter","outputs":[{"internalType":"contract ICurveMinter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curvePool","outputs":[{"internalType":"contract ICurveDeposit","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cvxRewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"debtThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"delegatedAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyExit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"estimatedTotalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"callCost","type":"uint256"}],"name":"harvestTrigger","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"harvester","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxReportDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metadataURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newStrategy","type":"address"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minReportDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"poolId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"profitFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_debtThreshold","type":"uint256"}],"name":"setDebtThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setEmergencyExit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_harvester","type":"address"}],"name":"setHarvester","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_delay","type":"uint256"}],"name":"setMaxReportDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_metadataURI","type":"string"}],"name":"setMetadataURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_delay","type":"uint256"}],"name":"setMinReportDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_profitFactor","type":"uint256"}],"name":"setProfitFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategyDeveloper","type":"address"}],"name":"setStrategyDeveloper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategyProposer","type":"address"}],"name":"setStrategyProposer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vault","type":"address"}],"name":"setVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"strategyDeveloper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategyProposer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isUniswap","type":"bool"}],"name":"switchDex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tendTrigger","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"want","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountNeeded","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"_loss","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b50604051620043c2380380620043c2833981016040819052620000349162000b59565b6014818787878787848484848484848484620000538484848462000256565b505050506001600160a01b038116620000b35760405162461bcd60e51b815260206004820152601460248201527f696e76616c696420706f6f6c206164647265737300000000000000000000000060448201526064015b60405180910390fd5b61a8c06007556203f4806008556103e860095569d3c21bcecceda1000000600a55600f80546001600160a01b03191673d9e1ce17f2641f24ae83637ab66a2cca9c378b9f1790556200010581620003e8565b6200010f62000488565b50505050506001600160a01b038616151594506200017593505050505760405162461bcd60e51b815260206004820152601760248201527f696e76616c696420626f6f7374657220616464726573730000000000000000006044820152606401620000aa565b6011829055601280546001600160a01b0319166001600160a01b038316908117909155604051631526fe2760e01b815260048101849052631526fe279060240160c06040518083038186803b158015620001ce57600080fd5b505afa158015620001e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000209919062000beb565b5050601380546001600160a01b039283166001600160a01b0319918216179091556014805495909216941693909317909255506200024890506200049e565b505050505050505062000d3c565b6006546001600160a01b031615620002b15760405162461bcd60e51b815260206004820152601c60248201527f537472617465677920616c726561647920696e697469616c697a6564000000006044820152606401620000aa565b600180546001600160a01b0319166001600160a01b03861690811790915560408051637e062a3560e11b8152905163fc0c546a91600480820192602092909190829003018186803b1580156200030657600080fd5b505afa1580156200031b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000341919062000c60565b600680546001600160a01b0319166001600160a01b03929092169190911790556200036b620004cb565b60065462000392906001600160a01b0316856000196200052f602090811b620019a817901c565b600280546001600160a01b039485166001600160a01b0319918216179091556003805493851693821693909317909255600580549190931691161790555060006007819055620151806008556064600955600a55565b600c80546f22d53366457f9d5e68ec105046fc43836001600160a01b031991821617909155600b8054610100600160a81b03191674d061d61a4d941c39e5453435b6345dc261c2fce000179055600d80549091166001600160a01b038316179055620004657311137b10c210b579405c21a07489e28f3c040ab190565b600e80546001600160a01b0319166001600160a01b039290921691909117905550565b620004926200068e565b6200049c6200077b565b565b6012546014546200049c916001600160a01b0391821691166000196200052f602090811b620019a817901c565b6006546001600160a01b0316732260fac5e5542a773aa44fbcfedf7c193bc2c599146200049c5760405162461bcd60e51b81526020600482015260116024820152703bb937b733903b30bab63a103a37b5b2b760791b6044820152606401620000aa565b801580620005bd5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156200058057600080fd5b505afa15801562000595573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005bb919062000c7e565b155b620006315760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401620000aa565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b1790915262000689918591620007a716565b505050565b620006a36200088560201b62001af71760201c565b600d54620006eb906001600160a01b0316600019732260fac5e5542a773aa44fbcfedf7c193bc2c5995b6001600160a01b03166200052f60201b620019a8179092919060201c565b600d54600e5460408051634163183360e11b815290516200049c936001600160a01b0390811693600019939116916382c6306691600480820192602092909190829003018186803b1580156200074057600080fd5b505afa15801562000755573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006cd919062000c60565b62000790620008d360201b62001b8b1760201c565b600f546200049c906001600160a01b031662000945565b600062000803826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620009b060201b62001be7179092919060201c565b80519091501562000689578080602001905181019062000824919062000c98565b620006895760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620000aa565b600e5460408051634163183360e11b815290516200049c926001600160a01b0316916000199183916382c63066916004808301926020929190829003018186803b1580156200074057600080fd5b600f546001600160a01b031660009081526010602052604090205460ff166200049c57600f80546001600160a01b039081166000908152601060205260409020805460ff1916600117905590546200049c9116600019620006cd73d533a949740bb3306d119cc777fa900ba034cd5290565b6001600160a01b03811660009081526015602052604090205460ff16620009ad576001600160a01b0381166000908152601560205260409020805460ff19166001179055620009ad81600019620006cd734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b90565b50565b6060620009c18484600085620009cb565b90505b9392505050565b60608247101562000a2e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620000aa565b843b62000a7e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620000aa565b600080866001600160a01b0316858760405162000a9c919062000ce9565b60006040518083038185875af1925050503d806000811462000adb576040519150601f19603f3d011682016040523d82523d6000602084013e62000ae0565b606091505b50909250905062000af382828662000afe565b979650505050505050565b6060831562000b0f575081620009c4565b82511562000b205782518084602001fd5b8160405162461bcd60e51b8152600401620000aa919062000d07565b80516001600160a01b038116811462000b5457600080fd5b919050565b60008060008060008060c0878903121562000b7357600080fd5b62000b7e8762000b3c565b955062000b8e6020880162000b3c565b945062000b9e6040880162000b3c565b935062000bae6060880162000b3c565b925062000bbe6080880162000b3c565b915062000bce60a0880162000b3c565b90509295509295509295565b8051801515811462000b5457600080fd5b60008060008060008060c0878903121562000c0557600080fd5b62000c108762000b3c565b955062000c206020880162000b3c565b945062000c306040880162000b3c565b935062000c406060880162000b3c565b925062000c506080880162000b3c565b915062000bce60a0880162000bda565b60006020828403121562000c7357600080fd5b620009c48262000b3c565b60006020828403121562000c9157600080fd5b5051919050565b60006020828403121562000cab57600080fd5b620009c48262000bda565b60005b8381101562000cd357818101518382015260200162000cb9565b8381111562000ce3576000848401525b50505050565b6000825162000cfd81846020870162000cb6565b9190910192915050565b602081526000825180602084015262000d2881604085016020870162000cb6565b601f01601f19169190910160400192915050565b6136768062000d4c6000396000f3fe608060405234801561001057600080fd5b506004361061024a5760003560e01c80635641ec031161013c5780639ec5a894116100be5780639ec5a894146104ba578063aa5ccb90146104cd578063be460a24146104e0578063c9c382a6146104f3578063ce5494bb14610506578063d3be98d914610519578063eabe91511461052c578063ed882c2b14610544578063efbb5cb014610557578063f017c92f1461055f578063fbfa77cf14610572578063fcf2d0ad1461058557600080fd5b80635641ec031461040e5780635fcbd2851461041b578063650d18801461042e5780636817031b14610442578063692058c2146104555780636bc5587614610468578063750521f51461047b5780638cdfe1661461048e5780638e6350e21461049757806391397ab41461049e57806395e80c50146104b157600080fd5b806325829410116101d05780632582941014610351578063280718e21461037257806328b7ccf7146103855780632cdacb501461038e5780632e1a7d4d146103a1578063380d0c08146103b457806339a172a8146103bc5780633d6e7388146103cf5780633e0dc34e146103e2578063440368a3146103eb5780634641257d146103f35780634bdaeac1146103fb57600080fd5b806301681a621461024f57806301ffc9a71461026457806303ee438c1461028c57806306fdde03146102a15780630f27701b146102c65780630f969b87146102d957806315de1daa146102ec5780631d12f28b146102ff5780631f1fcd5114610316578063218751b21461033657806322f3e2d414610349575b600080fd5b61026261025d366004613030565b61058d565b005b61027761027236600461304d565b61078b565b60405190151581526020015b60405180910390f35b6102946107c2565b60405161028391906130a7565b604080518082019091526009815268436f6e76657842544360b81b6020820152610294565b6102626102d4366004613030565b610850565b6102626102e73660046130da565b61092e565b6102626102fa366004613030565b6109c5565b610308600a5481565b604051908152602001610283565b600654610329906001600160a01b031681565b60405161028391906130f3565b600d54610329906001600160a01b031681565b610277610a98565b604080518082019091526005815264302e302e3160d81b6020820152610294565b600e54610329906001600160a01b031681565b61030860085481565b601254610329906001600160a01b031681565b6103086103af3660046130da565b610b35565b610262610ba9565b6102626103ca3660046130da565b610c1d565b600c54610329906001600160a01b031681565b61030860115481565b610262610cb4565b610262610db2565b600554610329906001600160a01b031681565b600b546102779060ff1681565b601454610329906001600160a01b031681565b61027761043c3660046130da565b50600090565b610262610450366004613030565b610ff7565b600f54610329906001600160a01b031681565b610262610476366004613115565b6110ca565b610262610489366004613132565b61118f565b61030860095481565b6000610308565b6102626104ac3660046130da565b61123b565b61030860075481565b600454610329906001600160a01b031681565b601354610329906001600160a01b031681565b600354610329906001600160a01b031681565b600254610329906001600160a01b031681565b610262610514366004613030565b6112d2565b610262610527366004613030565b6114a4565b600b546103299061010090046001600160a01b031681565b6102776105523660046130da565b611577565b6103086117ea565b61026261056d3660046130da565b611818565b600154610329906001600160a01b031681565b6102626118af565b610595611c00565b6001600160a01b0316336001600160a01b0316146105ce5760405162461bcd60e51b81526004016105c5906131a3565b60405180910390fd5b6006546001600160a01b03828116911614156106145760405162461bcd60e51b8152602060048201526005602482015264085dd85b9d60da1b60448201526064016105c5565b6001546001600160a01b038281169116141561065c5760405162461bcd60e51b81526020600482015260076024820152662173686172657360c81b60448201526064016105c5565b6000610666611c7d565b905060005b81518110156106ee57818181518110610686576106866131c8565b60200260200101516001600160a01b0316836001600160a01b031614156106dc5760405162461bcd60e51b815260206004820152600a602482015269085c1c9bdd1958dd195960b21b60448201526064016105c5565b806106e6816131f4565b91505061066b565b506107876106fa611c00565b6040516370a0823160e01b81526001600160a01b038516906370a08231906107269030906004016130f3565b60206040518083038186803b15801561073e57600080fd5b505afa158015610752573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610776919061320f565b6001600160a01b0385169190611c8f565b5050565b60006001600160e01b031982166321c7ec7360e01b14806107bc57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080546107cf90613228565b80601f01602080910402602001604051908101604052809291908181526020018280546107fb90613228565b80156108485780601f1061081d57610100808354040283529160200191610848565b820191906000526020600020905b81548152906001019060200180831161082b57829003601f168201915b505050505081565b6002546001600160a01b031633148061087357506003546001600160a01b031633145b806108965750610881611c00565b6001600160a01b0316336001600160a01b0316145b6108b25760405162461bcd60e51b81526004016105c5906131a3565b6001600160a01b0381166108d85760405162461bcd60e51b81526004016105c59061325d565b600280546001600160a01b0319166001600160a01b0383161790556040517f29013865cb0c474979c77a6b7ff64855048e7fd4eaa67ec4b204aff62fce271a906109239083906130f3565b60405180910390a150565b6002546001600160a01b031633148061095157506003546001600160a01b031633145b80610974575061095f611c00565b6001600160a01b0316336001600160a01b0316145b6109905760405162461bcd60e51b81526004016105c5906131a3565b600a8190556040518181527fa68ba126373d04c004c5748c300c9fca12bd444b3d4332e261f3bd2bac4a860090602001610923565b6002546001600160a01b03163314806109e857506003546001600160a01b031633145b80610a0b57506109f6611c00565b6001600160a01b0316336001600160a01b0316145b610a275760405162461bcd60e51b81526004016105c5906131a3565b6001600160a01b038116610a4d5760405162461bcd60e51b81526004016105c59061325d565b600580546001600160a01b0319166001600160a01b0383161790556040517fb5c90d3d3bc19784359b75a11e85c2a5dbbd9df01d168213475cff99ebd9d1ac906109239083906130f3565b6001546040516394abf3e560e01b815260009182916001600160a01b03909116906394abf3e590610acd9030906004016130f3565b60206040518083038186803b158015610ae557600080fd5b505afa158015610af9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1d919061320f565b1180610b3057506000610b2e6117ea565b115b905090565b6001546000906001600160a01b03163314610b7b5760405162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b60448201526064016105c5565b6000610b8683611cae565b600654909350909150610ba3906001600160a01b03163383611c8f565b50919050565b6002546001600160a01b0316331480610bcc57506003546001600160a01b031633145b80610bef5750610bda611c00565b6001600160a01b0316336001600160a01b0316145b610c0b5760405162461bcd60e51b81526004016105c5906131a3565b610c13611d08565b610c1b611d90565b565b6002546001600160a01b0316331480610c4057506003546001600160a01b031633145b80610c635750610c4e611c00565b6001600160a01b0316336001600160a01b0316145b610c7f5760405162461bcd60e51b81526004016105c5906131a3565b60078190556040518181527fbb2c369a0355a34b02ab5fce0643150c87e1c8dfe7c918d465591879f57948b190602001610923565b6005546001600160a01b0316331480610cd757506002546001600160a01b031633145b80610cec57506003546001600160a01b031633145b80610d0f5750610cfa611c00565b6001600160a01b0316336001600160a01b0316145b610d2b5760405162461bcd60e51b81526004016105c5906131a3565b60015460405163bdcf36bb60e01b8152610c1b916001600160a01b03169063bdcf36bb90610d5d9030906004016130f3565b60206040518083038186803b158015610d7557600080fd5b505afa158015610d89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dad919061320f565b611dad565b6005546001600160a01b0316331480610dd557506002546001600160a01b031633145b80610dea57506003546001600160a01b031633145b80610e0d5750610df8611c00565b6001600160a01b0316336001600160a01b0316145b610e295760405162461bcd60e51b81526004016105c5906131a3565b60015460405163bdcf36bb60e01b8152600091829182916001600160a01b03169063bdcf36bb90610e5e9030906004016130f3565b60206040518083038186803b158015610e7657600080fd5b505afa158015610e8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eae919061320f565b90506000600b5460ff1615610f01576000610ec76117ea565b9050610edf838211610ed95783611cae565b81611cae565b9450915082821115610efb57610ef58284611dcb565b94508291505b50610f12565b610f0a82611dd7565b919550935090505b6001546040516328766ebf60e21b81526004810186905260248101859052604481018390526001600160a01b039091169063a1d9bafc90606401602060405180830381600087803b158015610f6657600080fd5b505af1158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e919061320f565b9150610fa982611dad565b6040805185815260208101859052908101829052606081018390527f4c0f499ffe6befa0ca7c826b0916cf87bea98de658013e76938489368d60d5099060800160405180910390a150505050565b6002546001600160a01b031633148061101a57506003546001600160a01b031633145b8061103d5750611028611c00565b6001600160a01b0316336001600160a01b0316145b6110595760405162461bcd60e51b81526004016105c5906131a3565b6001600160a01b03811661107f5760405162461bcd60e51b81526004016105c59061325d565b600180546001600160a01b0319166001600160a01b0383161790556040517f6f558b65df41ac351cf689106e82861fcd8565c6e5826e57870ddfa645c6f365906109239083906130f3565b6002546001600160a01b03163314806110ed57506003546001600160a01b031633145b8061111057506110fb611c00565b6001600160a01b0316336001600160a01b0316145b61112c5760405162461bcd60e51b81526004016105c5906131a3565b801561115d57600f80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d179055611184565b600f80546001600160a01b03191673d9e1ce17f2641f24ae83637ab66a2cca9c378b9f1790555b61118c611d90565b50565b6002546001600160a01b03163314806111b257506003546001600160a01b031633145b806111d557506111c0611c00565b6001600160a01b0316336001600160a01b0316145b6111f15760405162461bcd60e51b81526004016105c5906131a3565b6111fd60008383612f64565b507f300e67d5a415b6d015a471d9c7b95dd58f3e8290af965e84e0f845de2996dda6828260405161122f929190613282565b60405180910390a15050565b6002546001600160a01b031633148061125e57506003546001600160a01b031633145b80611281575061126c611c00565b6001600160a01b0316336001600160a01b0316145b61129d5760405162461bcd60e51b81526004016105c5906131a3565b60098190556040518181527fd94596337df4c2f0f44d30a7fc5db1c7bb60d9aca4185ed77c6fd96eb45ec29890602001610923565b6001546001600160a01b031633148061130357506112ee611c00565b6001600160a01b0316336001600160a01b0316145b61133d5760405162461bcd60e51b815260206004820152600b60248201526a08585d5d1a1bdc9a5cd95960aa1b60448201526064016105c5565b6001546040805163fbfa77cf60e01b815290516001600160a01b039283169284169163fbfa77cf916004808301926020929190829003018186803b15801561138457600080fd5b505afa158015611398573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bc91906132b1565b6001600160a01b0316146114025760405162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59081d985d5b1d609a1b60448201526064016105c5565b61140b81611ef0565b6006546040516370a0823160e01b815261118c9183916001600160a01b03909116906370a08231906114419030906004016130f3565b60206040518083038186803b15801561145957600080fd5b505afa15801561146d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611491919061320f565b6006546001600160a01b03169190611c8f565b6002546001600160a01b03163314806114c757506003546001600160a01b031633145b806114ea57506114d5611c00565b6001600160a01b0316336001600160a01b0316145b6115065760405162461bcd60e51b81526004016105c5906131a3565b6001600160a01b03811661152c5760405162461bcd60e51b81526004016105c59061325d565b600380546001600160a01b0319166001600160a01b0383161790556040517f7baa8662db9e306c9d709f736b79600a01c095653fa62032ab0fe926ade5eb5d906109239083906130f3565b60015460405163228bfd9f60e01b815260009182916001600160a01b039091169063228bfd9f906115ac9030906004016130f3565b60a06040518083038186803b1580156115c457600080fd5b505afa1580156115d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115fc9190613314565b805190915061160e5750600092915050565b60075461162682602001516116204290565b90611dcb565b10156116355750600092915050565b60085461164782602001516116204290565b106116555750600192915050565b60015460405163bdcf36bb60e01b81526000916001600160a01b03169063bdcf36bb906116869030906004016130f3565b60206040518083038186803b15801561169e57600080fd5b505afa1580156116b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d6919061320f565b9050600a548111156116ec575060019392505050565b60006116f66117ea565b90508260400151611712600a5483611f0890919063ffffffff16565b101561172357506001949350505050565b60008360400151821115611744576040840151611741908390611dcb565b90505b60015460405163d764801360e01b81526000916001600160a01b03169063d7648013906117759030906004016130f3565b60206040518083038186803b15801561178d57600080fd5b505afa1580156117a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c5919061320f565b90506117d18183611f08565b6009546117de9089611f14565b10979650505050505050565b60006117f4611f20565b6117fc611f35565b611804611fde565b61180e9190613383565b610b309190613383565b6002546001600160a01b031633148061183b57506003546001600160a01b031633145b8061185e5750611849611c00565b6001600160a01b0316336001600160a01b0316145b61187a5760405162461bcd60e51b81526004016105c5906131a3565b60088190556040518181527f5430e11864ad7aa9775b07d12657fe52df9aa2ba734355bd8ef8747be2c800c590602001610923565b6002546001600160a01b03163314806118d257506003546001600160a01b031633145b806118f557506118e0611c00565b6001600160a01b0316336001600160a01b0316145b6119115760405162461bcd60e51b81526004016105c5906131a3565b600b805460ff19166001908117909155546040805163507257cd60e11b815290516001600160a01b039092169163a0e4af9a9160048082019260009290919082900301818387803b15801561196557600080fd5b505af1158015611979573d6000803e3d6000fd5b50506040517f97e963041e952738788b9d4871d854d282065b8f90a464928d6528f2e9a4fd0b925060009150a1565b801580611a315750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156119f757600080fd5b505afa158015611a0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a2f919061320f565b155b611a9c5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016105c5565b611af28363095ea7b360e01b8484604051602401611abb92919061339b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261205f565b505050565b600e5460408051634163183360e11b81529051610c1b926001600160a01b0316916000199183916382c63066916004808301926020929190829003018186803b158015611b4357600080fd5b505afa158015611b57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b7b91906132b1565b6001600160a01b031691906119a8565b600f546001600160a01b031660009081526010602052604090205460ff16610c1b57600f80546001600160a01b039081166000908152601060205260409020805460ff191660011790559054610c1b9116600019611b7b612131565b6060611bf68484600085612149565b90505b9392505050565b60015460408051635aa6e67560e01b815290516000926001600160a01b031691635aa6e675916004808301926020929190829003018186803b158015611c4557600080fd5b505afa158015611c59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3091906132b1565b6060610b30611c8a612131565b612271565b611af28363a9059cbb60e01b8484604051602401611abb92919061339b565b600080611cb9612335565b6000611cc3611fde565b905083811015611cfe57611cdf611cda82866133b4565b612348565b9250611ceb8184613383565b9250611cf783856133b4565b9150611d02565b8392505b50915091565b611d10611af7565b600d54611d3d906001600160a01b0316600019732260fac5e5542a773aa44fbcfedf7c193bc2c599611b7b565b600d54600e5460408051634163183360e11b81529051610c1b936001600160a01b0390811693600019939116916382c6306691600480820192602092909190829003018186803b158015611b4357600080fd5b611d98611b8b565b600f54610c1b906001600160a01b031661240d565b600b5460ff1615611dbb5750565b611dc361245f565b61118c6124ea565b6000611bf982846133b4565b600080600080611de5611fde565b9050611def612335565b6000611df9611fde565b9050611e0582826133b4565b94506000611e116117ea565b60015460405163228bfd9f60e01b81529192506000916001600160a01b039091169063228bfd9f90611e479030906004016130f3565b60a06040518083038186803b158015611e5f57600080fd5b505afa158015611e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e979190613314565b60400151905080821015611eb657611eaf82826133b4565b9550600096505b8715611ee557611ec588612348565b50611ee28888611ed3611fde565b611edd91906133b4565b6124f2565b94505b505050509193909250565b611ef8612335565b610787611f03612508565b612512565b6000611bf98284613383565b6000611bf982846133cb565b6000610b30611f2d612131565b6125d661280c565b600080611f40612508565b90508015611fd657600d546000906001600160a01b031663cc2b27d78360026040516001600160e01b031960e085901b1681526004810192909252600f0b602482015260440160206040518083038186803b158015611f9e57600080fd5b505afa158015611fb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf9919061320f565b600091505090565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a082319061200f9030906004016130f3565b60206040518083038186803b15801561202757600080fd5b505afa15801561203b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b30919061320f565b60006120b4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611be79092919063ffffffff16565b805190915015611af257808060200190518101906120d291906133ea565b611af25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c5565b73d533a949740bb3306d119cc777fa900ba034cd5290565b6060824710156121aa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105c5565b843b6121f85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c5565b600080866001600160a01b031685876040516122149190613407565b60006040518083038185875af1925050503d8060008114612251576040519150601f19603f3d011682016040523d82523d6000602084013e612256565b606091505b50915091506122668282866129e3565b979650505050505050565b604080516003808252608082019092526060916000919060208201848036833701905050905082816000815181106122ab576122ab6131c8565b60200260200101906001600160a01b031690816001600160a01b0316815250506122d3612a1c565b816001815181106122e6576122e66131c8565b6001600160a01b039283166020918202929092010152601454825191169082906002908110612317576123176131c8565b6001600160a01b039092166020928302919091019091015292915050565b610c1b612340612131565b612a34612c0f565b6000806123be565b60206040518083038186803b15801561236857600080fd5b505afa15801561237c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a0919061320f565b6123ac906127d86133cb565b6123b69190613454565b915050612404565b6123c6612fe8565b838160026020020152600d5460405163cf701ff760e01b8152612710916001600160a01b03169063cf701ff7906123509085906001906004016134ca565b611bf981612512565b6001600160a01b03811660009081526015602052604090205460ff1661118c576001600160a01b0381166000908152601560205260409020805460ff1916600117905561118c81600019611b7b612a1c565b6000612469611fde565b9050801561118c57612479612fe8565b818160026020020152600d5460405162a6cbcd60e21b81526001600160a01b039091169063029b2f34906124b49084906000906004016134e7565b600060405180830381600087803b1580156124ce57600080fd5b505af11580156124e2573d6000803e3d6000fd5b505050505050565b610c1b612dc7565b60008183106125015781611bf9565b5090919050565b6000610b30612eda565b60008061251d612508565b9050600061252b84836124f2565b905061253681612f0b565b600d546000906001600160a01b0316631a4d01d28360026040516001600160e01b031960e085901b1681526004810192909252600f0b602482015260006044820152606401602060405180830381600087803b15801561259557600080fd5b505af11580156125a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125cd919061320f565b95945050505050565b600081156128035760606125e8612f14565b6006546001600160a01b03908116911614156126885760408051600280825260608201835290916020830190803683370190505090508381600081518110612632576126326131c8565b6001600160a01b039283166020918202929092010152600654825191169082906001908110612663576126636131c8565b60200260200101906001600160a01b031690816001600160a01b03168152505061274a565b60408051600380825260808201909252906020820160608036833701905050905083816000815181106126bd576126bd6131c8565b60200260200101906001600160a01b031690816001600160a01b0316815250506126e5612f14565b816001815181106126f8576126f86131c8565b6001600160a01b039283166020918202929092010152600654825191169082906002908110612729576127296131c8565b60200260200101906001600160a01b031690816001600160a01b0316815250505b600f5460405163d06ca61f60e01b81526000916001600160a01b03169063d06ca61f9061277d9087908690600401613546565b60006040518083038186803b15801561279557600080fd5b505afa1580156127a9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526127d1919081019061355f565b905080600183516127e291906133b4565b815181106127f2576127f26131c8565b6020026020010151925050506107bc565b50600092915050565b6013546040516246613160e11b815260009182916001600160a01b0390911690628cc2629061283f9030906004016130f3565b60206040518083038186803b15801561285757600080fd5b505afa15801561286b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061288f919061320f565b905080156129d9576103e86a52b7d2dcc80cd2e400000069152d02c7e14af680000060006128bb612a1c565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156128f357600080fd5b505afa158015612907573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061292b919061320f565b905060008061293a8484613454565b90508581101561298657600061295082886133b4565b90508661295d828a6133cb565b6129679190613454565b9250600061297585886133b4565b905080841115612983578093505b50505b60006129968b898c63ffffffff16565b6129a09082613383565b905082156129ca576129bd6129b3612a1c565b848c63ffffffff16565b6129c79082613383565b90505b97506107bc9650505050505050565b5060009392505050565b606083156129f2575081611bf9565b825115612a025782518084602001fd5b8160405162461bcd60e51b81526004016105c591906130a7565b734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b90565b60008115612803576060612a46612f14565b6006546001600160a01b0390811691161415612ae65760408051600280825260608201835290916020830190803683370190505090508381600081518110612a9057612a906131c8565b6001600160a01b039283166020918202929092010152600654825191169082906001908110612ac157612ac16131c8565b60200260200101906001600160a01b031690816001600160a01b031681525050612ba8565b6040805160038082526080820190925290602082016060803683370190505090508381600081518110612b1b57612b1b6131c8565b60200260200101906001600160a01b031690816001600160a01b031681525050612b43612f14565b81600181518110612b5657612b566131c8565b6001600160a01b039283166020918202929092010152600654825191169082906002908110612b8757612b876131c8565b60200260200101906001600160a01b031690816001600160a01b0316815250505b600f546040516338ed173960e01b81526000916001600160a01b0316906338ed173990612be19087908590879030904290600401613604565b600060405180830381600087803b158015612bfb57600080fd5b505af11580156127a9573d6000803e3d6000fd5b601354604051637050ccd960e01b8152306004820152600160248201526001600160a01b0390911690637050ccd990604401602060405180830381600087803b158015612c5b57600080fd5b505af1158015612c6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9391906133ea565b506040516370a0823160e01b81526000906001600160a01b038416906370a0823190612cc39030906004016130f3565b60206040518083038186803b158015612cdb57600080fd5b505afa158015612cef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d13919061320f565b90506000612d1f612a1c565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401612d4a91906130f3565b60206040518083038186803b158015612d6257600080fd5b505afa158015612d76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d9a919061320f565b9050612daa84838563ffffffff16565b50612dc0612db6612a1c565b828563ffffffff16565b5050505050565b6014546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612df89030906004016130f3565b60206040518083038186803b158015612e1057600080fd5b505afa158015612e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e48919061320f565b9050801561118c5760125460115460405163303acfe760e11b81526004810191909152600160248201526001600160a01b03909116906360759fce906044015b602060405180830381600087803b158015612ea257600080fd5b505af1158015612eb6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078791906133ea565b6013546040516370a0823160e01b81526000916001600160a01b0316906370a082319061200f9030906004016130f3565b61118c81612f2c565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290565b601354604051636197390160e11b815260048101839052600160248201526001600160a01b039091169063c32e720290604401612e88565b828054612f7090613228565b90600052602060002090601f016020900481019282612f925760008555612fd8565b82601f10612fab5782800160ff19823516178555612fd8565b82800160010185558215612fd8579182015b82811115612fd8578235825591602001919060010190612fbd565b50612fe4929150613006565b5090565b60405180608001604052806004906020820280368337509192915050565b5b80821115612fe45760008155600101613007565b6001600160a01b038116811461118c57600080fd5b60006020828403121561304257600080fd5b8135611bf98161301b565b60006020828403121561305f57600080fd5b81356001600160e01b031981168114611bf957600080fd5b60005b8381101561309257818101518382015260200161307a565b838111156130a1576000848401525b50505050565b60208152600082518060208401526130c6816040850160208701613077565b601f01601f19169190910160400192915050565b6000602082840312156130ec57600080fd5b5035919050565b6001600160a01b0391909116815260200190565b801515811461118c57600080fd5b60006020828403121561312757600080fd5b8135611bf981613107565b6000806020838503121561314557600080fd5b82356001600160401b038082111561315c57600080fd5b818501915085601f83011261317057600080fd5b81358181111561317f57600080fd5b86602082850101111561319157600080fd5b60209290920196919550909350505050565b6020808252600b908201526a08585d5d1a1bdc9a5e995960aa1b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415613208576132086131de565b5060010190565b60006020828403121561322157600080fd5b5051919050565b600181811c9082168061323c57607f821691505b60208210811415610ba357634e487b7160e01b600052602260045260246000fd5b6020808252600b908201526a021206164647265737320360ac1b604082015260600190565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6000602082840312156132c357600080fd5b8151611bf98161301b565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561330c5761330c6132ce565b604052919050565b600060a0828403121561332657600080fd5b60405160a081018181106001600160401b0382111715613348576133486132ce565b806040525082518152602083015160208201526040830151604082015260608301516060820152608083015160808201528091505092915050565b60008219821115613396576133966131de565b500190565b6001600160a01b03929092168252602082015260400190565b6000828210156133c6576133c66131de565b500390565b60008160001904831182151516156133e5576133e56131de565b500290565b6000602082840312156133fc57600080fd5b8151611bf981613107565b60008251613419818460208701613077565b9190910192915050565b6002811015613442578151835260209283019290910190600101613423565b50505082151560408301529392505050565b60008261347157634e487b7160e01b600052601260045260246000fd5b500490565b6003811015613495578151835260209283019290910190600101613476565b50505082151560608301529392505050565b8060005b60048110156130a15781518452602093840193909101906001016134ab565b60a081016134d882856134a7565b82151560808301529392505050565b60a081016134f582856134a7565b8260808301529392505050565b600081518084526020808501945080840160005b8381101561353b5781516001600160a01b031687529582019590820190600101613516565b509495945050505050565b828152604060208201526000611bf66040830184613502565b6000602080838503121561357257600080fd5b82516001600160401b038082111561358957600080fd5b818501915085601f83011261359d57600080fd5b8151818111156135af576135af6132ce565b8060051b91506135c08483016132e4565b81815291830184019184810190888411156135da57600080fd5b938501935b838510156135f8578451825293850193908501906135df565b98975050505050505050565b85815284602082015260a06040820152600061362360a0830186613502565b6001600160a01b039490941660608301525060800152939250505056fea2646970667358221220b097b2c1d705897097a5826f9a49055ad6823172d308c73ec1bca20e0929fdb864736f6c63430008090033000000000000000000000000aaeee9f40db7aaf5f4d4514d62b9a046066c47d300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e9cdd67b924a8e82709207373699bb749f8851ce000000000000000000000000d5bcf53e2c81e1991570f33fa881c49eea570c8d000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae31

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061024a5760003560e01c80635641ec031161013c5780639ec5a894116100be5780639ec5a894146104ba578063aa5ccb90146104cd578063be460a24146104e0578063c9c382a6146104f3578063ce5494bb14610506578063d3be98d914610519578063eabe91511461052c578063ed882c2b14610544578063efbb5cb014610557578063f017c92f1461055f578063fbfa77cf14610572578063fcf2d0ad1461058557600080fd5b80635641ec031461040e5780635fcbd2851461041b578063650d18801461042e5780636817031b14610442578063692058c2146104555780636bc5587614610468578063750521f51461047b5780638cdfe1661461048e5780638e6350e21461049757806391397ab41461049e57806395e80c50146104b157600080fd5b806325829410116101d05780632582941014610351578063280718e21461037257806328b7ccf7146103855780632cdacb501461038e5780632e1a7d4d146103a1578063380d0c08146103b457806339a172a8146103bc5780633d6e7388146103cf5780633e0dc34e146103e2578063440368a3146103eb5780634641257d146103f35780634bdaeac1146103fb57600080fd5b806301681a621461024f57806301ffc9a71461026457806303ee438c1461028c57806306fdde03146102a15780630f27701b146102c65780630f969b87146102d957806315de1daa146102ec5780631d12f28b146102ff5780631f1fcd5114610316578063218751b21461033657806322f3e2d414610349575b600080fd5b61026261025d366004613030565b61058d565b005b61027761027236600461304d565b61078b565b60405190151581526020015b60405180910390f35b6102946107c2565b60405161028391906130a7565b604080518082019091526009815268436f6e76657842544360b81b6020820152610294565b6102626102d4366004613030565b610850565b6102626102e73660046130da565b61092e565b6102626102fa366004613030565b6109c5565b610308600a5481565b604051908152602001610283565b600654610329906001600160a01b031681565b60405161028391906130f3565b600d54610329906001600160a01b031681565b610277610a98565b604080518082019091526005815264302e302e3160d81b6020820152610294565b600e54610329906001600160a01b031681565b61030860085481565b601254610329906001600160a01b031681565b6103086103af3660046130da565b610b35565b610262610ba9565b6102626103ca3660046130da565b610c1d565b600c54610329906001600160a01b031681565b61030860115481565b610262610cb4565b610262610db2565b600554610329906001600160a01b031681565b600b546102779060ff1681565b601454610329906001600160a01b031681565b61027761043c3660046130da565b50600090565b610262610450366004613030565b610ff7565b600f54610329906001600160a01b031681565b610262610476366004613115565b6110ca565b610262610489366004613132565b61118f565b61030860095481565b6000610308565b6102626104ac3660046130da565b61123b565b61030860075481565b600454610329906001600160a01b031681565b601354610329906001600160a01b031681565b600354610329906001600160a01b031681565b600254610329906001600160a01b031681565b610262610514366004613030565b6112d2565b610262610527366004613030565b6114a4565b600b546103299061010090046001600160a01b031681565b6102776105523660046130da565b611577565b6103086117ea565b61026261056d3660046130da565b611818565b600154610329906001600160a01b031681565b6102626118af565b610595611c00565b6001600160a01b0316336001600160a01b0316146105ce5760405162461bcd60e51b81526004016105c5906131a3565b60405180910390fd5b6006546001600160a01b03828116911614156106145760405162461bcd60e51b8152602060048201526005602482015264085dd85b9d60da1b60448201526064016105c5565b6001546001600160a01b038281169116141561065c5760405162461bcd60e51b81526020600482015260076024820152662173686172657360c81b60448201526064016105c5565b6000610666611c7d565b905060005b81518110156106ee57818181518110610686576106866131c8565b60200260200101516001600160a01b0316836001600160a01b031614156106dc5760405162461bcd60e51b815260206004820152600a602482015269085c1c9bdd1958dd195960b21b60448201526064016105c5565b806106e6816131f4565b91505061066b565b506107876106fa611c00565b6040516370a0823160e01b81526001600160a01b038516906370a08231906107269030906004016130f3565b60206040518083038186803b15801561073e57600080fd5b505afa158015610752573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610776919061320f565b6001600160a01b0385169190611c8f565b5050565b60006001600160e01b031982166321c7ec7360e01b14806107bc57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080546107cf90613228565b80601f01602080910402602001604051908101604052809291908181526020018280546107fb90613228565b80156108485780601f1061081d57610100808354040283529160200191610848565b820191906000526020600020905b81548152906001019060200180831161082b57829003601f168201915b505050505081565b6002546001600160a01b031633148061087357506003546001600160a01b031633145b806108965750610881611c00565b6001600160a01b0316336001600160a01b0316145b6108b25760405162461bcd60e51b81526004016105c5906131a3565b6001600160a01b0381166108d85760405162461bcd60e51b81526004016105c59061325d565b600280546001600160a01b0319166001600160a01b0383161790556040517f29013865cb0c474979c77a6b7ff64855048e7fd4eaa67ec4b204aff62fce271a906109239083906130f3565b60405180910390a150565b6002546001600160a01b031633148061095157506003546001600160a01b031633145b80610974575061095f611c00565b6001600160a01b0316336001600160a01b0316145b6109905760405162461bcd60e51b81526004016105c5906131a3565b600a8190556040518181527fa68ba126373d04c004c5748c300c9fca12bd444b3d4332e261f3bd2bac4a860090602001610923565b6002546001600160a01b03163314806109e857506003546001600160a01b031633145b80610a0b57506109f6611c00565b6001600160a01b0316336001600160a01b0316145b610a275760405162461bcd60e51b81526004016105c5906131a3565b6001600160a01b038116610a4d5760405162461bcd60e51b81526004016105c59061325d565b600580546001600160a01b0319166001600160a01b0383161790556040517fb5c90d3d3bc19784359b75a11e85c2a5dbbd9df01d168213475cff99ebd9d1ac906109239083906130f3565b6001546040516394abf3e560e01b815260009182916001600160a01b03909116906394abf3e590610acd9030906004016130f3565b60206040518083038186803b158015610ae557600080fd5b505afa158015610af9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1d919061320f565b1180610b3057506000610b2e6117ea565b115b905090565b6001546000906001600160a01b03163314610b7b5760405162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b60448201526064016105c5565b6000610b8683611cae565b600654909350909150610ba3906001600160a01b03163383611c8f565b50919050565b6002546001600160a01b0316331480610bcc57506003546001600160a01b031633145b80610bef5750610bda611c00565b6001600160a01b0316336001600160a01b0316145b610c0b5760405162461bcd60e51b81526004016105c5906131a3565b610c13611d08565b610c1b611d90565b565b6002546001600160a01b0316331480610c4057506003546001600160a01b031633145b80610c635750610c4e611c00565b6001600160a01b0316336001600160a01b0316145b610c7f5760405162461bcd60e51b81526004016105c5906131a3565b60078190556040518181527fbb2c369a0355a34b02ab5fce0643150c87e1c8dfe7c918d465591879f57948b190602001610923565b6005546001600160a01b0316331480610cd757506002546001600160a01b031633145b80610cec57506003546001600160a01b031633145b80610d0f5750610cfa611c00565b6001600160a01b0316336001600160a01b0316145b610d2b5760405162461bcd60e51b81526004016105c5906131a3565b60015460405163bdcf36bb60e01b8152610c1b916001600160a01b03169063bdcf36bb90610d5d9030906004016130f3565b60206040518083038186803b158015610d7557600080fd5b505afa158015610d89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dad919061320f565b611dad565b6005546001600160a01b0316331480610dd557506002546001600160a01b031633145b80610dea57506003546001600160a01b031633145b80610e0d5750610df8611c00565b6001600160a01b0316336001600160a01b0316145b610e295760405162461bcd60e51b81526004016105c5906131a3565b60015460405163bdcf36bb60e01b8152600091829182916001600160a01b03169063bdcf36bb90610e5e9030906004016130f3565b60206040518083038186803b158015610e7657600080fd5b505afa158015610e8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eae919061320f565b90506000600b5460ff1615610f01576000610ec76117ea565b9050610edf838211610ed95783611cae565b81611cae565b9450915082821115610efb57610ef58284611dcb565b94508291505b50610f12565b610f0a82611dd7565b919550935090505b6001546040516328766ebf60e21b81526004810186905260248101859052604481018390526001600160a01b039091169063a1d9bafc90606401602060405180830381600087803b158015610f6657600080fd5b505af1158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e919061320f565b9150610fa982611dad565b6040805185815260208101859052908101829052606081018390527f4c0f499ffe6befa0ca7c826b0916cf87bea98de658013e76938489368d60d5099060800160405180910390a150505050565b6002546001600160a01b031633148061101a57506003546001600160a01b031633145b8061103d5750611028611c00565b6001600160a01b0316336001600160a01b0316145b6110595760405162461bcd60e51b81526004016105c5906131a3565b6001600160a01b03811661107f5760405162461bcd60e51b81526004016105c59061325d565b600180546001600160a01b0319166001600160a01b0383161790556040517f6f558b65df41ac351cf689106e82861fcd8565c6e5826e57870ddfa645c6f365906109239083906130f3565b6002546001600160a01b03163314806110ed57506003546001600160a01b031633145b8061111057506110fb611c00565b6001600160a01b0316336001600160a01b0316145b61112c5760405162461bcd60e51b81526004016105c5906131a3565b801561115d57600f80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d179055611184565b600f80546001600160a01b03191673d9e1ce17f2641f24ae83637ab66a2cca9c378b9f1790555b61118c611d90565b50565b6002546001600160a01b03163314806111b257506003546001600160a01b031633145b806111d557506111c0611c00565b6001600160a01b0316336001600160a01b0316145b6111f15760405162461bcd60e51b81526004016105c5906131a3565b6111fd60008383612f64565b507f300e67d5a415b6d015a471d9c7b95dd58f3e8290af965e84e0f845de2996dda6828260405161122f929190613282565b60405180910390a15050565b6002546001600160a01b031633148061125e57506003546001600160a01b031633145b80611281575061126c611c00565b6001600160a01b0316336001600160a01b0316145b61129d5760405162461bcd60e51b81526004016105c5906131a3565b60098190556040518181527fd94596337df4c2f0f44d30a7fc5db1c7bb60d9aca4185ed77c6fd96eb45ec29890602001610923565b6001546001600160a01b031633148061130357506112ee611c00565b6001600160a01b0316336001600160a01b0316145b61133d5760405162461bcd60e51b815260206004820152600b60248201526a08585d5d1a1bdc9a5cd95960aa1b60448201526064016105c5565b6001546040805163fbfa77cf60e01b815290516001600160a01b039283169284169163fbfa77cf916004808301926020929190829003018186803b15801561138457600080fd5b505afa158015611398573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bc91906132b1565b6001600160a01b0316146114025760405162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59081d985d5b1d609a1b60448201526064016105c5565b61140b81611ef0565b6006546040516370a0823160e01b815261118c9183916001600160a01b03909116906370a08231906114419030906004016130f3565b60206040518083038186803b15801561145957600080fd5b505afa15801561146d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611491919061320f565b6006546001600160a01b03169190611c8f565b6002546001600160a01b03163314806114c757506003546001600160a01b031633145b806114ea57506114d5611c00565b6001600160a01b0316336001600160a01b0316145b6115065760405162461bcd60e51b81526004016105c5906131a3565b6001600160a01b03811661152c5760405162461bcd60e51b81526004016105c59061325d565b600380546001600160a01b0319166001600160a01b0383161790556040517f7baa8662db9e306c9d709f736b79600a01c095653fa62032ab0fe926ade5eb5d906109239083906130f3565b60015460405163228bfd9f60e01b815260009182916001600160a01b039091169063228bfd9f906115ac9030906004016130f3565b60a06040518083038186803b1580156115c457600080fd5b505afa1580156115d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115fc9190613314565b805190915061160e5750600092915050565b60075461162682602001516116204290565b90611dcb565b10156116355750600092915050565b60085461164782602001516116204290565b106116555750600192915050565b60015460405163bdcf36bb60e01b81526000916001600160a01b03169063bdcf36bb906116869030906004016130f3565b60206040518083038186803b15801561169e57600080fd5b505afa1580156116b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d6919061320f565b9050600a548111156116ec575060019392505050565b60006116f66117ea565b90508260400151611712600a5483611f0890919063ffffffff16565b101561172357506001949350505050565b60008360400151821115611744576040840151611741908390611dcb565b90505b60015460405163d764801360e01b81526000916001600160a01b03169063d7648013906117759030906004016130f3565b60206040518083038186803b15801561178d57600080fd5b505afa1580156117a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c5919061320f565b90506117d18183611f08565b6009546117de9089611f14565b10979650505050505050565b60006117f4611f20565b6117fc611f35565b611804611fde565b61180e9190613383565b610b309190613383565b6002546001600160a01b031633148061183b57506003546001600160a01b031633145b8061185e5750611849611c00565b6001600160a01b0316336001600160a01b0316145b61187a5760405162461bcd60e51b81526004016105c5906131a3565b60088190556040518181527f5430e11864ad7aa9775b07d12657fe52df9aa2ba734355bd8ef8747be2c800c590602001610923565b6002546001600160a01b03163314806118d257506003546001600160a01b031633145b806118f557506118e0611c00565b6001600160a01b0316336001600160a01b0316145b6119115760405162461bcd60e51b81526004016105c5906131a3565b600b805460ff19166001908117909155546040805163507257cd60e11b815290516001600160a01b039092169163a0e4af9a9160048082019260009290919082900301818387803b15801561196557600080fd5b505af1158015611979573d6000803e3d6000fd5b50506040517f97e963041e952738788b9d4871d854d282065b8f90a464928d6528f2e9a4fd0b925060009150a1565b801580611a315750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156119f757600080fd5b505afa158015611a0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a2f919061320f565b155b611a9c5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016105c5565b611af28363095ea7b360e01b8484604051602401611abb92919061339b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261205f565b505050565b600e5460408051634163183360e11b81529051610c1b926001600160a01b0316916000199183916382c63066916004808301926020929190829003018186803b158015611b4357600080fd5b505afa158015611b57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b7b91906132b1565b6001600160a01b031691906119a8565b600f546001600160a01b031660009081526010602052604090205460ff16610c1b57600f80546001600160a01b039081166000908152601060205260409020805460ff191660011790559054610c1b9116600019611b7b612131565b6060611bf68484600085612149565b90505b9392505050565b60015460408051635aa6e67560e01b815290516000926001600160a01b031691635aa6e675916004808301926020929190829003018186803b158015611c4557600080fd5b505afa158015611c59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3091906132b1565b6060610b30611c8a612131565b612271565b611af28363a9059cbb60e01b8484604051602401611abb92919061339b565b600080611cb9612335565b6000611cc3611fde565b905083811015611cfe57611cdf611cda82866133b4565b612348565b9250611ceb8184613383565b9250611cf783856133b4565b9150611d02565b8392505b50915091565b611d10611af7565b600d54611d3d906001600160a01b0316600019732260fac5e5542a773aa44fbcfedf7c193bc2c599611b7b565b600d54600e5460408051634163183360e11b81529051610c1b936001600160a01b0390811693600019939116916382c6306691600480820192602092909190829003018186803b158015611b4357600080fd5b611d98611b8b565b600f54610c1b906001600160a01b031661240d565b600b5460ff1615611dbb5750565b611dc361245f565b61118c6124ea565b6000611bf982846133b4565b600080600080611de5611fde565b9050611def612335565b6000611df9611fde565b9050611e0582826133b4565b94506000611e116117ea565b60015460405163228bfd9f60e01b81529192506000916001600160a01b039091169063228bfd9f90611e479030906004016130f3565b60a06040518083038186803b158015611e5f57600080fd5b505afa158015611e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e979190613314565b60400151905080821015611eb657611eaf82826133b4565b9550600096505b8715611ee557611ec588612348565b50611ee28888611ed3611fde565b611edd91906133b4565b6124f2565b94505b505050509193909250565b611ef8612335565b610787611f03612508565b612512565b6000611bf98284613383565b6000611bf982846133cb565b6000610b30611f2d612131565b6125d661280c565b600080611f40612508565b90508015611fd657600d546000906001600160a01b031663cc2b27d78360026040516001600160e01b031960e085901b1681526004810192909252600f0b602482015260440160206040518083038186803b158015611f9e57600080fd5b505afa158015611fb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf9919061320f565b600091505090565b6006546040516370a0823160e01b81526000916001600160a01b0316906370a082319061200f9030906004016130f3565b60206040518083038186803b15801561202757600080fd5b505afa15801561203b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b30919061320f565b60006120b4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611be79092919063ffffffff16565b805190915015611af257808060200190518101906120d291906133ea565b611af25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c5565b73d533a949740bb3306d119cc777fa900ba034cd5290565b6060824710156121aa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105c5565b843b6121f85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c5565b600080866001600160a01b031685876040516122149190613407565b60006040518083038185875af1925050503d8060008114612251576040519150601f19603f3d011682016040523d82523d6000602084013e612256565b606091505b50915091506122668282866129e3565b979650505050505050565b604080516003808252608082019092526060916000919060208201848036833701905050905082816000815181106122ab576122ab6131c8565b60200260200101906001600160a01b031690816001600160a01b0316815250506122d3612a1c565b816001815181106122e6576122e66131c8565b6001600160a01b039283166020918202929092010152601454825191169082906002908110612317576123176131c8565b6001600160a01b039092166020928302919091019091015292915050565b610c1b612340612131565b612a34612c0f565b6000806123be565b60206040518083038186803b15801561236857600080fd5b505afa15801561237c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a0919061320f565b6123ac906127d86133cb565b6123b69190613454565b915050612404565b6123c6612fe8565b838160026020020152600d5460405163cf701ff760e01b8152612710916001600160a01b03169063cf701ff7906123509085906001906004016134ca565b611bf981612512565b6001600160a01b03811660009081526015602052604090205460ff1661118c576001600160a01b0381166000908152601560205260409020805460ff1916600117905561118c81600019611b7b612a1c565b6000612469611fde565b9050801561118c57612479612fe8565b818160026020020152600d5460405162a6cbcd60e21b81526001600160a01b039091169063029b2f34906124b49084906000906004016134e7565b600060405180830381600087803b1580156124ce57600080fd5b505af11580156124e2573d6000803e3d6000fd5b505050505050565b610c1b612dc7565b60008183106125015781611bf9565b5090919050565b6000610b30612eda565b60008061251d612508565b9050600061252b84836124f2565b905061253681612f0b565b600d546000906001600160a01b0316631a4d01d28360026040516001600160e01b031960e085901b1681526004810192909252600f0b602482015260006044820152606401602060405180830381600087803b15801561259557600080fd5b505af11580156125a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125cd919061320f565b95945050505050565b600081156128035760606125e8612f14565b6006546001600160a01b03908116911614156126885760408051600280825260608201835290916020830190803683370190505090508381600081518110612632576126326131c8565b6001600160a01b039283166020918202929092010152600654825191169082906001908110612663576126636131c8565b60200260200101906001600160a01b031690816001600160a01b03168152505061274a565b60408051600380825260808201909252906020820160608036833701905050905083816000815181106126bd576126bd6131c8565b60200260200101906001600160a01b031690816001600160a01b0316815250506126e5612f14565b816001815181106126f8576126f86131c8565b6001600160a01b039283166020918202929092010152600654825191169082906002908110612729576127296131c8565b60200260200101906001600160a01b031690816001600160a01b0316815250505b600f5460405163d06ca61f60e01b81526000916001600160a01b03169063d06ca61f9061277d9087908690600401613546565b60006040518083038186803b15801561279557600080fd5b505afa1580156127a9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526127d1919081019061355f565b905080600183516127e291906133b4565b815181106127f2576127f26131c8565b6020026020010151925050506107bc565b50600092915050565b6013546040516246613160e11b815260009182916001600160a01b0390911690628cc2629061283f9030906004016130f3565b60206040518083038186803b15801561285757600080fd5b505afa15801561286b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061288f919061320f565b905080156129d9576103e86a52b7d2dcc80cd2e400000069152d02c7e14af680000060006128bb612a1c565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156128f357600080fd5b505afa158015612907573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061292b919061320f565b905060008061293a8484613454565b90508581101561298657600061295082886133b4565b90508661295d828a6133cb565b6129679190613454565b9250600061297585886133b4565b905080841115612983578093505b50505b60006129968b898c63ffffffff16565b6129a09082613383565b905082156129ca576129bd6129b3612a1c565b848c63ffffffff16565b6129c79082613383565b90505b97506107bc9650505050505050565b5060009392505050565b606083156129f2575081611bf9565b825115612a025782518084602001fd5b8160405162461bcd60e51b81526004016105c591906130a7565b734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b90565b60008115612803576060612a46612f14565b6006546001600160a01b0390811691161415612ae65760408051600280825260608201835290916020830190803683370190505090508381600081518110612a9057612a906131c8565b6001600160a01b039283166020918202929092010152600654825191169082906001908110612ac157612ac16131c8565b60200260200101906001600160a01b031690816001600160a01b031681525050612ba8565b6040805160038082526080820190925290602082016060803683370190505090508381600081518110612b1b57612b1b6131c8565b60200260200101906001600160a01b031690816001600160a01b031681525050612b43612f14565b81600181518110612b5657612b566131c8565b6001600160a01b039283166020918202929092010152600654825191169082906002908110612b8757612b876131c8565b60200260200101906001600160a01b031690816001600160a01b0316815250505b600f546040516338ed173960e01b81526000916001600160a01b0316906338ed173990612be19087908590879030904290600401613604565b600060405180830381600087803b158015612bfb57600080fd5b505af11580156127a9573d6000803e3d6000fd5b601354604051637050ccd960e01b8152306004820152600160248201526001600160a01b0390911690637050ccd990604401602060405180830381600087803b158015612c5b57600080fd5b505af1158015612c6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9391906133ea565b506040516370a0823160e01b81526000906001600160a01b038416906370a0823190612cc39030906004016130f3565b60206040518083038186803b158015612cdb57600080fd5b505afa158015612cef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d13919061320f565b90506000612d1f612a1c565b6001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401612d4a91906130f3565b60206040518083038186803b158015612d6257600080fd5b505afa158015612d76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d9a919061320f565b9050612daa84838563ffffffff16565b50612dc0612db6612a1c565b828563ffffffff16565b5050505050565b6014546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612df89030906004016130f3565b60206040518083038186803b158015612e1057600080fd5b505afa158015612e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e48919061320f565b9050801561118c5760125460115460405163303acfe760e11b81526004810191909152600160248201526001600160a01b03909116906360759fce906044015b602060405180830381600087803b158015612ea257600080fd5b505af1158015612eb6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078791906133ea565b6013546040516370a0823160e01b81526000916001600160a01b0316906370a082319061200f9030906004016130f3565b61118c81612f2c565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290565b601354604051636197390160e11b815260048101839052600160248201526001600160a01b039091169063c32e720290604401612e88565b828054612f7090613228565b90600052602060002090601f016020900481019282612f925760008555612fd8565b82601f10612fab5782800160ff19823516178555612fd8565b82800160010185558215612fd8579182015b82811115612fd8578235825591602001919060010190612fbd565b50612fe4929150613006565b5090565b60405180608001604052806004906020820280368337509192915050565b5b80821115612fe45760008155600101613007565b6001600160a01b038116811461118c57600080fd5b60006020828403121561304257600080fd5b8135611bf98161301b565b60006020828403121561305f57600080fd5b81356001600160e01b031981168114611bf957600080fd5b60005b8381101561309257818101518382015260200161307a565b838111156130a1576000848401525b50505050565b60208152600082518060208401526130c6816040850160208701613077565b601f01601f19169190910160400192915050565b6000602082840312156130ec57600080fd5b5035919050565b6001600160a01b0391909116815260200190565b801515811461118c57600080fd5b60006020828403121561312757600080fd5b8135611bf981613107565b6000806020838503121561314557600080fd5b82356001600160401b038082111561315c57600080fd5b818501915085601f83011261317057600080fd5b81358181111561317f57600080fd5b86602082850101111561319157600080fd5b60209290920196919550909350505050565b6020808252600b908201526a08585d5d1a1bdc9a5e995960aa1b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415613208576132086131de565b5060010190565b60006020828403121561322157600080fd5b5051919050565b600181811c9082168061323c57607f821691505b60208210811415610ba357634e487b7160e01b600052602260045260246000fd5b6020808252600b908201526a021206164647265737320360ac1b604082015260600190565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6000602082840312156132c357600080fd5b8151611bf98161301b565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561330c5761330c6132ce565b604052919050565b600060a0828403121561332657600080fd5b60405160a081018181106001600160401b0382111715613348576133486132ce565b806040525082518152602083015160208201526040830151604082015260608301516060820152608083015160808201528091505092915050565b60008219821115613396576133966131de565b500190565b6001600160a01b03929092168252602082015260400190565b6000828210156133c6576133c66131de565b500390565b60008160001904831182151516156133e5576133e56131de565b500290565b6000602082840312156133fc57600080fd5b8151611bf981613107565b60008251613419818460208701613077565b9190910192915050565b6002811015613442578151835260209283019290910190600101613423565b50505082151560408301529392505050565b60008261347157634e487b7160e01b600052601260045260246000fd5b500490565b6003811015613495578151835260209283019290910190600101613476565b50505082151560608301529392505050565b8060005b60048110156130a15781518452602093840193909101906001016134ab565b60a081016134d882856134a7565b82151560808301529392505050565b60a081016134f582856134a7565b8260808301529392505050565b600081518084526020808501945080840160005b8381101561353b5781516001600160a01b031687529582019590820190600101613516565b509495945050505050565b828152604060208201526000611bf66040830184613502565b6000602080838503121561357257600080fd5b82516001600160401b038082111561358957600080fd5b818501915085601f83011261359d57600080fd5b8151818111156135af576135af6132ce565b8060051b91506135c08483016132e4565b81815291830184019184810190888411156135da57600080fd5b938501935b838510156135f8578451825293850193908501906135df565b98975050505050505050565b85815284602082015260a06040820152600061362360a0830186613502565b6001600160a01b039490941660608301525060800152939250505056fea2646970667358221220b097b2c1d705897097a5826f9a49055ad6823172d308c73ec1bca20e0929fdb864736f6c63430008090033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000aaeee9f40db7aaf5f4d4514d62b9a046066c47d300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e9cdd67b924a8e82709207373699bb749f8851ce000000000000000000000000d5bcf53e2c81e1991570f33fa881c49eea570c8d000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae31

-----Decoded View---------------
Arg [0] : _vault (address): 0xaaeEe9F40DB7aaF5F4D4514d62b9A046066C47d3
Arg [1] : _proposer (address): 0x0000000000000000000000000000000000000000
Arg [2] : _developer (address): 0x0000000000000000000000000000000000000000
Arg [3] : _keeper (address): 0xE9CDD67b924a8e82709207373699bb749F8851CE
Arg [4] : _pool (address): 0xd5BCf53e2C81e1991570f33Fa881c49EEa570C8D
Arg [5] : _booster (address): 0xF403C135812408BFbE8713b5A23a04b3D48AAE31

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000aaeee9f40db7aaf5f4d4514d62b9a046066c47d3
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 000000000000000000000000e9cdd67b924a8e82709207373699bb749f8851ce
Arg [4] : 000000000000000000000000d5bcf53e2c81e1991570f33fa881c49eea570c8d
Arg [5] : 000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae31


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

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