ETH Price: $2,520.25 (+3.24%)

Contract

0xAF345c813CE17Cc5837BfD14a910D365223F3B95
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Transfer Ownersh...179928112023-08-25 16:10:59374 days ago1692979859IN
0xAF345c81...5223F3B95
0 ETH0.0011800641
Update Supported...176277402023-07-05 12:40:11425 days ago1688560811IN
0xAF345c81...5223F3B95
0 ETH0.0023846152
0x60a06040176277182023-07-05 12:35:47425 days ago1688560547IN
 Create: GeneralTokenConverter
0 ETH0.1765401850.78546641

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
203223252024-07-16 23:20:5948 days ago1721172059
0xAF345c81...5223F3B95
0.03695773 ETH
203223252024-07-16 23:20:5948 days ago1721172059
0xAF345c81...5223F3B95
0.03695773 ETH
202745942024-07-10 7:26:1155 days ago1720596371
0xAF345c81...5223F3B95
0.0369634 ETH
202745942024-07-10 7:26:1155 days ago1720596371
0xAF345c81...5223F3B95
0.0369634 ETH
202220902024-07-02 23:24:5962 days ago1719962699
0xAF345c81...5223F3B95
0.02650137 ETH
202220902024-07-02 23:24:5962 days ago1719962699
0xAF345c81...5223F3B95
0.02650137 ETH
201219092024-06-18 23:26:2376 days ago1718753183
0xAF345c81...5223F3B95
0.03802072 ETH
201219092024-06-18 23:26:2376 days ago1718753183
0xAF345c81...5223F3B95
0.03802072 ETH
200217842024-06-04 23:36:3590 days ago1717544195
0xAF345c81...5223F3B95
0.12511743 ETH
200217842024-06-04 23:36:3590 days ago1717544195
0xAF345c81...5223F3B95
0.12511743 ETH
200187642024-06-04 13:30:1190 days ago1717507811
0xAF345c81...5223F3B95
4.07575857 ETH
200187642024-06-04 13:30:1190 days ago1717507811
0xAF345c81...5223F3B95
4.07575857 ETH
200152172024-06-04 1:36:5991 days ago1717465019
0xAF345c81...5223F3B95
0.05550275 ETH
200152172024-06-04 1:36:5991 days ago1717465019
0xAF345c81...5223F3B95
0.05550275 ETH
200114342024-06-03 12:55:5991 days ago1717419359
0xAF345c81...5223F3B95
16.61070755 ETH
200114342024-06-03 12:55:5991 days ago1717419359
0xAF345c81...5223F3B95
16.61070755 ETH
199699132024-05-28 17:39:2397 days ago1716917963
0xAF345c81...5223F3B95
0.9211831 ETH
199699132024-05-28 17:39:2397 days ago1716917963
0xAF345c81...5223F3B95
0.9211831 ETH
199693872024-05-28 15:53:5997 days ago1716911639
0xAF345c81...5223F3B95
0.10336619 ETH
199693872024-05-28 15:53:5997 days ago1716911639
0xAF345c81...5223F3B95
0.10336619 ETH
199317262024-05-23 9:35:59102 days ago1716456959
0xAF345c81...5223F3B95
0.59538065 ETH
199317262024-05-23 9:35:59102 days ago1716456959
0xAF345c81...5223F3B95
0.59538065 ETH
199313782024-05-23 8:25:47102 days ago1716452747
0xAF345c81...5223F3B95
19.98120399 ETH
199313782024-05-23 8:25:47102 days ago1716452747
0xAF345c81...5223F3B95
19.98120399 ETH
199159192024-05-21 4:33:11105 days ago1716265991
0xAF345c81...5223F3B95
8.76338536 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
GeneralTokenConverter

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 24 : GeneralTokenConverter.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;
pragma abicoder v2;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";

import { IConverterRegistry } from "./IConverterRegistry.sol";
import { ITokenConverter } from "./ITokenConverter.sol";

import { IERC4626 } from "../../common/ERC4626/IERC4626.sol";
import { IBalancerPool } from "../../interfaces/IBalancerPool.sol";
import { IBalancerV1Pool } from "../../interfaces/IBalancerV1Pool.sol";
import { IBalancerVault } from "../../interfaces/IBalancerVault.sol";
import { ICurveAPool } from "../../interfaces/ICurveAPool.sol";
import { ICurvePlainPool } from "../../interfaces/ICurvePlainPool.sol";
import { ICurveYPoolSwap, ICurveYPoolDeposit } from "../../interfaces/ICurveYPool.sol";
import { ICurveMetaPoolSwap } from "../../interfaces/ICurveMetaPool.sol";
import { ICurveCryptoPool } from "../../interfaces/ICurveCryptoPool.sol";
import { IUniswapV2Pair } from "../../interfaces/IUniswapV2Pair.sol";
import { IUniswapV3Pool } from "../../interfaces/IUniswapV3Pool.sol";
import { IUniswapV3Router } from "../../interfaces/IUniswapV3Router.sol";
import { IWETH } from "../../interfaces/IWETH.sol";

import { ConverterBase } from "./ConverterBase.sol";

// solhint-disable var-name-mixedcase
// solhint-disable not-rely-on-time

/// @title GeneralTokenConverter
/// @notice This implements token converting for `pool_type` from 0 to 14.
/// For other types, it will retrieve the implementation from
/// `ConverterRegistry` contract and delegate call.
contract GeneralTokenConverter is Ownable, ConverterBase, ITokenConverter {
  using SafeERC20 for IERC20;

  /*************
   * Constants *
   *************/

  /// @inheritdoc ITokenConverter
  address public immutable override registry;

  /// @dev The address of Balancer V2 Vault
  address private constant BALANCER_VAULT = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;

  /// @dev The address of Uniswap V3 Router
  address private constant UNISWAP_V3_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564;

  /*************
   * Variables *
   *************/

  /// @notice The mask of supported pool types.
  /// @dev If the `i`-th bit is `1`, the `i`-th pool type is supported in this contract.
  uint256 public supportedPoolTypes;

  /***************
   * Constructor *
   ***************/

  constructor(address _registry) {
    registry = _registry;
  }

  /*************************
   * Public View Functions *
   *************************/

  /// @inheritdoc ITokenConverter
  function getTokenPair(uint256 _route) external view override returns (address, address) {
    uint256 _poolType = _route & 255;
    uint256 _action = (_route >> 8) & 3;

    return _getTokenPair(_poolType, _action, _route >> 10);
  }

  /// @inheritdoc ITokenConverter
  function queryConvert(uint256 _encoding, uint256 _amountIn) external view override returns (uint256 _amountOut) {
    uint256 _poolType = _encoding & 255;
    uint256 _action = (_encoding >> 8) & 3;

    if (((supportedPoolTypes >> _poolType) & 1) == 1) {
      _encoding = _encoding >> 10;
      if (_action == 0) _amountOut = _querySwap(_poolType, _encoding, _amountIn);
      else if (_action == 1) _amountOut = _queryWrap(_poolType, _encoding, _amountIn);
      else if (_action == 2) _amountOut = _queryUnwrap(_poolType, _encoding, _amountIn);
      else revert("invalid action");
    } else {
      address _converter = IConverterRegistry(registry).getConverter(_poolType);
      _amountOut = ITokenConverter(_converter).queryConvert(_encoding, _amountIn);
    }
  }

  /****************************
   * Public Mutated Functions *
   ****************************/

  /// @inheritdoc ITokenConverter
  function convert(
    uint256 _encoding,
    uint256 _amountIn,
    address _recipient
  ) external payable override returns (uint256 _amountOut) {
    uint256 _poolType = _encoding & 255;
    uint256 _action = (_encoding >> 8) & 3;

    if (((supportedPoolTypes >> _poolType) & 1) == 1) {
      _encoding = _encoding >> 10;
      if (_action == 0) _amountOut = _swap(_poolType, _encoding, _amountIn, _recipient);
      else if (_action == 1) _amountOut = _wrap(_poolType, _encoding, _amountIn, _recipient);
      else if (_action == 2) _amountOut = _unwrap(_poolType, _encoding, _amountIn, _recipient);
      else revert("invalid action");
    } else {
      address _converter = IConverterRegistry(registry).getConverter(_poolType);
      // solhint-disable-next-line avoid-low-level-calls
      (bool _success, bytes memory _result) = _converter.delegatecall(
        abi.encodeWithSelector(ITokenConverter.convert.selector, _recipient, _encoding, _amountIn)
      );
      // below lines will propagate inner error up
      if (!_success) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
          let ptr := mload(0x40)
          let size := returndatasize()
          returndatacopy(ptr, 0, size)
          revert(ptr, size)
        }
      }
      _amountOut = abi.decode(_result, (uint256));
    }
  }

  /// @inheritdoc ITokenConverter
  function withdrawFund(address _token, address _recipient) external override {
    require(msg.sender == registry, "only registry");

    if (_token == address(0)) {
      (bool success, ) = _recipient.call{ value: address(this).balance }("");
      require(success, "withdraw ETH failed");
    } else {
      IERC20(_token).safeTransfer(_recipient, IERC20(_token).balanceOf(address(this)));
    }
  }

  /*******************************
   * Public Restricted Functions *
   *******************************/

  /// @notice Update the pool types supported by this contract by default.
  /// @param _supportedPoolTypes The mask of pool types supported.
  function updateSupportedPoolTypes(uint256 _supportedPoolTypes) external onlyOwner {
    supportedPoolTypes = _supportedPoolTypes;
  }

  /**********************
   * Internal Functions *
   **********************/

  /// @dev Internal function to find token pair based on route encoding.
  /// @param _poolType The type of the route.
  /// @param _action The action of the route.
  /// @param _encoding The customized encoding of the route.
  /// @return _tokenIn The address of input token.
  /// @return _tokenOut The address of output token.
  function _getTokenPair(
    uint256 _poolType,
    uint256 _action,
    uint256 _encoding
  ) internal view returns (address _tokenIn, address _tokenOut) {
    address _pool = address(_encoding & 1461501637330902918203684832716283019655932542975);

    if (_action == 0) {
      // swap
      if (_poolType <= 1) {
        // UniswapV2 or UniswapV3
        _tokenIn = IUniswapV2Pair(_pool).token0();
        _tokenOut = IUniswapV2Pair(_pool).token1();
        uint256 zero_for_one = (_encoding >> 184) & 1;
        if (zero_for_one == 0) {
          (_tokenIn, _tokenOut) = (_tokenOut, _tokenIn);
        }
      } else if (_poolType == 2) {
        // BalancerV1
        address[] memory _tokens = IBalancerV1Pool(_pool).getCurrentTokens();
        _tokenIn = _tokens[(_encoding >> 163) & 7];
        _tokenIn = _tokens[(_encoding >> 166) & 7];
      } else if (_poolType == 3) {
        // BalancerV2
        bytes32 _poolId = IBalancerPool(_pool).getPoolId();
        (address[] memory _tokens, , ) = IBalancerVault(BALANCER_VAULT).getPoolTokens(_poolId);
        _tokenIn = _tokens[(_encoding >> 163) & 7];
        _tokenOut = _tokens[(_encoding >> 166) & 7];
      } else if (_poolType <= 8) {
        // Curve
        _tokenIn = _getCurveTokenByIndex(_pool, _poolType, (_encoding >> 163) & 7, _encoding);
        _tokenOut = _getCurveTokenByIndex(_pool, _poolType, (_encoding >> 166) & 7, _encoding);
      }
    } else if (_action == 1) {
      _tokenOut = _pool;
      if (4 <= _poolType && _poolType <= 8) {
        _pool = _getTokenMinter(_pool);
        _tokenIn = _getCurveTokenByIndex(_pool, _poolType, (_encoding >> 163) & 7, _encoding);
      } else if (_poolType == 9) {
        _tokenIn = IERC4626(_pool).asset();
      } else {
        _tokenOut = address(0);
      }
    } else if (_action == 2) {
      _tokenIn = _pool;
      if (4 <= _poolType && _poolType <= 8) {
        _pool = _getTokenMinter(_pool);
        _tokenOut = _getCurveTokenByIndex(_pool, _poolType, (_encoding >> 166) & 7, _encoding);
      } else if (_poolType == 9) {
        _tokenOut = IERC4626(_pool).asset();
      } else {
        _tokenIn = address(0);
      }
    }
    if (_tokenIn == ETH) _tokenIn = WETH;
    if (_tokenOut == ETH) _tokenOut = WETH;
  }

  /// @dev Internal function to return the minter for curve lp token.
  /// @param _token The address of token.
  /// @return _minter The address of minter for the token.
  function _getTokenMinter(address _token) internal view returns (address _minter) {
    // solhint-disable-next-line no-inline-assembly
    assembly {
      // keccack("minter()")
      mstore(0x00, 0x0754617200000000000000000000000000000000000000000000000000000000)
      let success := staticcall(gas(), _token, 0x00, 0x04, 0x00, 0x20)
      if success {
        _minter := mload(0x00)
      }
      if iszero(_minter) {
        _minter := _token
      }
    }
  }

  /// @dev Internal function to get the curve token by index.
  /// @param _poolType The pool type.
  /// @param _index The index of the token.
  /// @param _encoding The customized encoding of the route.
  /// @return _token The address of the token.
  function _getCurveTokenByIndex(
    address _pool,
    uint256 _poolType,
    uint256 _index,
    uint256 _encoding
  ) internal view returns (address _token) {
    if ((_poolType == 5 || _poolType == 6) && (((_encoding >> 169) & 1) == 1)) {
      _token = ICurveAPool(_pool).underlying_coins(_index);
    } else {
      try ICurvePlainPool(_pool).coins(_index) returns (address result) {
        _token = result;
      } catch {
        _token = ICurvePlainPool(_pool).coins(int128(_index));
      }
    }
  }

  /*************************************
   * Internal Functions for Token Swap *
   *************************************/

  /// @dev Query the amount of output token by swapping.
  /// @param _poolType The pool type.
  /// @param _encoding The customized encoding of the route.
  /// @param _amountIn The amount of input token.
  /// @return _amountOut The amount of output token.
  function _querySwap(
    uint256 _poolType,
    uint256 _encoding,
    uint256 _amountIn
  ) internal view returns (uint256 _amountOut) {
    address _pool = address(_encoding & 1461501637330902918203684832716283019655932542975);
    if (_poolType == 0) {} else if (_poolType == 1) {} else if (_poolType == 2) {} else if (_poolType == 3) {} else if (
      _poolType <= 8
    ) {
      uint256 indexIn = (_encoding >> 163) & 7;
      uint256 indexOut = (_encoding >> 166) & 7;
      if (_poolType == 8) {
        _amountOut = ICurveCryptoPool(_pool).get_dy(indexIn, indexOut, _amountIn);
      } else if (_poolType == 5 && ((_encoding >> 169) & 1) == 1) {
        _amountOut = ICurveAPool(_pool).get_dy_underlying(int128(indexIn), int128(indexOut), _amountIn);
      } else if (_poolType == 6 && ((_encoding >> 169) & 1) == 1) {
        _amountOut = ICurveYPoolSwap(_pool).get_dy_underlying(int128(indexIn), int128(indexOut), _amountIn);
      } else {
        _amountOut = ICurvePlainPool(_pool).get_dy(int128(indexIn), int128(indexOut), _amountIn);
      }
    }
  }

  /// @dev Swap from one token to another token.
  /// @param _poolType The pool type.
  /// @param _encoding The customized encoding of the route.
  /// @param _amountIn The amount of input token.
  /// @param _recipient The address of output token receiver.
  /// @return _amountOut The amount of output token.
  function _swap(
    uint256 _poolType,
    uint256 _encoding,
    uint256 _amountIn,
    address _recipient
  ) internal returns (uint256 _amountOut) {
    (address _tokenIn, address _tokenOut) = _getTokenPair(_poolType, 0, _encoding);
    address _pool = address(_encoding & 1461501637330902918203684832716283019655932542975);

    if ((_poolType == 4 || _poolType == 8) && ((_encoding >> 169) & 1) == 1) {
      // tokenIn is (W)ETH and we are going to use ETH.
      _unwrapIfNeeded(_amountIn);
    } else {
      _wrapTokenIfNeeded(_tokenIn, _amountIn);
    }

    if (_poolType == 0) {
      // Uniswap V2
      if (((_encoding >> 185) & 1) == 1) {
        IUniswapV2Pair(_pool).executeVirtualOrders(block.timestamp);
      }
      uint256 zero_for_one = (_encoding >> 184) & 1;
      (uint256 rIn, uint256 rOut, ) = IUniswapV2Pair(_pool).getReserves();
      if (zero_for_one == 0) {
        (rIn, rOut) = (rOut, rIn);
      }

      // We won't handle fee on transfer token here.
      _amountOut = _amountIn * ((_encoding >> 160) & 16777215);
      _amountOut = (_amountOut * rOut) / (rIn * 1000000 + _amountOut);

      IERC20(_tokenIn).safeTransfer(_pool, _amountIn);
      if (zero_for_one == 1) {
        IUniswapV2Pair(_pool).swap(0, _amountOut, _recipient, new bytes(0));
      } else {
        IUniswapV2Pair(_pool).swap(_amountOut, 0, _recipient, new bytes(0));
      }
      return _amountOut;
    } else if (_poolType == 1) {
      // UniswapV3
      uint24 _fee = uint24((_encoding >> 160) & 16777215);
      _approve(_tokenIn, UNISWAP_V3_ROUTER, _amountIn);
      IUniswapV3Router.ExactInputSingleParams memory _params = IUniswapV3Router.ExactInputSingleParams(
        _tokenIn,
        _tokenOut,
        _fee,
        _recipient,
        // solhint-disable-next-line not-rely-on-time
        block.timestamp + 1,
        _amountIn,
        1,
        0
      );
      return IUniswapV3Router(UNISWAP_V3_ROUTER).exactInputSingle(_params);
    } else if (_poolType == 2) {
      // BalancerV1
      _approve(_tokenIn, _pool, _amountIn);
      IBalancerV1Pool(_pool).swapExactAmountIn(_tokenIn, _amountIn, _tokenOut, 0, uint256(-1));
    } else if (_poolType == 3) {
      bytes32 _poolId = IBalancerPool(_pool).getPoolId();
      _wrapTokenIfNeeded(_tokenIn, _amountIn);
      _approve(_tokenIn, BALANCER_VAULT, _amountIn);
      return
        IBalancerVault(BALANCER_VAULT).swap(
          IBalancerVault.SingleSwap({
            poolId: _poolId,
            kind: IBalancerVault.SwapKind.GIVEN_IN,
            assetIn: _tokenIn,
            assetOut: _tokenOut,
            amount: _amountIn,
            userData: new bytes(0)
          }),
          IBalancerVault.FundManagement({
            sender: address(this),
            fromInternalBalance: false,
            recipient: payable(_recipient),
            toInternalBalance: false
          }),
          0,
          // solhint-disable-next-line not-rely-on-time
          block.timestamp
        );
    } else if (_poolType <= 8) {
      uint256 indexIn = (_encoding >> 163) & 7;
      uint256 indexOut = (_encoding >> 166) & 7;
      _approve(_tokenIn, _pool, _amountIn);
      if (_poolType == 4) {
        if (((_encoding >> 169) & 1) == 0) {
          _approve(_tokenIn, _pool, _amountIn);
          ICurvePlainPool(_pool).exchange(int128(indexIn), int128(indexOut), _amountIn, 0);
        } else {
          ICurvePlainPool(_pool).exchange{ value: _amountIn }(int128(indexIn), int128(indexOut), _amountIn, 0);
        }
      } else if (_poolType == 5) {
        _approve(_tokenIn, _pool, _amountIn);
        if (((_encoding >> 169) & 1) == 0) {
          ICurveAPool(_pool).exchange(int128(indexIn), int128(indexOut), _amountIn, 0);
        } else {
          ICurveAPool(_pool).exchange_underlying(int128(indexIn), int128(indexOut), _amountIn, 0);
        }
      } else if (_poolType == 6) {
        if (((_encoding >> 169) & 1) == 1) {
          _pool = ICurveYPoolDeposit(_pool).curve();
        }
        _approve(_tokenIn, _pool, _amountIn);
        if (((_encoding >> 169) & 1) == 0) {
          ICurveYPoolSwap(_pool).exchange(int128(indexIn), int128(indexOut), _amountIn, 0);
        } else {
          ICurveYPoolSwap(_pool).exchange_underlying(int128(indexIn), int128(indexOut), _amountIn, 0);
        }
      } else if (_poolType == 7) {
        _approve(_tokenIn, _pool, _amountIn);
        ICurveMetaPoolSwap(_pool).exchange(int128(indexIn), int128(indexOut), _amountIn, 0);
      } else if (_poolType == 8) {
        if (((_encoding >> 169) & 1) == 0) {
          _approve(_tokenIn, _pool, _amountIn);
          ICurveCryptoPool(_pool).exchange(indexIn, indexOut, _amountIn, 0);
        } else {
          ICurveCryptoPool(_pool).exchange{ value: _amountIn }(indexIn, indexOut, _amountIn, 0);
        }
      }
    } else {
      revert("invalid poolType");
    }

    if (_tokenOut == WETH) {
      _wrapTokenIfNeeded(_tokenOut, address(this).balance);
    }

    _amountOut = IERC20(_tokenOut).balanceOf(address(this));
    if (_recipient != address(this)) {
      IERC20(_tokenOut).safeTransfer(_recipient, _amountOut);
    }
  }

  /*****************************************
   * Internal Functions for Token Wrapping *
   *****************************************/

  /// @dev Query the amount of output token by wrapping.
  /// @param _poolType The pool type.
  /// @param _encoding The customized encoding of the route.
  /// @param _amountIn The amount of input token.
  /// @return _amountOut The amount of output token.
  function _queryWrap(
    uint256 _poolType,
    uint256 _encoding,
    uint256 _amountIn
  ) internal view returns (uint256 _amountOut) {
    address _pool = address(_encoding & 1461501637330902918203684832716283019655932542975);
    if (4 <= _poolType && _poolType <= 8) {
      uint256 _tokens = ((_encoding >> 160) & 7) + 1;
      uint256 _indexIn = (_encoding >> 166) & 7;

      if (_tokens == 2) {
        uint256[2] memory _amounts;
        _amounts[_indexIn] = _amountIn;
        _amountOut = ICurvePlainPool(_pool).calc_token_amount(_amounts, true);
      } else if (_tokens == 3) {
        uint256[3] memory _amounts;
        _amounts[_indexIn] = _amountIn;
        _amountOut = ICurvePlainPool(_pool).calc_token_amount(_amounts, true);
      } else {
        uint256[4] memory _amounts;
        _amounts[_indexIn] = _amountIn;
        _amountOut = ICurvePlainPool(_pool).calc_token_amount(_amounts, true);
      }
    } else if (_poolType == 9) {
      _amountOut = IERC4626(_pool).previewDeposit(_amountIn);
    }
  }

  /// @dev Wrap from one token to another token.
  /// @param _poolType The pool type.
  /// @param _encoding The customized encoding of the route.
  /// @param _amountIn The amount of input token.
  /// @param _recipient The address of output token receiver.
  /// @return _amountOut The amount of output token.
  function _wrap(
    uint256 _poolType,
    uint256 _encoding,
    uint256 _amountIn,
    address _recipient
  ) internal returns (uint256 _amountOut) {
    (address _tokenIn, address _tokenOut) = _getTokenPair(_poolType, 1, _encoding);
    address _pool = address(_encoding & 1461501637330902918203684832716283019655932542975);

    if ((_poolType == 4 || _poolType == 8) && ((_encoding >> 169) & 1) == 1) {
      // tokenIn is (W)ETH and we are going to use ETH.
      _unwrapIfNeeded(_amountIn);
    } else {
      _wrapTokenIfNeeded(_tokenIn, _amountIn);
    }

    if (4 <= _poolType && _poolType <= 8) {
      _pool = _getTokenMinter(_pool);
      uint256 _tokens = ((_encoding >> 160) & 7) + 1;
      uint256 _indexIn = (_encoding >> 163) & 7;
      require(2 <= _tokens && _tokens <= 4, "invalid tokens");

      if (_poolType == 5) {
        bool _use_underlying = ((_encoding >> 169) & 1) == 1;
        _approve(_tokenIn, _pool, _amountIn);
        if (_tokens == 2) {
          uint256[2] memory _amounts;
          _amounts[_indexIn] = _amountIn;
          ICurveAPool(_pool).add_liquidity(_amounts, 0, _use_underlying);
        } else if (_tokens == 3) {
          uint256[3] memory _amounts;
          _amounts[_indexIn] = _amountIn;
          ICurveAPool(_pool).add_liquidity(_amounts, 0, _use_underlying);
        } else {
          uint256[4] memory _amounts;
          _amounts[_indexIn] = _amountIn;
          ICurveAPool(_pool).add_liquidity(_amounts, 0, _use_underlying);
        }
      } else {
        bool _use_eth = (_poolType == 4 || _poolType == 8) && (((_encoding >> 169) & 1) == 1);
        if (!_use_eth) {
          _approve(_tokenIn, _pool, _amountIn);
        }
        if (_tokens == 2) {
          uint256[2] memory _amounts;
          _amounts[_indexIn] = _amountIn;
          if (_use_eth) {
            ICurvePlainPool(_pool).add_liquidity{ value: _amountIn }(_amounts, 0);
          } else {
            ICurvePlainPool(_pool).add_liquidity(_amounts, 0);
          }
        } else if (_tokens == 3) {
          uint256[3] memory _amounts;
          _amounts[_indexIn] = _amountIn;
          if (_use_eth) {
            ICurvePlainPool(_pool).add_liquidity{ value: _amountIn }(_amounts, 0);
          } else {
            ICurvePlainPool(_pool).add_liquidity(_amounts, 0);
          }
        } else {
          uint256[4] memory _amounts;
          _amounts[_indexIn] = _amountIn;
          if (_use_eth) {
            ICurvePlainPool(_pool).add_liquidity{ value: _amountIn }(_amounts, 0);
          } else {
            ICurvePlainPool(_pool).add_liquidity(_amounts, 0);
          }
        }
      }
    } else if (_poolType == 9) {
      _approve(_tokenIn, _pool, _amountIn);
      _amountOut = IERC4626(_pool).deposit(_amountIn, _recipient);
      return _amountOut;
    } else {
      revert("invalid poolType");
    }

    _amountOut = IERC20(_tokenOut).balanceOf(address(this));
    if (_recipient != address(this)) {
      IERC20(_tokenOut).safeTransfer(_recipient, _amountOut);
    }
  }

  /*******************************************
   * Internal Functions for Token Unwrapping *
   *******************************************/

  /// @dev Query the amount of output token by unwrapping.
  /// @param _poolType The pool type.
  /// @param _encoding The customized encoding of the route.
  /// @param _amountIn The amount of input token.
  /// @return _amountOut The amount of output token.
  function _queryUnwrap(
    uint256 _poolType,
    uint256 _encoding,
    uint256 _amountIn
  ) internal view returns (uint256 _amountOut) {
    address _pool = address(_encoding & 1461501637330902918203684832716283019655932542975);

    if (4 <= _poolType && _poolType <= 8) {
      _pool = _getTokenMinter(_pool);
      uint256 _indexOut = (_encoding >> 166) & 7;
      if (_poolType == 8) {
        _amountOut = ICurveCryptoPool(_pool).calc_withdraw_one_coin(_amountIn, _indexOut);
      } else {
        _amountOut = ICurvePlainPool(_pool).calc_withdraw_one_coin(_amountIn, int128(_indexOut));
      }
    } else if (_poolType == 9) {
      _amountOut = IERC4626(_pool).previewRedeem(_amountIn);
    }
  }

  /// @dev Unwrap from one token to another token.
  /// @param _poolType The pool type.
  /// @param _encoding The customized encoding of the route.
  /// @param _amountIn The amount of input token.
  /// @param _recipient The address of output token receiver.
  /// @return _amountOut The amount of output token.
  function _unwrap(
    uint256 _poolType,
    uint256 _encoding,
    uint256 _amountIn,
    address _recipient
  ) internal returns (uint256 _amountOut) {
    (, address _tokenOut) = _getTokenPair(_poolType, 2, _encoding);
    address _pool = address(_encoding & 1461501637330902918203684832716283019655932542975);

    if (4 <= _poolType && _poolType <= 8) {
      _pool = _getTokenMinter(_pool);
      uint256 _tokens = ((_encoding >> 160) & 7) + 1;
      uint256 _indexOut = (_encoding >> 166) & 7;
      require(2 <= _tokens && _tokens <= 4, "invalid tokens");

      if (_poolType == 4) {
        ICurvePlainPool(_pool).remove_liquidity_one_coin(_amountIn, int128(_indexOut), 0);
      } else if (_poolType == 5) {
        bool _use_underlying = ((_encoding >> 169) & 1) == 1;
        ICurveAPool(_pool).remove_liquidity_one_coin(_amountIn, int128(_indexOut), 0, _use_underlying);
      } else if (_poolType == 6) {
        ICurveYPoolDeposit(_pool).remove_liquidity_one_coin(_amountIn, int128(_indexOut), 0, true);
      } else if (_poolType == 7) {
        ICurveMetaPoolSwap(_pool).remove_liquidity_one_coin(_amountIn, int128(_indexOut), 0);
      } else {
        ICurveCryptoPool(_pool).remove_liquidity_one_coin(_amountIn, _indexOut, 0);
      }
    } else if (_poolType == 9) {
      _amountOut = IERC4626(_pool).redeem(_amountIn, _recipient, address(this));
      return _amountOut;
    } else {
      revert("invalid poolType");
    }

    if (_tokenOut == WETH) {
      _wrapTokenIfNeeded(_tokenOut, address(this).balance);
    }

    _amountOut = IERC20(_tokenOut).balanceOf(address(this));
    if (_recipient != address(this)) {
      IERC20(_tokenOut).safeTransfer(_recipient, _amountOut);
    }
  }
}

File 2 of 24 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

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

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

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

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

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

File 3 of 24 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

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

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

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

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

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

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

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

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

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

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

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

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

File 4 of 24 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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 5 of 24 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC20.sol";
import "../../math/SafeMath.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 SafeMath for uint256;
    using Address for address;

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

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

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

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

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

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

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

File 6 of 24 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 7 of 24 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

File 8 of 24 : IERC4626.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

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

import "../../interfaces/IERC20Metadata.sol";

// Copy from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/interfaces/IERC4626.sol

/**
 * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
 * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
 *
 * _Available since v4.7._
 */
interface IERC4626 is IERC20, IERC20Metadata {
  event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);

  event Withdraw(
    address indexed sender,
    address indexed receiver,
    address indexed owner,
    uint256 assets,
    uint256 shares
  );

  /**
   * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
   *
   * - MUST be an ERC-20 token contract.
   * - MUST NOT revert.
   */
  function asset() external view returns (address assetTokenAddress);

  /**
   * @dev Returns the total amount of the underlying asset that is “managed” by Vault.
   *
   * - SHOULD include any compounding that occurs from yield.
   * - MUST be inclusive of any fees that are charged against assets in the Vault.
   * - MUST NOT revert.
   */
  function totalAssets() external view returns (uint256 totalManagedAssets);

  /**
   * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
   * scenario where all the conditions are met.
   *
   * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
   * - MUST NOT show any variations depending on the caller.
   * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
   * - MUST NOT revert.
   *
   * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
   * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
   * from.
   */
  function convertToShares(uint256 assets) external view returns (uint256 shares);

  /**
   * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
   * scenario where all the conditions are met.
   *
   * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
   * - MUST NOT show any variations depending on the caller.
   * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
   * - MUST NOT revert.
   *
   * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
   * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
   * from.
   */
  function convertToAssets(uint256 shares) external view returns (uint256 assets);

  /**
   * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
   * through a deposit call.
   *
   * - MUST return a limited value if receiver is subject to some deposit limit.
   * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
   * - MUST NOT revert.
   */
  function maxDeposit(address receiver) external view returns (uint256 maxAssets);

  /**
   * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
   * current on-chain conditions.
   *
   * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
   *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
   *   in the same transaction.
   * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
   *   deposit would be accepted, regardless if the user has enough tokens approved, etc.
   * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
   * - MUST NOT revert.
   *
   * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
   * share price or some other type of condition, meaning the depositor will lose assets by depositing.
   */
  function previewDeposit(uint256 assets) external view returns (uint256 shares);

  /**
   * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
   *
   * - MUST emit the Deposit event.
   * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
   *   deposit execution, and are accounted for during deposit.
   * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
   *   approving enough underlying tokens to the Vault contract, etc).
   *
   * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
   */
  function deposit(uint256 assets, address receiver) external returns (uint256 shares);

  /**
   * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
   * - MUST return a limited value if receiver is subject to some mint limit.
   * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
   * - MUST NOT revert.
   */
  function maxMint(address receiver) external view returns (uint256 maxShares);

  /**
   * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
   * current on-chain conditions.
   *
   * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
   *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
   *   same transaction.
   * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
   *   would be accepted, regardless if the user has enough tokens approved, etc.
   * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
   * - MUST NOT revert.
   *
   * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
   * share price or some other type of condition, meaning the depositor will lose assets by minting.
   */
  function previewMint(uint256 shares) external view returns (uint256 assets);

  /**
   * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
   *
   * - MUST emit the Deposit event.
   * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
   *   execution, and are accounted for during mint.
   * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
   *   approving enough underlying tokens to the Vault contract, etc).
   *
   * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
   */
  function mint(uint256 shares, address receiver) external returns (uint256 assets);

  /**
   * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
   * Vault, through a withdraw call.
   *
   * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
   * - MUST NOT revert.
   */
  function maxWithdraw(address owner) external view returns (uint256 maxAssets);

  /**
   * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
   * given current on-chain conditions.
   *
   * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
   *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
   *   called
   *   in the same transaction.
   * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
   *   the withdrawal would be accepted, regardless if the user has enough shares, etc.
   * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
   * - MUST NOT revert.
   *
   * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
   * share price or some other type of condition, meaning the depositor will lose assets by depositing.
   */
  function previewWithdraw(uint256 assets) external view returns (uint256 shares);

  /**
   * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
   *
   * - MUST emit the Withdraw event.
   * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
   *   withdraw execution, and are accounted for during withdraw.
   * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
   *   not having enough shares, etc).
   *
   * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
   * Those methods should be performed separately.
   */
  function withdraw(
    uint256 assets,
    address receiver,
    address owner
  ) external returns (uint256 shares);

  /**
   * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
   * through a redeem call.
   *
   * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
   * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
   * - MUST NOT revert.
   */
  function maxRedeem(address owner) external view returns (uint256 maxShares);

  /**
   * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
   * given current on-chain conditions.
   *
   * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
   *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
   *   same transaction.
   * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
   *   redemption would be accepted, regardless if the user has enough shares, etc.
   * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
   * - MUST NOT revert.
   *
   * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
   * share price or some other type of condition, meaning the depositor will lose assets by redeeming.
   */
  function previewRedeem(uint256 shares) external view returns (uint256 assets);

  /**
   * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
   *
   * - MUST emit the Withdraw event.
   * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
   *   redeem execution, and are accounted for during redeem.
   * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
   *   not having enough shares, etc).
   *
   * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
   * Those methods should be performed separately.
   */
  function redeem(
    uint256 shares,
    address receiver,
    address owner
  ) external returns (uint256 assets);
}

File 9 of 24 : ConverterBase.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";

import { IWETH } from "../../interfaces/IWETH.sol";

abstract contract ConverterBase {
  using SafeERC20 for IERC20;

  /*************
   * Constants *
   *************/

  /// @dev The address of ETH which is commonly used.
  address internal constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

  /// @dev The address of WETH token.
  address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

  /****************************
   * Public Mutated Functions *
   ****************************/

  // solhint-disable-next-line no-empty-blocks
  receive() external payable {}

  /**********************
   * Internal Functions *
   **********************/

  function _isETH(address _token) internal pure returns (bool) {
    return _token == ETH || _token == address(0);
  }

  function _wrapTokenIfNeeded(address _token, uint256 _amount) internal {
    if (_token == WETH && IERC20(_token).balanceOf(address(this)) < _amount) {
      IWETH(_token).deposit{ value: _amount }();
    }
  }

  function _unwrapIfNeeded(uint256 _amount) internal {
    if (address(this).balance < _amount) {
      IWETH(WETH).withdraw(_amount);
    }
  }

  function _approve(
    address _token,
    address _spender,
    uint256 _amount
  ) internal {
    if (!_isETH(_token) && IERC20(_token).allowance(address(this), _spender) < _amount) {
      // hBTC cannot approve 0
      if (_token != 0x0316EB71485b0Ab14103307bf65a021042c6d380) {
        IERC20(_token).safeApprove(_spender, 0);
      }
      IERC20(_token).safeApprove(_spender, uint256(-1));
    }
  }
}

File 10 of 24 : IConverterRegistry.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

interface IConverterRegistry {
  /*************************
   * Public View Functions *
   *************************/

  /// @notice Return the input token and output token for the route.
  /// @param route The encoding of the route.
  /// @return tokenIn The address of input token.
  /// @return tokenOut The address of output token.
  function getTokenPair(uint256 route) external view returns (address tokenIn, address tokenOut);

  /// @notice Return the address of converter for a specific pool type.
  /// @param poolType The type of converter.
  /// @return converter The address of converter.
  function getConverter(uint256 poolType) external view returns (address converter);
}

File 11 of 24 : ITokenConverter.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

interface ITokenConverter {
  /*************************
   * Public View Functions *
   *************************/

  /// @notice The address of Converter Registry.
  function registry() external view returns (address);

  /// @notice Return the input token and output token for the route.
  /// @param route The encoding of the route.
  /// @return tokenIn The address of input token.
  /// @return tokenOut The address of output token.
  function getTokenPair(uint256 route) external view returns (address tokenIn, address tokenOut);

  /// @notice Query the output token amount according to the encoding.
  ///
  /// @dev See the comments in `convert` for the meaning of encoding.
  ///
  /// @param encoding The encoding used to convert.
  /// @param amountIn The amount of input token.
  /// @param amountOut The amount of output token received.
  function queryConvert(uint256 encoding, uint256 amountIn) external view returns (uint256 amountOut);

  /****************************
   * Public Mutated Functions *
   ****************************/

  /// @notice Convert input token to output token according to the encoding.
  /// Assuming that the input token is already in the contract.
  ///
  /// @dev encoding for single route
  /// |   8 bits  | 2 bits |  246 bits  |
  /// | pool_type | action | customized |
  ///
  /// + pool_type = 0: UniswapV2, only action = 0
  ///   customized = |   160 bits   | 24 bits |     1 bit    | 1 bit | ... |
  ///                | pool address | fee_num | zero_for_one | twamm | ... |
  /// + pool_type = 1: UniswapV3, only action = 0
  ///   customized = |   160 bits   | 24 bits |     1 bit    | ... |
  ///                | pool address | fee_num | zero_for_one | ... |
  /// + pool_type = 2: BalancerV1, only action = 0
  ///   customized = |   160 bits   | 3 bits |  3 bits  |   3 bits  | ... |
  ///                | pool address | tokens | index in | index out | ... |
  /// + pool_type = 3: BalancerV2, only action = 0
  ///   customized = |   160 bits   | 3 bits |  3 bits  |   3 bits  | ... |
  ///                | pool address | tokens | index in | index out | ... |
  /// + pool_type = 4: CurvePlainPool or CurveFactoryPlainPool
  ///   customized = |   160 bits   | 3 bits |  3 bits  |   3 bits  |  1 bit  | ... |
  ///                | pool address | tokens | index in | index out | use_eth | ... |
  /// + pool_type = 5: CurveAPool
  ///   customized = |   160 bits   | 3 bits |  3 bits  |   3 bits  |     1 bits     | ... |
  ///                | pool address | tokens | index in | index out | use_underlying | ... |
  /// + pool_type = 6: CurveYPool
  ///   customized = |   160 bits   | 3 bits |  3 bits  |   3 bits  |     1 bits     | ... |
  ///                | pool address | tokens | index in | index out | use_underlying | ... |
  /// + pool_type = 7: CurveMetaPool or CurveFactoryMetaPool
  ///   customized = |   160 bits   | 3 bits |  3 bits  |   3 bits  | ... |
  ///                | pool address | tokens | index in | index out | ... |
  /// + pool_type = 8: CurveCryptoPool or CurveFactoryCryptoPool
  ///   customized = |   160 bits   | 3 bits |  3 bits  |   3 bits  |  1 bit  | ... |
  ///                | pool address | tokens | index in | index out | use_eth | ... |
  /// + pool_type = 9: ERC4626
  ///   customized = |   160 bits   | ... |
  ///                | pool address | ... |
  ///
  /// Note: tokens + 1 is the number of tokens of the pool
  ///
  /// + action = 0: swap
  /// + action = 1: add liquidity / wrap / stake
  /// + action = 2: remove liquidity / unwrap / unstake
  ///
  /// @param encoding The encoding used to convert.
  /// @param amountIn The amount of input token.
  /// @param recipient The address of token receiver.
  /// @return amountOut The amount of output token received.
  function convert(
    uint256 encoding,
    uint256 amountIn,
    address recipient
  ) external payable returns (uint256 amountOut);

  /// @notice Withdraw dust assets in this contract.
  /// @param token The address of token to withdraw.
  /// @param recipient The address of token receiver.
  function withdrawFund(address token, address recipient) external;
}

File 12 of 24 : IBalancerPool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

interface IBalancerPool {
  function getPoolId() external view returns (bytes32);
}

File 13 of 24 : IBalancerV1Pool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

interface IBalancerV1Pool {
  function getCurrentTokens() external view returns (address[] memory tokens);

  function joinPool(uint256 poolAmountOut, uint256[] calldata maxAmountsIn) external;

  function exitPool(uint256 poolAmountIn, uint256[] calldata minAmountsOut) external;

  function swapExactAmountIn(
    address tokenIn,
    uint256 tokenAmountIn,
    address tokenOut,
    uint256 minAmountOut,
    uint256 maxPrice
  ) external returns (uint256 tokenAmountOut, uint256 spotPriceAfter);

  function swapExactAmountOut(
    address tokenIn,
    uint256 maxAmountIn,
    address tokenOut,
    uint256 tokenAmountOut,
    uint256 maxPrice
  ) external returns (uint256 tokenAmountIn, uint256 spotPriceAfter);

  function joinswapExternAmountIn(
    address tokenIn,
    uint256 tokenAmountIn,
    uint256 minPoolAmountOut
  ) external returns (uint256 poolAmountOut);

  function joinswapPoolAmountOut(
    address tokenIn,
    uint256 poolAmountOut,
    uint256 maxAmountIn
  ) external returns (uint256 tokenAmountIn);

  function exitswapPoolAmountIn(
    address tokenOut,
    uint256 poolAmountIn,
    uint256 minAmountOut
  ) external returns (uint256 tokenAmountOut);

  function exitswapExternAmountOut(
    address tokenOut,
    uint256 tokenAmountOut,
    uint256 maxPoolAmountIn
  ) external returns (uint256 poolAmountIn);
}

File 14 of 24 : IBalancerVault.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;
pragma abicoder v2;

interface IBalancerVault {
  enum JoinKind {
    INIT,
    EXACT_TOKENS_IN_FOR_BPT_OUT,
    TOKEN_IN_FOR_EXACT_BPT_OUT,
    ALL_TOKENS_IN_FOR_EXACT_BPT_OUT
  }

  enum SwapKind {
    GIVEN_IN,
    GIVEN_OUT
  }

  struct SingleSwap {
    bytes32 poolId;
    SwapKind kind;
    address assetIn;
    address assetOut;
    uint256 amount;
    bytes userData;
  }

  struct FundManagement {
    address sender;
    bool fromInternalBalance;
    address payable recipient;
    bool toInternalBalance;
  }

  function getPoolTokens(bytes32 poolId)
    external
    view
    returns (
      address[] memory tokens,
      uint256[] memory balances,
      uint256 lastChangeBlock
    );

  function swap(
    SingleSwap memory singleSwap,
    FundManagement memory funds,
    uint256 limit,
    uint256 deadline
  ) external payable returns (uint256 amountCalculated);

  struct JoinPoolRequest {
    address[] assets;
    uint256[] maxAmountsIn;
    bytes userData;
    bool fromInternalBalance;
  }

  function joinPool(
    bytes32 poolId,
    address sender,
    address recipient,
    JoinPoolRequest memory request
  ) external payable;
}

File 15 of 24 : ICurveAPool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

// solhint-disable var-name-mixedcase, func-name-mixedcase

interface ICurveAPool {
  function remove_liquidity_one_coin(
    uint256 _token_amount,
    int128 i,
    uint256 _min_amount,
    bool _use_underlying
  ) external returns (uint256);

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

  function exchange(
    int128 i,
    int128 j,
    uint256 dx,
    uint256 min_dy
  ) external returns (uint256);

  function exchange_underlying(
    int128 i,
    int128 j,
    uint256 dx,
    uint256 min_dy
  ) external returns (uint256);

  function get_dy(
    int128 i,
    int128 j,
    uint256 dx
  ) external view returns (uint256);

  function get_dy_underlying(
    int128 i,
    int128 j,
    uint256 dx
  ) external view returns (uint256);

  function add_liquidity(
    uint256[2] memory _amounts,
    uint256 _min_mint_amount,
    bool _use_underlying
  ) external returns (uint256);

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

  function add_liquidity(
    uint256[3] memory _amounts,
    uint256 _min_mint_amount,
    bool _use_underlying
  ) external returns (uint256);

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

  function add_liquidity(
    uint256[4] memory _amounts,
    uint256 _min_mint_amount,
    bool _use_underlying
  ) external returns (uint256);

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

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

  function underlying_coins(uint256 index) external view returns (address);

  function lp_token() external view returns (address);
}

/// @dev This is the interface of Curve aave-style Pool with 2 tokens, examples:
/// + saave: https://curve.fi/saave
interface ICurveA2Pool is ICurveAPool {

}

/// @dev This is the interface of Curve aave-style Pool with 3 tokens, examples:
/// aave: https://curve.fi/aave
/// ironbank: https://curve.fi/ib
interface ICurveA3Pool is ICurveAPool {

}

/// @dev This is the interface of Curve aave-style Pool with 3 tokens, examples:
interface ICurveA4Pool is ICurveAPool {

}

File 16 of 24 : ICurveCryptoPool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

// solhint-disable func-name-mixedcase, var-name-mixedcase

/// @dev This is the interface of Curve Crypto Pools (including Factory Pool), examples:
/// + cvxeth: https://curve.fi/cvxeth
/// + crveth: https://curve.fi/crveth
/// + eursusd: https://curve.fi/eursusd
/// + teth: https://curve.fi/teth
/// + spelleth: https://curve.fi/spelleth

/// + FXS/ETH: https://curve.fi/factory-crypto/3
/// + YFI/ETH: https://curve.fi/factory-crypto/8
/// + AAVE/palStkAAVE: https://curve.fi/factory-crypto/9
/// + DYDX/ETH: https://curve.fi/factory-crypto/10
/// + SDT/ETH: https://curve.fi/factory-crypto/11
/// + BTRFLY/ETH: https://curve.fi/factory-crypto/17
/// + cvxFXS/FXS: https://curve.fi/factory-crypto/18
interface ICurveCryptoPool {
  function lp_price() external view returns (uint256);

  function price_oracle() external view returns (uint256);

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

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

  function remove_liquidity_one_coin(
    uint256 token_amount,
    uint256 i,
    uint256 min_amount
  ) external returns (uint256);

  function calc_withdraw_one_coin(uint256 token_amount, uint256 i) external view returns (uint256);

  function exchange(
    uint256 i,
    uint256 j,
    uint256 dx,
    uint256 min_dy
  ) external payable returns (uint256);

  function exchange_underlying(
    uint256 i,
    uint256 j,
    uint256 dx,
    uint256 min_dy
  ) external payable returns (uint256);

  function get_dy(
    uint256 i,
    uint256 j,
    uint256 dx
  ) external view returns (uint256);

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

  function token() external view returns (address);
}

/// @dev This is the interface of Zap Contract for Curve Meta Crypto Pools, examples:
/// + eurtusd: https://curve.fi/eurtusd
/// + xautusd: https://curve.fi/xautusd
interface IZapCurveMetaCryptoPool {
  function add_liquidity(uint256[4] memory amounts, uint256 min_mint_amount) external returns (uint256);

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

  function remove_liquidity_one_coin(
    uint256 token_amount,
    uint256 i,
    uint256 min_amount
  ) external;

  function calc_withdraw_one_coin(uint256 token_amount, uint256 i) external view returns (uint256);

  function exchange_underlying(
    uint256 i,
    uint256 j,
    uint256 dx,
    uint256 min_dy
  ) external returns (uint256);

  function get_dy_underlying(
    uint256 i,
    uint256 j,
    uint256 dx
  ) external view returns (uint256);

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

  function underlying_coins(uint256 index) external view returns (address);

  function token() external view returns (address);

  function base_pool() external view returns (address);

  function pool() external view returns (address);
}

/// @dev This is the interface of Curve Tri Crypto Pools, examples:
/// + tricrypto2: https://curve.fi/tricrypto2
/// + tricrypto: https://curve.fi/tricrypto
interface ICurveTriCryptoPool {
  function add_liquidity(uint256[3] memory amounts, uint256 min_mint_amount) external;

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

  function remove_liquidity_one_coin(
    uint256 token_amount,
    uint256 i,
    uint256 min_amount
  ) external;

  function calc_withdraw_one_coin(uint256 token_amount, uint256 i) external view returns (uint256);

  function exchange(
    uint256 i,
    uint256 j,
    uint256 dx,
    uint256 min_dy,
    bool use_eth
  ) external;

  function get_dy(
    uint256 i,
    uint256 j,
    uint256 dx
  ) external view returns (uint256);

  function token() external view returns (address);

  function coins(uint256 index) external returns (address);
}

File 17 of 24 : ICurveMetaPool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

// solhint-disable var-name-mixedcase, func-name-mixedcase

/// @dev This is the interface of Curve Meta Pool with (3pool or sbtc), examples:
/// + ust: https://curve.fi/ust
/// + dusd: https://www.curve.fi/dusd
/// + gusd: https://curve.fi/gusd
/// + husd: https://curve.fi/husd
/// + rai: https://curve.fi/rai
/// + musd: https://curve.fi/musd
///
/// + bbtc: https://curve.fi/bbtc
/// + obtc: https://www.curve.fi/obtc
/// + pbtc: https://www.curve.fi/pbtc
/// + tbtc: https://www.curve.fi/tbtc
interface ICurveMetaPoolSwap {
  function add_liquidity(uint256[2] memory _amounts, uint256 _min_mint_amount) external returns (uint256);

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

  function remove_liquidity_one_coin(
    uint256 token_amount,
    int128 i,
    uint256 min_amount
  ) external returns (uint256);

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

  function exchange(
    int128 i,
    int128 j,
    uint256 dx,
    uint256 min_dy
  ) external returns (uint256);

  function exchange_underlying(
    int128 i,
    int128 j,
    uint256 dx,
    uint256 min_dy
  ) external returns (uint256);

  function get_dy(
    int128 i,
    int128 j,
    uint256 dx
  ) external view returns (uint256);

  function get_dy_underlying(
    int128 i,
    int128 j,
    uint256 dx
  ) external view returns (uint256);

  function base_pool() external view returns (address);

  function base_coins(uint256 index) external view returns (address);

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

  function token() external view returns (address);
}

interface ICurveMetaPoolDeposit {
  function add_liquidity(uint256[4] memory amounts, uint256 min_mint_amount) external returns (uint256);

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

  function remove_liquidity_one_coin(
    uint256 token_amount,
    int128 i,
    uint256 min_amount
  ) external returns (uint256);

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

  function token() external view returns (address);

  function base_pool() external view returns (address);

  function pool() external view returns (address);

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

  function base_coins(uint256 index) external view returns (address);
}

File 18 of 24 : ICurvePlainPool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

// solhint-disable var-name-mixedcase, func-name-mixedcase

interface ICurvePlainPool {
  function exchange(
    int128 i,
    int128 j,
    uint256 dx,
    uint256 min_dy
  ) external payable;

  function get_dy(
    int128 i,
    int128 j,
    uint256 dx
  ) external view returns (uint256);

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

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

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

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

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

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

  function remove_liquidity_one_coin(
    uint256 _token_amount,
    int128 i,
    uint256 min_amount
  ) external;

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

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

  function balances(uint256 index) external view returns (uint256);

  // ren and sbtc pool
  function coins(int128 index) external view returns (address);

  // ren and sbtc pool
  function balances(int128 index) external view returns (uint256);

  function get_virtual_price() external view returns (uint256);
}

File 19 of 24 : ICurveYPool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

// solhint-disable var-name-mixedcase, func-name-mixedcase

interface ICurveYPoolSwap {
  function exchange(
    int128 i,
    int128 j,
    uint256 dx,
    uint256 min_dy
  ) external;

  function exchange_underlying(
    int128 i,
    int128 j,
    uint256 dx,
    uint256 min_dy
  ) external;

  function get_dy(
    int128 i,
    int128 j,
    uint256 dx
  ) external view returns (uint256);

  function get_dy_underlying(
    int128 i,
    int128 j,
    uint256 dx
  ) external view returns (uint256);

  function add_liquidity(uint256[2] memory _amounts, uint256 _min_mint_amount) external;

  function add_liquidity(uint256[3] memory _amounts, uint256 _min_mint_amount) external;

  function add_liquidity(uint256[4] memory _amounts, uint256 _min_mint_amount) external;

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

  function underlying_coins(uint256 index) external view returns (address);
}

interface ICurveYPoolDeposit {
  function remove_liquidity_one_coin(
    uint256 _token_amount,
    int128 i,
    uint256 _min_amount,
    bool donate_dust
  ) external;

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

  function add_liquidity(uint256[2] memory _amounts, uint256 _min_mint_amount) external;

  function add_liquidity(uint256[3] memory _amounts, uint256 _min_mint_amount) external;

  function add_liquidity(uint256[4] memory _amounts, uint256 _min_mint_amount) external;

  function token() external view returns (address);

  function curve() external view returns (address);

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

  function underlying_coins(uint256 index) external view returns (address);

  function coins(int128 index) external view returns (address);

  function underlying_coins(int128 index) external view returns (address);
}

// solhint-disable var-name-mixedcase, func-name-mixedcase
/// @dev This is the interface of Curve yearn-style Pool with 2 tokens, examples:
/// + compound: https://curve.fi/compound
interface ICurveY2PoolDeposit is ICurveYPoolDeposit {

}

interface ICurveY2PoolSwap is ICurveYPoolSwap {}

/// @dev This is the interface of Curve yearn-style Pool with 3 tokens, examples:
/// usdt: https://curve.fi/usdt
interface ICurveY3PoolDeposit is ICurveYPoolDeposit {

}

interface ICurveY3PoolSwap is ICurveYPoolSwap {}

/// @dev This is the interface of Curve yearn-style Pool with 4 tokens, examples:
/// + pax: https://curve.fi/pax
/// + y: https://curve.fi/iearn
/// + busd: https://curve.fi/busd
/// + susd v2: https://curve.fi/susdv2
interface ICurveY4PoolDeposit is ICurveYPoolDeposit {

}

interface ICurveY4PoolSwap is ICurveYPoolSwap {}

File 20 of 24 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

interface IERC20Metadata {
  function decimals() external view returns (uint8);

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

  function name() external view returns (string memory);
}

File 21 of 24 : IUniswapV2Pair.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

interface IUniswapV2Pair {
  function token0() external view returns (address);

  function token1() external view returns (address);

  function executeVirtualOrders(uint256 blockTimestamp) external;

  function getReserves()
    external
    view
    returns (
      uint112 _reserve0,
      uint112 _reserve1,
      uint32 _blockTimestampLast
    );

  function swap(
    uint256 amount0Out,
    uint256 amount1Out,
    address to,
    bytes calldata data
  ) external;
}

File 22 of 24 : IUniswapV3Pool.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

interface IUniswapV3Pool {
  function token0() external returns (address);

  function token1() external returns (address);

  function fee() external returns (uint24);
}

File 23 of 24 : IUniswapV3Router.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;
pragma abicoder v2;

interface IUniswapV3Router {
  struct ExactInputSingleParams {
    address tokenIn;
    address tokenOut;
    uint24 fee;
    address recipient;
    uint256 deadline;
    uint256 amountIn;
    uint256 amountOutMinimum;
    uint160 sqrtPriceLimitX96;
  }

  function exactInputSingle(ExactInputSingleParams calldata params) external returns (uint256 amountOut);
}

File 24 of 24 : IWETH.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;

interface IWETH {
  function deposit() external payable;

  function withdraw(uint256 wad) external;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_registry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"uint256","name":"_encoding","type":"uint256"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"convert","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_route","type":"uint256"}],"name":"getTokenPair","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_encoding","type":"uint256"},{"internalType":"uint256","name":"_amountIn","type":"uint256"}],"name":"queryConvert","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"supportedPoolTypes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_supportedPoolTypes","type":"uint256"}],"name":"updateSupportedPoolTypes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"withdrawFund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523480156200001157600080fd5b5060405162003e6d38038062003e6d8339810160408190526200003491620000a4565b600062000040620000a0565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060601b6001600160601b031916608052620000d4565b3390565b600060208284031215620000b6578081fd5b81516001600160a01b0381168114620000cd578182fd5b9392505050565b60805160601c613d6c62000101600039806101e652806103f1528061062052806106ff5250613d6c6000f3fe6080604052600436106100955760003560e01c80637c21ce14116100595780637c21ce14146101385780638da5cb5b146101665780639114750b1461017b578063f2fde38b1461019b578063fb57363c146101bb5761009c565b806322fdad5f146100a1578063392f084f146100c35780635744ba15146100ec578063715018a6146101015780637b103999146101165761009c565b3661009c57005b600080fd5b3480156100ad57600080fd5b506100c16100bc366004613454565b6101db565b005b6100d66100d1366004613643565b610351565b6040516100e391906138f6565b60405180910390f35b3480156100f857600080fd5b506100d661055a565b34801561010d57600080fd5b506100c1610560565b34801561012257600080fd5b5061012b61061e565b6040516100e3919061375f565b34801561014457600080fd5b506101586101533660046135e7565b610642565b6040516100e3929190613773565b34801561017257600080fd5b5061012b61066b565b34801561018757600080fd5b506100d66101963660046135ff565b61067a565b3480156101a757600080fd5b506100c16101b636600461341c565b610811565b3480156101c757600080fd5b506100c16101d63660046135e7565b610925565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461022c5760405162461bcd60e51b815260040161022390613a2c565b60405180910390fd5b6001600160a01b0382166102bc576000816001600160a01b0316476040516102539061375c565b60006040518083038185875af1925050503d8060008114610290576040519150601f19603f3d011682016040523d82523d6000602084013e610295565b606091505b50509050806102b65760405162461bcd60e51b815260040161022390613985565b5061034d565b61034d81836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016102ec919061375f565b60206040518083038186803b15801561030457600080fd5b505afa158015610318573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033c9190613581565b6001600160a01b038516919061099e565b5050565b6001805460009160ff8616916003600888901c169190831c811614156103d757600a9590951c948061039057610389828787876109f5565b92506103d2565b80600114156103a557610389828787876115a3565b80600214156103ba5761038982878787611b74565b60405162461bcd60e51b815260040161022390613a04565b610551565b604051635120990b60e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635120990b906104269086906004016138f6565b60206040518083038186803b15801561043e57600080fd5b505afa158015610452573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104769190613438565b9050600080826001600160a01b031663392f084f60e01b888b8b6040516024016104a2939291906137c1565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516104e09190613740565b600060405180830381855af49150503d806000811461051b576040519150601f19603f3d011682016040523d82523d6000602084013e610520565b606091505b509150915081610537576040513d806000833e8082fd5b8080602001905181019061054b9190613581565b95505050505b50509392505050565b60015481565b610568611fcf565b6001600160a01b031661057961066b565b6001600160a01b0316146105d4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f000000000000000000000000000000000000000000000000000000000000000081565b60008060ff83166003600885901c166106608282600a88901c611fd3565b935093505050915091565b6000546001600160a01b031690565b6001805460009160ff8516916003600887901c169190831c811614156106e557600a9490941c93806106b8576106b1828686612544565b92506106e0565b80600114156106cc576106b1828686612752565b80600214156103ba576106b18286866129b7565b610809565b604051635120990b60e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635120990b906107349086906004016138f6565b60206040518083038186803b15801561074c57600080fd5b505afa158015610760573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107849190613438565b604051639114750b60e01b81529091506001600160a01b03821690639114750b906107b59089908990600401613bc8565b60206040518083038186803b1580156107cd57600080fd5b505afa1580156107e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108059190613581565b9350505b505092915050565b610819611fcf565b6001600160a01b031661082a61066b565b6001600160a01b031614610885576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166108ca5760405162461bcd60e51b8152600401808060200182810382526026815260200180613c8b6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b61092d611fcf565b6001600160a01b031661093e61066b565b6001600160a01b031614610999576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600155565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526109f0908490612b37565b505050565b6000806000610a0687600088611fd3565b90925090506001600160a01b0386166004881480610a245750876008145b8015610a37575060a987901c6001166001145b15610a4a57610a4586612be8565b610a54565b610a548387612c66565b87610c9c5760b987901c60011660011415610ac857604051632e0ae37560e01b81526001600160a01b03821690632e0ae37590610a959042906004016138f6565b600060405180830381600087803b158015610aaf57600080fd5b505af1158015610ac3573d6000803e3d6000fd5b505050505b600060b888901c6001169050600080836001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610b1057600080fd5b505afa158015610b24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b489190613599565b506001600160701b031691506001600160701b031691508260001415610b6a57905b60a08a901c62ffffff16890296508682620f4240020181880281610b8a57fe5b049650610ba16001600160a01b038716858b61099e565b8260011415610c2057604080516000808252602082019283905263022c0d9f60e01b9092526001600160a01b0386169163022c0d9f91610be991908b908d906024810161394e565b600060405180830381600087803b158015610c0357600080fd5b505af1158015610c17573d6000803e3d6000fd5b50505050610c91565b604080516000808252602082019283905263022c0d9f60e01b9092526001600160a01b0386169163022c0d9f91610c5e918b918d906024810161394e565b600060405180830381600087803b158015610c7857600080fd5b505af1158015610c8c573d6000803e3d6000fd5b505050505b50505050505061159b565b8760011415610db05762ffffff60a088901c16610cce8473e592427a0aece92de3edee1f18e0157c0586156489612d66565b60408051610100810182526001600160a01b038087168252858116602083015262ffffff841682840152881660608201526001428101608083015260a082018a905260c0820152600060e0820152905163414bf38960e01b815273e592427a0aece92de3edee1f18e0157c058615649063414bf38990610d52908490600401613a53565b602060405180830381600087803b158015610d6c57600080fd5b505af1158015610d80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da49190613581565b9550505050505061159b565b8760021415610e5357610dc4838288612d66565b604051638201aa3f60e01b81526001600160a01b03821690638201aa3f90610dfb9086908a9087906000906000199060040161378d565b6040805180830381600087803b158015610e1457600080fd5b505af1158015610e28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4c9190613620565b50506114c6565b8760031415610ff4576000816001600160a01b03166338fff2d06040518163ffffffff1660e01b815260040160206040518083038186803b158015610e9757600080fd5b505afa158015610eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecf9190613581565b9050610edb8488612c66565b610efa8473ba12222222228d8ba445958a75a0704d566bf2c889612d66565b6040805160c081018252828152600060208083018290526001600160a01b038881168486015287811660608086019190915260808086018e90528651858152808501885260a087015286519081018752308152928301849052908b1682860152810182905292516352bbbe2960e01b815273ba12222222228d8ba445958a75a0704d566bf2c8936352bbbe2993610f979390924290600401613abc565b602060405180830381600087803b158015610fb157600080fd5b505af1158015610fc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe99190613581565b94505050505061159b565b600888116114ae57600760a388901c81169060a689901c1661101785848a612d66565b896004141561110e57600160a98a901c166110a15761103785848a612d66565b604051630f7c084960e21b81526001600160a01b03841690633df021249061106a90859085908d9060009060040161392b565b600060405180830381600087803b15801561108457600080fd5b505af1158015611098573d6000803e3d6000fd5b50505050611109565b604051630f7c084960e21b81526001600160a01b03841690633df02124908a906110d69086908690849060009060040161392b565b6000604051808303818588803b1580156110ef57600080fd5b505af1158015611103573d6000803e3d6000fd5b50505050505b610e4c565b89600514156112445761112285848a612d66565b600160a98a901c166111b957604051630f7c084960e21b81526001600160a01b03841690633df021249061116190859085908d9060009060040161392b565b602060405180830381600087803b15801561117b57600080fd5b505af115801561118f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b39190613581565b50611109565b604051635320bf6b60e11b81526001600160a01b0384169063a6417ed6906111ec90859085908d9060009060040161392b565b602060405180830381600087803b15801561120657600080fd5b505af115801561121a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123e9190613581565b50610e4c565b89600614156113855760a989901c600116600114156112d157826001600160a01b0316637165485d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561129657600080fd5b505afa1580156112aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ce9190613438565b92505b6112dc85848a612d66565b600160a98a901c1661131b57604051630f7c084960e21b81526001600160a01b03841690633df021249061106a90859085908d9060009060040161392b565b604051635320bf6b60e11b81526001600160a01b0384169063a6417ed69061134e90859085908d9060009060040161392b565b600060405180830381600087803b15801561136857600080fd5b505af115801561137c573d6000803e3d6000fd5b50505050610e4c565b89600714156113cc5761139985848a612d66565b604051630f7c084960e21b81526001600160a01b03841690633df02124906111ec90859085908d9060009060040161392b565b8960081415610e4c57600160a98a901c1661141f576113ec85848a612d66565b604051630b68372160e31b81526001600160a01b03841690635b41b908906111ec90859085908d90600090600401613bec565b604051630b68372160e31b81526001600160a01b03841690635b41b908908a9061145490869086908490600090600401613bec565b6020604051808303818588803b15801561146d57600080fd5b505af1158015611481573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906114a69190613581565b5050506114c6565b60405162461bcd60e51b8152600401610223906139b2565b6001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214156114f5576114f58247612c66565b6040516370a0823160e01b81526001600160a01b038316906370a082319061152190309060040161375f565b60206040518083038186803b15801561153957600080fd5b505afa15801561154d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115719190613581565b93506001600160a01b0385163014611597576115976001600160a01b038316868661099e565b5050505b949350505050565b60008060006115b487600188611fd3565b90925090506001600160a01b03861660048814806115d25750876008145b80156115e5575060a987901c6001166001145b156115f8576115f386612be8565b611602565b6116028387612c66565b87600411158015611614575060088811155b15611ad65761162281612e49565b905060a087901c60079081166001019060a389901c166002821080159061164a575060048211155b6116665760405162461bcd60e51b8152600401610223906139dc565b896005141561182b57600160a98a901c81161461168486858b612d66565b826002141561173157611695613336565b898184600281106116a257fe5b602002015260405163ee22be2360e01b81526001600160a01b0386169063ee22be23906116d8908490600090879060040161381a565b602060405180830381600087803b1580156116f257600080fd5b505af1158015611706573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172a9190613581565b5050611825565b826003141561178557611742613354565b8981846003811061174f57fe5b60200201526040516315b74c9d60e11b81526001600160a01b03861690632b6e993a906116d89084906000908790600401613876565b61178d613372565b8981846004811061179a57fe5b602002015260405163dc3a2d8160e01b81526001600160a01b0386169063dc3a2d81906117d090849060009087906004016138d2565b602060405180830381600087803b1580156117ea57600080fd5b505af11580156117fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118229190613581565b50505b50611acf565b60008a6004148061183c57508a6008145b801561184f575060a98a901c6001166001145b9050806118615761186186858b612d66565b826002141561195a57611872613336565b8981846002811061187f57fe5b602002015281156118f257604051630b4c7e4d60e01b81526001600160a01b03861690630b4c7e4d908c906118bb9085906000906004016137ff565b6000604051808303818588803b1580156118d457600080fd5b505af11580156118e8573d6000803e3d6000fd5b5050505050611954565b604051630b4c7e4d60e01b81526001600160a01b03861690630b4c7e4d906119219084906000906004016137ff565b600060405180830381600087803b15801561193b57600080fd5b505af115801561194f573d6000803e3d6000fd5b505050505b50611acd565b82600314156119e35761196b613354565b8981846003811061197857fe5b602002015281156119b457604051634515cef360e01b81526001600160a01b03861690634515cef3908c906118bb90859060009060040161385b565b604051634515cef360e01b81526001600160a01b03861690634515cef39061192190849060009060040161385b565b6119eb613372565b898184600481106119f857fe5b60200201528115611a6a5760405162a6cbcd60e21b81526001600160a01b0386169063029b2f34908c90611a339085906000906004016138b7565b6000604051808303818588803b158015611a4c57600080fd5b505af1158015611a60573d6000803e3d6000fd5b5050505050611acb565b60405162a6cbcd60e21b81526001600160a01b0386169063029b2f3490611a989084906000906004016138b7565b600060405180830381600087803b158015611ab257600080fd5b505af1158015611ac6573d6000803e3d6000fd5b505050505b505b505b50506114f5565b87600914156114ae57611aea838288612d66565b604051636e553f6560e01b81526001600160a01b03821690636e553f6590611b189089908990600401613b48565b602060405180830381600087803b158015611b3257600080fd5b505af1158015611b46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6a9190613581565b935050505061159b565b600080611b8386600287611fd3565b9150506001600160a01b03851660048710801590611ba2575060088711155b15611e6057611bb081612e49565b905060a086901c60079081166001019060a688901c1660028210801590611bd8575060048211155b611bf45760405162461bcd60e51b8152600401610223906139dc565b8860041415611c6557604051630d2680e960e11b81526001600160a01b03841690631a4d01d290611c2e908a908590600090600401613b8f565b600060405180830381600087803b158015611c4857600080fd5b505af1158015611c5c573d6000803e3d6000fd5b50505050611e59565b8860051415611d055760405163517a55a360e01b8152600160a98a901c811614906001600160a01b0385169063517a55a390611cac908b9086906000908790600401613ba8565b602060405180830381600087803b158015611cc657600080fd5b505af1158015611cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfe9190613581565b5050611e59565b8860061415611d425760405163517a55a360e01b81526001600160a01b0384169063517a55a390611c2e908a908590600090600190600401613ba8565b8860071415611dd457604051630d2680e960e11b81526001600160a01b03841690631a4d01d290611d7c908a908590600090600401613b8f565b602060405180830381600087803b158015611d9657600080fd5b505af1158015611daa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dce9190613581565b50611e59565b60405163f1dc3cc960e01b81526001600160a01b0384169063f1dc3cc990611e05908a908590600090600401613bd6565b602060405180830381600087803b158015611e1f57600080fd5b505af1158015611e33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e579190613581565b505b5050611ef4565b86600914156114ae57604051635d043b2960e11b81526001600160a01b0382169063ba08765290611e9990889088903090600401613b5f565b602060405180830381600087803b158015611eb357600080fd5b505af1158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190613581565b9250505061159b565b6001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611f2357611f238247612c66565b6040516370a0823160e01b81526001600160a01b038316906370a0823190611f4f90309060040161375f565b60206040518083038186803b158015611f6757600080fd5b505afa158015611f7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9f9190613581565b92506001600160a01b0384163014611fc557611fc56001600160a01b038316858561099e565b5050949350505050565b3390565b6000806001600160a01b0383168461233657600186116120ea57806001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561202657600080fd5b505afa15801561203a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061205e9190613438565b9250806001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561209957600080fd5b505afa1580156120ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d19190613438565b9150600160b885901c16806120e4579192915b50612331565b85600214156121ac576000816001600160a01b031663cc77828d6040518163ffffffff1660e01b815260040160006040518083038186803b15801561212e57600080fd5b505afa158015612142573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261216a919081019061348c565b90508060a386901c6007168151811061217f57fe5b602002602001015193508060a686901c6007168151811061219c57fe5b6020026020010151935050612331565b85600314156122fe576000816001600160a01b03166338fff2d06040518163ffffffff1660e01b815260040160206040518083038186803b1580156121f057600080fd5b505afa158015612204573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122289190613581565b604051631f29a8cd60e31b815290915060009073ba12222222228d8ba445958a75a0704d566bf2c89063f94d4668906122659085906004016138f6565b60006040518083038186803b15801561227d57600080fd5b505afa158015612291573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526122b991908101906134bf565b505090508060a387901c600716815181106122d057fe5b602002602001015194508060a687901c600716815181106122ed57fe5b602002602001015193505050612331565b6008861161233157612319818760a387901c60071687612e7b565b925061232e818760a687901c60071687612e7b565b91505b6124c1565b84600114156124015780915085600411158015612354575060088611155b1561237e5761236281612e49565b9050612377818760a387901c60071687612e7b565b9250612331565b85600914156123f857806001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156123c057600080fd5b505afa1580156123d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123779190613438565b600091506124c1565b84600214156124c1578092508560041115801561241f575060088611155b156124425761242d81612e49565b905061232e818760a687901c60071687612e7b565b85600914156124bc57806001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561248457600080fd5b505afa158015612498573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232e9190613438565b600092505b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156124fe5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc292505b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561253b5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc291505b50935093915050565b60006001600160a01b0383168461255a5761274a565b84600114156125685761274a565b84600214156125765761274a565b84600314156125845761274a565b6008851161274a57600760a385901c81169060a686901c16600887141561262c5760405163556d6e9f60e01b81526001600160a01b0384169063556d6e9f906125d590859085908a90600401613bd6565b60206040518083038186803b1580156125ed57600080fd5b505afa158015612601573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126259190613581565b9350612747565b866005148015612643575060a986901c6001166001145b15612678576040516307211ef760e01b81526001600160a01b038416906307211ef7906125d590859085908a9060040161390d565b86600614801561268f575060a986901c6001166001145b156126c4576040516307211ef760e01b81526001600160a01b038416906307211ef7906125d590859085908a9060040161390d565b604051635e0d443f60e01b81526001600160a01b03841690635e0d443f906126f490859085908a9060040161390d565b60206040518083038186803b15801561270c57600080fd5b505afa158015612720573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127449190613581565b93505b50505b509392505050565b60006001600160a01b03831660048510801590612770575060088511155b156129295760a084901c60079081166001019060a686901c1660028214156128335761279a613336565b858183600281106127a757fe5b602002015260405163ed8e84f360e01b81526001600160a01b0385169063ed8e84f3906127db9084906001906004016137e2565b60206040518083038186803b1580156127f357600080fd5b505afa158015612807573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061282b9190613581565b945050612922565b816003141561288557612844613354565b8581836003811061285157fe5b6020020152604051633883e11960e01b81526001600160a01b03851690633883e119906127db90849060019060040161383e565b61288d613372565b8581836004811061289a57fe5b602002015260405163cf701ff760e01b81526001600160a01b0385169063cf701ff7906128ce90849060019060040161389a565b60206040518083038186803b1580156128e657600080fd5b505afa1580156128fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291e9190613581565b9450505b505061274a565b846009141561274a5760405163ef8b30f760e01b81526001600160a01b0382169063ef8b30f79061295e9086906004016138f6565b60206040518083038186803b15801561297657600080fd5b505afa15801561298a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ae9190613581565b95945050505050565b60006001600160a01b038316600485108015906129d5575060088511155b15612b02576129e381612e49565b9050600760a685901c166008861415612a7b576040516327d8462f60e11b81526001600160a01b03831690634fb08c5e90612a249087908590600401613bc8565b60206040518083038186803b158015612a3c57600080fd5b505afa158015612a50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a749190613581565b9250612afc565b60405163cc2b27d760e01b81526001600160a01b0383169063cc2b27d790612aa99087908590600401613b7e565b60206040518083038186803b158015612ac157600080fd5b505afa158015612ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af99190613581565b92505b5061274a565b846009141561274a5760405163266d6a8360e11b81526001600160a01b03821690634cdad5069061295e9086906004016138f6565b6000612b8c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612fcb9092919063ffffffff16565b8051909150156109f057808060200190516020811015612bab57600080fd5b50516109f05760405162461bcd60e51b815260040180806020018281038252602a815260200180613cd7602a913960400191505060405180910390fd5b80471015612c635773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015612c4a57600080fd5b505af1158015612c5e573d6000803e3d6000fd5b505050505b50565b6001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015612d09575080826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612cdb57600080fd5b505afa158015612cef573d6000803e3d6000fd5b505050506040513d6020811015612d0557600080fd5b5051105b1561034d57816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612d4957600080fd5b505af1158015612d5d573d6000803e3d6000fd5b50505050505050565b612d6f83612fe4565b158015612df5575060408051636eb1769f60e11b81523060048201526001600160a01b0384811660248301529151839286169163dd62ed3e916044808301926020929190829003018186803b158015612dc757600080fd5b505afa158015612ddb573d6000803e3d6000fd5b505050506040513d6020811015612df157600080fd5b5051105b156109f057730316eb71485b0ab14103307bf65a021042c6d3806001600160a01b03841614612e3357612e336001600160a01b03841683600061301e565b6109f06001600160a01b0384168360001961301e565b60006303aa30b960e11b6000526020600060046000855afa8015612e6d5760005191505b5080612e765750805b919050565b60008360051480612e8c5750836006145b8015612e9f575060a982901c6001166001145b15612f2757604051630b9947eb60e41b81526001600160a01b0386169063b9947eb090612ed09086906004016138f6565b60206040518083038186803b158015612ee857600080fd5b505afa158015612efc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f209190613438565b905061159b565b60405163c661065760e01b81526001600160a01b0386169063c661065790612f539086906004016138f6565b60206040518083038186803b158015612f6b57600080fd5b505afa925050508015612f9b575060408051601f3d908101601f19168201909252612f9891810190613438565b60015b6129ae5760405163046e8dd760e31b81526001600160a01b038616906323746eb890612ed09086906004016138ff565b6060612fda8484600085613131565b90505b9392505050565b60006001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee148061301857506001600160a01b038216155b92915050565b8015806130a4575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561307657600080fd5b505afa15801561308a573d6000803e3d6000fd5b505050506040513d60208110156130a057600080fd5b5051155b6130df5760405162461bcd60e51b8152600401808060200182810382526036815260200180613d016036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526109f0908490612b37565b6060824710156131725760405162461bcd60e51b8152600401808060200182810382526026815260200180613cb16026913960400191505060405180910390fd5b61317b8561328c565b6131cc576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b6020831061320a5780518252601f1990920191602091820191016131eb565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461326c576040519150601f19603f3d011682016040523d82523d6000602084013e613271565b606091505b5091509150613281828286613292565b979650505050505050565b3b151590565b606083156132a1575081612fdd565b8251156132b15782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156132fb5781810151838201526020016132e3565b50505050905090810190601f1680156133285780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b600082601f8301126133a0578081fd5b815160206133b56133b083613c2b565b613c07565b82815281810190858301838502870184018810156133d1578586fd5b855b858110156133f85781516133e681613c75565b845292840192908401906001016133d3565b5090979650505050505050565b80516001600160701b0381168114612e7657600080fd5b60006020828403121561342d578081fd5b8135612fdd81613c75565b600060208284031215613449578081fd5b8151612fdd81613c75565b60008060408385031215613466578081fd5b823561347181613c75565b9150602083013561348181613c75565b809150509250929050565b60006020828403121561349d578081fd5b815167ffffffffffffffff8111156134b3578182fd5b61159b84828501613390565b6000806000606084860312156134d3578081fd5b835167ffffffffffffffff808211156134ea578283fd5b6134f687838801613390565b945060209150818601518181111561350c578384fd5b86019050601f8101871361351e578283fd5b805161352c6133b082613c2b565b81815283810190838501858402850186018b1015613548578687fd5b8694505b8385101561356a57805183526001949094019391850191850161354c565b508096505050505050604084015190509250925092565b600060208284031215613592578081fd5b5051919050565b6000806000606084860312156135ad578283fd5b6135b684613405565b92506135c460208501613405565b9150604084015163ffffffff811681146135dc578182fd5b809150509250925092565b6000602082840312156135f8578081fd5b5035919050565b60008060408385031215613611578182fd5b50508035926020909101359150565b60008060408385031215613632578182fd5b505080516020909101519092909150565b600080600060608486031215613657578283fd5b833592506020840135915060408401356135dc81613c75565b8060005b6002811015613693578151845260209384019390910190600101613674565b50505050565b8060005b600381101561369357815184526020938401939091019060010161369d565b8060005b60048110156136935781518452602093840193909101906001016136c0565b600081518084526136f7816020860160208601613c49565b601f01601f19169290920160200192915050565b80516001600160a01b039081168352602080830151151590840152604080830151909116908301526060908101511515910152565b60008251613752818460208701613c49565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03958616815260208101949094529190931660408301526060820192909252608081019190915260a00190565b6001600160a01b039390931683526020830191909152604082015260600190565b606081016137f08285613670565b82151560408301529392505050565b6060810161380d8285613670565b8260408301529392505050565b608081016138288286613670565b8360408301528215156060830152949350505050565b6080810161384c8285613699565b82151560608301529392505050565b608081016138698285613699565b8260608301529392505050565b60a081016138848286613699565b8360608301528215156080830152949350505050565b60a081016138a882856136bc565b82151560808301529392505050565b60a081016138c582856136bc565b8260808301529392505050565b60c081016138e082866136bc565b83608083015282151560a0830152949350505050565b90815260200190565b600f9190910b815260200190565b600f93840b81529190920b6020820152604081019190915260600190565b600f94850b81529290930b60208301526040820152606081019190915260800190565b600085825284602083015260018060a01b03841660408301526080606083015261397b60808301846136df565b9695505050505050565b6020808252601390820152721dda5d1a191c985dc81155120819985a5b1959606a1b604082015260600190565b60208082526010908201526f696e76616c696420706f6f6c5479706560801b604082015260600190565b6020808252600e908201526d696e76616c696420746f6b656e7360901b604082015260600190565b6020808252600e908201526d34b73b30b634b21030b1ba34b7b760911b604082015260600190565b6020808252600d908201526c6f6e6c7920726567697374727960981b604082015260600190565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c0808401519083015260e09283015116918101919091526101000190565b600060e08252855160e0830152602086015160028110613ad857fe5b61010083015260408601516001600160a01b03908116610120840152606087015116610140830152608086015161016083015260a086015160c0610180840152613b266101a08401826136df565b915050613b36602083018661370b565b60a082019390935260c0015292915050565b9182526001600160a01b0316602082015260400190565b9283526001600160a01b03918216602084015216604082015260600190565b918252600f0b602082015260400190565b928352600f9190910b6020830152604082015260600190565b938452600f9290920b602084015260408301521515606082015260800190565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60405181810167ffffffffffffffff81118282101715613c2357fe5b604052919050565b600067ffffffffffffffff821115613c3f57fe5b5060209081020190565b60005b83811015613c64578181015183820152602001613c4c565b838111156136935750506000910152565b6001600160a01b0381168114612c6357600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220f8a03449209acf98094a4ee048c4ff6e63d762ba389af7b7b0f236f120946cf964736f6c63430007060033000000000000000000000000a617206663343b6353acf27566586ee9b53dfb2b

Deployed Bytecode

0x6080604052600436106100955760003560e01c80637c21ce14116100595780637c21ce14146101385780638da5cb5b146101665780639114750b1461017b578063f2fde38b1461019b578063fb57363c146101bb5761009c565b806322fdad5f146100a1578063392f084f146100c35780635744ba15146100ec578063715018a6146101015780637b103999146101165761009c565b3661009c57005b600080fd5b3480156100ad57600080fd5b506100c16100bc366004613454565b6101db565b005b6100d66100d1366004613643565b610351565b6040516100e391906138f6565b60405180910390f35b3480156100f857600080fd5b506100d661055a565b34801561010d57600080fd5b506100c1610560565b34801561012257600080fd5b5061012b61061e565b6040516100e3919061375f565b34801561014457600080fd5b506101586101533660046135e7565b610642565b6040516100e3929190613773565b34801561017257600080fd5b5061012b61066b565b34801561018757600080fd5b506100d66101963660046135ff565b61067a565b3480156101a757600080fd5b506100c16101b636600461341c565b610811565b3480156101c757600080fd5b506100c16101d63660046135e7565b610925565b336001600160a01b037f000000000000000000000000a617206663343b6353acf27566586ee9b53dfb2b161461022c5760405162461bcd60e51b815260040161022390613a2c565b60405180910390fd5b6001600160a01b0382166102bc576000816001600160a01b0316476040516102539061375c565b60006040518083038185875af1925050503d8060008114610290576040519150601f19603f3d011682016040523d82523d6000602084013e610295565b606091505b50509050806102b65760405162461bcd60e51b815260040161022390613985565b5061034d565b61034d81836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016102ec919061375f565b60206040518083038186803b15801561030457600080fd5b505afa158015610318573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033c9190613581565b6001600160a01b038516919061099e565b5050565b6001805460009160ff8616916003600888901c169190831c811614156103d757600a9590951c948061039057610389828787876109f5565b92506103d2565b80600114156103a557610389828787876115a3565b80600214156103ba5761038982878787611b74565b60405162461bcd60e51b815260040161022390613a04565b610551565b604051635120990b60e01b81526000906001600160a01b037f000000000000000000000000a617206663343b6353acf27566586ee9b53dfb2b1690635120990b906104269086906004016138f6565b60206040518083038186803b15801561043e57600080fd5b505afa158015610452573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104769190613438565b9050600080826001600160a01b031663392f084f60e01b888b8b6040516024016104a2939291906137c1565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516104e09190613740565b600060405180830381855af49150503d806000811461051b576040519150601f19603f3d011682016040523d82523d6000602084013e610520565b606091505b509150915081610537576040513d806000833e8082fd5b8080602001905181019061054b9190613581565b95505050505b50509392505050565b60015481565b610568611fcf565b6001600160a01b031661057961066b565b6001600160a01b0316146105d4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f000000000000000000000000a617206663343b6353acf27566586ee9b53dfb2b81565b60008060ff83166003600885901c166106608282600a88901c611fd3565b935093505050915091565b6000546001600160a01b031690565b6001805460009160ff8516916003600887901c169190831c811614156106e557600a9490941c93806106b8576106b1828686612544565b92506106e0565b80600114156106cc576106b1828686612752565b80600214156103ba576106b18286866129b7565b610809565b604051635120990b60e01b81526000906001600160a01b037f000000000000000000000000a617206663343b6353acf27566586ee9b53dfb2b1690635120990b906107349086906004016138f6565b60206040518083038186803b15801561074c57600080fd5b505afa158015610760573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107849190613438565b604051639114750b60e01b81529091506001600160a01b03821690639114750b906107b59089908990600401613bc8565b60206040518083038186803b1580156107cd57600080fd5b505afa1580156107e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108059190613581565b9350505b505092915050565b610819611fcf565b6001600160a01b031661082a61066b565b6001600160a01b031614610885576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166108ca5760405162461bcd60e51b8152600401808060200182810382526026815260200180613c8b6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b61092d611fcf565b6001600160a01b031661093e61066b565b6001600160a01b031614610999576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600155565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526109f0908490612b37565b505050565b6000806000610a0687600088611fd3565b90925090506001600160a01b0386166004881480610a245750876008145b8015610a37575060a987901c6001166001145b15610a4a57610a4586612be8565b610a54565b610a548387612c66565b87610c9c5760b987901c60011660011415610ac857604051632e0ae37560e01b81526001600160a01b03821690632e0ae37590610a959042906004016138f6565b600060405180830381600087803b158015610aaf57600080fd5b505af1158015610ac3573d6000803e3d6000fd5b505050505b600060b888901c6001169050600080836001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610b1057600080fd5b505afa158015610b24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b489190613599565b506001600160701b031691506001600160701b031691508260001415610b6a57905b60a08a901c62ffffff16890296508682620f4240020181880281610b8a57fe5b049650610ba16001600160a01b038716858b61099e565b8260011415610c2057604080516000808252602082019283905263022c0d9f60e01b9092526001600160a01b0386169163022c0d9f91610be991908b908d906024810161394e565b600060405180830381600087803b158015610c0357600080fd5b505af1158015610c17573d6000803e3d6000fd5b50505050610c91565b604080516000808252602082019283905263022c0d9f60e01b9092526001600160a01b0386169163022c0d9f91610c5e918b918d906024810161394e565b600060405180830381600087803b158015610c7857600080fd5b505af1158015610c8c573d6000803e3d6000fd5b505050505b50505050505061159b565b8760011415610db05762ffffff60a088901c16610cce8473e592427a0aece92de3edee1f18e0157c0586156489612d66565b60408051610100810182526001600160a01b038087168252858116602083015262ffffff841682840152881660608201526001428101608083015260a082018a905260c0820152600060e0820152905163414bf38960e01b815273e592427a0aece92de3edee1f18e0157c058615649063414bf38990610d52908490600401613a53565b602060405180830381600087803b158015610d6c57600080fd5b505af1158015610d80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da49190613581565b9550505050505061159b565b8760021415610e5357610dc4838288612d66565b604051638201aa3f60e01b81526001600160a01b03821690638201aa3f90610dfb9086908a9087906000906000199060040161378d565b6040805180830381600087803b158015610e1457600080fd5b505af1158015610e28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4c9190613620565b50506114c6565b8760031415610ff4576000816001600160a01b03166338fff2d06040518163ffffffff1660e01b815260040160206040518083038186803b158015610e9757600080fd5b505afa158015610eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecf9190613581565b9050610edb8488612c66565b610efa8473ba12222222228d8ba445958a75a0704d566bf2c889612d66565b6040805160c081018252828152600060208083018290526001600160a01b038881168486015287811660608086019190915260808086018e90528651858152808501885260a087015286519081018752308152928301849052908b1682860152810182905292516352bbbe2960e01b815273ba12222222228d8ba445958a75a0704d566bf2c8936352bbbe2993610f979390924290600401613abc565b602060405180830381600087803b158015610fb157600080fd5b505af1158015610fc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe99190613581565b94505050505061159b565b600888116114ae57600760a388901c81169060a689901c1661101785848a612d66565b896004141561110e57600160a98a901c166110a15761103785848a612d66565b604051630f7c084960e21b81526001600160a01b03841690633df021249061106a90859085908d9060009060040161392b565b600060405180830381600087803b15801561108457600080fd5b505af1158015611098573d6000803e3d6000fd5b50505050611109565b604051630f7c084960e21b81526001600160a01b03841690633df02124908a906110d69086908690849060009060040161392b565b6000604051808303818588803b1580156110ef57600080fd5b505af1158015611103573d6000803e3d6000fd5b50505050505b610e4c565b89600514156112445761112285848a612d66565b600160a98a901c166111b957604051630f7c084960e21b81526001600160a01b03841690633df021249061116190859085908d9060009060040161392b565b602060405180830381600087803b15801561117b57600080fd5b505af115801561118f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b39190613581565b50611109565b604051635320bf6b60e11b81526001600160a01b0384169063a6417ed6906111ec90859085908d9060009060040161392b565b602060405180830381600087803b15801561120657600080fd5b505af115801561121a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123e9190613581565b50610e4c565b89600614156113855760a989901c600116600114156112d157826001600160a01b0316637165485d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561129657600080fd5b505afa1580156112aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ce9190613438565b92505b6112dc85848a612d66565b600160a98a901c1661131b57604051630f7c084960e21b81526001600160a01b03841690633df021249061106a90859085908d9060009060040161392b565b604051635320bf6b60e11b81526001600160a01b0384169063a6417ed69061134e90859085908d9060009060040161392b565b600060405180830381600087803b15801561136857600080fd5b505af115801561137c573d6000803e3d6000fd5b50505050610e4c565b89600714156113cc5761139985848a612d66565b604051630f7c084960e21b81526001600160a01b03841690633df02124906111ec90859085908d9060009060040161392b565b8960081415610e4c57600160a98a901c1661141f576113ec85848a612d66565b604051630b68372160e31b81526001600160a01b03841690635b41b908906111ec90859085908d90600090600401613bec565b604051630b68372160e31b81526001600160a01b03841690635b41b908908a9061145490869086908490600090600401613bec565b6020604051808303818588803b15801561146d57600080fd5b505af1158015611481573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906114a69190613581565b5050506114c6565b60405162461bcd60e51b8152600401610223906139b2565b6001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214156114f5576114f58247612c66565b6040516370a0823160e01b81526001600160a01b038316906370a082319061152190309060040161375f565b60206040518083038186803b15801561153957600080fd5b505afa15801561154d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115719190613581565b93506001600160a01b0385163014611597576115976001600160a01b038316868661099e565b5050505b949350505050565b60008060006115b487600188611fd3565b90925090506001600160a01b03861660048814806115d25750876008145b80156115e5575060a987901c6001166001145b156115f8576115f386612be8565b611602565b6116028387612c66565b87600411158015611614575060088811155b15611ad65761162281612e49565b905060a087901c60079081166001019060a389901c166002821080159061164a575060048211155b6116665760405162461bcd60e51b8152600401610223906139dc565b896005141561182b57600160a98a901c81161461168486858b612d66565b826002141561173157611695613336565b898184600281106116a257fe5b602002015260405163ee22be2360e01b81526001600160a01b0386169063ee22be23906116d8908490600090879060040161381a565b602060405180830381600087803b1580156116f257600080fd5b505af1158015611706573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172a9190613581565b5050611825565b826003141561178557611742613354565b8981846003811061174f57fe5b60200201526040516315b74c9d60e11b81526001600160a01b03861690632b6e993a906116d89084906000908790600401613876565b61178d613372565b8981846004811061179a57fe5b602002015260405163dc3a2d8160e01b81526001600160a01b0386169063dc3a2d81906117d090849060009087906004016138d2565b602060405180830381600087803b1580156117ea57600080fd5b505af11580156117fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118229190613581565b50505b50611acf565b60008a6004148061183c57508a6008145b801561184f575060a98a901c6001166001145b9050806118615761186186858b612d66565b826002141561195a57611872613336565b8981846002811061187f57fe5b602002015281156118f257604051630b4c7e4d60e01b81526001600160a01b03861690630b4c7e4d908c906118bb9085906000906004016137ff565b6000604051808303818588803b1580156118d457600080fd5b505af11580156118e8573d6000803e3d6000fd5b5050505050611954565b604051630b4c7e4d60e01b81526001600160a01b03861690630b4c7e4d906119219084906000906004016137ff565b600060405180830381600087803b15801561193b57600080fd5b505af115801561194f573d6000803e3d6000fd5b505050505b50611acd565b82600314156119e35761196b613354565b8981846003811061197857fe5b602002015281156119b457604051634515cef360e01b81526001600160a01b03861690634515cef3908c906118bb90859060009060040161385b565b604051634515cef360e01b81526001600160a01b03861690634515cef39061192190849060009060040161385b565b6119eb613372565b898184600481106119f857fe5b60200201528115611a6a5760405162a6cbcd60e21b81526001600160a01b0386169063029b2f34908c90611a339085906000906004016138b7565b6000604051808303818588803b158015611a4c57600080fd5b505af1158015611a60573d6000803e3d6000fd5b5050505050611acb565b60405162a6cbcd60e21b81526001600160a01b0386169063029b2f3490611a989084906000906004016138b7565b600060405180830381600087803b158015611ab257600080fd5b505af1158015611ac6573d6000803e3d6000fd5b505050505b505b505b50506114f5565b87600914156114ae57611aea838288612d66565b604051636e553f6560e01b81526001600160a01b03821690636e553f6590611b189089908990600401613b48565b602060405180830381600087803b158015611b3257600080fd5b505af1158015611b46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6a9190613581565b935050505061159b565b600080611b8386600287611fd3565b9150506001600160a01b03851660048710801590611ba2575060088711155b15611e6057611bb081612e49565b905060a086901c60079081166001019060a688901c1660028210801590611bd8575060048211155b611bf45760405162461bcd60e51b8152600401610223906139dc565b8860041415611c6557604051630d2680e960e11b81526001600160a01b03841690631a4d01d290611c2e908a908590600090600401613b8f565b600060405180830381600087803b158015611c4857600080fd5b505af1158015611c5c573d6000803e3d6000fd5b50505050611e59565b8860051415611d055760405163517a55a360e01b8152600160a98a901c811614906001600160a01b0385169063517a55a390611cac908b9086906000908790600401613ba8565b602060405180830381600087803b158015611cc657600080fd5b505af1158015611cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfe9190613581565b5050611e59565b8860061415611d425760405163517a55a360e01b81526001600160a01b0384169063517a55a390611c2e908a908590600090600190600401613ba8565b8860071415611dd457604051630d2680e960e11b81526001600160a01b03841690631a4d01d290611d7c908a908590600090600401613b8f565b602060405180830381600087803b158015611d9657600080fd5b505af1158015611daa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dce9190613581565b50611e59565b60405163f1dc3cc960e01b81526001600160a01b0384169063f1dc3cc990611e05908a908590600090600401613bd6565b602060405180830381600087803b158015611e1f57600080fd5b505af1158015611e33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e579190613581565b505b5050611ef4565b86600914156114ae57604051635d043b2960e11b81526001600160a01b0382169063ba08765290611e9990889088903090600401613b5f565b602060405180830381600087803b158015611eb357600080fd5b505af1158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190613581565b9250505061159b565b6001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415611f2357611f238247612c66565b6040516370a0823160e01b81526001600160a01b038316906370a0823190611f4f90309060040161375f565b60206040518083038186803b158015611f6757600080fd5b505afa158015611f7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9f9190613581565b92506001600160a01b0384163014611fc557611fc56001600160a01b038316858561099e565b5050949350505050565b3390565b6000806001600160a01b0383168461233657600186116120ea57806001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561202657600080fd5b505afa15801561203a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061205e9190613438565b9250806001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561209957600080fd5b505afa1580156120ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d19190613438565b9150600160b885901c16806120e4579192915b50612331565b85600214156121ac576000816001600160a01b031663cc77828d6040518163ffffffff1660e01b815260040160006040518083038186803b15801561212e57600080fd5b505afa158015612142573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261216a919081019061348c565b90508060a386901c6007168151811061217f57fe5b602002602001015193508060a686901c6007168151811061219c57fe5b6020026020010151935050612331565b85600314156122fe576000816001600160a01b03166338fff2d06040518163ffffffff1660e01b815260040160206040518083038186803b1580156121f057600080fd5b505afa158015612204573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122289190613581565b604051631f29a8cd60e31b815290915060009073ba12222222228d8ba445958a75a0704d566bf2c89063f94d4668906122659085906004016138f6565b60006040518083038186803b15801561227d57600080fd5b505afa158015612291573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526122b991908101906134bf565b505090508060a387901c600716815181106122d057fe5b602002602001015194508060a687901c600716815181106122ed57fe5b602002602001015193505050612331565b6008861161233157612319818760a387901c60071687612e7b565b925061232e818760a687901c60071687612e7b565b91505b6124c1565b84600114156124015780915085600411158015612354575060088611155b1561237e5761236281612e49565b9050612377818760a387901c60071687612e7b565b9250612331565b85600914156123f857806001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156123c057600080fd5b505afa1580156123d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123779190613438565b600091506124c1565b84600214156124c1578092508560041115801561241f575060088611155b156124425761242d81612e49565b905061232e818760a687901c60071687612e7b565b85600914156124bc57806001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561248457600080fd5b505afa158015612498573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232e9190613438565b600092505b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156124fe5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc292505b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561253b5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc291505b50935093915050565b60006001600160a01b0383168461255a5761274a565b84600114156125685761274a565b84600214156125765761274a565b84600314156125845761274a565b6008851161274a57600760a385901c81169060a686901c16600887141561262c5760405163556d6e9f60e01b81526001600160a01b0384169063556d6e9f906125d590859085908a90600401613bd6565b60206040518083038186803b1580156125ed57600080fd5b505afa158015612601573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126259190613581565b9350612747565b866005148015612643575060a986901c6001166001145b15612678576040516307211ef760e01b81526001600160a01b038416906307211ef7906125d590859085908a9060040161390d565b86600614801561268f575060a986901c6001166001145b156126c4576040516307211ef760e01b81526001600160a01b038416906307211ef7906125d590859085908a9060040161390d565b604051635e0d443f60e01b81526001600160a01b03841690635e0d443f906126f490859085908a9060040161390d565b60206040518083038186803b15801561270c57600080fd5b505afa158015612720573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127449190613581565b93505b50505b509392505050565b60006001600160a01b03831660048510801590612770575060088511155b156129295760a084901c60079081166001019060a686901c1660028214156128335761279a613336565b858183600281106127a757fe5b602002015260405163ed8e84f360e01b81526001600160a01b0385169063ed8e84f3906127db9084906001906004016137e2565b60206040518083038186803b1580156127f357600080fd5b505afa158015612807573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061282b9190613581565b945050612922565b816003141561288557612844613354565b8581836003811061285157fe5b6020020152604051633883e11960e01b81526001600160a01b03851690633883e119906127db90849060019060040161383e565b61288d613372565b8581836004811061289a57fe5b602002015260405163cf701ff760e01b81526001600160a01b0385169063cf701ff7906128ce90849060019060040161389a565b60206040518083038186803b1580156128e657600080fd5b505afa1580156128fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291e9190613581565b9450505b505061274a565b846009141561274a5760405163ef8b30f760e01b81526001600160a01b0382169063ef8b30f79061295e9086906004016138f6565b60206040518083038186803b15801561297657600080fd5b505afa15801561298a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ae9190613581565b95945050505050565b60006001600160a01b038316600485108015906129d5575060088511155b15612b02576129e381612e49565b9050600760a685901c166008861415612a7b576040516327d8462f60e11b81526001600160a01b03831690634fb08c5e90612a249087908590600401613bc8565b60206040518083038186803b158015612a3c57600080fd5b505afa158015612a50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a749190613581565b9250612afc565b60405163cc2b27d760e01b81526001600160a01b0383169063cc2b27d790612aa99087908590600401613b7e565b60206040518083038186803b158015612ac157600080fd5b505afa158015612ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af99190613581565b92505b5061274a565b846009141561274a5760405163266d6a8360e11b81526001600160a01b03821690634cdad5069061295e9086906004016138f6565b6000612b8c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612fcb9092919063ffffffff16565b8051909150156109f057808060200190516020811015612bab57600080fd5b50516109f05760405162461bcd60e51b815260040180806020018281038252602a815260200180613cd7602a913960400191505060405180910390fd5b80471015612c635773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015612c4a57600080fd5b505af1158015612c5e573d6000803e3d6000fd5b505050505b50565b6001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015612d09575080826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612cdb57600080fd5b505afa158015612cef573d6000803e3d6000fd5b505050506040513d6020811015612d0557600080fd5b5051105b1561034d57816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612d4957600080fd5b505af1158015612d5d573d6000803e3d6000fd5b50505050505050565b612d6f83612fe4565b158015612df5575060408051636eb1769f60e11b81523060048201526001600160a01b0384811660248301529151839286169163dd62ed3e916044808301926020929190829003018186803b158015612dc757600080fd5b505afa158015612ddb573d6000803e3d6000fd5b505050506040513d6020811015612df157600080fd5b5051105b156109f057730316eb71485b0ab14103307bf65a021042c6d3806001600160a01b03841614612e3357612e336001600160a01b03841683600061301e565b6109f06001600160a01b0384168360001961301e565b60006303aa30b960e11b6000526020600060046000855afa8015612e6d5760005191505b5080612e765750805b919050565b60008360051480612e8c5750836006145b8015612e9f575060a982901c6001166001145b15612f2757604051630b9947eb60e41b81526001600160a01b0386169063b9947eb090612ed09086906004016138f6565b60206040518083038186803b158015612ee857600080fd5b505afa158015612efc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f209190613438565b905061159b565b60405163c661065760e01b81526001600160a01b0386169063c661065790612f539086906004016138f6565b60206040518083038186803b158015612f6b57600080fd5b505afa925050508015612f9b575060408051601f3d908101601f19168201909252612f9891810190613438565b60015b6129ae5760405163046e8dd760e31b81526001600160a01b038616906323746eb890612ed09086906004016138ff565b6060612fda8484600085613131565b90505b9392505050565b60006001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee148061301857506001600160a01b038216155b92915050565b8015806130a4575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561307657600080fd5b505afa15801561308a573d6000803e3d6000fd5b505050506040513d60208110156130a057600080fd5b5051155b6130df5760405162461bcd60e51b8152600401808060200182810382526036815260200180613d016036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526109f0908490612b37565b6060824710156131725760405162461bcd60e51b8152600401808060200182810382526026815260200180613cb16026913960400191505060405180910390fd5b61317b8561328c565b6131cc576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b6020831061320a5780518252601f1990920191602091820191016131eb565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461326c576040519150601f19603f3d011682016040523d82523d6000602084013e613271565b606091505b5091509150613281828286613292565b979650505050505050565b3b151590565b606083156132a1575081612fdd565b8251156132b15782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156132fb5781810151838201526020016132e3565b50505050905090810190601f1680156133285780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b600082601f8301126133a0578081fd5b815160206133b56133b083613c2b565b613c07565b82815281810190858301838502870184018810156133d1578586fd5b855b858110156133f85781516133e681613c75565b845292840192908401906001016133d3565b5090979650505050505050565b80516001600160701b0381168114612e7657600080fd5b60006020828403121561342d578081fd5b8135612fdd81613c75565b600060208284031215613449578081fd5b8151612fdd81613c75565b60008060408385031215613466578081fd5b823561347181613c75565b9150602083013561348181613c75565b809150509250929050565b60006020828403121561349d578081fd5b815167ffffffffffffffff8111156134b3578182fd5b61159b84828501613390565b6000806000606084860312156134d3578081fd5b835167ffffffffffffffff808211156134ea578283fd5b6134f687838801613390565b945060209150818601518181111561350c578384fd5b86019050601f8101871361351e578283fd5b805161352c6133b082613c2b565b81815283810190838501858402850186018b1015613548578687fd5b8694505b8385101561356a57805183526001949094019391850191850161354c565b508096505050505050604084015190509250925092565b600060208284031215613592578081fd5b5051919050565b6000806000606084860312156135ad578283fd5b6135b684613405565b92506135c460208501613405565b9150604084015163ffffffff811681146135dc578182fd5b809150509250925092565b6000602082840312156135f8578081fd5b5035919050565b60008060408385031215613611578182fd5b50508035926020909101359150565b60008060408385031215613632578182fd5b505080516020909101519092909150565b600080600060608486031215613657578283fd5b833592506020840135915060408401356135dc81613c75565b8060005b6002811015613693578151845260209384019390910190600101613674565b50505050565b8060005b600381101561369357815184526020938401939091019060010161369d565b8060005b60048110156136935781518452602093840193909101906001016136c0565b600081518084526136f7816020860160208601613c49565b601f01601f19169290920160200192915050565b80516001600160a01b039081168352602080830151151590840152604080830151909116908301526060908101511515910152565b60008251613752818460208701613c49565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03958616815260208101949094529190931660408301526060820192909252608081019190915260a00190565b6001600160a01b039390931683526020830191909152604082015260600190565b606081016137f08285613670565b82151560408301529392505050565b6060810161380d8285613670565b8260408301529392505050565b608081016138288286613670565b8360408301528215156060830152949350505050565b6080810161384c8285613699565b82151560608301529392505050565b608081016138698285613699565b8260608301529392505050565b60a081016138848286613699565b8360608301528215156080830152949350505050565b60a081016138a882856136bc565b82151560808301529392505050565b60a081016138c582856136bc565b8260808301529392505050565b60c081016138e082866136bc565b83608083015282151560a0830152949350505050565b90815260200190565b600f9190910b815260200190565b600f93840b81529190920b6020820152604081019190915260600190565b600f94850b81529290930b60208301526040820152606081019190915260800190565b600085825284602083015260018060a01b03841660408301526080606083015261397b60808301846136df565b9695505050505050565b6020808252601390820152721dda5d1a191c985dc81155120819985a5b1959606a1b604082015260600190565b60208082526010908201526f696e76616c696420706f6f6c5479706560801b604082015260600190565b6020808252600e908201526d696e76616c696420746f6b656e7360901b604082015260600190565b6020808252600e908201526d34b73b30b634b21030b1ba34b7b760911b604082015260600190565b6020808252600d908201526c6f6e6c7920726567697374727960981b604082015260600190565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c0808401519083015260e09283015116918101919091526101000190565b600060e08252855160e0830152602086015160028110613ad857fe5b61010083015260408601516001600160a01b03908116610120840152606087015116610140830152608086015161016083015260a086015160c0610180840152613b266101a08401826136df565b915050613b36602083018661370b565b60a082019390935260c0015292915050565b9182526001600160a01b0316602082015260400190565b9283526001600160a01b03918216602084015216604082015260600190565b918252600f0b602082015260400190565b928352600f9190910b6020830152604082015260600190565b938452600f9290920b602084015260408301521515606082015260800190565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60405181810167ffffffffffffffff81118282101715613c2357fe5b604052919050565b600067ffffffffffffffff821115613c3f57fe5b5060209081020190565b60005b83811015613c64578181015183820152602001613c4c565b838111156136935750506000910152565b6001600160a01b0381168114612c6357600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220f8a03449209acf98094a4ee048c4ff6e63d762ba389af7b7b0f236f120946cf964736f6c63430007060033

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

000000000000000000000000a617206663343b6353acf27566586ee9b53dfb2b

-----Decoded View---------------
Arg [0] : _registry (address): 0xa617206663343b6353acF27566586eE9b53DFb2b

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000a617206663343b6353acf27566586ee9b53dfb2b


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

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

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