Contract Address Details

0x9c560A6879E4D3a8a88C8f6f39ebf028Ad7860Ab

Contract Name
PoolRegistry
Creator
0x5bdb37–2eef34 at 0x997f10–05f380
Balance
0 Evmos ( )
Tokens
Fetching tokens...
Transactions
5 Transactions
Transfers
0 Transfers
Gas Used
2,782,461
Last Balance Update
8005532
Contract name:
PoolRegistry




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




Optimization runs
10000
Verified at
2022-05-28T08:59:31.096609Z

Constructor Arguments

0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef340000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34

Arg [0] (address) : 0x5bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34
Arg [1] (address) : 0x5bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34

              

contracts/registries/PoolRegistry.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "../helper/BaseBoringBatchable.sol";
import "../interfaces/ISwap.sol";
import "../interfaces/ISwapGuarded.sol";
import "../interfaces/IMetaSwap.sol";
import "../interfaces/IPoolRegistry.sol";
import "../meta/MetaSwapDeposit.sol";

/**
 * @title PoolRegistry
 * @notice This contract holds list of pools deployed.
 */
contract PoolRegistry is
    AccessControl,
    ReentrancyGuard,
    BaseBoringBatchable,
    IPoolRegistry
{
    using SafeMath for uint256;

    /// @notice Role responsible for managing pools.
    bytes32 public constant SADDLE_MANAGER_ROLE =
        keccak256("SADDLE_MANAGER_ROLE");
    /// @notice Role responsible for managing community pools
    bytes32 public constant COMMUNITY_MANAGER_ROLE =
        keccak256("COMMUNITY_MANAGER_ROLE");
    /// @notice Role that represents approved owners of pools.
    /// owner of each pool must have this role if the pool is to be approved.
    bytes32 public constant SADDLE_APPROVED_POOL_OWNER_ROLE =
        keccak256("SADDLE_APPROVED_POOL_OWNER_ROLE");

    /// @inheritdoc IPoolRegistry
    mapping(address => uint256) public override poolsIndexOfPlusOne;
    /// @inheritdoc IPoolRegistry
    mapping(bytes32 => uint256) public override poolsIndexOfNamePlusOne;

    PoolData[] private pools;
    mapping(uint256 => address[]) private eligiblePairsMap;

    /**
     * @notice Add a new registry entry to the master list.
     * @param poolAddress address of the added pool
     * @param index index of the added pool in the pools list
     * @param poolData added pool data
     */
    event AddPool(
        address indexed poolAddress,
        uint256 index,
        PoolData poolData
    );

    /**
     * @notice Add a new registry entry to the master list.
     * @param poolAddress address of the added pool
     * @param index index of the added pool in the pools list
     * @param poolData added pool data
     */
    event AddCommunityPool(
        address indexed poolAddress,
        uint256 index,
        PoolData poolData
    );

    /**
     * @notice Add a new registry entry to the master list.
     * @param poolAddress address of the updated pool
     * @param index index of the updated pool in the pools list
     * @param poolData updated pool data
     */
    event UpdatePool(
        address indexed poolAddress,
        uint256 index,
        PoolData poolData
    );

    /**
     * @notice Add a new registry entry to the master list.
     * @param poolAddress address of the removed pool
     * @param index index of the removed pool in the pools list
     */
    event RemovePool(address indexed poolAddress, uint256 index);

    /**
     * @notice Deploy this contract and set appropriate roles
     * @param admin address who should have the DEFAULT_ADMIN_ROLE
     * @dev caller of this function will be set as the owner on deployment
     */
    constructor(address admin, address poolOwner) public payable {
        require(admin != address(0), "admin == 0");
        _setupRole(DEFAULT_ADMIN_ROLE, admin);
        _setupRole(SADDLE_MANAGER_ROLE, msg.sender);
        _setupRole(SADDLE_APPROVED_POOL_OWNER_ROLE, poolOwner);
    }

    /// @inheritdoc IPoolRegistry
    function addCommunityPool(PoolData memory data) external payable override {
        require(
            hasRole(COMMUNITY_MANAGER_ROLE, msg.sender),
            "PR: Only managers can add pools"
        );

        // Check token addresses
        for (uint8 i = 0; i < data.tokens.length; i++) {
            for (uint8 j = 0; j < i; j++) {
                eligiblePairsMap[
                    uint160(address(data.tokens[i])) ^
                        uint160(address(data.tokens[j]))
                ].push(data.poolAddress);
            }
        }

        // Check meta swap deposit address
        if (data.metaSwapDepositAddress != address(0)) {
            for (uint8 i = 0; i < data.underlyingTokens.length; i++) {
                // add combinations of tokens to eligible pairs map
                // i reprents the indexes of the underlying tokens of metaLPToken.
                // j represents the indexes of MetaSwap level tokens that are not metaLPToken.
                // Example: tokens = [sUSD, baseLPToken]
                //         underlyingTokens = [sUSD, DAI, USDC, USDT]
                // i represents index of [DAI, USDC, USDT] in underlyingTokens
                // j represents index of [sUSD] in underlyingTokens
                if (i > data.tokens.length.sub(2))
                    for (uint256 j = 0; j < data.tokens.length - 1; j++) {
                        eligiblePairsMap[
                            uint160(address(data.underlyingTokens[i])) ^
                                uint160(address(data.underlyingTokens[j]))
                        ].push(data.metaSwapDepositAddress);
                    }
            }
        }

        pools.push(data);
        poolsIndexOfPlusOne[data.poolAddress] = pools.length;
        poolsIndexOfNamePlusOne[data.poolName] = pools.length;

        emit AddCommunityPool(data.poolAddress, pools.length - 1, data);
    }

    /// @inheritdoc IPoolRegistry
    function addPool(PoolInputData memory inputData)
        external
        payable
        override
        nonReentrant
    {
        require(
            hasRole(SADDLE_MANAGER_ROLE, msg.sender),
            "PR: Only managers can add pools"
        );
        require(inputData.poolAddress != address(0), "PR: poolAddress is 0");
        require(
            poolsIndexOfPlusOne[inputData.poolAddress] == 0,
            "PR: Pool is already added"
        );

        IERC20[] memory tokens = new IERC20[](8);
        IERC20[] memory underlyingTokens = new IERC20[](8);

        PoolData memory data = PoolData(
            inputData.poolAddress,
            address(0),
            inputData.typeOfAsset,
            inputData.poolName,
            inputData.targetAddress,
            tokens,
            underlyingTokens,
            address(0),
            inputData.metaSwapDepositAddress,
            inputData.isSaddleApproved,
            inputData.isRemoved,
            inputData.isGuarded
        );

        // Get lp token address
        data.lpToken = inputData.isGuarded
            ? _getSwapStorageGuarded(inputData.poolAddress).lpToken
            : _getSwapStorage(inputData.poolAddress).lpToken;

        // Check token addresses
        for (uint8 i = 0; i < 8; i++) {
            try ISwap(inputData.poolAddress).getToken(i) returns (
                IERC20 token
            ) {
                require(address(token) != address(0), "PR: token is 0");
                tokens[i] = token;
                // add combinations of tokens to eligible pairs map
                for (uint8 j = 0; j < i; j++) {
                    eligiblePairsMap[
                        uint160(address(tokens[i])) ^
                            uint160(address(tokens[j]))
                    ].push(inputData.poolAddress);
                }
            } catch {
                assembly {
                    mstore(tokens, sub(mload(tokens), sub(8, i)))
                }
                break;
            }
        }

        // Check meta swap deposit address
        if (inputData.metaSwapDepositAddress != address(0)) {
            // Get base pool address
            data.basePoolAddress = address(
                MetaSwapDeposit(inputData.metaSwapDepositAddress).baseSwap()
            );
            require(
                poolsIndexOfPlusOne[data.basePoolAddress] > 0,
                "PR: base pool not found"
            );

            // Get underlying tokens
            for (uint8 i = 0; i < 8; i++) {
                try
                    MetaSwapDeposit(inputData.metaSwapDepositAddress).getToken(
                        i
                    )
                returns (IERC20 token) {
                    require(address(token) != address(0), "PR: token is 0");
                    underlyingTokens[i] = token;
                    // add combinations of tokens to eligible pairs map
                    // i reprents the indexes of the underlying tokens of metaLPToken.
                    // j represents the indexes of MetaSwap level tokens that are not metaLPToken.
                    // Example: tokens = [sUSD, baseLPToken]
                    //         underlyingTokens = [sUSD, DAI, USDC, USDT]
                    // i represents index of [DAI, USDC, USDT] in underlyingTokens
                    // j represents index of [sUSD] in underlyingTokens
                    if (i > tokens.length.sub(2))
                        for (uint256 j = 0; j < tokens.length - 1; j++) {
                            eligiblePairsMap[
                                uint160(address(underlyingTokens[i])) ^
                                    uint160(address(underlyingTokens[j]))
                            ].push(inputData.metaSwapDepositAddress);
                        }
                } catch {
                    assembly {
                        mstore(
                            underlyingTokens,
                            sub(mload(underlyingTokens), sub(8, i))
                        )
                    }
                    break;
                }
            }
            require(
                address(
                    MetaSwapDeposit(inputData.metaSwapDepositAddress).metaSwap()
                ) == inputData.poolAddress,
                "PR: metaSwap address mismatch"
            );
        } else {
            assembly {
                mstore(underlyingTokens, sub(mload(underlyingTokens), 8))
            }
        }

        pools.push(data);
        poolsIndexOfPlusOne[data.poolAddress] = pools.length;
        poolsIndexOfNamePlusOne[data.poolName] = pools.length;

        emit AddPool(inputData.poolAddress, pools.length - 1, data);
    }

    /// @inheritdoc IPoolRegistry
    function approvePool(address poolAddress)
        external
        payable
        override
        managerOnly
    {
        uint256 poolIndex = poolsIndexOfPlusOne[poolAddress];
        require(poolIndex > 0, "PR: Pool not found");

        PoolData storage poolData = pools[poolIndex];

        require(
            poolData.poolAddress == poolAddress,
            "PR: poolAddress mismatch"
        );

        // Effect
        poolData.isSaddleApproved = true;

        // Interaction
        require(
            hasRole(
                SADDLE_APPROVED_POOL_OWNER_ROLE,
                ISwap(poolAddress).owner()
            ),
            "Pool is not owned by saddle"
        );

        emit UpdatePool(poolAddress, poolIndex, poolData);
    }

    /// @inheritdoc IPoolRegistry
    function updatePool(PoolData memory poolData)
        external
        payable
        override
        managerOnly
    {
        uint256 poolIndex = poolsIndexOfPlusOne[poolData.poolAddress];
        require(poolIndex > 0, "PR: Pool not found");
        poolIndex -= 1;

        pools[poolIndex] = poolData;

        emit UpdatePool(poolData.poolAddress, poolIndex, poolData);
    }

    /// @inheritdoc IPoolRegistry
    function removePool(address poolAddress)
        external
        payable
        override
        managerOnly
    {
        uint256 poolIndex = poolsIndexOfPlusOne[poolAddress];
        require(poolIndex > 0, "PR: Pool not found");
        poolIndex -= 1;

        pools[poolIndex].isRemoved = true;

        emit RemovePool(poolAddress, poolIndex);
    }

    /// @inheritdoc IPoolRegistry
    function getPoolDataAtIndex(uint256 index)
        external
        view
        override
        returns (PoolData memory)
    {
        require(index < pools.length, "PR: Index out of bounds");
        return pools[index];
    }

    /// @inheritdoc IPoolRegistry
    function getPoolData(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (PoolData memory)
    {
        return pools[poolsIndexOfPlusOne[poolAddress] - 1];
    }

    /// @inheritdoc IPoolRegistry
    function getPoolDataByName(bytes32 poolName)
        external
        view
        override
        returns (PoolData memory)
    {
        uint256 index = poolsIndexOfNamePlusOne[poolName];
        require(index > 0, "PR: Pool not found");
        return pools[index - 1];
    }

    modifier hasMatchingPool(address poolAddress) {
        require(
            poolsIndexOfPlusOne[poolAddress] > 0,
            "PR: No matching pool found"
        );
        _;
    }

    modifier managerOnly() {
        require(
            hasRole(SADDLE_MANAGER_ROLE, msg.sender),
            "PR: Caller is not saddle manager"
        );
        _;
    }

    /// @inheritdoc IPoolRegistry
    function getVirtualPrice(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (uint256)
    {
        return ISwap(poolAddress).getVirtualPrice();
    }

    /// @inheritdoc IPoolRegistry
    function getA(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (uint256)
    {
        return ISwap(poolAddress).getA();
    }

    /// @inheritdoc IPoolRegistry
    function getPaused(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (bool)
    {
        return ISwap(poolAddress).paused();
    }

    /// @inheritdoc IPoolRegistry
    function getSwapStorage(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (SwapStorageData memory swapStorageData)
    {
        swapStorageData = pools[poolsIndexOfPlusOne[poolAddress] - 1].isGuarded
            ? _getSwapStorageGuarded(poolAddress)
            : _getSwapStorage(poolAddress);
    }

    function _getSwapStorage(address poolAddress)
        internal
        view
        returns (SwapStorageData memory swapStorageData)
    {
        (
            swapStorageData.initialA,
            swapStorageData.futureA,
            swapStorageData.initialATime,
            swapStorageData.futureATime,
            swapStorageData.swapFee,
            swapStorageData.adminFee,
            swapStorageData.lpToken
        ) = ISwap(poolAddress).swapStorage();
    }

    function _getSwapStorageGuarded(address poolAddress)
        internal
        view
        returns (SwapStorageData memory swapStorageData)
    {
        (
            swapStorageData.initialA,
            swapStorageData.futureA,
            swapStorageData.initialATime,
            swapStorageData.futureATime,
            swapStorageData.swapFee,
            swapStorageData.adminFee,
            ,
            swapStorageData.lpToken
        ) = ISwapGuarded(poolAddress).swapStorage();
    }

    /// @inheritdoc IPoolRegistry
    function getTokens(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (IERC20[] memory tokens)
    {
        return pools[poolsIndexOfPlusOne[poolAddress] - 1].tokens;
    }

    /// @inheritdoc IPoolRegistry
    function getUnderlyingTokens(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (IERC20[] memory underlyingTokens)
    {
        return pools[poolsIndexOfPlusOne[poolAddress] - 1].underlyingTokens;
    }

    /// @inheritdoc IPoolRegistry
    function getPoolsLength() external view override returns (uint256) {
        return pools.length;
    }

    /// @inheritdoc IPoolRegistry
    function getEligiblePools(address from, address to)
        external
        view
        override
        returns (address[] memory eligiblePools)
    {
        require(
            from != address(0) && from != to,
            "PR: from and to cannot be the zero address"
        );
        return eligiblePairsMap[uint160(from) ^ uint160(to)];
    }

    /// @inheritdoc IPoolRegistry
    function getTokenBalances(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (uint256[] memory balances)
    {
        return _getTokenBalances(poolAddress);
    }

    function _getTokenBalances(address poolAddress)
        internal
        view
        returns (uint256[] memory balances)
    {
        uint256 tokensLength = pools[poolsIndexOfPlusOne[poolAddress] - 1]
            .tokens
            .length;
        balances = new uint256[](tokensLength);
        for (uint8 i = 0; i < tokensLength; i++) {
            balances[i] = ISwap(poolAddress).getTokenBalance(i);
        }
    }

    /// @inheritdoc IPoolRegistry
    function getUnderlyingTokenBalances(address poolAddress)
        external
        view
        override
        hasMatchingPool(poolAddress)
        returns (uint256[] memory balances)
    {
        uint256 poolIndex = poolsIndexOfPlusOne[poolAddress] - 1;
        address basePoolAddress = pools[poolIndex].basePoolAddress;
        uint256[] memory basePoolBalances = _getTokenBalances(basePoolAddress);
        uint256 underlyingTokensLength = pools[poolIndex]
            .underlyingTokens
            .length;
        uint256 metaLPTokenIndex = underlyingTokensLength -
            basePoolBalances.length;
        uint256 baseLPTokenBalance = ISwap(poolAddress).getTokenBalance(
            uint8(metaLPTokenIndex)
        );
        uint256 baseLPTokenTotalSupply = LPToken(
            pools[poolsIndexOfPlusOne[basePoolAddress] - 1].lpToken
        ).totalSupply();

        balances = new uint256[](underlyingTokensLength);
        for (uint8 i = 0; i < metaLPTokenIndex; i++) {
            balances[i] = ISwap(poolAddress).getTokenBalance(i);
        }
        for (uint256 i = metaLPTokenIndex; i < underlyingTokensLength; i++) {
            balances[i] = basePoolBalances[i - metaLPTokenIndex]
                .mul(baseLPTokenBalance)
                .div(baseLPTokenTotalSupply);
        }
    }
}
        

contracts/interfaces/IAllowlist.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IAllowlist {
    function getPoolAccountLimit(address poolAddress)
        external
        view
        returns (uint256);

    function getPoolCap(address poolAddress) external view returns (uint256);

    function verifyAddress(address account, bytes32[] calldata merkleProof)
        external
        returns (bool);
}
          

@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        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;
    }
    uint256[49] private __gap;
}
          

contracts/interfaces/IMetaSwap.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

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

interface IMetaSwap {
    // pool data view functions
    function getA() external view returns (uint256);

    function getToken(uint8 index) external view returns (IERC20);

    function getTokenIndex(address tokenAddress) external view returns (uint8);

    function getTokenBalance(uint8 index) external view returns (uint256);

    function getVirtualPrice() external view returns (uint256);

    function isGuarded() external view returns (bool);

    function metaSwapStorage()
        external
        view
        returns (
            address baseSwap,
            uint256 baseVirtualPrice,
            uint256 baseCacheLastUpdated
        );

    // min return calculation functions
    function calculateSwap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256);

    function calculateSwapUnderlying(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256);

    function calculateTokenAmount(uint256[] calldata amounts, bool deposit)
        external
        view
        returns (uint256);

    function calculateRemoveLiquidity(uint256 amount)
        external
        view
        returns (uint256[] memory);

    function calculateRemoveLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex
    ) external view returns (uint256 availableTokenAmount);

    // state modifying functions
    function initialize(
        IERC20[] memory _pooledTokens,
        uint8[] memory decimals,
        string memory lpTokenName,
        string memory lpTokenSymbol,
        uint256 _a,
        uint256 _fee,
        uint256 _adminFee,
        address lpTokenTargetAddress
    ) external;

    function initializeMetaSwap(
        IERC20[] memory _pooledTokens,
        uint8[] memory decimals,
        string memory lpTokenName,
        string memory lpTokenSymbol,
        uint256 _a,
        uint256 _fee,
        uint256 _adminFee,
        address lpTokenTargetAddress,
        ISwap baseSwap
    ) external;

    function swap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) external returns (uint256);

    function swapUnderlying(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) external returns (uint256);

    function addLiquidity(
        uint256[] calldata amounts,
        uint256 minToMint,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidity(
        uint256 amount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external returns (uint256[] memory);

    function removeLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex,
        uint256 minAmount,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidityImbalance(
        uint256[] calldata amounts,
        uint256 maxBurnAmount,
        uint256 deadline
    ) external returns (uint256);
}
          

@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMathUpgradeable {
    /**
     * @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;
    }
}
          

@openzeppelin/contracts-upgradeable/proxy/Initializable.sol

// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;

import "../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}
          

@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/ContextUpgradeable.sol";
import "./ERC20Upgradeable.sol";
import "../../proxy/Initializable.sol";

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {
    function __ERC20Burnable_init() internal initializer {
        __Context_init_unchained();
        __ERC20Burnable_init_unchained();
    }

    function __ERC20Burnable_init_unchained() internal initializer {
    }
    using SafeMathUpgradeable for uint256;

    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");

        _approve(account, _msgSender(), decreasedAllowance);
        _burn(account, amount);
    }
    uint256[50] private __gap;
}
          

@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/ContextUpgradeable.sol";
import "./IERC20Upgradeable.sol";
import "../../math/SafeMathUpgradeable.sol";
import "../../proxy/Initializable.sol";

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

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal initializer {
        __Context_init_unchained();
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

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

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

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

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

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

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

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

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

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

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

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

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

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

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

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

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

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

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

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

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

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

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

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

@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @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);
}
          

@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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);
    }

    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);
            }
        }
    }
}
          

@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";

/*
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal initializer {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal initializer {
    }
    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;
    }
    uint256[50] private __gap;
}
          

@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal initializer {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal initializer {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
    uint256[49] private __gap;
}
          

@openzeppelin/contracts/access/AccessControl.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context {
    using EnumerableSet for EnumerableSet.AddressSet;
    using Address for address;

    struct RoleData {
        EnumerableSet.AddressSet members;
        bytes32 adminRole;
    }

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view returns (bool) {
        return _roles[role].members.contains(account);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view returns (uint256) {
        return _roles[role].members.length();
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
        return _roles[role].members.at(index);
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");

        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");

        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
        _roles[role].adminRole = adminRole;
    }

    function _grantRole(bytes32 role, address account) private {
        if (_roles[role].members.add(account)) {
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (_roles[role].members.remove(account)) {
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
          

@openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

@openzeppelin/contracts/math/SafeMath.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/token/ERC20/ERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";

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

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

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

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

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

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

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

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

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

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

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

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

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

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

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

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

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

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

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

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

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

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

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

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

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

@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

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

@openzeppelin/contracts/token/ERC20/SafeERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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");
        }
    }
}
          

@openzeppelin/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/utils/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;
    }
}
          

@openzeppelin/contracts/utils/EnumerableSet.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}
          

@openzeppelin/contracts/utils/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
          

contracts/LPToken.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./interfaces/ISwap.sol";

/**
 * @title Liquidity Provider Token
 * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.
 * It is used to represent user's shares when providing liquidity to swap contracts.
 * @dev Only Swap contracts should initialize and own LPToken contracts.
 */
contract LPToken is ERC20BurnableUpgradeable, OwnableUpgradeable {
    using SafeMathUpgradeable for uint256;

    /**
     * @notice Initializes this LPToken contract with the given name and symbol
     * @dev The caller of this function will become the owner. A Swap contract should call this
     * in its initializer function.
     * @param name name of this token
     * @param symbol symbol of this token
     */
    function initialize(string memory name, string memory symbol)
        external
        initializer
        returns (bool)
    {
        __Context_init_unchained();
        __ERC20_init_unchained(name, symbol);
        __Ownable_init_unchained();
        return true;
    }

    /**
     * @notice Mints the given amount of LPToken to the recipient.
     * @dev only owner can call this mint function
     * @param recipient address of account to receive the tokens
     * @param amount amount of tokens to mint
     */
    function mint(address recipient, uint256 amount) external onlyOwner {
        require(amount != 0, "LPToken: cannot mint 0");
        _mint(recipient, amount);
    }

    /**
     * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including
     * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.
     * This assumes the owner is set to a Swap contract's address.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual override(ERC20Upgradeable) {
        super._beforeTokenTransfer(from, to, amount);
        require(to != address(this), "LPToken: cannot send to itself");
    }
}
          

contracts/helper/BaseBoringBatchable.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

// solhint-disable avoid-low-level-calls
// solhint-disable no-inline-assembly

// Audit on 5-Jan-2021 by Keno and BoringCrypto
// WARNING!!!
// Combining BoringBatchable with msg.value can cause double spending issues
// https://www.paradigm.xyz/2021/08/two-rights-might-make-a-wrong/

contract BaseBoringBatchable {
    /// @dev Helper function to extract a useful revert message from a failed call.
    /// If the returned data is malformed or not correctly abi encoded then this call can fail itself.
    function _getRevertMsg(bytes memory _returnData)
        internal
        pure
        returns (string memory)
    {
        // If the _res length is less than 68, then the transaction failed silently (without a revert message)
        if (_returnData.length < 68) return "Transaction reverted silently";

        assembly {
            // Slice the sighash.
            _returnData := add(_returnData, 0x04)
        }
        return abi.decode(_returnData, (string)); // All that remains is the revert string
    }

    /// @notice Allows batched call to self (this contract).
    /// @param calls An array of inputs for each call.
    /// @param revertOnFail If True then reverts after a failed call and stops doing further calls.
    // F1: External is ok here because this is the batch function, adding it to a batch makes no sense
    // F2: Calls in the batch may be payable, delegatecall operates in the same context, so each call in the batch has access to msg.value
    // C3: The length of the loop is fully under user control, so can't be exploited
    // C7: Delegatecall is only used on the same contract, so it's safe
    function batch(bytes[] calldata calls, bool revertOnFail) external payable {
        for (uint256 i = 0; i < calls.length; i++) {
            (bool success, bytes memory result) = address(this).delegatecall(
                calls[i]
            );
            if (!success && revertOnFail) {
                revert(_getRevertMsg(result));
            }
        }
    }
}
          

contracts/interfaces/IPoolRegistry.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

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

interface IPoolRegistry {
    /* Structs */

    struct PoolInputData {
        address poolAddress;
        uint8 typeOfAsset;
        bytes32 poolName;
        address targetAddress;
        address metaSwapDepositAddress;
        bool isSaddleApproved;
        bool isRemoved;
        bool isGuarded;
    }

    struct PoolData {
        address poolAddress;
        address lpToken;
        uint8 typeOfAsset;
        bytes32 poolName;
        address targetAddress;
        IERC20[] tokens;
        IERC20[] underlyingTokens;
        address basePoolAddress;
        address metaSwapDepositAddress;
        bool isSaddleApproved;
        bool isRemoved;
        bool isGuarded;
    }

    struct SwapStorageData {
        uint256 initialA;
        uint256 futureA;
        uint256 initialATime;
        uint256 futureATime;
        uint256 swapFee;
        uint256 adminFee;
        address lpToken;
    }

    /* Public Variables */

    /**
     * @notice Returns the index + 1 of the pool address in the registry
     * @param poolAddress address to look for
     */
    function poolsIndexOfPlusOne(address poolAddress)
        external
        returns (uint256);

    /**
     * @notice Returns the index + 1 of the pool name in the registry
     * @param poolName pool name in bytes32 format to look for
     */
    function poolsIndexOfNamePlusOne(bytes32 poolName)
        external
        returns (uint256);

    /* Functions */

    /**
     * @notice Add a new pool to the registry
     * @param inputData PoolInputData struct for the new pool
     * @dev Before adding a meta pool, the user must first add the underlying base pool.
     * Only Swap and MetaSwap contracts need to be added.
     */
    function addPool(PoolInputData memory inputData) external payable;

    /**
     * @notice Add a new pool to the registry
     * @param data PoolInputData struct for the new pool
     * @dev Before adding a meta pool, the user must first add the underlying base pool.
     * Only Swap and MetaSwap contracts need to be added.
     */
    function addCommunityPool(PoolData memory data) external payable;

    /**
     * @notice Approve community deployed pools to be upgraded as Saddle owned
     * @dev since array entries are difficult to remove, we modify the entry to mark it
     * as a Saddle owned pool.
     * @param poolAddress address of the community pool
     */
    function approvePool(address poolAddress) external payable;

    /**
     * @notice Overwrite existing entry with new PoolData
     * @param poolData new PoolData struct to store
     */
    function updatePool(PoolData memory poolData) external payable;

    /**
     * @notice Remove pool from the registry
     * @dev Since arrays are not easily reducable, the entry will be marked as removed.
     * @param poolAddress address of the pool to remove
     */
    function removePool(address poolAddress) external payable;

    /**
     * @notice Returns PoolData for given pool address
     * @param poolAddress address of the pool to read
     */
    function getPoolData(address poolAddress)
        external
        view
        returns (PoolData memory);

    /**
     * @notice Returns PoolData at given index
     * @param index index of the pool to read
     */
    function getPoolDataAtIndex(uint256 index)
        external
        view
        returns (PoolData memory);

    /**
     * @notice Returns PoolData with given name
     * @param poolName name of the pool to read
     */
    function getPoolDataByName(bytes32 poolName)
        external
        view
        returns (PoolData memory);

    /**
     * @notice Returns virtual price of the given pool address
     * @param poolAddress address of the pool to read
     */
    function getVirtualPrice(address poolAddress)
        external
        view
        returns (uint256);

    /**
     * @notice Returns A of the given pool address
     * @param poolAddress address of the pool to read
     */
    function getA(address poolAddress) external view returns (uint256);

    /**
     * @notice Returns the paused status of the given pool address
     * @param poolAddress address of the pool to read
     */
    function getPaused(address poolAddress) external view returns (bool);

    /**
     * @notice Returns the SwapStorage struct of the given pool address
     * @param poolAddress address of the pool to read
     */
    function getSwapStorage(address poolAddress)
        external
        view
        returns (SwapStorageData memory swapStorageData);

    /**
     * @notice Returns the tokens of the given pool address
     * @param poolAddress address of the pool to read
     */
    function getTokens(address poolAddress)
        external
        view
        returns (IERC20[] memory);

    /**
     * @notice Returns the underlying tokens of the given pool address. Base pools will return an empty array.
     * @param poolAddress address of the pool to read
     */
    function getUnderlyingTokens(address poolAddress)
        external
        view
        returns (IERC20[] memory);

    /**
     * @notice Returns number of entries in the registry. Includes removed pools
     * in the list as well.
     */
    function getPoolsLength() external view returns (uint256);

    /**
     * @notice Returns an array of pool addresses that can swap between from and to
     * @param from address of the token to swap from
     * @param to address of the token to swap to
     * @return eligiblePools array of pool addresses that can swap between from and to
     */
    function getEligiblePools(address from, address to)
        external
        view
        returns (address[] memory eligiblePools);

    /**
     * @notice Returns an array of balances of the tokens
     * @param poolAddress address of the pool to look up the token balances for
     * @return balances array of token balances
     */
    function getTokenBalances(address poolAddress)
        external
        view
        returns (uint256[] memory balances);

    /**
     * @notice Returns an array of balances of the tokens
     * @param poolAddress address of the pool to look up the token balances for
     * @return balances array of token balances
     */
    function getUnderlyingTokenBalances(address poolAddress)
        external
        view
        returns (uint256[] memory balances);
}
          

contracts/interfaces/ISwap.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

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

interface ISwap {
    // pool data view functions
    function getA() external view returns (uint256);

    function getAPrecise() external view returns (uint256);

    function getAllowlist() external view returns (IAllowlist);

    function getToken(uint8 index) external view returns (IERC20);

    function getTokenIndex(address tokenAddress) external view returns (uint8);

    function getTokenBalance(uint8 index) external view returns (uint256);

    function getVirtualPrice() external view returns (uint256);

    function owner() external view returns (address);

    function isGuarded() external view returns (bool);

    function paused() external view returns (bool);

    function swapStorage()
        external
        view
        returns (
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            address
        );

    // min return calculation functions
    function calculateSwap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256);

    function calculateTokenAmount(uint256[] calldata amounts, bool deposit)
        external
        view
        returns (uint256);

    function calculateRemoveLiquidity(uint256 amount)
        external
        view
        returns (uint256[] memory);

    function calculateRemoveLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex
    ) external view returns (uint256 availableTokenAmount);

    // state modifying functions
    function initialize(
        IERC20[] memory pooledTokens,
        uint8[] memory decimals,
        string memory lpTokenName,
        string memory lpTokenSymbol,
        uint256 a,
        uint256 fee,
        uint256 adminFee,
        address lpTokenTargetAddress
    ) external;

    function swap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) external returns (uint256);

    function addLiquidity(
        uint256[] calldata amounts,
        uint256 minToMint,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidity(
        uint256 amount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external returns (uint256[] memory);

    function removeLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex,
        uint256 minAmount,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidityImbalance(
        uint256[] calldata amounts,
        uint256 maxBurnAmount,
        uint256 deadline
    ) external returns (uint256);
}
          

contracts/interfaces/ISwapGuarded.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

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

interface ISwapGuarded {
    // pool data view functions
    function getA() external view returns (uint256);

    function getAllowlist() external view returns (IAllowlist);

    function getToken(uint8 index) external view returns (IERC20);

    function getTokenIndex(address tokenAddress) external view returns (uint8);

    function getTokenBalance(uint8 index) external view returns (uint256);

    function getVirtualPrice() external view returns (uint256);

    function isGuarded() external view returns (bool);

    // min return calculation functions
    function calculateSwap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256);

    function calculateTokenAmount(uint256[] calldata amounts, bool deposit)
        external
        view
        returns (uint256);

    function calculateRemoveLiquidity(uint256 amount)
        external
        view
        returns (uint256[] memory);

    function calculateRemoveLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex
    ) external view returns (uint256 availableTokenAmount);

    // state modifying functions
    function swap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) external returns (uint256);

    function addLiquidity(
        uint256[] calldata amounts,
        uint256 minToMint,
        uint256 deadline,
        bytes32[] calldata merkleProof
    ) external returns (uint256);

    function removeLiquidity(
        uint256 amount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external returns (uint256[] memory);

    function removeLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex,
        uint256 minAmount,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidityImbalance(
        uint256[] calldata amounts,
        uint256 maxBurnAmount,
        uint256 deadline
    ) external returns (uint256);

    // withdraw fee update function
    function updateUserWithdrawFee(address recipient, uint256 transferAmount)
        external;

    function swapStorage()
        external
        view
        returns (
            uint256 initialA,
            uint256 futureA,
            uint256 initialATime,
            uint256 futureATime,
            uint256 swapFee,
            uint256 adminFee,
            uint256 defaultWithdrawFee,
            address lpToken
        );
}
          

contracts/meta/MetaSwapDeposit.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "../LPToken.sol";
import "../interfaces/ISwap.sol";
import "../interfaces/IMetaSwap.sol";

/**
 * @title MetaSwapDeposit
 * @notice This contract flattens the LP token in a MetaSwap pool for easier user access. MetaSwap must be
 * deployed before this contract can be initialized successfully.
 *
 * For example, suppose there exists a base Swap pool consisting of [DAI, USDC, USDT].
 * Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either
 * the LP token or the underlying tokens and sUSD.
 *
 * MetaSwapDeposit flattens the LP token and remaps them to a single array, allowing users
 * to ignore the dependency on BaseSwapLPToken. Using the above example, MetaSwapDeposit can act
 * as a Swap containing [sUSD, DAI, USDC, USDT] tokens.
 */
contract MetaSwapDeposit is Initializable, ReentrancyGuardUpgradeable {
    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    ISwap public baseSwap;
    IMetaSwap public metaSwap;
    IERC20[] public baseTokens;
    IERC20[] public metaTokens;
    IERC20[] public tokens;
    IERC20 public metaLPToken;

    uint256 constant MAX_UINT256 = 2**256 - 1;

    struct RemoveLiquidityImbalanceInfo {
        ISwap baseSwap;
        IMetaSwap metaSwap;
        IERC20 metaLPToken;
        uint8 baseLPTokenIndex;
        bool withdrawFromBase;
        uint256 leftoverMetaLPTokenAmount;
    }

    /**
     * @notice Sets the address for the base Swap contract, MetaSwap contract, and the
     * MetaSwap LP token contract.
     * @param _baseSwap the address of the base Swap contract
     * @param _metaSwap the address of the MetaSwap contract
     * @param _metaLPToken the address of the MetaSwap LP token contract
     */
    function initialize(
        ISwap _baseSwap,
        IMetaSwap _metaSwap,
        IERC20 _metaLPToken
    ) external initializer {
        __ReentrancyGuard_init();
        // Check and approve base level tokens to be deposited to the base Swap contract
        {
            uint8 i;
            for (; i < 32; i++) {
                try _baseSwap.getToken(i) returns (IERC20 token) {
                    baseTokens.push(token);
                    token.safeApprove(address(_baseSwap), MAX_UINT256);
                    token.safeApprove(address(_metaSwap), MAX_UINT256);
                } catch {
                    break;
                }
            }
            require(i > 1, "baseSwap must have at least 2 tokens");
        }

        // Check and approve meta level tokens to be deposited to the MetaSwap contract
        IERC20 baseLPToken;
        {
            uint8 i;
            for (; i < 32; i++) {
                try _metaSwap.getToken(i) returns (IERC20 token) {
                    baseLPToken = token;
                    metaTokens.push(token);
                    tokens.push(token);
                    token.safeApprove(address(_metaSwap), MAX_UINT256);
                } catch {
                    break;
                }
            }
            require(i > 1, "metaSwap must have at least 2 tokens");
        }

        // Flatten baseTokens and append it to tokens array
        tokens[tokens.length - 1] = baseTokens[0];
        for (uint8 i = 1; i < baseTokens.length; i++) {
            tokens.push(baseTokens[i]);
        }

        // Approve base Swap LP token to be burned by the base Swap contract for withdrawing
        baseLPToken.safeApprove(address(_baseSwap), MAX_UINT256);
        // Approve MetaSwap LP token to be burned by the MetaSwap contract for withdrawing
        _metaLPToken.safeApprove(address(_metaSwap), MAX_UINT256);

        // Initialize storage variables
        baseSwap = _baseSwap;
        metaSwap = _metaSwap;
        metaLPToken = _metaLPToken;
    }

    // Mutative functions

    /**
     * @notice Swap two underlying tokens using the meta pool and the base pool
     * @param tokenIndexFrom the token the user wants to swap from
     * @param tokenIndexTo the token the user wants to swap to
     * @param dx the amount of tokens the user wants to swap from
     * @param minDy the min amount the user would like to receive, or revert.
     * @param deadline latest timestamp to accept this transaction
     */
    function swap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) external nonReentrant returns (uint256) {
        tokens[tokenIndexFrom].safeTransferFrom(msg.sender, address(this), dx);
        uint256 tokenToAmount = metaSwap.swapUnderlying(
            tokenIndexFrom,
            tokenIndexTo,
            dx,
            minDy,
            deadline
        );
        tokens[tokenIndexTo].safeTransfer(msg.sender, tokenToAmount);
        return tokenToAmount;
    }

    /**
     * @notice Add liquidity to the pool with the given amounts of tokens
     * @param amounts the amounts of each token to add, in their native precision
     * @param minToMint the minimum LP tokens adding this amount of liquidity
     * should mint, otherwise revert. Handy for front-running mitigation
     * @param deadline latest timestamp to accept this transaction
     * @return amount of LP token user minted and received
     */
    function addLiquidity(
        uint256[] calldata amounts,
        uint256 minToMint,
        uint256 deadline
    ) external nonReentrant returns (uint256) {
        // Read to memory to save on gas
        IERC20[] memory memBaseTokens = baseTokens;
        IERC20[] memory memMetaTokens = metaTokens;
        uint256 baseLPTokenIndex = memMetaTokens.length - 1;

        require(amounts.length == memBaseTokens.length + baseLPTokenIndex);

        uint256 baseLPTokenAmount;
        {
            // Transfer base tokens from the caller and deposit to the base Swap pool
            uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);
            bool shouldDepositBaseTokens;
            for (uint8 i = 0; i < memBaseTokens.length; i++) {
                IERC20 token = memBaseTokens[i];
                uint256 depositAmount = amounts[baseLPTokenIndex + i];
                if (depositAmount > 0) {
                    token.safeTransferFrom(
                        msg.sender,
                        address(this),
                        depositAmount
                    );
                    baseAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer
                    // if there are any base Swap level tokens, flag it for deposits
                    shouldDepositBaseTokens = true;
                }
            }
            if (shouldDepositBaseTokens) {
                // Deposit any base Swap level tokens and receive baseLPToken
                baseLPTokenAmount = baseSwap.addLiquidity(
                    baseAmounts,
                    0,
                    deadline
                );
            }
        }

        uint256 metaLPTokenAmount;
        {
            // Transfer remaining meta level tokens from the caller
            uint256[] memory metaAmounts = new uint256[](metaTokens.length);
            for (uint8 i = 0; i < baseLPTokenIndex; i++) {
                IERC20 token = memMetaTokens[i];
                uint256 depositAmount = amounts[i];
                if (depositAmount > 0) {
                    token.safeTransferFrom(
                        msg.sender,
                        address(this),
                        depositAmount
                    );
                    metaAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer
                }
            }
            // Update the baseLPToken amount that will be deposited
            metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;

            // Deposit the meta level tokens and the baseLPToken
            metaLPTokenAmount = metaSwap.addLiquidity(
                metaAmounts,
                minToMint,
                deadline
            );
        }

        // Transfer the meta lp token to the caller
        metaLPToken.safeTransfer(msg.sender, metaLPTokenAmount);

        return metaLPTokenAmount;
    }

    /**
     * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly
     * over period of 4 weeks since last deposit will apply.
     * @dev Liquidity can always be removed, even when the pool is paused.
     * @param amount the amount of LP tokens to burn
     * @param minAmounts the minimum amounts of each token in the pool
     *        acceptable for this burn. Useful as a front-running mitigation
     * @param deadline latest timestamp to accept this transaction
     * @return amounts of tokens user received
     */
    function removeLiquidity(
        uint256 amount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external nonReentrant returns (uint256[] memory) {
        IERC20[] memory memBaseTokens = baseTokens;
        IERC20[] memory memMetaTokens = metaTokens;
        uint256[] memory totalRemovedAmounts;

        {
            uint256 numOfAllTokens = memBaseTokens.length +
                memMetaTokens.length -
                1;
            require(minAmounts.length == numOfAllTokens, "out of range");
            totalRemovedAmounts = new uint256[](numOfAllTokens);
        }

        // Transfer meta lp token from the caller to this
        metaLPToken.safeTransferFrom(msg.sender, address(this), amount);

        uint256 baseLPTokenAmount;
        {
            // Remove liquidity from the MetaSwap pool
            uint256[] memory removedAmounts;
            uint256 baseLPTokenIndex = memMetaTokens.length - 1;
            {
                uint256[] memory metaMinAmounts = new uint256[](
                    memMetaTokens.length
                );
                for (uint8 i = 0; i < baseLPTokenIndex; i++) {
                    metaMinAmounts[i] = minAmounts[i];
                }
                removedAmounts = metaSwap.removeLiquidity(
                    amount,
                    metaMinAmounts,
                    deadline
                );
            }

            // Send the meta level tokens to the caller
            for (uint8 i = 0; i < baseLPTokenIndex; i++) {
                totalRemovedAmounts[i] = removedAmounts[i];
                memMetaTokens[i].safeTransfer(msg.sender, removedAmounts[i]);
            }
            baseLPTokenAmount = removedAmounts[baseLPTokenIndex];

            // Remove liquidity from the base Swap pool
            {
                uint256[] memory baseMinAmounts = new uint256[](
                    memBaseTokens.length
                );
                for (uint8 i = 0; i < baseLPTokenIndex; i++) {
                    baseMinAmounts[i] = minAmounts[baseLPTokenIndex + i];
                }
                removedAmounts = baseSwap.removeLiquidity(
                    baseLPTokenAmount,
                    baseMinAmounts,
                    deadline
                );
            }

            // Send the base level tokens to the caller
            for (uint8 i = 0; i < memBaseTokens.length; i++) {
                totalRemovedAmounts[baseLPTokenIndex + i] = removedAmounts[i];
                memBaseTokens[i].safeTransfer(msg.sender, removedAmounts[i]);
            }
        }

        return totalRemovedAmounts;
    }

    /**
     * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly
     * over period of 4 weeks since last deposit will apply.
     * @param tokenAmount the amount of the token you want to receive
     * @param tokenIndex the index of the token you want to receive
     * @param minAmount the minimum amount to withdraw, otherwise revert
     * @param deadline latest timestamp to accept this transaction
     * @return amount of chosen token user received
     */
    function removeLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex,
        uint256 minAmount,
        uint256 deadline
    ) external nonReentrant returns (uint256) {
        uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);
        uint8 baseTokensLength = uint8(baseTokens.length);

        // Transfer metaLPToken from the caller
        metaLPToken.safeTransferFrom(msg.sender, address(this), tokenAmount);

        IERC20 token;
        if (tokenIndex < baseLPTokenIndex) {
            // When the desired token is meta level token, we can just call `removeLiquidityOneToken` directly
            metaSwap.removeLiquidityOneToken(
                tokenAmount,
                tokenIndex,
                minAmount,
                deadline
            );
            token = metaTokens[tokenIndex];
        } else if (tokenIndex < baseLPTokenIndex + baseTokensLength) {
            // When the desired token is a base level token, we need to first withdraw via baseLPToken, then withdraw
            // the desired token from the base Swap contract.
            uint256 removedBaseLPTokenAmount = metaSwap.removeLiquidityOneToken(
                tokenAmount,
                baseLPTokenIndex,
                0,
                deadline
            );

            baseSwap.removeLiquidityOneToken(
                removedBaseLPTokenAmount,
                tokenIndex - baseLPTokenIndex,
                minAmount,
                deadline
            );
            token = baseTokens[tokenIndex - baseLPTokenIndex];
        } else {
            revert("out of range");
        }

        uint256 amountWithdrawn = token.balanceOf(address(this));
        token.safeTransfer(msg.sender, amountWithdrawn);
        return amountWithdrawn;
    }

    /**
     * @notice Remove liquidity from the pool, weighted differently than the
     * pool's current balances. Withdraw fee that decays linearly
     * over period of 4 weeks since last deposit will apply.
     * @param amounts how much of each token to withdraw
     * @param maxBurnAmount the max LP token provider is willing to pay to
     * remove liquidity. Useful as a front-running mitigation.
     * @param deadline latest timestamp to accept this transaction
     * @return amount of LP tokens burned
     */
    function removeLiquidityImbalance(
        uint256[] calldata amounts,
        uint256 maxBurnAmount,
        uint256 deadline
    ) external nonReentrant returns (uint256) {
        IERC20[] memory memBaseTokens = baseTokens;
        IERC20[] memory memMetaTokens = metaTokens;
        uint256[] memory metaAmounts = new uint256[](memMetaTokens.length);
        uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);

        require(
            amounts.length == memBaseTokens.length + memMetaTokens.length - 1,
            "out of range"
        );

        RemoveLiquidityImbalanceInfo memory v = RemoveLiquidityImbalanceInfo(
            baseSwap,
            metaSwap,
            metaLPToken,
            uint8(metaAmounts.length - 1),
            false,
            0
        );

        for (uint8 i = 0; i < v.baseLPTokenIndex; i++) {
            metaAmounts[i] = amounts[i];
        }

        for (uint8 i = 0; i < baseAmounts.length; i++) {
            baseAmounts[i] = amounts[v.baseLPTokenIndex + i];
            if (baseAmounts[i] > 0) {
                v.withdrawFromBase = true;
            }
        }

        // Calculate how much base LP token we need to get the desired amount of underlying tokens
        if (v.withdrawFromBase) {
            metaAmounts[v.baseLPTokenIndex] = v
                .baseSwap
                .calculateTokenAmount(baseAmounts, false)
                .mul(10005)
                .div(10000);
        }

        // Transfer MetaSwap LP token from the caller to this contract
        v.metaLPToken.safeTransferFrom(
            msg.sender,
            address(this),
            maxBurnAmount
        );

        // Withdraw the paired meta level tokens and the base LP token from the MetaSwap pool
        uint256 burnedMetaLPTokenAmount = v.metaSwap.removeLiquidityImbalance(
            metaAmounts,
            maxBurnAmount,
            deadline
        );
        v.leftoverMetaLPTokenAmount = maxBurnAmount.sub(
            burnedMetaLPTokenAmount
        );

        // If underlying tokens are desired, withdraw them from the base Swap pool
        if (v.withdrawFromBase) {
            v.baseSwap.removeLiquidityImbalance(
                baseAmounts,
                metaAmounts[v.baseLPTokenIndex],
                deadline
            );

            // Base Swap may require LESS base LP token than the amount we have
            // In that case, deposit it to the MetaSwap pool.
            uint256[] memory leftovers = new uint256[](metaAmounts.length);
            IERC20 baseLPToken = memMetaTokens[v.baseLPTokenIndex];
            uint256 leftoverBaseLPTokenAmount = baseLPToken.balanceOf(
                address(this)
            );
            if (leftoverBaseLPTokenAmount > 0) {
                leftovers[v.baseLPTokenIndex] = leftoverBaseLPTokenAmount;
                v.leftoverMetaLPTokenAmount = v.leftoverMetaLPTokenAmount.add(
                    v.metaSwap.addLiquidity(leftovers, 0, deadline)
                );
            }
        }

        // Transfer all withdrawn tokens to the caller
        for (uint8 i = 0; i < amounts.length; i++) {
            IERC20 token;
            if (i < v.baseLPTokenIndex) {
                token = memMetaTokens[i];
            } else {
                token = memBaseTokens[i - v.baseLPTokenIndex];
            }
            if (amounts[i] > 0) {
                token.safeTransfer(msg.sender, amounts[i]);
            }
        }

        // If there were any extra meta lp token, transfer them back to the caller as well
        if (v.leftoverMetaLPTokenAmount > 0) {
            v.metaLPToken.safeTransfer(msg.sender, v.leftoverMetaLPTokenAmount);
        }

        return maxBurnAmount - v.leftoverMetaLPTokenAmount;
    }

    // VIEW FUNCTIONS

    /**
     * @notice A simple method to calculate prices from deposits or
     * withdrawals, excluding fees but including slippage. This is
     * helpful as an input into the various "min" parameters on calls
     * to fight front-running. When withdrawing from the base pool in imbalanced
     * fashion, the recommended slippage setting is 0.2% or higher.
     *
     * @dev This shouldn't be used outside frontends for user estimates.
     *
     * @param amounts an array of token amounts to deposit or withdrawal,
     * corresponding to pooledTokens. The amount should be in each
     * pooled token's native precision. If a token charges a fee on transfers,
     * use the amount that gets transferred after the fee.
     * @param deposit whether this is a deposit or a withdrawal
     * @return token amount the user will receive
     */
    function calculateTokenAmount(uint256[] calldata amounts, bool deposit)
        external
        view
        returns (uint256)
    {
        uint256[] memory metaAmounts = new uint256[](metaTokens.length);
        uint256[] memory baseAmounts = new uint256[](baseTokens.length);
        uint256 baseLPTokenIndex = metaAmounts.length - 1;

        for (uint8 i = 0; i < baseLPTokenIndex; i++) {
            metaAmounts[i] = amounts[i];
        }

        for (uint8 i = 0; i < baseAmounts.length; i++) {
            baseAmounts[i] = amounts[baseLPTokenIndex + i];
        }

        uint256 baseLPTokenAmount = baseSwap.calculateTokenAmount(
            baseAmounts,
            deposit
        );
        metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;

        return metaSwap.calculateTokenAmount(metaAmounts, deposit);
    }

    /**
     * @notice A simple method to calculate amount of each underlying
     * tokens that is returned upon burning given amount of LP tokens
     * @param amount the amount of LP tokens that would be burned on withdrawal
     * @return array of token balances that the user will receive
     */
    function calculateRemoveLiquidity(uint256 amount)
        external
        view
        returns (uint256[] memory)
    {
        uint256[] memory metaAmounts = metaSwap.calculateRemoveLiquidity(
            amount
        );
        uint8 baseLPTokenIndex = uint8(metaAmounts.length - 1);
        uint256[] memory baseAmounts = baseSwap.calculateRemoveLiquidity(
            metaAmounts[baseLPTokenIndex]
        );

        uint256[] memory totalAmounts = new uint256[](
            baseLPTokenIndex + baseAmounts.length
        );
        for (uint8 i = 0; i < baseLPTokenIndex; i++) {
            totalAmounts[i] = metaAmounts[i];
        }
        for (uint8 i = 0; i < baseAmounts.length; i++) {
            totalAmounts[baseLPTokenIndex + i] = baseAmounts[i];
        }

        return totalAmounts;
    }

    /**
     * @notice Calculate the amount of underlying token available to withdraw
     * when withdrawing via only single token
     * @param tokenAmount the amount of LP token to burn
     * @param tokenIndex index of which token will be withdrawn
     * @return availableTokenAmount calculated amount of underlying token
     * available to withdraw
     */
    function calculateRemoveLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex
    ) external view returns (uint256) {
        uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);

        if (tokenIndex < baseLPTokenIndex) {
            return
                metaSwap.calculateRemoveLiquidityOneToken(
                    tokenAmount,
                    tokenIndex
                );
        } else {
            uint256 baseLPTokenAmount = metaSwap
                .calculateRemoveLiquidityOneToken(
                    tokenAmount,
                    baseLPTokenIndex
                );
            return
                baseSwap.calculateRemoveLiquidityOneToken(
                    baseLPTokenAmount,
                    tokenIndex - baseLPTokenIndex
                );
        }
    }

    /**
     * @notice Returns the address of the pooled token at given index. Reverts if tokenIndex is out of range.
     * This is a flattened representation of the pooled tokens.
     * @param index the index of the token
     * @return address of the token at given index
     */
    function getToken(uint8 index) external view returns (IERC20) {
        require(index < tokens.length, "index out of range");
        return tokens[index];
    }

    /**
     * @notice Calculate amount of tokens you receive on swap
     * @param tokenIndexFrom the token the user wants to sell
     * @param tokenIndexTo the token the user wants to buy
     * @param dx the amount of tokens the user wants to sell. If the token charges
     * a fee on transfers, use the amount that gets transferred after the fee.
     * @return amount of tokens the user will receive
     */
    function calculateSwap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256) {
        return
            metaSwap.calculateSwapUnderlying(tokenIndexFrom, tokenIndexTo, dx);
    }
}
          
>

Contract ABI

[{"type":"constructor","stateMutability":"payable","inputs":[{"type":"address","name":"admin","internalType":"address"},{"type":"address","name":"poolOwner","internalType":"address"}]},{"type":"event","name":"AddCommunityPool","inputs":[{"type":"address","name":"poolAddress","internalType":"address","indexed":true},{"type":"uint256","name":"index","internalType":"uint256","indexed":false},{"type":"tuple","name":"poolData","internalType":"struct IPoolRegistry.PoolData","indexed":false,"components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"address","name":"lpToken","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"},{"type":"address","name":"basePoolAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}],"anonymous":false},{"type":"event","name":"AddPool","inputs":[{"type":"address","name":"poolAddress","internalType":"address","indexed":true},{"type":"uint256","name":"index","internalType":"uint256","indexed":false},{"type":"tuple","name":"poolData","internalType":"struct IPoolRegistry.PoolData","indexed":false,"components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"address","name":"lpToken","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"},{"type":"address","name":"basePoolAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}],"anonymous":false},{"type":"event","name":"RemovePool","inputs":[{"type":"address","name":"poolAddress","internalType":"address","indexed":true},{"type":"uint256","name":"index","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"UpdatePool","inputs":[{"type":"address","name":"poolAddress","internalType":"address","indexed":true},{"type":"uint256","name":"index","internalType":"uint256","indexed":false},{"type":"tuple","name":"poolData","internalType":"struct IPoolRegistry.PoolData","indexed":false,"components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"address","name":"lpToken","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"},{"type":"address","name":"basePoolAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"COMMUNITY_MANAGER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"SADDLE_APPROVED_POOL_OWNER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"SADDLE_MANAGER_ROLE","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"addCommunityPool","inputs":[{"type":"tuple","name":"data","internalType":"struct IPoolRegistry.PoolData","components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"address","name":"lpToken","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"},{"type":"address","name":"basePoolAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"addPool","inputs":[{"type":"tuple","name":"inputData","internalType":"struct IPoolRegistry.PoolInputData","components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"approvePool","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"batch","inputs":[{"type":"bytes[]","name":"calls","internalType":"bytes[]"},{"type":"bool","name":"revertOnFail","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getA","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"eligiblePools","internalType":"address[]"}],"name":"getEligiblePools","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"getPaused","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct IPoolRegistry.PoolData","components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"address","name":"lpToken","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"},{"type":"address","name":"basePoolAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}],"name":"getPoolData","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct IPoolRegistry.PoolData","components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"address","name":"lpToken","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"},{"type":"address","name":"basePoolAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}],"name":"getPoolDataAtIndex","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct IPoolRegistry.PoolData","components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"address","name":"lpToken","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"},{"type":"address","name":"basePoolAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}],"name":"getPoolDataByName","inputs":[{"type":"bytes32","name":"poolName","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPoolsLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"swapStorageData","internalType":"struct IPoolRegistry.SwapStorageData","components":[{"type":"uint256","name":"initialA","internalType":"uint256"},{"type":"uint256","name":"futureA","internalType":"uint256"},{"type":"uint256","name":"initialATime","internalType":"uint256"},{"type":"uint256","name":"futureATime","internalType":"uint256"},{"type":"uint256","name":"swapFee","internalType":"uint256"},{"type":"uint256","name":"adminFee","internalType":"uint256"},{"type":"address","name":"lpToken","internalType":"address"}]}],"name":"getSwapStorage","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"balances","internalType":"uint256[]"}],"name":"getTokenBalances","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"}],"name":"getTokens","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"balances","internalType":"uint256[]"}],"name":"getUnderlyingTokenBalances","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"}],"name":"getUnderlyingTokens","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVirtualPrice","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"poolsIndexOfNamePlusOne","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"poolsIndexOfPlusOne","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"removePool","inputs":[{"type":"address","name":"poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"updatePool","inputs":[{"type":"tuple","name":"poolData","internalType":"struct IPoolRegistry.PoolData","components":[{"type":"address","name":"poolAddress","internalType":"address"},{"type":"address","name":"lpToken","internalType":"address"},{"type":"uint8","name":"typeOfAsset","internalType":"uint8"},{"type":"bytes32","name":"poolName","internalType":"bytes32"},{"type":"address","name":"targetAddress","internalType":"address"},{"type":"address[]","name":"tokens","internalType":"contract IERC20[]"},{"type":"address[]","name":"underlyingTokens","internalType":"contract IERC20[]"},{"type":"address","name":"basePoolAddress","internalType":"address"},{"type":"address","name":"metaSwapDepositAddress","internalType":"address"},{"type":"bool","name":"isSaddleApproved","internalType":"bool"},{"type":"bool","name":"isRemoved","internalType":"bool"},{"type":"bool","name":"isGuarded","internalType":"bool"}]}]}]
              

Contract Creation Code

0x608060405260405162004657380380620046578339810160408190526200002691620001dd565b600180556001600160a01b0382166200005c5760405162461bcd60e51b815260040162000053906200021b565b60405180910390fd5b62000069600083620000c9565b620000957fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33620000c9565b620000c17f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c2682620000c9565b505062000258565b620000d58282620000d9565b5050565b600082815260208181526040909120620000fe91839062002baf62000152821b17901c565b15620000d5576200010e62000172565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600062000169836001600160a01b03841662000176565b90505b92915050565b3390565b6000620001848383620001c5565b620001bc575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200016c565b5060006200016c565b60009081526001919091016020526040902054151590565b60008060408385031215620001f0578182fd5b8251620001fd816200023f565b602084015190925062000210816200023f565b809150509250929050565b6020808252600a9082015269061646d696e203d3d20360b41b604082015260600190565b6001600160a01b03811681146200025557600080fd5b50565b6143ef80620002686000396000f3fe6080604052600436106101e35760003560e01c8063764f3aa811610102578063b55d990411610095578063d2423b5111610064578063d2423b5114610570578063d547741f14610583578063e7dc263b146105a3578063f1be0eba146105b6576101e3565b8063b55d9904146104ee578063c5730e2d1461050e578063ca15c8731461053b578063ce883cdb1461055b576101e3565b8063a217fddf116100d1578063a217fddf14610484578063a7666d4b14610499578063afd5beed146104b9578063b26a5102146104ce576101e3565b8063764f3aa8146103f75780638a754bbe146104175780639010d07c1461042a57806391d1485414610457576101e3565b80633b7d09461161017a5780635b506a00116101495780635b506a001461038d578063656dc2e4146103ad578063676bca21146103cd5780636d2f2246146103e2576101e3565b80633b7d09461461031a578063424c265b1461032d578063450efe21146103405780634ed33ace1461036d576101e3565b8063248a9ca3116101b6578063248a9ca3146102805780632e23cc80146102ad5780632f2ff15d146102da57806336568abe146102fa576101e3565b8063017f2093146101e857806306b6e7771461021e57806313d21cdf146102335780631ed668db14610253575b600080fd5b3480156101f457600080fd5b506102086102033660046134fe565b6105d6565b60405161021591906140ee565b60405180910390f35b61023161022c366004613605565b6107ea565b005b34801561023f57600080fd5b5061020861024e3660046133f2565b610af1565b34801561025f57600080fd5b5061027361026e3660046133f2565b610b5c565b6040516102159190614101565b34801561028c57600080fd5b506102a061029b3660046134fe565b610c08565b6040516102159190613b2f565b3480156102b957600080fd5b506102cd6102c83660046133f2565b610c1d565b6040516102159190613aec565b3480156102e657600080fd5b506102316102f5366004613516565b610fc2565b34801561030657600080fd5b50610231610315366004613516565b61100a565b6102316103283660046133f2565b61104c565b61023161033b3660046133f2565b61113e565b34801561034c57600080fd5b5061036061035b3660046133f2565b611364565b6040516102159190613ad9565b34801561037957600080fd5b506102a06103883660046133f2565b61143c565b34801561039957600080fd5b506102a06103a83660046134fe565b6114e4565b3480156103b957600080fd5b506103606103c83660046133f2565b6114f6565b3480156103d957600080fd5b506102a06115cc565b3480156103ee57600080fd5b506102a06115f0565b34801561040357600080fd5b506102cd6104123660046133f2565b611614565b610231610425366004613605565b611657565b34801561043657600080fd5b5061044a61044536600461353a565b611bc7565b6040516102159190613a78565b34801561046357600080fd5b50610477610472366004613516565b611be8565b6040516102159190613b24565b34801561049057600080fd5b506102a0611c00565b3480156104a557600080fd5b506102086104b43660046134fe565b611c05565b3480156104c557600080fd5b506102a0611e00565b3480156104da57600080fd5b506102a06104e93660046133f2565b611e24565b3480156104fa57600080fd5b506104776105093660046133f2565b611e36565b34801561051a57600080fd5b5061052e61052936600461342a565b611ede565b6040516102159190613a8c565b34801561054757600080fd5b506102a06105563660046134fe565b611f9d565b34801561056757600080fd5b506102a0611fb4565b61023161057e366004613462565b611fba565b34801561058f57600080fd5b5061023161059e366004613516565b61207d565b6102316105b1366004613751565b6120b7565b3480156105c257600080fd5b506102a06105d13660046133f2565b612b3f565b6105de6131e5565b600082815260036020526040902054806106135760405162461bcd60e51b815260040161060a9061405a565b60405180910390fd5b6004600182038154811061062357fe5b60009182526020918290206040805161018081018252600890930290910180546001600160a01b03908116845260018201548082168587015260ff7401000000000000000000000000000000000000000090910416848401526002820154606085015260038201541660808401526004810180548351818702810187019094528084529394919360a0860193928301828280156106e957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116106cb575b505050505081526020016005820180548060200260200160405190810160405280929190818152602001828054801561074b57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161072d575b505050918352505060068201546001600160a01b039081166020830152600790920154918216604082015260ff74010000000000000000000000000000000000000000830481161515606083015275010000000000000000000000000000000000000000008304811615156080830152760100000000000000000000000000000000000000000000909204909116151560a0909101529150505b919050565b6108147fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6108305760405162461bcd60e51b815260040161060a90613ce8565b80516001600160a01b0316600090815260026020526040902054806108675760405162461bcd60e51b815260040161060a9061405a565b600181039050816004828154811061087b57fe5b6000918252602091829020835160089092020180546001600160a01b039283167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617825584840151600183018054604088015160ff1674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff93871691851691909117929092169190911790556060850151600283015560808501516003830180549190941691161790915560a08301518051919261095a92600485019290910190613248565b5060c08201518051610976916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915582516040519116907f21292cd2979873e2f844b8d081ebe90c5d4095362e2814ea54332ec7b6fd432e90610ae59084908690614158565b60405180910390a25050565b610af96131e5565b6001600160a01b0382166000908152600260205260409020548290610b305760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b0383166000908152600260205260409020546004805490916000190190811061062357fe5b610b646132c5565b6001600160a01b0382166000908152600260205260409020548290610b9b5760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b03831660009081526002602052604090205460048054909160001901908110610bc757fe5b906000526020600020906008020160070160169054906101000a900460ff16610bf857610bf383612bc4565b610c01565b610c0183612c6b565b9392505050565b60009081526020819052604090206002015490565b6001600160a01b0381166000908152600260205260409020546060908290610c575760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b03831660009081526002602052604081205460048054600019909201929183908110610c8657fe5b60009182526020909120600660089092020101546001600160a01b031690506060610cb082612d14565b9050600060048481548110610cc157fe5b6000918252602082206005600890920201015483516040517f91ceb3eb000000000000000000000000000000000000000000000000000000008152919350830391906001600160a01b038a16906391ceb3eb90610d229085906004016142bc565b60206040518083038186803b158015610d3a57600080fd5b505afa158015610d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7291906137fa565b905060006004600160026000896001600160a01b03166001600160a01b03168152602001908152602001600020540381548110610dab57fe5b600091825260209182902060016008909202010154604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216926318160ddd92600480840193829003018186803b158015610e1557600080fd5b505afa158015610e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4d91906137fa565b90508367ffffffffffffffff81118015610e6657600080fd5b50604051908082528060200260200182016040528015610e90578160200160208202803683370190505b50985060005b838160ff161015610f58576040517f91ceb3eb0000000000000000000000000000000000000000000000000000000081526001600160a01b038c16906391ceb3eb90610ee69084906004016142bc565b60206040518083038186803b158015610efe57600080fd5b505afa158015610f12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3691906137fa565b8a8260ff1681518110610f4557fe5b6020908102919091010152600101610e96565b50825b84811015610fb457610f9582610f8f858988860381518110610f7957fe5b6020026020010151612e6990919063ffffffff16565b90612ea3565b8a8281518110610fa157fe5b6020908102919091010152600101610f5b565b505050505050505050919050565b600082815260208190526040902060020154610fe090610472612ed5565b610ffc5760405162461bcd60e51b815260040161060a90613be6565b6110068282612ed9565b5050565b611012612ed5565b6001600160a01b0316816001600160a01b0316146110425760405162461bcd60e51b815260040161060a90614091565b6110068282612f42565b6110767fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6110925760405162461bcd60e51b815260040161060a90613ce8565b6001600160a01b038116600090815260026020526040902054806110c85760405162461bcd60e51b815260040161060a9061405a565b6001810390506001600482815481106110dd57fe5b906000526020600020906008020160070160156101000a81548160ff021916908315150217905550816001600160a01b03167ff53dcf4cb920d5a07b1ae3e0756c787bb675805c0176515e9cc6a33226f068b282604051610ae59190613b2f565b6111687fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6111845760405162461bcd60e51b815260040161060a90613ce8565b6001600160a01b038116600090815260026020526040902054806111ba5760405162461bcd60e51b815260040161060a9061405a565b6000600482815481106111c957fe5b6000918252602090912060089091020180549091506001600160a01b038481169116146112085760405162461bcd60e51b815260040161060a90613cb1565b6007810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055604080517f8da5cb5b0000000000000000000000000000000000000000000000000000000081529051611300917f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c26916001600160a01b03871691638da5cb5b916004808301926020929190829003018186803b1580156112c857600080fd5b505afa1580156112dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610472919061340e565b61131c5760405162461bcd60e51b815260040161060a90613c43565b826001600160a01b03167f21292cd2979873e2f844b8d081ebe90c5d4095362e2814ea54332ec7b6fd432e8383604051611357929190614179565b60405180910390a2505050565b6001600160a01b038116600090815260026020526040902054606090829061139e5760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b038316600090815260026020526040902054600480549091600019019081106113ca57fe5b906000526020600020906008020160040180548060200260200160405190810160405280929190818152602001828054801561142f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611411575b5050505050915050919050565b6001600160a01b03811660009081526002602052604081205482906114735760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b031663d46300fd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114ac57600080fd5b505afa1580156114c0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0191906137fa565b60036020526000908152604090205481565b6001600160a01b03811660009081526002602052604090205460609082906115305760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b0383166000908152600260205260409020546004805490916000190190811061155c57fe5b906000526020600020906008020160050180548060200260200160405190810160405280929190818152602001828054801561142f576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611411575050505050915050919050565b7fa9eb1bd0b8bd5d75005d4e3c25736746c884daef9ecff243b81b4cc73cfb7f9e81565b7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd81565b6001600160a01b038116600090815260026020526040902054606090829061164e5760405162461bcd60e51b815260040161060a90613fb5565b610c0183612d14565b6116817fa9eb1bd0b8bd5d75005d4e3c25736746c884daef9ecff243b81b4cc73cfb7f9e33611be8565b61169d5760405162461bcd60e51b815260040161060a90613e45565b60005b8160a00151518160ff16101561176f5760005b8160ff168160ff16101561176657600560008460a001518360ff16815181106116d857fe5b60200260200101518560a001518560ff16815181106116f357fe5b6020908102919091018101516001600160a01b0392188216835282810193909352604090910160009081208651815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016116b3565b506001016116a0565b506101008101516001600160a01b0316156118775760005b8160c00151518160ff1610156118755760a0820151516117a8906002612fab565b8160ff16111561186d5760005b60018360a00151510381101561186b57600560008460c0015183815181106117d957fe5b60200260200101518560c001518560ff16815181106117f457fe5b6020908102919091018101516001600160a01b039218821683528281019390935260409091016000908120610100870151815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016117b5565b505b600101611787565b505b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600890920291820180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b039384161782556020808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c860180546040890151908516928716929092177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000060ff9093169290920291909117905560608601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d86015560808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e86018054909316941693909317905560a08401518051859492936119fe937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f01920190613248565b5060c08201518051611a1a916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915560045482518216600090815260026020908152604080832084905560608601518352600390915290819020829055835190519216917f662dd796ff757466e483389dd24bcbb94cb0591dfd6b1972962f5a147b69333191611bbc9160001991909101908590614158565b60405180910390a250565b6000828152602081905260408120611bdf9083612fd3565b90505b92915050565b6000828152602081905260408120611bdf9083612fdf565b600081565b611c0d6131e5565b6004548210611c2e5760405162461bcd60e51b815260040161060a90613ed9565b60048281548110611c3b57fe5b60009182526020918290206040805161018081018252600890930290910180546001600160a01b03908116845260018201548082168587015260ff7401000000000000000000000000000000000000000090910416848401526002820154606085015260038201541660808401526004810180548351818702810187019094528084529394919360a086019392830182828015611d0157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ce3575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015611d6357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d45575b505050918352505060068201546001600160a01b039081166020830152600790920154918216604082015260ff74010000000000000000000000000000000000000000830481161515606083015275010000000000000000000000000000000000000000008304811615156080830152760100000000000000000000000000000000000000000000909204909116151560a0909101529050919050565b7f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c2681565b60026020526000908152604090205481565b6001600160a01b0381166000908152600260205260408120548290611e6d5760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ea657600080fd5b505afa158015611eba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0191906134e2565b60606001600160a01b03831615801590611f0a5750816001600160a01b0316836001600160a01b031614155b611f265760405162461bcd60e51b815260040161060a90613de8565b6001600160a01b038383181660009081526005602090815260409182902080548351818402810184019094528084529091830182828015611f9057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611f72575b5050505050905092915050565b6000818152602081905260408120611be290612ff4565b60045490565b60005b82811015612077576000606030868685818110611fd657fe5b9050602002810190611fe891906142ca565b604051611ff6929190613a68565b600060405180830381855af49150503d8060008114612031576040519150601f19603f3d011682016040523d82523d6000602084013e612036565b606091505b5091509150811580156120465750835b1561206d5761205481612fff565b60405162461bcd60e51b815260040161060a9190613b38565b5050600101611fbd565b50505050565b60008281526020819052604090206002015461209b90610472612ed5565b6110425760405162461bcd60e51b815260040161060a90613d8b565b600260015414156120da5760405162461bcd60e51b815260040161060a90614023565b60026001556121097fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6121255760405162461bcd60e51b815260040161060a90613e45565b80516001600160a01b031661214c5760405162461bcd60e51b815260040161060a90613f10565b80516001600160a01b0316600090815260026020526040902054156121835760405162461bcd60e51b815260040161060a90613fec565b6040805160088082526101208201909252606091602082016101008036833750506040805160088082526101208201909252929350606092915060208201610100803683370190505090506121d66131e5565b60405180610180016040528085600001516001600160a01b0316815260200160006001600160a01b03168152602001856020015160ff1681526020018560400151815260200185606001516001600160a01b0316815260200184815260200183815260200160006001600160a01b0316815260200185608001516001600160a01b031681526020018560a00151151581526020018560c00151151581526020018560e00151151581525090508360e0015161229f57835161229690612bc4565b60c001516122af565b83516122aa90612c6b565b60c001515b6001600160a01b0316602082015260005b60088160ff16101561249a5784516040517f82b866000000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906382b86600906123149084906004016142bc565b60206040518083038186803b15801561232c57600080fd5b505afa92505050801561237a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526123779181019061340e565b60015b61238c5780600803845103845261249a565b6001600160a01b0381166123b25760405162461bcd60e51b815260040161060a90613f7e565b80858360ff16815181106123c257fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060005b8260ff168160ff1610156124905760056000878360ff168151811061240657fe5b6020026020010151888660ff168151811061241d57fe5b6020908102919091018101516001600160a01b0392188216835282810193909352604090910160009081208a51815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016123e5565b50506001016122c0565b5060808401516001600160a01b0316156127e05783608001516001600160a01b0316639750a8ee6040518163ffffffff1660e01b815260040160206040518083038186803b1580156124eb57600080fd5b505afa1580156124ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612523919061340e565b6001600160a01b031660e0820181905260009081526002602052604090205461255e5760405162461bcd60e51b815260040161060a90613c7a565b60005b60088160ff1610156127315784608001516001600160a01b03166382b86600826040518263ffffffff1660e01b815260040161259d91906142bc565b60206040518083038186803b1580156125b557600080fd5b505afa925050508015612603575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526126009181019061340e565b60015b61261557806008038351038352612731565b6001600160a01b03811661263b5760405162461bcd60e51b815260040161060a90613f7e565b80848360ff168151811061264b57fe5b6001600160a01b03909216602092830291909101909101528451612670906002612fab565b8260ff1611156127285760005b6001865103811015612726576005600086838151811061269957fe5b6020026020010151878660ff16815181106126b057fe5b6020908102919091018101516001600160a01b03921882168352828101939093526040909101600090812060808b0151815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790550161267d565b505b50600101612561565b5083600001516001600160a01b031684608001516001600160a01b031663cb2ef5fe6040518163ffffffff1660e01b815260040160206040518083038186803b15801561277d57600080fd5b505afa158015612791573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b5919061340e565b6001600160a01b0316146127db5760405162461bcd60e51b815260040161060a90613f47565b6127e8565b600882510382525b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600890920291820180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b039384161782556020808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c860180546040890151908516928716929092177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000060ff9093169290920291909117905560608601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d86015560808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e86018054909316941693909317905560a084015180518594929361296f937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f01920190613248565b5060c0820151805161298b916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915560045482518216600090815260026020908152604080832084905560608601518352600390915290819020829055865190519216917f15ec4115f45227a2f5b970962fd2294c7be9ba12b0652daae49ff679c02a1e0291612b2d9160001991909101908590614158565b60405180910390a25050600180555050565b6001600160a01b0381166000908152600260205260408120548290612b765760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b031663e25aa5fa6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114ac57600080fd5b6000611bdf836001600160a01b03841661305f565b612bcc6132c5565b816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612c0557600080fd5b505afa158015612c19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c3d9190613812565b6001600160a01b031660c088015260a087015260808601526060850152604084015260208301528152919050565b612c736132c5565b816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b81526004016101006040518083038186803b158015612cad57600080fd5b505afa158015612cc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce59190613871565b6001600160a01b031660c08901525060a087015260808601526060850152604084015260208301528152919050565b6001600160a01b038116600090815260026020526040812054600480546060939260001901908110612d4257fe5b90600052602060002090600802016004018054905090508067ffffffffffffffff81118015612d7057600080fd5b50604051908082528060200260200182016040528015612d9a578160200160208202803683370190505b50915060005b818160ff161015612e62576040517f91ceb3eb0000000000000000000000000000000000000000000000000000000081526001600160a01b038516906391ceb3eb90612df09084906004016142bc565b60206040518083038186803b158015612e0857600080fd5b505afa158015612e1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e4091906137fa565b838260ff1681518110612e4f57fe5b6020908102919091010152600101612da0565b5050919050565b600082612e7857506000611be2565b82820282848281612e8557fe5b0414611bdf5760405162461bcd60e51b815260040161060a90613e7c565b6000808211612ec45760405162461bcd60e51b815260040161060a90613d54565b818381612ecd57fe5b049392505050565b3390565b6000828152602081905260409020612ef19082612baf565b1561100657612efe612ed5565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081905260409020612f5a90826130a9565b1561100657612f67612ed5565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600082821115612fcd5760405162461bcd60e51b815260040161060a90613d1d565b50900390565b6000611bdf83836130be565b6000611bdf836001600160a01b038416613103565b6000611be28261311b565b6060604482511015613045575060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c7900000060208201526107e5565b60048201915081806020019051810190611be2919061355b565b600061306b8383613103565b6130a157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611be2565b506000611be2565b6000611bdf836001600160a01b03841661311f565b815460009082106130e15760405162461bcd60e51b815260040161060a90613b89565b8260000182815481106130f057fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081815260018301602052604081205480156131db578354600019808301919081019060009087908390811061315257fe5b906000526020600020015490508087600001848154811061316f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061319f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611be2565b6000915050611be2565b604080516101808101825260008082526020820181905291810182905260608082018390526080820183905260a0820181905260c082015260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b8280548282559060005260206000209081019282156132b5579160200282015b828111156132b557825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178255602090920191600190910190613268565b506132c192915061330b565b5090565b6040518060e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b5b808211156132c15780547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010161330c565b8035611be281614393565b600082601f83011261335d578081fd5b813567ffffffffffffffff811115613373578182fd5b6020808202613383828201614334565b8381529350818401858301828701840188101561339f57600080fd5b600092505b848310156133cb5780356133b781614393565b8252600192909201919083019083016133a4565b505050505092915050565b8035611be2816143ab565b803560ff81168114611be257600080fd5b600060208284031215613403578081fd5b8135611bdf81614393565b60006020828403121561341f578081fd5b8151611bdf81614393565b6000806040838503121561343c578081fd5b823561344781614393565b9150602083013561345781614393565b809150509250929050565b600080600060408486031215613476578081fd5b833567ffffffffffffffff8082111561348d578283fd5b818601915086601f8301126134a0578283fd5b8135818111156134ae578384fd5b87602080830285010111156134c1578384fd5b602092830195509350508401356134d7816143ab565b809150509250925092565b6000602082840312156134f3578081fd5b8151611bdf816143ab565b60006020828403121561350f578081fd5b5035919050565b60008060408385031215613528578182fd5b82359150602083013561345781614393565b6000806040838503121561354c578182fd5b50508035926020909101359150565b60006020828403121561356c578081fd5b815167ffffffffffffffff80821115613583578283fd5b818401915084601f830112613596578283fd5b8151818111156135a4578384fd5b6135d560207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601614334565b91508082528560208285010111156135eb578384fd5b6135fc816020840160208601614367565b50949350505050565b600060208284031215613616578081fd5b813567ffffffffffffffff8082111561362d578283fd5b8184019150610180808387031215613643578384fd5b61364c81614334565b90506136588684613342565b81526136678660208501613342565b602082015261367986604085016133e1565b6040820152606083013560608201526136958660808501613342565b608082015260a0830135828111156136ab578485fd5b6136b78782860161334d565b60a08301525060c0830135828111156136ce578485fd5b6136da8782860161334d565b60c0830152506136ed8660e08501613342565b60e0820152610100915061370386838501613342565b828201526101209150613718868385016133d6565b82820152610140915061372d868385016133d6565b828201526101609150613742868385016133d6565b91810191909152949350505050565b6000610100808385031215613764578182fd5b61376d81614334565b9050823561377a81614393565b815261378984602085016133e1565b60208201526040830135604082015260608301356137a681614393565b60608201526137b88460808501613342565b60808201526137ca8460a085016133d6565b60a08201526137dc8460c085016133d6565b60c08201526137ee8460e085016133d6565b60e08201529392505050565b60006020828403121561380b578081fd5b5051919050565b600080600080600080600060e0888a03121561382c578485fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c088015161386181614393565b8091505092959891949750929550565b600080600080600080600080610100898b03121561388d578182fd5b885197506020890151965060408901519550606089015194506080890151935060a0890151925060c0890151915060e08901516138c981614393565b809150509295985092959890939650565b6001600160a01b03169052565b6000815180845260208085019450808401835b8381101561391f5781516001600160a01b0316875295820195908201906001016138fa565b509495945050505050565b6000815480845260208085019450838352808320835b8381101561391f5781546001600160a01b031687529582019560019182019101613940565b15159052565b600061018061397b8484516138da565b602083015161398d60208601826138da565b5060408301516139a06040860182613a61565b506060830151606085015260808301516139bd60808601826138da565b5060a08301518160a08601526139d5828601826138e7565b91505060c083015184820360c08601526139ef82826138e7565b91505060e0830151613a0460e08601826138da565b5061010080840151613a18828701826138da565b505061012080840151613a2d82870182613965565b505061014080840151613a4282870182613965565b505061016080840151613a5782870182613965565b5090949350505050565b60ff169052565b6000828483379101908152919050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b81811015613acd5783516001600160a01b031683529284019291840191600101613aa8565b50909695505050505050565b600060208252611bdf60208301846138e7565b6020808252825182820181905260009190848201906040850190845b81811015613acd57835183529284019291840191600101613b08565b901515815260200190565b90815260200190565b6000602082528251806020840152613b57816040850160208701614367565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252601b908201527f506f6f6c206973206e6f74206f776e656420627920736164646c650000000000604082015260600190565b60208082526017908201527f50523a206261736520706f6f6c206e6f7420666f756e64000000000000000000604082015260600190565b60208082526018908201527f50523a20706f6f6c41646472657373206d69736d617463680000000000000000604082015260600190565b6020808252818101527f50523a2043616c6c6572206973206e6f7420736164646c65206d616e61676572604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b6020808252602a908201527f50523a2066726f6d20616e6420746f2063616e6e6f7420626520746865207a6560408201527f726f206164647265737300000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f50523a204f6e6c79206d616e61676572732063616e2061646420706f6f6c7300604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60408201527f7700000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526017908201527f50523a20496e646578206f7574206f6620626f756e6473000000000000000000604082015260600190565b60208082526014908201527f50523a20706f6f6c416464726573732069732030000000000000000000000000604082015260600190565b6020808252601d908201527f50523a206d657461537761702061646472657373206d69736d61746368000000604082015260600190565b6020808252600e908201527f50523a20746f6b656e2069732030000000000000000000000000000000000000604082015260600190565b6020808252601a908201527f50523a204e6f206d61746368696e6720706f6f6c20666f756e64000000000000604082015260600190565b60208082526019908201527f50523a20506f6f6c20697320616c726561647920616464656400000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526012908201527f50523a20506f6f6c206e6f7420666f756e640000000000000000000000000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b600060208252611bdf602083018461396b565b600060e082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a08301526001600160a01b0360c08401511660c083015292915050565b600083825260406020830152614171604083018461396b565b949350505050565b60008382526040602083015261419b60408301614196855461435b565b6138da565b60018301546001600160a01b036141b7606085018284166138da565b6141ca6080850160ff8460a01c16613a61565b600285015460a08501526141e1600386015461435b565b91506141f060c08501836138da565b61018091508160e085015261420c6101c085016004870161392a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc085820301610100860152614244816005880161392a565b9050614253600687015461435b565b6142616101208701826138da565b50600786015461427761014087018483166138da565b61428b610160870160ff8360a01c16613965565b61429d84870160ff8360a81c16613965565b6142b16101a0870160ff8360b01c16613965565b509695505050505050565b60ff91909116815260200190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126142fe578283fd5b83018035915067ffffffffffffffff821115614318578283fd5b60200191503681900382131561432d57600080fd5b9250929050565b60405181810167ffffffffffffffff8111828210171561435357600080fd5b604052919050565b6001600160a01b031690565b60005b8381101561438257818101518382015260200161436a565b838111156120775750506000910152565b6001600160a01b03811681146143a857600080fd5b50565b80151581146143a857600080fdfea2646970667358221220a6fc023ff37d5be4b8e43227139f8db51b182e42e63581000f6c263629d5471364736f6c634300060c00330000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef340000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34

Deployed ByteCode

0x6080604052600436106101e35760003560e01c8063764f3aa811610102578063b55d990411610095578063d2423b5111610064578063d2423b5114610570578063d547741f14610583578063e7dc263b146105a3578063f1be0eba146105b6576101e3565b8063b55d9904146104ee578063c5730e2d1461050e578063ca15c8731461053b578063ce883cdb1461055b576101e3565b8063a217fddf116100d1578063a217fddf14610484578063a7666d4b14610499578063afd5beed146104b9578063b26a5102146104ce576101e3565b8063764f3aa8146103f75780638a754bbe146104175780639010d07c1461042a57806391d1485414610457576101e3565b80633b7d09461161017a5780635b506a00116101495780635b506a001461038d578063656dc2e4146103ad578063676bca21146103cd5780636d2f2246146103e2576101e3565b80633b7d09461461031a578063424c265b1461032d578063450efe21146103405780634ed33ace1461036d576101e3565b8063248a9ca3116101b6578063248a9ca3146102805780632e23cc80146102ad5780632f2ff15d146102da57806336568abe146102fa576101e3565b8063017f2093146101e857806306b6e7771461021e57806313d21cdf146102335780631ed668db14610253575b600080fd5b3480156101f457600080fd5b506102086102033660046134fe565b6105d6565b60405161021591906140ee565b60405180910390f35b61023161022c366004613605565b6107ea565b005b34801561023f57600080fd5b5061020861024e3660046133f2565b610af1565b34801561025f57600080fd5b5061027361026e3660046133f2565b610b5c565b6040516102159190614101565b34801561028c57600080fd5b506102a061029b3660046134fe565b610c08565b6040516102159190613b2f565b3480156102b957600080fd5b506102cd6102c83660046133f2565b610c1d565b6040516102159190613aec565b3480156102e657600080fd5b506102316102f5366004613516565b610fc2565b34801561030657600080fd5b50610231610315366004613516565b61100a565b6102316103283660046133f2565b61104c565b61023161033b3660046133f2565b61113e565b34801561034c57600080fd5b5061036061035b3660046133f2565b611364565b6040516102159190613ad9565b34801561037957600080fd5b506102a06103883660046133f2565b61143c565b34801561039957600080fd5b506102a06103a83660046134fe565b6114e4565b3480156103b957600080fd5b506103606103c83660046133f2565b6114f6565b3480156103d957600080fd5b506102a06115cc565b3480156103ee57600080fd5b506102a06115f0565b34801561040357600080fd5b506102cd6104123660046133f2565b611614565b610231610425366004613605565b611657565b34801561043657600080fd5b5061044a61044536600461353a565b611bc7565b6040516102159190613a78565b34801561046357600080fd5b50610477610472366004613516565b611be8565b6040516102159190613b24565b34801561049057600080fd5b506102a0611c00565b3480156104a557600080fd5b506102086104b43660046134fe565b611c05565b3480156104c557600080fd5b506102a0611e00565b3480156104da57600080fd5b506102a06104e93660046133f2565b611e24565b3480156104fa57600080fd5b506104776105093660046133f2565b611e36565b34801561051a57600080fd5b5061052e61052936600461342a565b611ede565b6040516102159190613a8c565b34801561054757600080fd5b506102a06105563660046134fe565b611f9d565b34801561056757600080fd5b506102a0611fb4565b61023161057e366004613462565b611fba565b34801561058f57600080fd5b5061023161059e366004613516565b61207d565b6102316105b1366004613751565b6120b7565b3480156105c257600080fd5b506102a06105d13660046133f2565b612b3f565b6105de6131e5565b600082815260036020526040902054806106135760405162461bcd60e51b815260040161060a9061405a565b60405180910390fd5b6004600182038154811061062357fe5b60009182526020918290206040805161018081018252600890930290910180546001600160a01b03908116845260018201548082168587015260ff7401000000000000000000000000000000000000000090910416848401526002820154606085015260038201541660808401526004810180548351818702810187019094528084529394919360a0860193928301828280156106e957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116106cb575b505050505081526020016005820180548060200260200160405190810160405280929190818152602001828054801561074b57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161072d575b505050918352505060068201546001600160a01b039081166020830152600790920154918216604082015260ff74010000000000000000000000000000000000000000830481161515606083015275010000000000000000000000000000000000000000008304811615156080830152760100000000000000000000000000000000000000000000909204909116151560a0909101529150505b919050565b6108147fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6108305760405162461bcd60e51b815260040161060a90613ce8565b80516001600160a01b0316600090815260026020526040902054806108675760405162461bcd60e51b815260040161060a9061405a565b600181039050816004828154811061087b57fe5b6000918252602091829020835160089092020180546001600160a01b039283167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617825584840151600183018054604088015160ff1674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff93871691851691909117929092169190911790556060850151600283015560808501516003830180549190941691161790915560a08301518051919261095a92600485019290910190613248565b5060c08201518051610976916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915582516040519116907f21292cd2979873e2f844b8d081ebe90c5d4095362e2814ea54332ec7b6fd432e90610ae59084908690614158565b60405180910390a25050565b610af96131e5565b6001600160a01b0382166000908152600260205260409020548290610b305760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b0383166000908152600260205260409020546004805490916000190190811061062357fe5b610b646132c5565b6001600160a01b0382166000908152600260205260409020548290610b9b5760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b03831660009081526002602052604090205460048054909160001901908110610bc757fe5b906000526020600020906008020160070160169054906101000a900460ff16610bf857610bf383612bc4565b610c01565b610c0183612c6b565b9392505050565b60009081526020819052604090206002015490565b6001600160a01b0381166000908152600260205260409020546060908290610c575760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b03831660009081526002602052604081205460048054600019909201929183908110610c8657fe5b60009182526020909120600660089092020101546001600160a01b031690506060610cb082612d14565b9050600060048481548110610cc157fe5b6000918252602082206005600890920201015483516040517f91ceb3eb000000000000000000000000000000000000000000000000000000008152919350830391906001600160a01b038a16906391ceb3eb90610d229085906004016142bc565b60206040518083038186803b158015610d3a57600080fd5b505afa158015610d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7291906137fa565b905060006004600160026000896001600160a01b03166001600160a01b03168152602001908152602001600020540381548110610dab57fe5b600091825260209182902060016008909202010154604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216926318160ddd92600480840193829003018186803b158015610e1557600080fd5b505afa158015610e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4d91906137fa565b90508367ffffffffffffffff81118015610e6657600080fd5b50604051908082528060200260200182016040528015610e90578160200160208202803683370190505b50985060005b838160ff161015610f58576040517f91ceb3eb0000000000000000000000000000000000000000000000000000000081526001600160a01b038c16906391ceb3eb90610ee69084906004016142bc565b60206040518083038186803b158015610efe57600080fd5b505afa158015610f12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3691906137fa565b8a8260ff1681518110610f4557fe5b6020908102919091010152600101610e96565b50825b84811015610fb457610f9582610f8f858988860381518110610f7957fe5b6020026020010151612e6990919063ffffffff16565b90612ea3565b8a8281518110610fa157fe5b6020908102919091010152600101610f5b565b505050505050505050919050565b600082815260208190526040902060020154610fe090610472612ed5565b610ffc5760405162461bcd60e51b815260040161060a90613be6565b6110068282612ed9565b5050565b611012612ed5565b6001600160a01b0316816001600160a01b0316146110425760405162461bcd60e51b815260040161060a90614091565b6110068282612f42565b6110767fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6110925760405162461bcd60e51b815260040161060a90613ce8565b6001600160a01b038116600090815260026020526040902054806110c85760405162461bcd60e51b815260040161060a9061405a565b6001810390506001600482815481106110dd57fe5b906000526020600020906008020160070160156101000a81548160ff021916908315150217905550816001600160a01b03167ff53dcf4cb920d5a07b1ae3e0756c787bb675805c0176515e9cc6a33226f068b282604051610ae59190613b2f565b6111687fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6111845760405162461bcd60e51b815260040161060a90613ce8565b6001600160a01b038116600090815260026020526040902054806111ba5760405162461bcd60e51b815260040161060a9061405a565b6000600482815481106111c957fe5b6000918252602090912060089091020180549091506001600160a01b038481169116146112085760405162461bcd60e51b815260040161060a90613cb1565b6007810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055604080517f8da5cb5b0000000000000000000000000000000000000000000000000000000081529051611300917f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c26916001600160a01b03871691638da5cb5b916004808301926020929190829003018186803b1580156112c857600080fd5b505afa1580156112dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610472919061340e565b61131c5760405162461bcd60e51b815260040161060a90613c43565b826001600160a01b03167f21292cd2979873e2f844b8d081ebe90c5d4095362e2814ea54332ec7b6fd432e8383604051611357929190614179565b60405180910390a2505050565b6001600160a01b038116600090815260026020526040902054606090829061139e5760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b038316600090815260026020526040902054600480549091600019019081106113ca57fe5b906000526020600020906008020160040180548060200260200160405190810160405280929190818152602001828054801561142f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611411575b5050505050915050919050565b6001600160a01b03811660009081526002602052604081205482906114735760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b031663d46300fd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114ac57600080fd5b505afa1580156114c0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0191906137fa565b60036020526000908152604090205481565b6001600160a01b03811660009081526002602052604090205460609082906115305760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b0383166000908152600260205260409020546004805490916000190190811061155c57fe5b906000526020600020906008020160050180548060200260200160405190810160405280929190818152602001828054801561142f576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611411575050505050915050919050565b7fa9eb1bd0b8bd5d75005d4e3c25736746c884daef9ecff243b81b4cc73cfb7f9e81565b7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd81565b6001600160a01b038116600090815260026020526040902054606090829061164e5760405162461bcd60e51b815260040161060a90613fb5565b610c0183612d14565b6116817fa9eb1bd0b8bd5d75005d4e3c25736746c884daef9ecff243b81b4cc73cfb7f9e33611be8565b61169d5760405162461bcd60e51b815260040161060a90613e45565b60005b8160a00151518160ff16101561176f5760005b8160ff168160ff16101561176657600560008460a001518360ff16815181106116d857fe5b60200260200101518560a001518560ff16815181106116f357fe5b6020908102919091018101516001600160a01b0392188216835282810193909352604090910160009081208651815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016116b3565b506001016116a0565b506101008101516001600160a01b0316156118775760005b8160c00151518160ff1610156118755760a0820151516117a8906002612fab565b8160ff16111561186d5760005b60018360a00151510381101561186b57600560008460c0015183815181106117d957fe5b60200260200101518560c001518560ff16815181106117f457fe5b6020908102919091018101516001600160a01b039218821683528281019390935260409091016000908120610100870151815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016117b5565b505b600101611787565b505b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600890920291820180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b039384161782556020808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c860180546040890151908516928716929092177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000060ff9093169290920291909117905560608601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d86015560808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e86018054909316941693909317905560a08401518051859492936119fe937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f01920190613248565b5060c08201518051611a1a916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915560045482518216600090815260026020908152604080832084905560608601518352600390915290819020829055835190519216917f662dd796ff757466e483389dd24bcbb94cb0591dfd6b1972962f5a147b69333191611bbc9160001991909101908590614158565b60405180910390a250565b6000828152602081905260408120611bdf9083612fd3565b90505b92915050565b6000828152602081905260408120611bdf9083612fdf565b600081565b611c0d6131e5565b6004548210611c2e5760405162461bcd60e51b815260040161060a90613ed9565b60048281548110611c3b57fe5b60009182526020918290206040805161018081018252600890930290910180546001600160a01b03908116845260018201548082168587015260ff7401000000000000000000000000000000000000000090910416848401526002820154606085015260038201541660808401526004810180548351818702810187019094528084529394919360a086019392830182828015611d0157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ce3575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015611d6357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d45575b505050918352505060068201546001600160a01b039081166020830152600790920154918216604082015260ff74010000000000000000000000000000000000000000830481161515606083015275010000000000000000000000000000000000000000008304811615156080830152760100000000000000000000000000000000000000000000909204909116151560a0909101529050919050565b7f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c2681565b60026020526000908152604090205481565b6001600160a01b0381166000908152600260205260408120548290611e6d5760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ea657600080fd5b505afa158015611eba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0191906134e2565b60606001600160a01b03831615801590611f0a5750816001600160a01b0316836001600160a01b031614155b611f265760405162461bcd60e51b815260040161060a90613de8565b6001600160a01b038383181660009081526005602090815260409182902080548351818402810184019094528084529091830182828015611f9057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611f72575b5050505050905092915050565b6000818152602081905260408120611be290612ff4565b60045490565b60005b82811015612077576000606030868685818110611fd657fe5b9050602002810190611fe891906142ca565b604051611ff6929190613a68565b600060405180830381855af49150503d8060008114612031576040519150601f19603f3d011682016040523d82523d6000602084013e612036565b606091505b5091509150811580156120465750835b1561206d5761205481612fff565b60405162461bcd60e51b815260040161060a9190613b38565b5050600101611fbd565b50505050565b60008281526020819052604090206002015461209b90610472612ed5565b6110425760405162461bcd60e51b815260040161060a90613d8b565b600260015414156120da5760405162461bcd60e51b815260040161060a90614023565b60026001556121097fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6121255760405162461bcd60e51b815260040161060a90613e45565b80516001600160a01b031661214c5760405162461bcd60e51b815260040161060a90613f10565b80516001600160a01b0316600090815260026020526040902054156121835760405162461bcd60e51b815260040161060a90613fec565b6040805160088082526101208201909252606091602082016101008036833750506040805160088082526101208201909252929350606092915060208201610100803683370190505090506121d66131e5565b60405180610180016040528085600001516001600160a01b0316815260200160006001600160a01b03168152602001856020015160ff1681526020018560400151815260200185606001516001600160a01b0316815260200184815260200183815260200160006001600160a01b0316815260200185608001516001600160a01b031681526020018560a00151151581526020018560c00151151581526020018560e00151151581525090508360e0015161229f57835161229690612bc4565b60c001516122af565b83516122aa90612c6b565b60c001515b6001600160a01b0316602082015260005b60088160ff16101561249a5784516040517f82b866000000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906382b86600906123149084906004016142bc565b60206040518083038186803b15801561232c57600080fd5b505afa92505050801561237a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526123779181019061340e565b60015b61238c5780600803845103845261249a565b6001600160a01b0381166123b25760405162461bcd60e51b815260040161060a90613f7e565b80858360ff16815181106123c257fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060005b8260ff168160ff1610156124905760056000878360ff168151811061240657fe5b6020026020010151888660ff168151811061241d57fe5b6020908102919091018101516001600160a01b0392188216835282810193909352604090910160009081208a51815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016123e5565b50506001016122c0565b5060808401516001600160a01b0316156127e05783608001516001600160a01b0316639750a8ee6040518163ffffffff1660e01b815260040160206040518083038186803b1580156124eb57600080fd5b505afa1580156124ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612523919061340e565b6001600160a01b031660e0820181905260009081526002602052604090205461255e5760405162461bcd60e51b815260040161060a90613c7a565b60005b60088160ff1610156127315784608001516001600160a01b03166382b86600826040518263ffffffff1660e01b815260040161259d91906142bc565b60206040518083038186803b1580156125b557600080fd5b505afa925050508015612603575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526126009181019061340e565b60015b61261557806008038351038352612731565b6001600160a01b03811661263b5760405162461bcd60e51b815260040161060a90613f7e565b80848360ff168151811061264b57fe5b6001600160a01b03909216602092830291909101909101528451612670906002612fab565b8260ff1611156127285760005b6001865103811015612726576005600086838151811061269957fe5b6020026020010151878660ff16815181106126b057fe5b6020908102919091018101516001600160a01b03921882168352828101939093526040909101600090812060808b0151815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790550161267d565b505b50600101612561565b5083600001516001600160a01b031684608001516001600160a01b031663cb2ef5fe6040518163ffffffff1660e01b815260040160206040518083038186803b15801561277d57600080fd5b505afa158015612791573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b5919061340e565b6001600160a01b0316146127db5760405162461bcd60e51b815260040161060a90613f47565b6127e8565b600882510382525b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600890920291820180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b039384161782556020808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c860180546040890151908516928716929092177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000060ff9093169290920291909117905560608601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d86015560808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e86018054909316941693909317905560a084015180518594929361296f937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f01920190613248565b5060c0820151805161298b916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915560045482518216600090815260026020908152604080832084905560608601518352600390915290819020829055865190519216917f15ec4115f45227a2f5b970962fd2294c7be9ba12b0652daae49ff679c02a1e0291612b2d9160001991909101908590614158565b60405180910390a25050600180555050565b6001600160a01b0381166000908152600260205260408120548290612b765760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b031663e25aa5fa6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114ac57600080fd5b6000611bdf836001600160a01b03841661305f565b612bcc6132c5565b816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612c0557600080fd5b505afa158015612c19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c3d9190613812565b6001600160a01b031660c088015260a087015260808601526060850152604084015260208301528152919050565b612c736132c5565b816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b81526004016101006040518083038186803b158015612cad57600080fd5b505afa158015612cc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce59190613871565b6001600160a01b031660c08901525060a087015260808601526060850152604084015260208301528152919050565b6001600160a01b038116600090815260026020526040812054600480546060939260001901908110612d4257fe5b90600052602060002090600802016004018054905090508067ffffffffffffffff81118015612d7057600080fd5b50604051908082528060200260200182016040528015612d9a578160200160208202803683370190505b50915060005b818160ff161015612e62576040517f91ceb3eb0000000000000000000000000000000000000000000000000000000081526001600160a01b038516906391ceb3eb90612df09084906004016142bc565b60206040518083038186803b158015612e0857600080fd5b505afa158015612e1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e4091906137fa565b838260ff1681518110612e4f57fe5b6020908102919091010152600101612da0565b5050919050565b600082612e7857506000611be2565b82820282848281612e8557fe5b0414611bdf5760405162461bcd60e51b815260040161060a90613e7c565b6000808211612ec45760405162461bcd60e51b815260040161060a90613d54565b818381612ecd57fe5b049392505050565b3390565b6000828152602081905260409020612ef19082612baf565b1561100657612efe612ed5565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081905260409020612f5a90826130a9565b1561100657612f67612ed5565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600082821115612fcd5760405162461bcd60e51b815260040161060a90613d1d565b50900390565b6000611bdf83836130be565b6000611bdf836001600160a01b038416613103565b6000611be28261311b565b6060604482511015613045575060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c7900000060208201526107e5565b60048201915081806020019051810190611be2919061355b565b600061306b8383613103565b6130a157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611be2565b506000611be2565b6000611bdf836001600160a01b03841661311f565b815460009082106130e15760405162461bcd60e51b815260040161060a90613b89565b8260000182815481106130f057fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081815260018301602052604081205480156131db578354600019808301919081019060009087908390811061315257fe5b906000526020600020015490508087600001848154811061316f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061319f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611be2565b6000915050611be2565b604080516101808101825260008082526020820181905291810182905260608082018390526080820183905260a0820181905260c082015260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b8280548282559060005260206000209081019282156132b5579160200282015b828111156132b557825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178255602090920191600190910190613268565b506132c192915061330b565b5090565b6040518060e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b5b808211156132c15780547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010161330c565b8035611be281614393565b600082601f83011261335d578081fd5b813567ffffffffffffffff811115613373578182fd5b6020808202613383828201614334565b8381529350818401858301828701840188101561339f57600080fd5b600092505b848310156133cb5780356133b781614393565b8252600192909201919083019083016133a4565b505050505092915050565b8035611be2816143ab565b803560ff81168114611be257600080fd5b600060208284031215613403578081fd5b8135611bdf81614393565b60006020828403121561341f578081fd5b8151611bdf81614393565b6000806040838503121561343c578081fd5b823561344781614393565b9150602083013561345781614393565b809150509250929050565b600080600060408486031215613476578081fd5b833567ffffffffffffffff8082111561348d578283fd5b818601915086601f8301126134a0578283fd5b8135818111156134ae578384fd5b87602080830285010111156134c1578384fd5b602092830195509350508401356134d7816143ab565b809150509250925092565b6000602082840312156134f3578081fd5b8151611bdf816143ab565b60006020828403121561350f578081fd5b5035919050565b60008060408385031215613528578182fd5b82359150602083013561345781614393565b6000806040838503121561354c578182fd5b50508035926020909101359150565b60006020828403121561356c578081fd5b815167ffffffffffffffff80821115613583578283fd5b818401915084601f830112613596578283fd5b8151818111156135a4578384fd5b6135d560207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601614334565b91508082528560208285010111156135eb578384fd5b6135fc816020840160208601614367565b50949350505050565b600060208284031215613616578081fd5b813567ffffffffffffffff8082111561362d578283fd5b8184019150610180808387031215613643578384fd5b61364c81614334565b90506136588684613342565b81526136678660208501613342565b602082015261367986604085016133e1565b6040820152606083013560608201526136958660808501613342565b608082015260a0830135828111156136ab578485fd5b6136b78782860161334d565b60a08301525060c0830135828111156136ce578485fd5b6136da8782860161334d565b60c0830152506136ed8660e08501613342565b60e0820152610100915061370386838501613342565b828201526101209150613718868385016133d6565b82820152610140915061372d868385016133d6565b828201526101609150613742868385016133d6565b91810191909152949350505050565b6000610100808385031215613764578182fd5b61376d81614334565b9050823561377a81614393565b815261378984602085016133e1565b60208201526040830135604082015260608301356137a681614393565b60608201526137b88460808501613342565b60808201526137ca8460a085016133d6565b60a08201526137dc8460c085016133d6565b60c08201526137ee8460e085016133d6565b60e08201529392505050565b60006020828403121561380b578081fd5b5051919050565b600080600080600080600060e0888a03121561382c578485fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c088015161386181614393565b8091505092959891949750929550565b600080600080600080600080610100898b03121561388d578182fd5b885197506020890151965060408901519550606089015194506080890151935060a0890151925060c0890151915060e08901516138c981614393565b809150509295985092959890939650565b6001600160a01b03169052565b6000815180845260208085019450808401835b8381101561391f5781516001600160a01b0316875295820195908201906001016138fa565b509495945050505050565b6000815480845260208085019450838352808320835b8381101561391f5781546001600160a01b031687529582019560019182019101613940565b15159052565b600061018061397b8484516138da565b602083015161398d60208601826138da565b5060408301516139a06040860182613a61565b506060830151606085015260808301516139bd60808601826138da565b5060a08301518160a08601526139d5828601826138e7565b91505060c083015184820360c08601526139ef82826138e7565b91505060e0830151613a0460e08601826138da565b5061010080840151613a18828701826138da565b505061012080840151613a2d82870182613965565b505061014080840151613a4282870182613965565b505061016080840151613a5782870182613965565b5090949350505050565b60ff169052565b6000828483379101908152919050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b81811015613acd5783516001600160a01b031683529284019291840191600101613aa8565b50909695505050505050565b600060208252611bdf60208301846138e7565b6020808252825182820181905260009190848201906040850190845b81811015613acd57835183529284019291840191600101613b08565b901515815260200190565b90815260200190565b6000602082528251806020840152613b57816040850160208701614367565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252601b908201527f506f6f6c206973206e6f74206f776e656420627920736164646c650000000000604082015260600190565b60208082526017908201527f50523a206261736520706f6f6c206e6f7420666f756e64000000000000000000604082015260600190565b60208082526018908201527f50523a20706f6f6c41646472657373206d69736d617463680000000000000000604082015260600190565b6020808252818101527f50523a2043616c6c6572206973206e6f7420736164646c65206d616e61676572604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b6020808252602a908201527f50523a2066726f6d20616e6420746f2063616e6e6f7420626520746865207a6560408201527f726f206164647265737300000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f50523a204f6e6c79206d616e61676572732063616e2061646420706f6f6c7300604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60408201527f7700000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526017908201527f50523a20496e646578206f7574206f6620626f756e6473000000000000000000604082015260600190565b60208082526014908201527f50523a20706f6f6c416464726573732069732030000000000000000000000000604082015260600190565b6020808252601d908201527f50523a206d657461537761702061646472657373206d69736d61746368000000604082015260600190565b6020808252600e908201527f50523a20746f6b656e2069732030000000000000000000000000000000000000604082015260600190565b6020808252601a908201527f50523a204e6f206d61746368696e6720706f6f6c20666f756e64000000000000604082015260600190565b60208082526019908201527f50523a20506f6f6c20697320616c726561647920616464656400000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526012908201527f50523a20506f6f6c206e6f7420666f756e640000000000000000000000000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b600060208252611bdf602083018461396b565b600060e082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a08301526001600160a01b0360c08401511660c083015292915050565b600083825260406020830152614171604083018461396b565b949350505050565b60008382526040602083015261419b60408301614196855461435b565b6138da565b60018301546001600160a01b036141b7606085018284166138da565b6141ca6080850160ff8460a01c16613a61565b600285015460a08501526141e1600386015461435b565b91506141f060c08501836138da565b61018091508160e085015261420c6101c085016004870161392a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc085820301610100860152614244816005880161392a565b9050614253600687015461435b565b6142616101208701826138da565b50600786015461427761014087018483166138da565b61428b610160870160ff8360a01c16613965565b61429d84870160ff8360a81c16613965565b6142b16101a0870160ff8360b01c16613965565b509695505050505050565b60ff91909116815260200190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126142fe578283fd5b83018035915067ffffffffffffffff821115614318578283fd5b60200191503681900382131561432d57600080fd5b9250929050565b60405181810167ffffffffffffffff8111828210171561435357600080fd5b604052919050565b6001600160a01b031690565b60005b8381101561438257818101518382015260200161436a565b838111156120775750506000910152565b6001600160a01b03811681146143a857600080fd5b50565b80151581146143a857600080fdfea2646970667358221220a6fc023ff37d5be4b8e43227139f8db51b182e42e63581000f6c263629d5471364736f6c634300060c0033