Contract 0x8A87c3e749Dc2121Ef0fdA037dBBfAc52dbbc06F

  Note: Our ETH balance display is temporarily unavailable. Please check back later.

Contract Overview

Balance:
Txn Hash Method
Block
From
To
Value
0x5f294c5d75ebdba61481bb58f64865753e2fa47e4a6f23725e04950a11be70bb0x60806040190498582023-12-25 18:09:44116 days 11 hrs ago0xd866b2332d4383c1bf719732177e2d9109c99dbc IN  Create: ChainedSpeedMarketsAMM0 ETH0.0000000458190.00001
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
ChainedSpeedMarketsAMM

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 26 : ChainedSpeedMarketsAMM.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// external
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

import "@openzeppelin/contracts-4.4.1/proxy/Clones.sol";

import "@pythnetwork/pyth-sdk-solidity/IPyth.sol";
import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol";

// internal
import "../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol";
import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol";
import "../utils/proxy/solidity-0.8.0/ProxyPausable.sol";
import "../utils/libraries/AddressSetLib.sol";

import "../interfaces/IStakingThales.sol";
import "../interfaces/IMultiCollateralOnOffRamp.sol";
import "../interfaces/IReferrals.sol";
import "../interfaces/ISpeedMarketsAMM.sol";
import "../interfaces/IAddressManager.sol";

import "./SpeedMarket.sol";
import "./ChainedSpeedMarket.sol";

/// @title An AMM for Thales chained speed markets
contract ChainedSpeedMarketsAMM is Initializable, ProxyOwned, ProxyPausable, ProxyReentrancyGuard {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using AddressSetLib for AddressSetLib.AddressSet;

    uint private constant ONE = 1e18;
    uint private constant MAX_APPROVAL = type(uint256).max;

    IERC20Upgradeable public sUSD;

    AddressSetLib.AddressSet internal _activeMarkets;
    AddressSetLib.AddressSet internal _maturedMarkets;

    mapping(address => AddressSetLib.AddressSet) internal _activeMarketsPerUser;
    mapping(address => AddressSetLib.AddressSet) internal _maturedMarketsPerUser;

    uint public minChainedMarkets;
    uint public maxChainedMarkets;

    uint64 public minTimeFrame;
    uint64 public maxTimeFrame;

    uint public minBuyinAmount;
    uint public maxBuyinAmount;

    uint public maxProfitPerIndividualMarket;

    uint private payoutMultiplier; // unused, part of payoutMultipliers

    uint public maxRisk;
    uint public currentRisk;

    address public chainedSpeedMarketMastercopy;

    bool public multicollateralEnabled;

    /// @notice The address of the address manager contract
    IAddressManager public addressManager;

    /// @notice payout multipliers for each number of chained markets, starting from minChainedMarkets up to maxChainedMarkets
    /// e.g. for 2-6 chained markets [1.7, 1.8, 1.9, 1.95, 2] - for 2 chained markets multiplier is 1.7, for 3 it is 1.8, ...
    uint[] public payoutMultipliers;

    // using this to solve stack too deep
    struct TempData {
        uint payout;
        uint payoutMultiplier;
        PythStructs.Price pythPrice;
        ISpeedMarketsAMM.Params speedAMMParams;
    }

    receive() external payable {}

    function initialize(address _owner, IERC20Upgradeable _sUSD) external initializer {
        setOwner(_owner);
        initNonReentrant();
        sUSD = _sUSD;
    }

    function createNewMarket(
        bytes32 asset,
        uint64 timeFrame,
        SpeedMarket.Direction[] calldata directions,
        uint buyinAmount,
        bytes[] calldata priceUpdateData,
        address referrer
    ) external payable nonReentrant notPaused {
        IAddressManager.Addresses memory contractsAddresses = addressManager.getAddresses();
        _createNewMarket(asset, timeFrame, directions, buyinAmount, priceUpdateData, true, referrer, contractsAddresses);
    }

    function createNewMarketWithDifferentCollateral(
        bytes32 asset,
        uint64 timeFrame,
        SpeedMarket.Direction[] calldata directions,
        bytes[] calldata priceUpdateData,
        address collateral,
        uint collateralAmount,
        bool isEth,
        address referrer
    ) external payable nonReentrant notPaused {
        IAddressManager.Addresses memory contractsAddresses = addressManager.getAddresses();
        uint buyinAmount = _getBuyinWithConversion(collateral, collateralAmount, isEth, contractsAddresses);
        _createNewMarket(asset, timeFrame, directions, buyinAmount, priceUpdateData, false, referrer, contractsAddresses);
    }

    function _getBuyinWithConversion(
        address collateral,
        uint collateralAmount,
        bool isEth,
        IAddressManager.Addresses memory contractsAddresses
    ) internal returns (uint buyinAmount) {
        require(multicollateralEnabled, "Multicollateral onramp not enabled");
        uint amountBefore = sUSD.balanceOf(address(this));

        IMultiCollateralOnOffRamp multiCollateralOnOffRamp = IMultiCollateralOnOffRamp(
            contractsAddresses.multiCollateralOnOffRamp
        );

        uint convertedAmount;
        if (isEth) {
            convertedAmount = multiCollateralOnOffRamp.onrampWithEth{value: collateralAmount}(collateralAmount);
        } else {
            IERC20Upgradeable(collateral).safeTransferFrom(msg.sender, address(this), collateralAmount);
            IERC20Upgradeable(collateral).approve(address(multiCollateralOnOffRamp), collateralAmount);
            convertedAmount = multiCollateralOnOffRamp.onramp(collateral, collateralAmount);
        }

        ISpeedMarketsAMM speedMarketsAMM = ISpeedMarketsAMM(contractsAddresses.speedMarketsAMM);
        buyinAmount = (convertedAmount * (ONE - speedMarketsAMM.safeBoxImpact())) / ONE;

        uint amountDiff = sUSD.balanceOf(address(this)) - amountBefore;
        require(amountDiff >= buyinAmount, "not enough received via onramp");
    }

    function _getPayout(
        uint _buyinAmount,
        uint8 _numOfDirections,
        uint _payoutMultiplier
    ) internal pure returns (uint _payout) {
        _payout = _buyinAmount;
        for (uint8 i = 0; i < _numOfDirections; i++) {
            _payout = (_payout * _payoutMultiplier) / ONE;
        }
    }

    function _handleReferrerAndSafeBox(
        address referrer,
        uint buyinAmount,
        uint safeBoxImpact,
        IAddressManager.Addresses memory contractsAddresses
    ) internal returns (uint referrerShare) {
        IReferrals referrals = IReferrals(contractsAddresses.referrals);
        if (address(referrals) != address(0)) {
            address newOrExistingReferrer;
            if (referrer != address(0)) {
                referrals.setReferrer(referrer, msg.sender);
                newOrExistingReferrer = referrer;
            } else {
                newOrExistingReferrer = referrals.referrals(msg.sender);
            }

            if (newOrExistingReferrer != address(0)) {
                uint referrerFeeByTier = referrals.getReferrerFee(newOrExistingReferrer);
                if (referrerFeeByTier > 0) {
                    referrerShare = (buyinAmount * referrerFeeByTier) / ONE;
                    sUSD.safeTransfer(newOrExistingReferrer, referrerShare);
                    emit ReferrerPaid(newOrExistingReferrer, msg.sender, referrerShare, buyinAmount);
                }
            }
        }

        sUSD.safeTransfer(contractsAddresses.safeBox, (buyinAmount * safeBoxImpact) / ONE - referrerShare);
    }

    function _createNewMarket(
        bytes32 asset,
        uint64 timeFrame,
        SpeedMarket.Direction[] calldata directions,
        uint buyinAmount,
        bytes[] memory priceUpdateData,
        bool transferSusd,
        address referrer,
        IAddressManager.Addresses memory contractsAddresses
    ) internal {
        TempData memory tempData;
        tempData.speedAMMParams = ISpeedMarketsAMM(contractsAddresses.speedMarketsAMM).getParams(asset);
        require(tempData.speedAMMParams.supportedAsset, "Asset is not supported");
        require(buyinAmount >= minBuyinAmount && buyinAmount <= maxBuyinAmount, "Wrong buy in amount");
        require(timeFrame >= minTimeFrame && timeFrame <= maxTimeFrame, "Wrong time frame");
        require(
            directions.length >= minChainedMarkets && directions.length <= maxChainedMarkets,
            "Wrong number of directions"
        );

        tempData.payoutMultiplier = payoutMultipliers[uint8(directions.length) - minChainedMarkets];
        tempData.payout = _getPayout(buyinAmount, uint8(directions.length), tempData.payoutMultiplier);
        require(tempData.payout <= maxProfitPerIndividualMarket, "Profit too high");

        currentRisk += (tempData.payout - buyinAmount);
        require(currentRisk <= maxRisk, "Out of liquidity");

        IPyth(contractsAddresses.pyth).updatePriceFeeds{value: IPyth(contractsAddresses.pyth).getUpdateFee(priceUpdateData)}(
            priceUpdateData
        );

        tempData.pythPrice = IPyth(contractsAddresses.pyth).getPriceUnsafe(tempData.speedAMMParams.pythId);
        require(
            (tempData.pythPrice.publishTime + tempData.speedAMMParams.maximumPriceDelay) > block.timestamp &&
                tempData.pythPrice.price > 0,
            "Stale price"
        );

        if (transferSusd) {
            uint totalAmountToTransfer = (buyinAmount * (ONE + tempData.speedAMMParams.safeBoxImpact)) / ONE;
            sUSD.safeTransferFrom(msg.sender, address(this), totalAmountToTransfer);
        }

        ChainedSpeedMarket csm = ChainedSpeedMarket(Clones.clone(chainedSpeedMarketMastercopy));
        csm.initialize(
            ChainedSpeedMarket.InitParams(
                address(this),
                msg.sender,
                asset,
                timeFrame,
                uint64(block.timestamp + timeFrame),
                uint64(block.timestamp + timeFrame * directions.length), // strike time
                tempData.pythPrice.price,
                directions,
                buyinAmount,
                tempData.speedAMMParams.safeBoxImpact,
                tempData.payoutMultiplier
            )
        );

        sUSD.safeTransfer(address(csm), tempData.payout);

        _handleReferrerAndSafeBox(referrer, buyinAmount, tempData.speedAMMParams.safeBoxImpact, contractsAddresses);

        _activeMarkets.add(address(csm));
        _activeMarketsPerUser[msg.sender].add(address(csm));

        if (contractsAddresses.stakingThales != address(0)) {
            IStakingThales(contractsAddresses.stakingThales).updateVolume(msg.sender, buyinAmount);
        }

        emit MarketCreated(
            address(csm),
            msg.sender,
            asset,
            timeFrame,
            uint64(block.timestamp + timeFrame * directions.length), // strike time
            tempData.pythPrice.price,
            directions,
            buyinAmount,
            tempData.payoutMultiplier,
            tempData.speedAMMParams.safeBoxImpact
        );
    }

    /// @notice resolveMarket resolves an active market
    /// @param market address of the market
    function resolveMarket(address market, bytes[][] calldata priceUpdateData) external payable nonReentrant notPaused {
        _resolveMarket(market, priceUpdateData);
    }

    /// @notice resolveMarketWithOfframp resolves an active market with offramp
    /// @param market address of the market
    function resolveMarketWithOfframp(
        address market,
        bytes[][] calldata priceUpdateData,
        address collateral,
        bool toEth
    ) external payable nonReentrant notPaused {
        address user = ChainedSpeedMarket(market).user();
        require(msg.sender == user, "Only allowed from market owner");
        uint amountBefore = sUSD.balanceOf(user);
        _resolveMarket(market, priceUpdateData);
        uint amountDiff = sUSD.balanceOf(user) - amountBefore;
        sUSD.safeTransferFrom(user, address(this), amountDiff);
        if (amountDiff > 0) {
            IMultiCollateralOnOffRamp multiCollateralOnOffRamp = IMultiCollateralOnOffRamp(
                addressManager.multiCollateralOnOffRamp()
            );
            if (toEth) {
                uint offramped = multiCollateralOnOffRamp.offrampIntoEth(amountDiff);
                address payable _to = payable(user);
                bool sent = _to.send(offramped);
                require(sent, "Failed to send Ether");
            } else {
                uint offramped = multiCollateralOnOffRamp.offramp(collateral, amountDiff);
                IERC20Upgradeable(collateral).safeTransfer(user, offramped);
            }
        }
    }

    /// @notice resolveMarkets in a batch
    function resolveMarketsBatch(address[] calldata markets, bytes[][][] calldata priceUpdateData)
        external
        payable
        nonReentrant
        notPaused
    {
        for (uint i = 0; i < markets.length; i++) {
            if (canResolveMarket(markets[i])) {
                _resolveMarket(markets[i], priceUpdateData[i]);
            }
        }
    }

    function _resolveMarket(address market, bytes[][] memory priceUpdateData) internal {
        require(canResolveMarket(market), "Can not resolve");

        IAddressManager.Addresses memory contractsAddresses = addressManager.getAddresses();
        ISpeedMarketsAMM speedMarketsAMM = ISpeedMarketsAMM(contractsAddresses.speedMarketsAMM);

        bytes32[] memory priceIds = new bytes32[](1);
        priceIds[0] = speedMarketsAMM.assetToPythId(ChainedSpeedMarket(market).asset());

        int64[] memory prices = new int64[](priceUpdateData.length);
        uint64 strikeTimePerDirection;
        for (uint i = 0; i < priceUpdateData.length; i++) {
            strikeTimePerDirection =
                ChainedSpeedMarket(market).initialStrikeTime() +
                uint64(i * ChainedSpeedMarket(market).timeFrame());

            IPyth pyth = IPyth(contractsAddresses.pyth);
            PythStructs.PriceFeed[] memory pricesPerDirection = pyth.parsePriceFeedUpdates{
                value: pyth.getUpdateFee(priceUpdateData[i])
            }(
                priceUpdateData[i],
                priceIds,
                strikeTimePerDirection,
                strikeTimePerDirection + speedMarketsAMM.maximumPriceDelayForResolving()
            );

            PythStructs.Price memory price = pricesPerDirection[0].price;
            require(price.price > 0, "invalid price");
            prices[i] = price.price;
        }

        _resolveMarketWithPrices(market, prices, false);
    }

    /// @notice admin resolve market for a given market address with finalPrice
    function resolveMarketManually(address _market, int64[] calldata _finalPrices) external isAddressWhitelisted {
        _resolveMarketManually(_market, _finalPrices);
    }

    /// @notice admin resolve for a given markets with finalPrices
    function resolveMarketManuallyBatch(address[] calldata markets, int64[][] calldata finalPrices)
        external
        isAddressWhitelisted
    {
        for (uint i = 0; i < markets.length; i++) {
            if (canResolveMarket(markets[i])) {
                _resolveMarketManually(markets[i], finalPrices[i]);
            }
        }
    }

    function _resolveMarketManually(address _market, int64[] calldata _finalPrices) internal {
        require(canResolveMarket(_market), "Can not resolve");
        _resolveMarketWithPrices(_market, _finalPrices, true);
    }

    /// @notice owner can resolve market for a given market address with finalPrices
    function resolveMarketAsOwner(address _market, int64[] calldata _finalPrices) external onlyOwner {
        require(canResolveMarket(_market), "Can not resolve");
        _resolveMarketWithPrices(_market, _finalPrices, false);
    }

    function _resolveMarketWithPrices(
        address market,
        int64[] memory _finalPrices,
        bool _isManually
    ) internal {
        ChainedSpeedMarket(market).resolve(_finalPrices, _isManually);
        if (ChainedSpeedMarket(market).resolved()) {
            _activeMarkets.remove(market);
            _maturedMarkets.add(market);
            address user = ChainedSpeedMarket(market).user();

            if (_activeMarketsPerUser[user].contains(market)) {
                _activeMarketsPerUser[user].remove(market);
            }
            _maturedMarketsPerUser[user].add(market);

            uint buyinAmount = ChainedSpeedMarket(market).buyinAmount();
            uint payout = _getPayout(
                buyinAmount,
                ChainedSpeedMarket(market).numOfDirections(),
                ChainedSpeedMarket(market).payoutMultiplier()
            );

            if (!ChainedSpeedMarket(market).isUserWinner()) {
                if (currentRisk > payout) {
                    currentRisk -= payout;
                } else {
                    currentRisk = 0;
                }
            }
        }

        emit MarketResolved(market, ChainedSpeedMarket(market).isUserWinner());
    }

    /// @notice Transfer amount to destination address
    function transferAmount(address _destination, uint _amount) external onlyOwner {
        sUSD.safeTransfer(_destination, _amount);
        emit AmountTransfered(_destination, _amount);
    }

    //////////// getters /////////////////

    /// @notice activeMarkets returns list of active markets
    /// @param index index of the page
    /// @param pageSize number of addresses per page
    /// @return address[] active market list
    function activeMarkets(uint index, uint pageSize) external view returns (address[] memory) {
        return _activeMarkets.getPage(index, pageSize);
    }

    /// @notice maturedMarkets returns list of matured markets
    /// @param index index of the page
    /// @param pageSize number of addresses per page
    /// @return address[] matured market list
    function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory) {
        return _maturedMarkets.getPage(index, pageSize);
    }

    /// @notice activeMarkets returns list of active markets per user
    function activeMarketsPerUser(
        uint index,
        uint pageSize,
        address user
    ) external view returns (address[] memory) {
        return _activeMarketsPerUser[user].getPage(index, pageSize);
    }

    /// @notice maturedMarkets returns list of matured markets per user
    function maturedMarketsPerUser(
        uint index,
        uint pageSize,
        address user
    ) external view returns (address[] memory) {
        return _maturedMarketsPerUser[user].getPage(index, pageSize);
    }

    /// @notice whether a market can be resolved
    function canResolveMarket(address market) public view returns (bool) {
        return
            _activeMarkets.contains(market) &&
            (ChainedSpeedMarket(market).initialStrikeTime() < block.timestamp) &&
            !ChainedSpeedMarket(market).resolved();
    }

    /// @notice get lengths of all arrays
    function getLengths(address user) external view returns (uint[4] memory) {
        return [
            _activeMarkets.elements.length,
            _maturedMarkets.elements.length,
            _activeMarketsPerUser[user].elements.length,
            _maturedMarketsPerUser[user].elements.length
        ];
    }

    //////////////////setters/////////////////

    /// @notice Set mastercopy to use to create markets
    /// @param _mastercopy to use to create markets
    function setMastercopy(address _mastercopy) external onlyOwner {
        chainedSpeedMarketMastercopy = _mastercopy;
        emit MastercopyChanged(_mastercopy);
    }

    /// @notice Set parameters for limits and payout
    function setLimitParams(
        uint64 _minTimeFrame,
        uint64 _maxTimeFrame,
        uint _minChainedMarkets,
        uint _maxChainedMarkets,
        uint _minBuyinAmount,
        uint _maxBuyinAmount,
        uint _maxProfitPerIndividualMarket,
        uint _maxRisk,
        uint[] calldata _payoutMultipliers
    ) external onlyOwner {
        require(_minChainedMarkets > 1, "min 2 chained markets");
        minTimeFrame = _minTimeFrame;
        maxTimeFrame = _maxTimeFrame;
        minChainedMarkets = _minChainedMarkets;
        maxChainedMarkets = _maxChainedMarkets;
        minBuyinAmount = _minBuyinAmount;
        maxBuyinAmount = _maxBuyinAmount;
        maxProfitPerIndividualMarket = _maxProfitPerIndividualMarket;
        maxRisk = _maxRisk;
        payoutMultipliers = _payoutMultipliers;
        emit LimitParamsChanged(
            _minTimeFrame,
            _maxTimeFrame,
            _minChainedMarkets,
            _maxChainedMarkets,
            _minBuyinAmount,
            _maxBuyinAmount,
            _maxProfitPerIndividualMarket,
            _maxRisk,
            _payoutMultipliers
        );
    }

    /// @notice set address manager contract address
    function setAddressManager(address _addressManager) external onlyOwner {
        addressManager = IAddressManager(_addressManager);
        emit AddressManagerChanged(_addressManager);
    }

    /// @notice set multicollateral enabled
    function setMultiCollateralOnOffRampEnabled(bool _enabled) external onlyOwner {
        address multiCollateralOnOffRamp = addressManager.multiCollateralOnOffRamp();
        if (multiCollateralOnOffRamp != address(0)) {
            sUSD.approve(multiCollateralOnOffRamp, _enabled ? MAX_APPROVAL : 0);
        }
        multicollateralEnabled = _enabled;
        emit MultiCollateralOnOffRampEnabled(_enabled);
    }

    //////////////////modifiers/////////////////

    modifier isAddressWhitelisted() {
        ISpeedMarketsAMM speedMarketsAMM = ISpeedMarketsAMM(addressManager.speedMarketsAMM());
        require(speedMarketsAMM.whitelistedAddresses(msg.sender), "Resolver not whitelisted");
        _;
    }

    //////////////////events/////////////////

    event MarketCreated(
        address market,
        address user,
        bytes32 asset,
        uint64 timeFrame,
        uint64 strikeTime,
        int64 strikePrice,
        SpeedMarket.Direction[] directions,
        uint buyinAmount,
        uint payoutMultiplier,
        uint safeBoxImpact
    );

    event MarketResolved(address market, bool userIsWinner);

    event MastercopyChanged(address mastercopy);
    event LimitParamsChanged(
        uint64 _minTimeFrame,
        uint64 _maxTimeFrame,
        uint _minChainedMarkets,
        uint _maxChainedMarkets,
        uint _minBuyinAmount,
        uint _maxBuyinAmount,
        uint _maxProfitPerIndividualMarket,
        uint _maxRisk,
        uint[] _payoutMultipliers
    );
    event ReferrerPaid(address refferer, address trader, uint amount, uint volume);
    event MultiCollateralOnOffRampEnabled(bool _enabled);
    event AmountTransfered(address _destination, uint _amount);
    event AddressManagerChanged(address _addressManager);
}

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

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

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

    function safeTransferFrom(
        IERC20Upgradeable 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(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

File 4 of 26 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/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 onlyInitializing {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_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 {
        _transferOwnership(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");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
    uint256[49] private __gap;
}

File 5 of 26 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^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 {ERC1967Proxy-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.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
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() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

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

pragma solidity ^0.8.0;

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

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library 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) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

File 8 of 26 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
    uint256[49] private __gap;
}

File 9 of 26 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 10 of 26 : IPyth.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "./PythStructs.sol";
import "./IPythEvents.sol";

/// @title Consume prices from the Pyth Network (https://pyth.network/).
/// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices for how to consume prices safely.
/// @author Pyth Data Association
interface IPyth is IPythEvents {
    /// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time
    function getValidTimePeriod() external view returns (uint validTimePeriod);

    /// @notice Returns the price and confidence interval.
    /// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds.
    /// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval.
    /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
    function getPrice(
        bytes32 id
    ) external view returns (PythStructs.Price memory price);

    /// @notice Returns the exponentially-weighted moving average price and confidence interval.
    /// @dev Reverts if the EMA price is not available.
    /// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval.
    /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
    function getEmaPrice(
        bytes32 id
    ) external view returns (PythStructs.Price memory price);

    /// @notice Returns the price of a price feed without any sanity checks.
    /// @dev This function returns the most recent price update in this contract without any recency checks.
    /// This function is unsafe as the returned price update may be arbitrarily far in the past.
    ///
    /// Users of this function should check the `publishTime` in the price to ensure that the returned price is
    /// sufficiently recent for their application. If you are considering using this function, it may be
    /// safer / easier to use either `getPrice` or `getPriceNoOlderThan`.
    /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
    function getPriceUnsafe(
        bytes32 id
    ) external view returns (PythStructs.Price memory price);

    /// @notice Returns the price that is no older than `age` seconds of the current time.
    /// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in
    /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
    /// recently.
    /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
    function getPriceNoOlderThan(
        bytes32 id,
        uint age
    ) external view returns (PythStructs.Price memory price);

    /// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.
    /// @dev This function returns the same price as `getEmaPrice` in the case where the price is available.
    /// However, if the price is not recent this function returns the latest available price.
    ///
    /// The returned price can be from arbitrarily far in the past; this function makes no guarantees that
    /// the returned price is recent or useful for any particular application.
    ///
    /// Users of this function should check the `publishTime` in the price to ensure that the returned price is
    /// sufficiently recent for their application. If you are considering using this function, it may be
    /// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.
    /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
    function getEmaPriceUnsafe(
        bytes32 id
    ) external view returns (PythStructs.Price memory price);

    /// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds
    /// of the current time.
    /// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in
    /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
    /// recently.
    /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
    function getEmaPriceNoOlderThan(
        bytes32 id,
        uint age
    ) external view returns (PythStructs.Price memory price);

    /// @notice Update price feeds with given update messages.
    /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
    /// `getUpdateFee` with the length of the `updateData` array.
    /// Prices will be updated if they are more recent than the current stored prices.
    /// The call will succeed even if the update is not the most recent.
    /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.
    /// @param updateData Array of price update data.
    function updatePriceFeeds(bytes[] calldata updateData) external payable;

    /// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is
    /// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the
    /// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`.
    ///
    /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
    /// `getUpdateFee` with the length of the `updateData` array.
    ///
    /// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime
    /// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have
    /// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.
    /// Otherwise, it calls updatePriceFeeds method to update the prices.
    ///
    /// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.
    /// @param updateData Array of price update data.
    /// @param priceIds Array of price ids.
    /// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`
    function updatePriceFeedsIfNecessary(
        bytes[] calldata updateData,
        bytes32[] calldata priceIds,
        uint64[] calldata publishTimes
    ) external payable;

    /// @notice Returns the required fee to update an array of price updates.
    /// @param updateData Array of price update data.
    /// @return feeAmount The required fee in Wei.
    function getUpdateFee(
        bytes[] calldata updateData
    ) external view returns (uint feeAmount);

    /// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published
    /// within `minPublishTime` and `maxPublishTime`.
    ///
    /// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price;
    /// otherwise, please consider using `updatePriceFeeds`. This method does not store the price updates on-chain.
    ///
    /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
    /// `getUpdateFee` with the length of the `updateData` array.
    ///
    ///
    /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is
    /// no update for any of the given `priceIds` within the given time range.
    /// @param updateData Array of price update data.
    /// @param priceIds Array of price ids.
    /// @param minPublishTime minimum acceptable publishTime for the given `priceIds`.
    /// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`.
    /// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order).
    function parsePriceFeedUpdates(
        bytes[] calldata updateData,
        bytes32[] calldata priceIds,
        uint64 minPublishTime,
        uint64 maxPublishTime
    ) external payable returns (PythStructs.PriceFeed[] memory priceFeeds);
}

File 11 of 26 : PythStructs.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

contract PythStructs {
    // A price with a degree of uncertainty, represented as a price +- a confidence interval.
    //
    // The confidence interval roughly corresponds to the standard error of a normal distribution.
    // Both the price and confidence are stored in a fixed-point numeric representation,
    // `x * (10^expo)`, where `expo` is the exponent.
    //
    // Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for how
    // to how this price safely.
    struct Price {
        // Price
        int64 price;
        // Confidence interval around the price
        uint64 conf;
        // Price exponent
        int32 expo;
        // Unix timestamp describing when the price was published
        uint publishTime;
    }

    // PriceFeed represents a current aggregate price from pyth publisher feeds.
    struct PriceFeed {
        // The price ID.
        bytes32 id;
        // Latest available price
        Price price;
        // Latest available exponentially-weighted moving average price
        Price emaPrice;
    }
}

File 12 of 26 : ProxyReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
 * available, which can be aplied 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.
 */
contract ProxyReentrancyGuard {
    /// @dev counter to allow mutex lock with only one SSTORE operation
    uint256 private _guardCounter;
    bool private _initialized;

    function initNonReentrant() public {
        require(!_initialized, "Already initialized");
        _initialized = true;
        _guardCounter = 1;
    }

    /**
     * @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() {
        _guardCounter += 1;
        uint256 localCounter = _guardCounter;
        _;
        require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
    }
}

File 13 of 26 : ProxyOwned.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// Clone of syntetix contract without constructor
contract ProxyOwned {
    address public owner;
    address public nominatedOwner;
    bool private _initialized;
    bool private _transferredAtInit;

    function setOwner(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        require(!_initialized, "Already initialized, use nominateNewOwner");
        _initialized = true;
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

    function nominateNewOwner(address _owner) external onlyOwner {
        nominatedOwner = _owner;
        emit OwnerNominated(_owner);
    }

    function acceptOwnership() external {
        require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
        emit OwnerChanged(owner, nominatedOwner);
        owner = nominatedOwner;
        nominatedOwner = address(0);
    }

    function transferOwnershipAtInit(address proxyAddress) external onlyOwner {
        require(proxyAddress != address(0), "Invalid address");
        require(!_transferredAtInit, "Already transferred");
        owner = proxyAddress;
        _transferredAtInit = true;
        emit OwnerChanged(owner, proxyAddress);
    }

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

    function _onlyOwner() private view {
        require(msg.sender == owner, "Only the contract owner may perform this action");
    }

    event OwnerNominated(address newOwner);
    event OwnerChanged(address oldOwner, address newOwner);
}

File 14 of 26 : ProxyPausable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// Inheritance
import "./ProxyOwned.sol";

// Clone of syntetix contract without constructor

contract ProxyPausable is ProxyOwned {
    uint public lastPauseTime;
    bool public paused;

    

    /**
     * @notice Change the paused state of the contract
     * @dev Only the contract owner may call this.
     */
    function setPaused(bool _paused) external onlyOwner {
        // Ensure we're actually changing the state before we do anything
        if (_paused == paused) {
            return;
        }

        // Set our paused state.
        paused = _paused;

        // If applicable, set the last pause time.
        if (paused) {
            lastPauseTime = block.timestamp;
        }

        // Let everyone know that our pause state has changed.
        emit PauseChanged(paused);
    }

    event PauseChanged(bool isPaused);

    modifier notPaused {
        require(!paused, "This action cannot be performed while the contract is paused");
        _;
    }
}

File 15 of 26 : AddressSetLib.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

library AddressSetLib {
    struct AddressSet {
        address[] elements;
        mapping(address => uint) indices;
    }

    function contains(AddressSet storage set, address candidate) internal view returns (bool) {
        if (set.elements.length == 0) {
            return false;
        }
        uint index = set.indices[candidate];
        return index != 0 || set.elements[0] == candidate;
    }

    function getPage(
        AddressSet storage set,
        uint index,
        uint pageSize
    ) internal view returns (address[] memory) {
        // NOTE: This implementation should be converted to slice operators if the compiler is updated to v0.6.0+
        uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow.

        // If the page extends past the end of the list, truncate it.
        if (endIndex > set.elements.length) {
            endIndex = set.elements.length;
        }
        if (endIndex <= index) {
            return new address[](0);
        }

        uint n = endIndex - index; // We already checked for negative overflow.
        address[] memory page = new address[](n);
        for (uint i; i < n; i++) {
            page[i] = set.elements[i + index];
        }
        return page;
    }

    function add(AddressSet storage set, address element) internal {
        // Adding to a set is an idempotent operation.
        if (!contains(set, element)) {
            set.indices[element] = set.elements.length;
            set.elements.push(element);
        }
    }

    function remove(AddressSet storage set, address element) internal {
        require(contains(set, element), "Element not in set.");
        // Replace the removed element with the last element of the list.
        uint index = set.indices[element];
        uint lastIndex = set.elements.length - 1; // We required that element is in the list, so it is not empty.
        if (index != lastIndex) {
            // No need to shift the last element if it is the one we want to delete.
            address shiftedElement = set.elements[lastIndex];
            set.elements[index] = shiftedElement;
            set.indices[shiftedElement] = index;
        }
        set.elements.pop();
        delete set.indices[element];
    }
}

File 16 of 26 : IStakingThales.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

interface IStakingThales {
    function updateVolume(address account, uint amount) external;

    /* ========== VIEWS / VARIABLES ==========  */
    function totalStakedAmount() external view returns (uint);

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

    function currentPeriodRewards() external view returns (uint);

    function currentPeriodFees() external view returns (uint);

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

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

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

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

    function getContractRewardFunds() external view returns (uint);

    function getContractFeeFunds() external view returns (uint);

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

File 17 of 26 : IMultiCollateralOnOffRamp.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

interface IMultiCollateralOnOffRamp {
    function onramp(address collateral, uint collateralAmount) external returns (uint);

    function onrampWithEth(uint amount) external payable returns (uint);

    function getMinimumReceived(address collateral, uint amount) external view returns (uint);

    function getMinimumNeeded(address collateral, uint amount) external view returns (uint);

    function WETH9() external view returns (address);

    function offrampIntoEth(uint amount) external returns (uint);

    function offramp(address collateral, uint amount) external returns (uint);
}

File 18 of 26 : IReferrals.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;

interface IReferrals {
    function referrals(address) external view returns (address);

    function getReferrerFee(address) external view returns (uint);

    function sportReferrals(address) external view returns (address);

    function setReferrer(address, address) external;
}

File 19 of 26 : ISpeedMarketsAMM.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

import "../SpeedMarkets/SpeedMarket.sol";

interface ISpeedMarketsAMM {
    struct Params {
        bool supportedAsset;
        bytes32 pythId;
        uint safeBoxImpact;
        uint64 maximumPriceDelay;
    }

    function sUSD() external view returns (IERC20Upgradeable);

    function supportedAsset(bytes32 _asset) external view returns (bool);

    function assetToPythId(bytes32 _asset) external view returns (bytes32);

    function minBuyinAmount() external view returns (uint);

    function maxBuyinAmount() external view returns (uint);

    function minimalTimeToMaturity() external view returns (uint);

    function maximalTimeToMaturity() external view returns (uint);

    function maximumPriceDelay() external view returns (uint64);

    function maximumPriceDelayForResolving() external view returns (uint64);

    function timeThresholdsForFees(uint _index) external view returns (uint);

    function lpFees(uint _index) external view returns (uint);

    function lpFee() external view returns (uint);

    function maxSkewImpact() external view returns (uint);

    function safeBoxImpact() external view returns (uint);

    function marketHasCreatedAtAttribute(address _market) external view returns (bool);

    function marketHasFeeAttribute(address _market) external view returns (bool);

    function maxRiskPerAsset(bytes32 _asset) external view returns (uint);

    function currentRiskPerAsset(bytes32 _asset) external view returns (uint);

    function maxRiskPerAssetAndDirection(bytes32 _asset, SpeedMarket.Direction _direction) external view returns (uint);

    function currentRiskPerAssetAndDirection(bytes32 _asset, SpeedMarket.Direction _direction) external view returns (uint);

    function whitelistedAddresses(address _wallet) external view returns (bool);

    function getLengths(address _user) external view returns (uint[5] memory);

    function getParams(bytes32 _asset) external view returns (Params memory);
}

File 20 of 26 : IAddressManager.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

interface IAddressManager {
    struct Addresses {
        address safeBox;
        address referrals;
        address stakingThales;
        address multiCollateralOnOffRamp;
        address pyth;
        address speedMarketsAMM;
    }

    function safeBox() external view returns (address);

    function referrals() external view returns (address);

    function stakingThales() external view returns (address);

    function multiCollateralOnOffRamp() external view returns (address);

    function pyth() external view returns (address);

    function speedMarketsAMM() external view returns (address);

    function getAddresses() external view returns (Addresses memory);
}

File 21 of 26 : SpeedMarket.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

import "../interfaces/ISpeedMarketsAMM.sol";

contract SpeedMarket {
    using SafeERC20Upgradeable for IERC20Upgradeable;

    struct InitParams {
        address _speedMarketsAMM;
        address _user;
        bytes32 _asset;
        uint64 _strikeTime;
        int64 _strikePrice;
        Direction _direction;
        uint _buyinAmount;
        uint _safeBoxImpact;
        uint _lpFee;
    }

    enum Direction {
        Up,
        Down
    }

    address public user;
    bytes32 public asset;
    uint64 public strikeTime;
    int64 public strikePrice;
    Direction public direction;
    uint public buyinAmount;

    bool public resolved;
    int64 public finalPrice;
    Direction public result;

    ISpeedMarketsAMM public speedMarketsAMM;

    uint public safeBoxImpact;
    uint public lpFee;

    uint256 public createdAt;

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

    bool public initialized = false;

    function initialize(InitParams calldata params) external {
        require(!initialized, "Speed market already initialized");
        initialized = true;
        speedMarketsAMM = ISpeedMarketsAMM(params._speedMarketsAMM);
        user = params._user;
        asset = params._asset;
        strikeTime = params._strikeTime;
        strikePrice = params._strikePrice;
        direction = params._direction;
        buyinAmount = params._buyinAmount;
        safeBoxImpact = params._safeBoxImpact;
        lpFee = params._lpFee;
        speedMarketsAMM.sUSD().approve(params._speedMarketsAMM, type(uint256).max);
        createdAt = block.timestamp;
    }

    function resolve(int64 _finalPrice) external onlyAMM {
        require(!resolved, "already resolved");
        require(block.timestamp > strikeTime, "not ready to be resolved");
        resolved = true;
        finalPrice = _finalPrice;

        if (finalPrice < strikePrice) {
            result = Direction.Down;
        } else if (finalPrice > strikePrice) {
            result = Direction.Up;
        } else {
            result = direction == Direction.Up ? Direction.Down : Direction.Up;
        }

        if (direction == result) {
            speedMarketsAMM.sUSD().safeTransfer(user, speedMarketsAMM.sUSD().balanceOf(address(this)));
        } else {
            speedMarketsAMM.sUSD().safeTransfer(address(speedMarketsAMM), speedMarketsAMM.sUSD().balanceOf(address(this)));
        }

        emit Resolved(finalPrice, result, direction == result);
    }

    function isUserWinner() external view returns (bool) {
        return resolved && (direction == result);
    }

    modifier onlyAMM() {
        require(msg.sender == address(speedMarketsAMM), "only the AMM may perform these methods");
        _;
    }

    event Resolved(int64 finalPrice, Direction result, bool userIsWinner);
}

File 22 of 26 : ChainedSpeedMarket.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// external
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

// internal
import "../interfaces/IChainedSpeedMarketsAMM.sol";

import "./SpeedMarket.sol";

contract ChainedSpeedMarket {
    using SafeERC20Upgradeable for IERC20Upgradeable;

    struct InitParams {
        address _chainedMarketsAMM;
        address _user;
        bytes32 _asset;
        uint64 _timeFrame;
        uint64 _initialStrikeTime;
        uint64 _strikeTime;
        int64 _initialStrikePrice;
        SpeedMarket.Direction[] _directions;
        uint _buyinAmount;
        uint _safeBoxImpact;
        uint _payoutMultiplier;
    }

    address public user;
    bytes32 public asset;
    uint64 public timeFrame;
    uint64 public initialStrikeTime;
    uint64 public strikeTime;
    int64 public initialStrikePrice;
    int64[] public strikePrices;
    SpeedMarket.Direction[] public directions;
    uint public buyinAmount;
    uint public safeBoxImpact;
    uint public payoutMultiplier;

    bool public resolved;
    int64[] public finalPrices;
    bool public isUserWinner;

    uint256 public createdAt;

    IChainedSpeedMarketsAMM public chainedMarketsAMM;

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

    bool public initialized = false;

    function initialize(InitParams calldata params) external {
        require(!initialized, "Chained market already initialized");
        initialized = true;
        chainedMarketsAMM = IChainedSpeedMarketsAMM(params._chainedMarketsAMM);
        user = params._user;
        asset = params._asset;
        timeFrame = params._timeFrame;
        initialStrikeTime = params._initialStrikeTime;
        strikeTime = params._strikeTime;
        initialStrikePrice = params._initialStrikePrice;
        directions = params._directions;
        buyinAmount = params._buyinAmount;
        safeBoxImpact = params._safeBoxImpact;
        payoutMultiplier = params._payoutMultiplier;
        chainedMarketsAMM.sUSD().approve(params._chainedMarketsAMM, type(uint256).max);
        createdAt = block.timestamp;
    }

    function resolve(int64[] calldata _finalPrices, bool _isManually) external onlyAMM {
        require(!resolved, "already resolved");
        require(block.timestamp > initialStrikeTime + (timeFrame * (_finalPrices.length - 1)), "not ready to be resolved");
        require(_finalPrices.length <= directions.length, "more prices than directions");

        finalPrices = _finalPrices;

        for (uint i = 0; i < _finalPrices.length; i++) {
            strikePrices.push(i == 0 ? initialStrikePrice : _finalPrices[i - 1]); // previous final price is current strike price
            bool userLostDirection = _finalPrices[i] > 0 &&
                strikePrices[i] > 0 &&
                ((_finalPrices[i] >= strikePrices[i] && directions[i] == SpeedMarket.Direction.Down) ||
                    (_finalPrices[i] <= strikePrices[i] && directions[i] == SpeedMarket.Direction.Up));

            // user lost stop checking rest of directions
            if (userLostDirection) {
                resolved = true;
                break;
            }
            // when last final price for last direction user won
            if (i == directions.length - 1) {
                require(!_isManually, "Can not resolve manually");
                isUserWinner = true;
                resolved = true;
            }
        }

        require(resolved, "Not ready to resolve");

        if (isUserWinner) {
            chainedMarketsAMM.sUSD().safeTransfer(user, chainedMarketsAMM.sUSD().balanceOf(address(this)));
        } else {
            chainedMarketsAMM.sUSD().safeTransfer(
                address(chainedMarketsAMM),
                chainedMarketsAMM.sUSD().balanceOf(address(this))
            );
        }

        emit Resolved(finalPrices, isUserWinner);
    }

    /// @notice numOfDirections returns number of directions (speed markets in chain)
    /// @return uint8
    function numOfDirections() external view returns (uint8) {
        return uint8(directions.length);
    }

    /// @notice numOfPrices returns number of strike/finales
    /// @return uint
    function numOfPrices() external view returns (uint) {
        return strikePrices.length;
    }

    modifier onlyAMM() {
        require(msg.sender == address(chainedMarketsAMM), "only the AMM may perform these methods");
        _;
    }

    event Resolved(int64[] finalPrices, bool userIsWinner);
}

File 23 of 26 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library 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;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

File 24 of 26 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/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 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 onlyInitializing {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 25 of 26 : IPythEvents.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

/// @title IPythEvents contains the events that Pyth contract emits.
/// @dev This interface can be used for listening to the updates for off-chain and testing purposes.
interface IPythEvents {
    /// @dev Emitted when the price feed with `id` has received a fresh update.
    /// @param id The Pyth Price Feed ID.
    /// @param publishTime Publish time of the given price update.
    /// @param price Price of the given price update.
    /// @param conf Confidence interval of the given price update.
    event PriceFeedUpdate(
        bytes32 indexed id,
        uint64 publishTime,
        int64 price,
        uint64 conf
    );

    /// @dev Emitted when a batch price update is processed successfully.
    /// @param chainId ID of the source chain that the batch price update comes from.
    /// @param sequenceNumber Sequence number of the batch price update.
    event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber);
}

File 26 of 26 : IChainedSpeedMarketsAMM.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

import "../SpeedMarkets/SpeedMarket.sol";
import "../SpeedMarkets/ChainedSpeedMarket.sol";

interface IChainedSpeedMarketsAMM {
    function sUSD() external view returns (IERC20Upgradeable);

    function minChainedMarkets() external view returns (uint);

    function maxChainedMarkets() external view returns (uint);

    function minTimeFrame() external view returns (uint64);

    function maxTimeFrame() external view returns (uint64);

    function minBuyinAmount() external view returns (uint);

    function maxBuyinAmount() external view returns (uint);

    function maxProfitPerIndividualMarket() external view returns (uint);

    function payoutMultipliers(uint8 _index) external view returns (uint);

    function maxRisk() external view returns (uint);

    function currentRisk() external view returns (uint);

    function getLengths(address _user) external view returns (uint[4] memory);
}

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_addressManager","type":"address"}],"name":"AddressManagerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"AmountTransfered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"_minTimeFrame","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"_maxTimeFrame","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"_minChainedMarkets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxChainedMarkets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minBuyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxBuyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxProfitPerIndividualMarket","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxRisk","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"_payoutMultipliers","type":"uint256[]"}],"name":"LimitParamsChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"timeFrame","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"strikeTime","type":"uint64"},{"indexed":false,"internalType":"int64","name":"strikePrice","type":"int64"},{"indexed":false,"internalType":"enum SpeedMarket.Direction[]","name":"directions","type":"uint8[]"},{"indexed":false,"internalType":"uint256","name":"buyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"payoutMultiplier","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"safeBoxImpact","type":"uint256"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"bool","name":"userIsWinner","type":"bool"}],"name":"MarketResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"mastercopy","type":"address"}],"name":"MastercopyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_enabled","type":"bool"}],"name":"MultiCollateralOnOffRampEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"refferer","type":"address"},{"indexed":false,"internalType":"address","name":"trader","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"volume","type":"uint256"}],"name":"ReferrerPaid","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"activeMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"activeMarketsPerUser","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"addressManager","outputs":[{"internalType":"contract IAddressManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"canResolveMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chainedSpeedMarketMastercopy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"timeFrame","type":"uint64"},{"internalType":"enum SpeedMarket.Direction[]","name":"directions","type":"uint8[]"},{"internalType":"uint256","name":"buyinAmount","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"},{"internalType":"address","name":"referrer","type":"address"}],"name":"createNewMarket","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"timeFrame","type":"uint64"},{"internalType":"enum SpeedMarket.Direction[]","name":"directions","type":"uint8[]"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"bool","name":"isEth","type":"bool"},{"internalType":"address","name":"referrer","type":"address"}],"name":"createNewMarketWithDifferentCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"currentRisk","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getLengths","outputs":[{"internalType":"uint256[4]","name":"","type":"uint256[4]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"maturedMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"maturedMarketsPerUser","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBuyinAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxChainedMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxProfitPerIndividualMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRisk","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTimeFrame","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBuyinAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minChainedMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minTimeFrame","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multicollateralEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"payoutMultipliers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"bytes[][]","name":"priceUpdateData","type":"bytes[][]"}],"name":"resolveMarket","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"int64[]","name":"_finalPrices","type":"int64[]"}],"name":"resolveMarketAsOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"int64[]","name":"_finalPrices","type":"int64[]"}],"name":"resolveMarketManually","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"markets","type":"address[]"},{"internalType":"int64[][]","name":"finalPrices","type":"int64[][]"}],"name":"resolveMarketManuallyBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"bytes[][]","name":"priceUpdateData","type":"bytes[][]"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"bool","name":"toEth","type":"bool"}],"name":"resolveMarketWithOfframp","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"markets","type":"address[]"},{"internalType":"bytes[][][]","name":"priceUpdateData","type":"bytes[][][]"}],"name":"resolveMarketsBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"sUSD","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_addressManager","type":"address"}],"name":"setAddressManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_minTimeFrame","type":"uint64"},{"internalType":"uint64","name":"_maxTimeFrame","type":"uint64"},{"internalType":"uint256","name":"_minChainedMarkets","type":"uint256"},{"internalType":"uint256","name":"_maxChainedMarkets","type":"uint256"},{"internalType":"uint256","name":"_minBuyinAmount","type":"uint256"},{"internalType":"uint256","name":"_maxBuyinAmount","type":"uint256"},{"internalType":"uint256","name":"_maxProfitPerIndividualMarket","type":"uint256"},{"internalType":"uint256","name":"_maxRisk","type":"uint256"},{"internalType":"uint256[]","name":"_payoutMultipliers","type":"uint256[]"}],"name":"setLimitParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_mastercopy","type":"address"}],"name":"setMastercopy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setMultiCollateralOnOffRampEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_destination","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b506151e3806100206000396000f3fe60806040526004361061026b5760003560e01c806379ba509711610144578063c3b83f5f116100b6578063e73efc9b1161007a578063e73efc9b14610749578063e9c51c5514610769578063ebc797721461077c578063f68aaac914610791578063f823c643146107a4578063ffde0f97146107ba57600080fd5b8063c3b83f5f146106c0578063c80a4fa5146106e0578063d7081e0314610700578063dc56e7b314610720578063e06409ae1461073657600080fd5b80638f563bbc116101085780638f563bbc1461060457806391b4ded9146106245780639324cac71461063a57806399c18e7e1461065f5780639fc4270314610680578063bd484b63146106a057600080fd5b806379ba50971461057657806382e59f571461058b5780638858a10c146105ab57806389c6318d146105be5780638da5cb5b146105de57600080fd5b80631b1ad49d116101dd578063485cc955116101a1578063485cc955146104d357806353a47bb7146104f35780635c975abb146105135780635f2e97641461052d57806368b9f66b146105405780636c9259f41461056057600080fd5b80631b1ad49d1461041e5780631f50899b1461045d57806323b312151461047d57806335f12752146104935780633ab76e9f146104b357600080fd5b806312aa38331161022f57806312aa38331461034057806313af40351461035657806314527f3a146103765780631627540c146103a657806316c38b3c146103c65780631994c4f9146103e657600080fd5b8063023fb259146102775780630652b57a146102ad57806307b53bb4146102cf5780631007ecdb146102f357806312039b6d1461031357600080fd5b3661027257005b600080fd5b34801561028357600080fd5b50610297610292366004614296565b6107d0565b6040516102a49190614c8a565b60405180910390f35b3480156102b957600080fd5b506102cd6102c8366004614296565b610823565b005b3480156102db57600080fd5b506102e560105481565b6040519081526020016102a4565b3480156102ff57600080fd5b506102cd61030e366004614436565b610880565b34801561031f57600080fd5b5061033361032e36600461489e565b610a93565b6040516102a49190614b6a565b34801561034c57600080fd5b506102e5600f5481565b34801561036257600080fd5b506102cd610371366004614296565b610ac3565b34801561038257600080fd5b50610396610391366004614296565b610bf7565b60405190151581526020016102a4565b3480156103b257600080fd5b506102cd6103c1366004614296565b610d08565b3480156103d257600080fd5b506102cd6103e136600461456e565b610d5e565b3480156103f257600080fd5b50601554610406906001600160a01b031681565b6040516001600160a01b0390911681526020016102a4565b34801561042a57600080fd5b50600e5461044590600160401b90046001600160401b031681565b6040516001600160401b0390911681526020016102a4565b34801561046957600080fd5b506102cd610478366004614296565b610dd4565b34801561048957600080fd5b506102e5600c5481565b34801561049f57600080fd5b50600e54610445906001600160401b031681565b3480156104bf57600080fd5b50601654610406906001600160a01b031681565b3480156104df57600080fd5b506102cd6104ee3660046143d3565b610e2a565b3480156104ff57600080fd5b50600154610406906001600160a01b031681565b34801561051f57600080fd5b506003546103969060ff1681565b6102cd61053b3660046145be565b610f16565b34801561054c57600080fd5b506102cd61055b36600461456e565b611031565b34801561056c57600080fd5b506102e560115481565b34801561058257600080fd5b506102cd6111c7565b34801561059757600080fd5b506102cd6105a63660046148f2565b6112c4565b6102cd6105b9366004614689565b6113c5565b3480156105ca57600080fd5b506103336105d936600461487d565b6114ca565b3480156105ea57600080fd5b50600054610406906201000090046001600160a01b031681565b34801561061057600080fd5b506102cd61061f36600461439a565b6114d8565b34801561063057600080fd5b506102e560025481565b34801561064657600080fd5b506005546104069061010090046001600160a01b031681565b34801561066b57600080fd5b5060155461039690600160a01b900460ff1681565b34801561068c57600080fd5b5061033361069b36600461489e565b611542565b3480156106ac57600080fd5b506102cd6106bb36600461439a565b611568565b3480156106cc57600080fd5b506102cd6106db366004614296565b6116b6565b3480156106ec57600080fd5b506102e56106fb366004614865565b6117cf565b34801561070c57600080fd5b506102cd61071b36600461440b565b6117f0565b34801561072c57600080fd5b506102e560135481565b6102cd610744366004614320565b611853565b34801561075557600080fd5b5061033361076436600461487d565b611cee565b6102cd6107773660046142ce565b611cfc565b34801561078857600080fd5b506102cd611d69565b6102cd61079f366004614436565b611dc7565b3480156107b057600080fd5b506102e5600d5481565b3480156107c657600080fd5b506102e560145481565b6107d8614071565b506040805160808101825260065481526008546020808301919091526001600160a01b039093166000818152600a85528381205483850152908152600b909352912054606082015290565b61082b611ee6565b601680546001600160a01b0319166001600160a01b0383169081179091556040519081527f399ded90cb5ed8d89ef7e76ff4af65c373f06d3bf5d7eef55f4228e7b702a18b906020015b60405180910390a150565b6016546040805163366843a560e21b815290516000926001600160a01b03169163d9a10e94916004808301926020929190829003018186803b1580156108c557600080fd5b505afa1580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd91906142b2565b60405162d9267b60e31b81523360048201529091506001600160a01b038216906306c933d89060240160206040518083038186803b15801561093e57600080fd5b505afa158015610952573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610976919061458a565b6109c25760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b60448201526064015b60405180910390fd5b60005b84811015610a8b57610a058686838181106109f057634e487b7160e01b600052603260045260246000fd5b90506020020160208101906103919190614296565b15610a7957610a79868683818110610a2d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a429190614296565b858584818110610a6257634e487b7160e01b600052603260045260246000fd5b9050602002810190610a749190614ef3565b611f60565b80610a838161510e565b9150506109c5565b505050505050565b6001600160a01b0381166000908152600a60205260409020606090610ab9908585611fc5565b90505b9392505050565b6001600160a01b038116610b195760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064016109b9565b600154600160a01b900460ff1615610b855760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b60648201526084016109b9565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610875565b6000610c04600683612109565b8015610c88575042826001600160a01b03166320c1bb466040518163ffffffff1660e01b815260040160206040518083038186803b158015610c4557600080fd5b505afa158015610c59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7d91906148d6565b6001600160401b0316105b8015610d025750816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015610cc857600080fd5b505afa158015610cdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d00919061458a565b155b92915050565b610d10611ee6565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610875565b610d66611ee6565b60035460ff1615158115151415610d7a5750565b6003805460ff191682151590811790915560ff1615610d9857426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610875565b50565b610ddc611ee6565b601580546001600160a01b0319166001600160a01b0383169081179091556040519081527fe9f33266a193fa018a5d4acaa6790d296c2344e2edcb5647eee2a01575d39b3690602001610875565b600054610100900460ff16610e455760005460ff1615610e49565b303b155b610eac5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016109b9565b600054610100900460ff16158015610ece576000805461ffff19166101011790555b610ed783610ac3565b610edf611d69565b60058054610100600160a81b0319166101006001600160a01b038516021790558015610f11576000805461ff00191690555b505050565b600160046000828254610f299190614fb5565b909155505060045460035460ff1615610f545760405162461bcd60e51b81526004016109b990614cf7565b601654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b158015610f9957600080fd5b505afa158015610fad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd1919061472e565b90506000610fe18787878561218b565b90506110018d8d8d8d858e8e90610ff891906150d5565b60008b8a6125bb565b505060045481146110245760405162461bcd60e51b81526004016109b990614d54565b5050505050505050505050565b611039611ee6565b60165460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f916004808301926020929190829003018186803b15801561107e57600080fd5b505afa158015611092573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b691906142b2565b90506001600160a01b0381161561116e5760055461010090046001600160a01b031663095ea7b382846110ea5760006110ee565b6000195b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561113457600080fd5b505af1158015611148573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116c919061458a565b505b60158054831515600160a01b0260ff60a01b199091161790556040517fb76eab56cfa3088dda43a9a4b3ea4bb7685b8007428d4a65248fdaa763d339f8906111bb90841515815260200190565b60405180910390a15050565b6001546001600160a01b0316331461123f5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b60648201526084016109b9565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6112cc611ee6565b600188116113145760405162461bcd60e51b81526020600482015260156024820152746d696e203220636861696e6564206d61726b65747360581b60448201526064016109b9565b600e80546001600160401b038b8116600160401b026fffffffffffffffffffffffffffffffff19909216908d1617179055600c889055600d879055600f86905560108590556011849055601383905561136f6017838361408f565b507ff286a7833e5a7fc3330b62b2ca952b0ab1e44791f67a465649f7da03516da2368a8a8a8a8a8a8a8a8a8a6040516113b19a99989796959493929190614e70565b60405180910390a150505050505050505050565b6001600460008282546113d89190614fb5565b909155505060045460035460ff16156114035760405162461bcd60e51b81526004016109b990614cf7565b601654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b15801561144857600080fd5b505afa15801561145c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611480919061472e565b905061149d8a8a8a8a8a6114948a8c6150d5565b60018a896125bb565b5060045481146114bf5760405162461bcd60e51b81526004016109b990614d54565b505050505050505050565b6060610abc60088484611fc5565b6114e0611ee6565b6114e983610bf7565b6115055760405162461bcd60e51b81526004016109b990614cce565b610f118383838080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509250612e29915050565b6001600160a01b0381166000908152600b60205260409020606090610ab9908585611fc5565b6016546040805163366843a560e21b815290516000926001600160a01b03169163d9a10e94916004808301926020929190829003018186803b1580156115ad57600080fd5b505afa1580156115c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e591906142b2565b60405162d9267b60e31b81523360048201529091506001600160a01b038216906306c933d89060240160206040518083038186803b15801561162657600080fd5b505afa15801561163a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165e919061458a565b6116a55760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b60448201526064016109b9565b6116b0848484611f60565b50505050565b6116be611ee6565b6001600160a01b0381166117065760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b60448201526064016109b9565b600154600160a81b900460ff16156117565760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b60448201526064016109b9565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610875565b601781815481106117df57600080fd5b600091825260209091200154905081565b6117f8611ee6565b6005546118149061010090046001600160a01b031683836132ba565b604080516001600160a01b0384168152602081018390527fc3ce4eeef579533b0a2d7ae2e50eb68dccae3b183dc8cce60267f3c9fa4935c091016111bb565b6001600460008282546118669190614fb5565b909155505060045460035460ff16156118915760405162461bcd60e51b81526004016109b990614cf7565b6000866001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b1580156118cc57600080fd5b505afa1580156118e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190491906142b2565b9050336001600160a01b0382161461195e5760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c7920616c6c6f7765642066726f6d206d61726b6574206f776e6572000060448201526064016109b9565b6005546040516370a0823160e01b81526001600160a01b038381166004830152600092610100900416906370a082319060240160206040518083038186803b1580156119a957600080fd5b505afa1580156119bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e191906145a6565b90506119f6886119f1888a61504e565b61331d565b6005546040516370a0823160e01b81526001600160a01b0384811660048301526000928492610100909104909116906370a082319060240160206040518083038186803b158015611a4657600080fd5b505afa158015611a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7e91906145a6565b611a889190615037565b600554909150611aa89061010090046001600160a01b031684308461391f565b8015611cca5760165460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f916004808301926020929190829003018186803b158015611af357600080fd5b505afa158015611b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2b91906142b2565b90508515611c2a5760405163b45e98d960e01b8152600481018390526000906001600160a01b0383169063b45e98d990602401602060405180830381600087803b158015611b7857600080fd5b505af1158015611b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb091906145a6565b60405190915085906000906001600160a01b0383169084156108fc0290859084818181858888f19350505050905080611c225760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b60448201526064016109b9565b505050611cc8565b604051630992646d60e31b81526001600160a01b0388811660048301526024820184905260009190831690634c93236890604401602060405180830381600087803b158015611c7857600080fd5b505af1158015611c8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb091906145a6565b9050611cc66001600160a01b03891686836132ba565b505b505b5050506004548114610a8b5760405162461bcd60e51b81526004016109b990614d54565b6060610abc60068484611fc5565b600160046000828254611d0f9190614fb5565b909155505060045460035460ff1615611d3a5760405162461bcd60e51b81526004016109b990614cf7565b611d48846119f1848661504e565b60045481146116b05760405162461bcd60e51b81526004016109b990614d54565b60055460ff1615611db25760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016109b9565b6005805460ff19166001908117909155600455565b600160046000828254611dda9190614fb5565b909155505060045460035460ff1615611e055760405162461bcd60e51b81526004016109b990614cf7565b60005b84811015611ebd57611e338686838181106109f057634e487b7160e01b600052603260045260246000fd5b15611eab57611eab868683818110611e5b57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611e709190614296565b858584818110611e9057634e487b7160e01b600052603260045260246000fd5b9050602002810190611ea29190614ef3565b6119f19161504e565b80611eb58161510e565b915050611e08565b506004548114611edf5760405162461bcd60e51b81526004016109b990614d54565b5050505050565b6000546201000090046001600160a01b03163314611f5e5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b60648201526084016109b9565b565b611f6983610bf7565b611f855760405162461bcd60e51b81526004016109b990614cce565b610f118383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525060019250612e29915050565b60606000611fd38385614fb5565b8554909150811115611fe3575083545b838111612000575050604080516000815260208101909152610abc565b600061200c8583615037565b90506000816001600160401b0381111561203657634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561205f578160200160208202803683370190505b50905060005b828110156120fe57876120788883614fb5565b8154811061209657634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168282815181106120d457634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152806120f68161510e565b915050612065565b509695505050505050565b815460009061211a57506000610d02565b6001600160a01b0382166000908152600184016020526040902054801515806121835750826001600160a01b03168460000160008154811061216c57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b949350505050565b601554600090600160a01b900460ff166121f25760405162461bcd60e51b815260206004820152602260248201527f4d756c7469636f6c6c61746572616c206f6e72616d70206e6f7420656e61626c604482015261195960f21b60648201526084016109b9565b6005546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a082319060240160206040518083038186803b15801561223b57600080fd5b505afa15801561224f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227391906145a6565b60608401519091506000851561230657604051631321b85d60e01b8152600481018890526001600160a01b03831690631321b85d9089906024016020604051808303818588803b1580156122c657600080fd5b505af11580156122da573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906122ff91906145a6565b9050612423565b61231b6001600160a01b03891633308a61391f565b60405163095ea7b360e01b81526001600160a01b0383811660048301526024820189905289169063095ea7b390604401602060405180830381600087803b15801561236557600080fd5b505af1158015612379573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239d919061458a565b506040516322ceb11360e21b81526001600160a01b03898116600483015260248201899052831690638b3ac44c90604401602060405180830381600087803b1580156123e857600080fd5b505af11580156123fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061242091906145a6565b90505b60008560a001519050670de0b6b3a7640000816001600160a01b031663d69fb6686040518163ffffffff1660e01b815260040160206040518083038186803b15801561246e57600080fd5b505afa158015612482573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a691906145a6565b6124b890670de0b6b3a7640000615037565b6124c29084615018565b6124cc9190614ff8565b6005546040516370a0823160e01b8152306004820152919650600091869161010090046001600160a01b0316906370a082319060240160206040518083038186803b15801561251a57600080fd5b505afa15801561252e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061255291906145a6565b61255c9190615037565b9050858110156125ae5760405162461bcd60e51b815260206004820152601e60248201527f6e6f7420656e6f75676820726563656976656420766961206f6e72616d70000060448201526064016109b9565b5050505050949350505050565b61261f6040805160808082018352600080835260208084018290528451928301855281835282018190528184018190526060820152909182019081526040805160808101825260008082526020828101829052928201819052606082015291015290565b60a0820151604051630ac0f68f60e21b8152600481018c90526001600160a01b0390911690632b03da3c9060240160806040518083038186803b15801561266557600080fd5b505afa158015612679573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061269d91906147d7565b60608201819052516126ea5760405162461bcd60e51b8152602060048201526016602482015275105cdcd95d081a5cc81b9bdd081cdd5c1c1bdc9d195960521b60448201526064016109b9565b600f5486101580156126fe57506010548611155b6127405760405162461bcd60e51b815260206004820152601360248201527215dc9bdb99c8189d5e481a5b88185b5bdd5b9d606a1b60448201526064016109b9565b600e546001600160401b03908116908a16108015906127755750600e546001600160401b03600160401b9091048116908a1611155b6127b45760405162461bcd60e51b815260206004820152601060248201526f57726f6e672074696d65206672616d6560801b60448201526064016109b9565b600c5487108015906127c85750600d548711155b6128145760405162461bcd60e51b815260206004820152601a60248201527f57726f6e67206e756d626572206f6620646972656374696f6e7300000000000060448201526064016109b9565b600c546017906128279060ff8a16615037565b8154811061284557634e487b7160e01b600052603260045260246000fd5b600091825260209182902001549082018190526128659087908990613957565b80825260115410156128ab5760405162461bcd60e51b815260206004820152600f60248201526e0a0e4deccd2e840e8dede40d0d2ced608b1b60448201526064016109b9565b80516128b8908790615037565b601460008282546128c99190614fb5565b909155505060135460145411156129155760405162461bcd60e51b815260206004820152601060248201526f4f7574206f66206c697175696469747960801b60448201526064016109b9565b608082015160405163d47eed4560e01b81526001600160a01b039091169063ef9e5e2890829063d47eed459061294f908a90600401614bb7565b60206040518083038186803b15801561296757600080fd5b505afa15801561297b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299f91906145a6565b876040518363ffffffff1660e01b81526004016129bc9190614bb7565b6000604051808303818588803b1580156129d557600080fd5b505af11580156129e9573d6000803e3d6000fd5b50505060808401516060840151602001516040516396834ad360e01b81526001600160a01b0390921693506396834ad39250612a2b9160040190815260200190565b60806040518083038186803b158015612a4357600080fd5b505afa158015612a57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7b919061484a565b604082018190526060808301518101519101514291612aa5916001600160401b0390911690614fb5565b118015612abd5750600081604001516000015160070b135b612af75760405162461bcd60e51b815260206004820152600b60248201526a5374616c6520707269636560a81b60448201526064016109b9565b8315612b5a576000670de0b6b3a7640000826060015160400151670de0b6b3a7640000612b249190614fb5565b612b2e9089615018565b612b389190614ff8565b600554909150612b589061010090046001600160a01b031633308461391f565b505b601554600090612b72906001600160a01b03166139a2565b9050806001600160a01b031663e0f51a5f604051806101600160405280306001600160a01b03168152602001336001600160a01b031681526020018e81526020018d6001600160401b031681526020018d6001600160401b031642612bd79190614fb5565b6001600160401b031681526020018c8c90508e6001600160401b0316612bfd9190615018565b612c079042614fb5565b6001600160401b0316815260200185604001516000015160070b81526020018c8c8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060208082018c90526060808801516040908101518185015291880151920191909152516001600160e01b031960e084901b168152612c9d9190600401614d8b565b600060405180830381600087803b158015612cb757600080fd5b505af1158015612ccb573d6000803e3d6000fd5b50508351600554612cee935061010090046001600160a01b0316915083906132ba565b612d02848884606001516040015186613a3f565b50612d0e600682613cbe565b336000908152600a60205260409020612d279082613cbe565b60408301516001600160a01b031615612da15760408084015190516302c7739b60e01b8152336004820152602481018990526001600160a01b03909116906302c7739b90604401600060405180830381600087803b158015612d8857600080fd5b505af1158015612d9c573d6000803e3d6000fd5b505050505b7fd061c182aaa319a32c4cb7717e176ffddabdf9a1d7f1dc1e5d8296ffc9eead1d81338d8d612dd98d6001600160401b038316615018565b612de39042614fb5565b8760400151600001518f8f8f8b602001518c6060015160400151604051612e149b9a99989796959493929190614abc565b60405180910390a15050505050505050505050565b60405163089eec6760e21b81526001600160a01b0384169063227bb19c90612e579085908590600401614c3c565b600060405180830381600087803b158015612e7157600080fd5b505af1158015612e85573d6000803e3d6000fd5b50505050826001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015612ec257600080fd5b505afa158015612ed6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612efa919061458a565b1561320057612f0a600684613d11565b612f15600884613cbe565b6000836001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b158015612f5057600080fd5b505afa158015612f64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f8891906142b2565b6001600160a01b0381166000908152600a60205260409020909150612fad9085612109565b15612fd4576001600160a01b0381166000908152600a60205260409020612fd49085613d11565b6001600160a01b0381166000908152600b60205260409020612ff69085613cbe565b6000846001600160a01b0316631fcc8bb26040518163ffffffff1660e01b815260040160206040518083038186803b15801561303157600080fd5b505afa158015613045573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061306991906145a6565b9050600061315882876001600160a01b031663e004b5bf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156130aa57600080fd5b505afa1580156130be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e29190614996565b886001600160a01b0316635c8127376040518163ffffffff1660e01b815260040160206040518083038186803b15801561311b57600080fd5b505afa15801561312f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315391906145a6565b613957565b9050856001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b15801561319357600080fd5b505afa1580156131a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cb919061458a565b6131fc578060145411156131f65780601460008282546131eb9190615037565b909155506131fc9050565b60006014555b5050505b7fe1ed361a9267ee898f74c2ae2b43810623c3ff7fbafed1bf79c651e5122bbd5283846001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b15801561325b57600080fd5b505afa15801561326f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613293919061458a565b604080516001600160a01b03909316835290151560208301520160405180910390a1505050565b6040516001600160a01b038316602482015260448101829052610f1190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613e94565b61332682610bf7565b6133425760405162461bcd60e51b81526004016109b990614cce565b601654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b15801561338757600080fd5b505afa15801561339b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133bf919061472e565b60a0810151604080516001808252818301909252929350909160009160208083019080368337019050509050816001600160a01b031663bd47a9b8866001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561343357600080fd5b505afa158015613447573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061346b91906145a6565b6040518263ffffffff1660e01b815260040161348991815260200190565b60206040518083038186803b1580156134a157600080fd5b505afa1580156134b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134d991906145a6565b816000815181106134fa57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050600084516001600160401b0381111561352f57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613558578160200160208202803683370190505b5090506000805b865181101561390957876001600160a01b0316638b13b64b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156135a157600080fd5b505afa1580156135b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d991906148d6565b6135ec906001600160401b031682615018565b886001600160a01b03166320c1bb466040518163ffffffff1660e01b815260040160206040518083038186803b15801561362557600080fd5b505afa158015613639573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061365d91906148d6565b6136679190614fcd565b91506000866080015190506000816001600160a01b0316634716e9c5836001600160a01b031663d47eed458c87815181106136b257634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b81526004016136d69190614bb7565b60206040518083038186803b1580156136ee57600080fd5b505afa158015613702573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372691906145a6565b8b868151811061374657634e487b7160e01b600052603260045260246000fd5b602002602001015189888c6001600160a01b031663cf898ca96040518163ffffffff1660e01b815260040160206040518083038186803b15801561378957600080fd5b505afa15801561379d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c191906148d6565b6137cb908b614fcd565b6040518663ffffffff1660e01b81526004016137ea9493929190614bca565b6000604051808303818588803b15801561380357600080fd5b505af1158015613817573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052613840919081019061449e565b905060008160008151811061386557634e487b7160e01b600052603260045260246000fd5b60200260200101516020015190506000816000015160070b136138ba5760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420707269636560981b60448201526064016109b9565b80600001518685815181106138df57634e487b7160e01b600052603260045260246000fd5b602002602001019060070b908160070b8152505050505080806139019061510e565b91505061355f565b5061391687836000612e29565b50505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526116b09085906323b872dd60e01b906084016132e6565b8260005b8360ff168160ff16101561399a57670de0b6b3a764000061397c8484615018565b6139869190614ff8565b91508061399281615129565b91505061395b565b509392505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b038116613a3a5760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b60448201526064016109b9565b919050565b60208101516000906001600160a01b03811615613c6f5760006001600160a01b03871615613ad05760405163bbddaca360e01b81526001600160a01b03888116600483015233602483015283169063bbddaca390604401600060405180830381600087803b158015613ab057600080fd5b505af1158015613ac4573d6000803e3d6000fd5b50505050869050613b4a565b604051639ca423b360e01b81523360048201526001600160a01b03831690639ca423b39060240160206040518083038186803b158015613b0f57600080fd5b505afa158015613b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b4791906142b2565b90505b6001600160a01b03811615613c6d5760405163c7d1f5f160e01b81526001600160a01b0382811660048301526000919084169063c7d1f5f19060240160206040518083038186803b158015613b9e57600080fd5b505afa158015613bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd691906145a6565b90508015613c6b57670de0b6b3a7640000613bf18289615018565b613bfb9190614ff8565b600554909450613c1a9061010090046001600160a01b031683866132ba565b604080516001600160a01b0384168152336020820152908101859052606081018890527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b505b8251613cb59083670de0b6b3a7640000613c89888a615018565b613c939190614ff8565b613c9d9190615037565b60055461010090046001600160a01b031691906132ba565b50949350505050565b613cc88282612109565b613d0d5781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555b5050565b613d1b8282612109565b613d5d5760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b60448201526064016109b9565b6001600160a01b0381166000908152600180840160205260408220548454909291613d8791615037565b9050808214613e2f576000846000018281548110613db557634e487b7160e01b600052603260045260246000fd5b60009182526020909120015485546001600160a01b0390911691508190869085908110613df257634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080613e4e57634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b6000613ee9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613f669092919063ffffffff16565b805190915015610f115780806020019051810190613f07919061458a565b610f115760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109b9565b6060610ab9848460008585843b613fbf5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109b9565b600080866001600160a01b03168587604051613fdb9190614aa0565b60006040518083038185875af1925050503d8060008114614018576040519150601f19603f3d011682016040523d82523d6000602084013e61401d565b606091505b509150915061402d828286614038565b979650505050505050565b60608315614047575081610abc565b8251156140575782518084602001fd5b8160405162461bcd60e51b81526004016109b99190614cbb565b60405180608001604052806004906020820280368337509192915050565b8280548282559060005260206000209081019282156140ca579160200282015b828111156140ca5782358255916020019190600101906140af565b506140d69291506140da565b5090565b5b808211156140d657600081556001016140db565b60006141026140fd84614f92565b614f62565b9050808382526020808301915083868660051b8601111561412257600080fd5b60005b868110156141b65781356001600160401b038082111561414457600080fd5b8188019150601f8a8184011261415957600080fd5b82358281111561416b5761416b61515f565b61417c818301601f19168801614f62565b92508083528b8782860101111561419257600080fd5b80878501888501376000908301870152508552509282019290820190600101614125565b505050509392505050565b60008083601f8401126141d2578182fd5b5081356001600160401b038111156141e8578182fd5b6020830191508360208260051b850101111561420357600080fd5b9250929050565b60006080828403121561421b578081fd5b604051608081018181106001600160401b038211171561423d5761423d61515f565b806040525080915082518060070b811461425657600080fd5b8152602083015161426681615198565b60208201526040830151600381900b811461428057600080fd5b6040820152606092830151920191909152919050565b6000602082840312156142a7578081fd5b8135610abc81615175565b6000602082840312156142c3578081fd5b8151610abc81615175565b6000806000604084860312156142e2578182fd5b83356142ed81615175565b925060208401356001600160401b03811115614307578283fd5b614313868287016141c1565b9497909650939450505050565b600080600080600060808688031215614337578283fd5b853561434281615175565b945060208601356001600160401b0381111561435c578384fd5b614368888289016141c1565b909550935050604086013561437c81615175565b9150606086013561438c8161518a565b809150509295509295909350565b6000806000604084860312156143ae578081fd5b83356143b981615175565b925060208401356001600160401b03811115614307578182fd5b600080604083850312156143e5578182fd5b82356143f081615175565b9150602083013561440081615175565b809150509250929050565b6000806040838503121561441d578182fd5b823561442881615175565b946020939093013593505050565b6000806000806040858703121561444b578182fd5b84356001600160401b0380821115614461578384fd5b61446d888389016141c1565b90965094506020870135915080821115614485578384fd5b50614492878288016141c1565b95989497509550505050565b600060208083850312156144b0578182fd5b82516001600160401b038111156144c5578283fd5b8301601f810185136144d5578283fd5b80516144e36140fd82614f92565b81815283810190838501610120808502860187018a1015614502578788fd5b8795505b848610156145605780828b03121561451c578788fd5b614524614f3a565b825181526145348b89850161420a565b888201526145458b60a0850161420a565b60408201528452600195909501949286019290810190614506565b509098975050505050505050565b60006020828403121561457f578081fd5b8135610abc8161518a565b60006020828403121561459b578081fd5b8151610abc8161518a565b6000602082840312156145b7578081fd5b5051919050565b6000806000806000806000806000806101008b8d0312156145dd578788fd5b8a35995060208b01356145ef81615198565b985060408b01356001600160401b038082111561460a57898afd5b6146168e838f016141c1565b909a50985060608d013591508082111561462e578687fd5b5061463b8d828e016141c1565b90975095505060808b013561464f81615175565b935060a08b0135925060c08b01356146668161518a565b915060e08b013561467681615175565b809150509295989b9194979a5092959850565b60008060008060008060008060c0898b0312156146a4578182fd5b8835975060208901356146b681615198565b965060408901356001600160401b03808211156146d1578384fd5b6146dd8c838d016141c1565b909850965060608b0135955060808b01359150808211156146fc578384fd5b506147098b828c016141c1565b90945092505060a089013561471d81615175565b809150509295985092959890939650565b600060c0828403121561473f578081fd5b60405160c081018181106001600160401b03821117156147615761476161515f565b604052825161476f81615175565b8152602083015161477f81615175565b6020820152604083015161479281615175565b604082015260608301516147a581615175565b606082015260808301516147b881615175565b608082015260a08301516147cb81615175565b60a08201529392505050565b6000608082840312156147e8578081fd5b604051608081018181106001600160401b038211171561480a5761480a61515f565b60405282516148188161518a565b808252506020830151602082015260408301516040820152606083015161483e81615198565b60608201529392505050565b60006080828403121561485b578081fd5b610abc838361420a565b600060208284031215614876578081fd5b5035919050565b6000806040838503121561488f578182fd5b50508035926020909101359150565b6000806000606084860312156148b2578081fd5b833592506020840135915060408401356148cb81615175565b809150509250925092565b6000602082840312156148e7578081fd5b8151610abc81615198565b6000806000806000806000806000806101208b8d031215614911578384fd5b8a3561491c81615198565b995060208b013561492c81615198565b985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b0135935060e08b013592506101008b01356001600160401b03811115614971578283fd5b61497d8d828e016141c1565b915080935050809150509295989b9194979a5092959850565b6000602082840312156149a7578081fd5b815160ff81168114610abc578182fd5b6000600282106149d557634e487b7160e01b81526021600452602481fd5b50815260200190565b600082825180855260208086019550808260051b840101818601855b84811015614a2857601f19868403018952614a16838351614a74565b988401989250908301906001016149fa565b5090979650505050505050565b6000815180845260208085019450808401835b83811015614a6957614a5b8783516149b7565b965090820190600101614a48565b509495945050505050565b60008151808452614a8c8160208601602086016150e2565b601f01601f19169290920160200192915050565b60008251614ab28184602087016150e2565b9190910192915050565b6001600160a01b038c811682528b166020820152604081018a90526001600160401b03898116606083015288166080820152600787900b60a082015261014060c0820181905281018590526000866101608301825b88811015614b4357823560028110614b27578485fd5b614b3183826149b7565b60209490940193925050600101614b11565b5060e084019690965250506101008101929092526101209091015298975050505050505050565b6020808252825182820181905260009190848201906040850190845b81811015614bab5783516001600160a01b031683529284019291840191600101614b86565b50909695505050505050565b602081526000610abc60208301846149de565b608081526000614bdd60808301876149de565b828103602084810191909152865180835287820192820190845b81811015614c1357845183529383019391830191600101614bf7565b50506001600160401b039687166040860152949095166060909301929092525090949350505050565b604080825283519082018190526000906020906060840190828701845b82811015614c7857815160070b84529284019290840190600101614c59565b50505093151592019190915250919050565b60808101818360005b6004811015614cb2578151835260209283019290910190600101614c93565b50505092915050565b602081526000610abc6020830184614a74565b6020808252600f908201526e43616e206e6f74207265736f6c766560881b604082015260600190565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208152614da56020820183516001600160a01b03169052565b60006020830151614dc160408401826001600160a01b03169052565b50604083015160608301526060830151614de660808401826001600160401b03169052565b5060808301516001600160401b03811660a08401525060a08301516001600160401b03811660c08401525060c0830151614e2560e084018260070b9052565b5060e08301516101606101008181860152614e44610180860184614a35565b908601516101208681019190915286015161014080870191909152909501519301929092525090919050565b60006101206001600160401b03808e168452808d166020850152508a60408401528960608401528860808401528760a08401528660c08401528560e08401528061010084015283818401525061014060018060fb1b03841115614ed1578182fd5b8360051b808683860137929092019091019081529a9950505050505050505050565b6000808335601e19843603018112614f09578283fd5b8301803591506001600160401b03821115614f22578283fd5b6020019150600581901b360382131561420357600080fd5b604051606081016001600160401b0381118282101715614f5c57614f5c61515f565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614f8a57614f8a61515f565b604052919050565b60006001600160401b03821115614fab57614fab61515f565b5060051b60200190565b60008219821115614fc857614fc8615149565b500190565b60006001600160401b03808316818516808303821115614fef57614fef615149565b01949350505050565b60008261501357634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561503257615032615149565b500290565b60008282101561504957615049615149565b500390565b600061505c6140fd84614f92565b808482526020808301925084368760051b87011115615079578485fd5b845b878110156150c95781356001600160401b03811115615098578687fd5b870136601f8201126150a8578687fd5b6150b63682358684016140ef565b865250938201939082019060010161507b565b50919695505050505050565b6000610abc3684846140ef565b60005b838110156150fd5781810151838201526020016150e5565b838111156116b05750506000910152565b600060001982141561512257615122615149565b5060010190565b600060ff821660ff81141561514057615140615149565b60010192915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610dd157600080fd5b8015158114610dd157600080fd5b6001600160401b0381168114610dd157600080fdfea2646970667358221220bb13557568426e21dea53ec6120422ee17f4677a6fd44d57dc02a706d847be3664736f6c63430008040033

Deployed Bytecode

0x60806040526004361061026b5760003560e01c806379ba509711610144578063c3b83f5f116100b6578063e73efc9b1161007a578063e73efc9b14610749578063e9c51c5514610769578063ebc797721461077c578063f68aaac914610791578063f823c643146107a4578063ffde0f97146107ba57600080fd5b8063c3b83f5f146106c0578063c80a4fa5146106e0578063d7081e0314610700578063dc56e7b314610720578063e06409ae1461073657600080fd5b80638f563bbc116101085780638f563bbc1461060457806391b4ded9146106245780639324cac71461063a57806399c18e7e1461065f5780639fc4270314610680578063bd484b63146106a057600080fd5b806379ba50971461057657806382e59f571461058b5780638858a10c146105ab57806389c6318d146105be5780638da5cb5b146105de57600080fd5b80631b1ad49d116101dd578063485cc955116101a1578063485cc955146104d357806353a47bb7146104f35780635c975abb146105135780635f2e97641461052d57806368b9f66b146105405780636c9259f41461056057600080fd5b80631b1ad49d1461041e5780631f50899b1461045d57806323b312151461047d57806335f12752146104935780633ab76e9f146104b357600080fd5b806312aa38331161022f57806312aa38331461034057806313af40351461035657806314527f3a146103765780631627540c146103a657806316c38b3c146103c65780631994c4f9146103e657600080fd5b8063023fb259146102775780630652b57a146102ad57806307b53bb4146102cf5780631007ecdb146102f357806312039b6d1461031357600080fd5b3661027257005b600080fd5b34801561028357600080fd5b50610297610292366004614296565b6107d0565b6040516102a49190614c8a565b60405180910390f35b3480156102b957600080fd5b506102cd6102c8366004614296565b610823565b005b3480156102db57600080fd5b506102e560105481565b6040519081526020016102a4565b3480156102ff57600080fd5b506102cd61030e366004614436565b610880565b34801561031f57600080fd5b5061033361032e36600461489e565b610a93565b6040516102a49190614b6a565b34801561034c57600080fd5b506102e5600f5481565b34801561036257600080fd5b506102cd610371366004614296565b610ac3565b34801561038257600080fd5b50610396610391366004614296565b610bf7565b60405190151581526020016102a4565b3480156103b257600080fd5b506102cd6103c1366004614296565b610d08565b3480156103d257600080fd5b506102cd6103e136600461456e565b610d5e565b3480156103f257600080fd5b50601554610406906001600160a01b031681565b6040516001600160a01b0390911681526020016102a4565b34801561042a57600080fd5b50600e5461044590600160401b90046001600160401b031681565b6040516001600160401b0390911681526020016102a4565b34801561046957600080fd5b506102cd610478366004614296565b610dd4565b34801561048957600080fd5b506102e5600c5481565b34801561049f57600080fd5b50600e54610445906001600160401b031681565b3480156104bf57600080fd5b50601654610406906001600160a01b031681565b3480156104df57600080fd5b506102cd6104ee3660046143d3565b610e2a565b3480156104ff57600080fd5b50600154610406906001600160a01b031681565b34801561051f57600080fd5b506003546103969060ff1681565b6102cd61053b3660046145be565b610f16565b34801561054c57600080fd5b506102cd61055b36600461456e565b611031565b34801561056c57600080fd5b506102e560115481565b34801561058257600080fd5b506102cd6111c7565b34801561059757600080fd5b506102cd6105a63660046148f2565b6112c4565b6102cd6105b9366004614689565b6113c5565b3480156105ca57600080fd5b506103336105d936600461487d565b6114ca565b3480156105ea57600080fd5b50600054610406906201000090046001600160a01b031681565b34801561061057600080fd5b506102cd61061f36600461439a565b6114d8565b34801561063057600080fd5b506102e560025481565b34801561064657600080fd5b506005546104069061010090046001600160a01b031681565b34801561066b57600080fd5b5060155461039690600160a01b900460ff1681565b34801561068c57600080fd5b5061033361069b36600461489e565b611542565b3480156106ac57600080fd5b506102cd6106bb36600461439a565b611568565b3480156106cc57600080fd5b506102cd6106db366004614296565b6116b6565b3480156106ec57600080fd5b506102e56106fb366004614865565b6117cf565b34801561070c57600080fd5b506102cd61071b36600461440b565b6117f0565b34801561072c57600080fd5b506102e560135481565b6102cd610744366004614320565b611853565b34801561075557600080fd5b5061033361076436600461487d565b611cee565b6102cd6107773660046142ce565b611cfc565b34801561078857600080fd5b506102cd611d69565b6102cd61079f366004614436565b611dc7565b3480156107b057600080fd5b506102e5600d5481565b3480156107c657600080fd5b506102e560145481565b6107d8614071565b506040805160808101825260065481526008546020808301919091526001600160a01b039093166000818152600a85528381205483850152908152600b909352912054606082015290565b61082b611ee6565b601680546001600160a01b0319166001600160a01b0383169081179091556040519081527f399ded90cb5ed8d89ef7e76ff4af65c373f06d3bf5d7eef55f4228e7b702a18b906020015b60405180910390a150565b6016546040805163366843a560e21b815290516000926001600160a01b03169163d9a10e94916004808301926020929190829003018186803b1580156108c557600080fd5b505afa1580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd91906142b2565b60405162d9267b60e31b81523360048201529091506001600160a01b038216906306c933d89060240160206040518083038186803b15801561093e57600080fd5b505afa158015610952573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610976919061458a565b6109c25760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b60448201526064015b60405180910390fd5b60005b84811015610a8b57610a058686838181106109f057634e487b7160e01b600052603260045260246000fd5b90506020020160208101906103919190614296565b15610a7957610a79868683818110610a2d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a429190614296565b858584818110610a6257634e487b7160e01b600052603260045260246000fd5b9050602002810190610a749190614ef3565b611f60565b80610a838161510e565b9150506109c5565b505050505050565b6001600160a01b0381166000908152600a60205260409020606090610ab9908585611fc5565b90505b9392505050565b6001600160a01b038116610b195760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064016109b9565b600154600160a01b900460ff1615610b855760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b60648201526084016109b9565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610875565b6000610c04600683612109565b8015610c88575042826001600160a01b03166320c1bb466040518163ffffffff1660e01b815260040160206040518083038186803b158015610c4557600080fd5b505afa158015610c59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7d91906148d6565b6001600160401b0316105b8015610d025750816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015610cc857600080fd5b505afa158015610cdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d00919061458a565b155b92915050565b610d10611ee6565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610875565b610d66611ee6565b60035460ff1615158115151415610d7a5750565b6003805460ff191682151590811790915560ff1615610d9857426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610875565b50565b610ddc611ee6565b601580546001600160a01b0319166001600160a01b0383169081179091556040519081527fe9f33266a193fa018a5d4acaa6790d296c2344e2edcb5647eee2a01575d39b3690602001610875565b600054610100900460ff16610e455760005460ff1615610e49565b303b155b610eac5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016109b9565b600054610100900460ff16158015610ece576000805461ffff19166101011790555b610ed783610ac3565b610edf611d69565b60058054610100600160a81b0319166101006001600160a01b038516021790558015610f11576000805461ff00191690555b505050565b600160046000828254610f299190614fb5565b909155505060045460035460ff1615610f545760405162461bcd60e51b81526004016109b990614cf7565b601654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b158015610f9957600080fd5b505afa158015610fad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd1919061472e565b90506000610fe18787878561218b565b90506110018d8d8d8d858e8e90610ff891906150d5565b60008b8a6125bb565b505060045481146110245760405162461bcd60e51b81526004016109b990614d54565b5050505050505050505050565b611039611ee6565b60165460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f916004808301926020929190829003018186803b15801561107e57600080fd5b505afa158015611092573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b691906142b2565b90506001600160a01b0381161561116e5760055461010090046001600160a01b031663095ea7b382846110ea5760006110ee565b6000195b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561113457600080fd5b505af1158015611148573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116c919061458a565b505b60158054831515600160a01b0260ff60a01b199091161790556040517fb76eab56cfa3088dda43a9a4b3ea4bb7685b8007428d4a65248fdaa763d339f8906111bb90841515815260200190565b60405180910390a15050565b6001546001600160a01b0316331461123f5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b60648201526084016109b9565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6112cc611ee6565b600188116113145760405162461bcd60e51b81526020600482015260156024820152746d696e203220636861696e6564206d61726b65747360581b60448201526064016109b9565b600e80546001600160401b038b8116600160401b026fffffffffffffffffffffffffffffffff19909216908d1617179055600c889055600d879055600f86905560108590556011849055601383905561136f6017838361408f565b507ff286a7833e5a7fc3330b62b2ca952b0ab1e44791f67a465649f7da03516da2368a8a8a8a8a8a8a8a8a8a6040516113b19a99989796959493929190614e70565b60405180910390a150505050505050505050565b6001600460008282546113d89190614fb5565b909155505060045460035460ff16156114035760405162461bcd60e51b81526004016109b990614cf7565b601654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b15801561144857600080fd5b505afa15801561145c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611480919061472e565b905061149d8a8a8a8a8a6114948a8c6150d5565b60018a896125bb565b5060045481146114bf5760405162461bcd60e51b81526004016109b990614d54565b505050505050505050565b6060610abc60088484611fc5565b6114e0611ee6565b6114e983610bf7565b6115055760405162461bcd60e51b81526004016109b990614cce565b610f118383838080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509250612e29915050565b6001600160a01b0381166000908152600b60205260409020606090610ab9908585611fc5565b6016546040805163366843a560e21b815290516000926001600160a01b03169163d9a10e94916004808301926020929190829003018186803b1580156115ad57600080fd5b505afa1580156115c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e591906142b2565b60405162d9267b60e31b81523360048201529091506001600160a01b038216906306c933d89060240160206040518083038186803b15801561162657600080fd5b505afa15801561163a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165e919061458a565b6116a55760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b60448201526064016109b9565b6116b0848484611f60565b50505050565b6116be611ee6565b6001600160a01b0381166117065760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b60448201526064016109b9565b600154600160a81b900460ff16156117565760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b60448201526064016109b9565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610875565b601781815481106117df57600080fd5b600091825260209091200154905081565b6117f8611ee6565b6005546118149061010090046001600160a01b031683836132ba565b604080516001600160a01b0384168152602081018390527fc3ce4eeef579533b0a2d7ae2e50eb68dccae3b183dc8cce60267f3c9fa4935c091016111bb565b6001600460008282546118669190614fb5565b909155505060045460035460ff16156118915760405162461bcd60e51b81526004016109b990614cf7565b6000866001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b1580156118cc57600080fd5b505afa1580156118e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190491906142b2565b9050336001600160a01b0382161461195e5760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c7920616c6c6f7765642066726f6d206d61726b6574206f776e6572000060448201526064016109b9565b6005546040516370a0823160e01b81526001600160a01b038381166004830152600092610100900416906370a082319060240160206040518083038186803b1580156119a957600080fd5b505afa1580156119bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e191906145a6565b90506119f6886119f1888a61504e565b61331d565b6005546040516370a0823160e01b81526001600160a01b0384811660048301526000928492610100909104909116906370a082319060240160206040518083038186803b158015611a4657600080fd5b505afa158015611a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7e91906145a6565b611a889190615037565b600554909150611aa89061010090046001600160a01b031684308461391f565b8015611cca5760165460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f916004808301926020929190829003018186803b158015611af357600080fd5b505afa158015611b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2b91906142b2565b90508515611c2a5760405163b45e98d960e01b8152600481018390526000906001600160a01b0383169063b45e98d990602401602060405180830381600087803b158015611b7857600080fd5b505af1158015611b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb091906145a6565b60405190915085906000906001600160a01b0383169084156108fc0290859084818181858888f19350505050905080611c225760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b60448201526064016109b9565b505050611cc8565b604051630992646d60e31b81526001600160a01b0388811660048301526024820184905260009190831690634c93236890604401602060405180830381600087803b158015611c7857600080fd5b505af1158015611c8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb091906145a6565b9050611cc66001600160a01b03891686836132ba565b505b505b5050506004548114610a8b5760405162461bcd60e51b81526004016109b990614d54565b6060610abc60068484611fc5565b600160046000828254611d0f9190614fb5565b909155505060045460035460ff1615611d3a5760405162461bcd60e51b81526004016109b990614cf7565b611d48846119f1848661504e565b60045481146116b05760405162461bcd60e51b81526004016109b990614d54565b60055460ff1615611db25760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016109b9565b6005805460ff19166001908117909155600455565b600160046000828254611dda9190614fb5565b909155505060045460035460ff1615611e055760405162461bcd60e51b81526004016109b990614cf7565b60005b84811015611ebd57611e338686838181106109f057634e487b7160e01b600052603260045260246000fd5b15611eab57611eab868683818110611e5b57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611e709190614296565b858584818110611e9057634e487b7160e01b600052603260045260246000fd5b9050602002810190611ea29190614ef3565b6119f19161504e565b80611eb58161510e565b915050611e08565b506004548114611edf5760405162461bcd60e51b81526004016109b990614d54565b5050505050565b6000546201000090046001600160a01b03163314611f5e5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b60648201526084016109b9565b565b611f6983610bf7565b611f855760405162461bcd60e51b81526004016109b990614cce565b610f118383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525060019250612e29915050565b60606000611fd38385614fb5565b8554909150811115611fe3575083545b838111612000575050604080516000815260208101909152610abc565b600061200c8583615037565b90506000816001600160401b0381111561203657634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561205f578160200160208202803683370190505b50905060005b828110156120fe57876120788883614fb5565b8154811061209657634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168282815181106120d457634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152806120f68161510e565b915050612065565b509695505050505050565b815460009061211a57506000610d02565b6001600160a01b0382166000908152600184016020526040902054801515806121835750826001600160a01b03168460000160008154811061216c57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b949350505050565b601554600090600160a01b900460ff166121f25760405162461bcd60e51b815260206004820152602260248201527f4d756c7469636f6c6c61746572616c206f6e72616d70206e6f7420656e61626c604482015261195960f21b60648201526084016109b9565b6005546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a082319060240160206040518083038186803b15801561223b57600080fd5b505afa15801561224f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227391906145a6565b60608401519091506000851561230657604051631321b85d60e01b8152600481018890526001600160a01b03831690631321b85d9089906024016020604051808303818588803b1580156122c657600080fd5b505af11580156122da573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906122ff91906145a6565b9050612423565b61231b6001600160a01b03891633308a61391f565b60405163095ea7b360e01b81526001600160a01b0383811660048301526024820189905289169063095ea7b390604401602060405180830381600087803b15801561236557600080fd5b505af1158015612379573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239d919061458a565b506040516322ceb11360e21b81526001600160a01b03898116600483015260248201899052831690638b3ac44c90604401602060405180830381600087803b1580156123e857600080fd5b505af11580156123fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061242091906145a6565b90505b60008560a001519050670de0b6b3a7640000816001600160a01b031663d69fb6686040518163ffffffff1660e01b815260040160206040518083038186803b15801561246e57600080fd5b505afa158015612482573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a691906145a6565b6124b890670de0b6b3a7640000615037565b6124c29084615018565b6124cc9190614ff8565b6005546040516370a0823160e01b8152306004820152919650600091869161010090046001600160a01b0316906370a082319060240160206040518083038186803b15801561251a57600080fd5b505afa15801561252e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061255291906145a6565b61255c9190615037565b9050858110156125ae5760405162461bcd60e51b815260206004820152601e60248201527f6e6f7420656e6f75676820726563656976656420766961206f6e72616d70000060448201526064016109b9565b5050505050949350505050565b61261f6040805160808082018352600080835260208084018290528451928301855281835282018190528184018190526060820152909182019081526040805160808101825260008082526020828101829052928201819052606082015291015290565b60a0820151604051630ac0f68f60e21b8152600481018c90526001600160a01b0390911690632b03da3c9060240160806040518083038186803b15801561266557600080fd5b505afa158015612679573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061269d91906147d7565b60608201819052516126ea5760405162461bcd60e51b8152602060048201526016602482015275105cdcd95d081a5cc81b9bdd081cdd5c1c1bdc9d195960521b60448201526064016109b9565b600f5486101580156126fe57506010548611155b6127405760405162461bcd60e51b815260206004820152601360248201527215dc9bdb99c8189d5e481a5b88185b5bdd5b9d606a1b60448201526064016109b9565b600e546001600160401b03908116908a16108015906127755750600e546001600160401b03600160401b9091048116908a1611155b6127b45760405162461bcd60e51b815260206004820152601060248201526f57726f6e672074696d65206672616d6560801b60448201526064016109b9565b600c5487108015906127c85750600d548711155b6128145760405162461bcd60e51b815260206004820152601a60248201527f57726f6e67206e756d626572206f6620646972656374696f6e7300000000000060448201526064016109b9565b600c546017906128279060ff8a16615037565b8154811061284557634e487b7160e01b600052603260045260246000fd5b600091825260209182902001549082018190526128659087908990613957565b80825260115410156128ab5760405162461bcd60e51b815260206004820152600f60248201526e0a0e4deccd2e840e8dede40d0d2ced608b1b60448201526064016109b9565b80516128b8908790615037565b601460008282546128c99190614fb5565b909155505060135460145411156129155760405162461bcd60e51b815260206004820152601060248201526f4f7574206f66206c697175696469747960801b60448201526064016109b9565b608082015160405163d47eed4560e01b81526001600160a01b039091169063ef9e5e2890829063d47eed459061294f908a90600401614bb7565b60206040518083038186803b15801561296757600080fd5b505afa15801561297b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299f91906145a6565b876040518363ffffffff1660e01b81526004016129bc9190614bb7565b6000604051808303818588803b1580156129d557600080fd5b505af11580156129e9573d6000803e3d6000fd5b50505060808401516060840151602001516040516396834ad360e01b81526001600160a01b0390921693506396834ad39250612a2b9160040190815260200190565b60806040518083038186803b158015612a4357600080fd5b505afa158015612a57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7b919061484a565b604082018190526060808301518101519101514291612aa5916001600160401b0390911690614fb5565b118015612abd5750600081604001516000015160070b135b612af75760405162461bcd60e51b815260206004820152600b60248201526a5374616c6520707269636560a81b60448201526064016109b9565b8315612b5a576000670de0b6b3a7640000826060015160400151670de0b6b3a7640000612b249190614fb5565b612b2e9089615018565b612b389190614ff8565b600554909150612b589061010090046001600160a01b031633308461391f565b505b601554600090612b72906001600160a01b03166139a2565b9050806001600160a01b031663e0f51a5f604051806101600160405280306001600160a01b03168152602001336001600160a01b031681526020018e81526020018d6001600160401b031681526020018d6001600160401b031642612bd79190614fb5565b6001600160401b031681526020018c8c90508e6001600160401b0316612bfd9190615018565b612c079042614fb5565b6001600160401b0316815260200185604001516000015160070b81526020018c8c8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060208082018c90526060808801516040908101518185015291880151920191909152516001600160e01b031960e084901b168152612c9d9190600401614d8b565b600060405180830381600087803b158015612cb757600080fd5b505af1158015612ccb573d6000803e3d6000fd5b50508351600554612cee935061010090046001600160a01b0316915083906132ba565b612d02848884606001516040015186613a3f565b50612d0e600682613cbe565b336000908152600a60205260409020612d279082613cbe565b60408301516001600160a01b031615612da15760408084015190516302c7739b60e01b8152336004820152602481018990526001600160a01b03909116906302c7739b90604401600060405180830381600087803b158015612d8857600080fd5b505af1158015612d9c573d6000803e3d6000fd5b505050505b7fd061c182aaa319a32c4cb7717e176ffddabdf9a1d7f1dc1e5d8296ffc9eead1d81338d8d612dd98d6001600160401b038316615018565b612de39042614fb5565b8760400151600001518f8f8f8b602001518c6060015160400151604051612e149b9a99989796959493929190614abc565b60405180910390a15050505050505050505050565b60405163089eec6760e21b81526001600160a01b0384169063227bb19c90612e579085908590600401614c3c565b600060405180830381600087803b158015612e7157600080fd5b505af1158015612e85573d6000803e3d6000fd5b50505050826001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015612ec257600080fd5b505afa158015612ed6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612efa919061458a565b1561320057612f0a600684613d11565b612f15600884613cbe565b6000836001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b158015612f5057600080fd5b505afa158015612f64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f8891906142b2565b6001600160a01b0381166000908152600a60205260409020909150612fad9085612109565b15612fd4576001600160a01b0381166000908152600a60205260409020612fd49085613d11565b6001600160a01b0381166000908152600b60205260409020612ff69085613cbe565b6000846001600160a01b0316631fcc8bb26040518163ffffffff1660e01b815260040160206040518083038186803b15801561303157600080fd5b505afa158015613045573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061306991906145a6565b9050600061315882876001600160a01b031663e004b5bf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156130aa57600080fd5b505afa1580156130be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e29190614996565b886001600160a01b0316635c8127376040518163ffffffff1660e01b815260040160206040518083038186803b15801561311b57600080fd5b505afa15801561312f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315391906145a6565b613957565b9050856001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b15801561319357600080fd5b505afa1580156131a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cb919061458a565b6131fc578060145411156131f65780601460008282546131eb9190615037565b909155506131fc9050565b60006014555b5050505b7fe1ed361a9267ee898f74c2ae2b43810623c3ff7fbafed1bf79c651e5122bbd5283846001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b15801561325b57600080fd5b505afa15801561326f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613293919061458a565b604080516001600160a01b03909316835290151560208301520160405180910390a1505050565b6040516001600160a01b038316602482015260448101829052610f1190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613e94565b61332682610bf7565b6133425760405162461bcd60e51b81526004016109b990614cce565b601654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b15801561338757600080fd5b505afa15801561339b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133bf919061472e565b60a0810151604080516001808252818301909252929350909160009160208083019080368337019050509050816001600160a01b031663bd47a9b8866001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561343357600080fd5b505afa158015613447573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061346b91906145a6565b6040518263ffffffff1660e01b815260040161348991815260200190565b60206040518083038186803b1580156134a157600080fd5b505afa1580156134b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134d991906145a6565b816000815181106134fa57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050600084516001600160401b0381111561352f57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613558578160200160208202803683370190505b5090506000805b865181101561390957876001600160a01b0316638b13b64b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156135a157600080fd5b505afa1580156135b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d991906148d6565b6135ec906001600160401b031682615018565b886001600160a01b03166320c1bb466040518163ffffffff1660e01b815260040160206040518083038186803b15801561362557600080fd5b505afa158015613639573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061365d91906148d6565b6136679190614fcd565b91506000866080015190506000816001600160a01b0316634716e9c5836001600160a01b031663d47eed458c87815181106136b257634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b81526004016136d69190614bb7565b60206040518083038186803b1580156136ee57600080fd5b505afa158015613702573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372691906145a6565b8b868151811061374657634e487b7160e01b600052603260045260246000fd5b602002602001015189888c6001600160a01b031663cf898ca96040518163ffffffff1660e01b815260040160206040518083038186803b15801561378957600080fd5b505afa15801561379d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c191906148d6565b6137cb908b614fcd565b6040518663ffffffff1660e01b81526004016137ea9493929190614bca565b6000604051808303818588803b15801561380357600080fd5b505af1158015613817573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052613840919081019061449e565b905060008160008151811061386557634e487b7160e01b600052603260045260246000fd5b60200260200101516020015190506000816000015160070b136138ba5760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420707269636560981b60448201526064016109b9565b80600001518685815181106138df57634e487b7160e01b600052603260045260246000fd5b602002602001019060070b908160070b8152505050505080806139019061510e565b91505061355f565b5061391687836000612e29565b50505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526116b09085906323b872dd60e01b906084016132e6565b8260005b8360ff168160ff16101561399a57670de0b6b3a764000061397c8484615018565b6139869190614ff8565b91508061399281615129565b91505061395b565b509392505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b038116613a3a5760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b60448201526064016109b9565b919050565b60208101516000906001600160a01b03811615613c6f5760006001600160a01b03871615613ad05760405163bbddaca360e01b81526001600160a01b03888116600483015233602483015283169063bbddaca390604401600060405180830381600087803b158015613ab057600080fd5b505af1158015613ac4573d6000803e3d6000fd5b50505050869050613b4a565b604051639ca423b360e01b81523360048201526001600160a01b03831690639ca423b39060240160206040518083038186803b158015613b0f57600080fd5b505afa158015613b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b4791906142b2565b90505b6001600160a01b03811615613c6d5760405163c7d1f5f160e01b81526001600160a01b0382811660048301526000919084169063c7d1f5f19060240160206040518083038186803b158015613b9e57600080fd5b505afa158015613bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd691906145a6565b90508015613c6b57670de0b6b3a7640000613bf18289615018565b613bfb9190614ff8565b600554909450613c1a9061010090046001600160a01b031683866132ba565b604080516001600160a01b0384168152336020820152908101859052606081018890527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b505b8251613cb59083670de0b6b3a7640000613c89888a615018565b613c939190614ff8565b613c9d9190615037565b60055461010090046001600160a01b031691906132ba565b50949350505050565b613cc88282612109565b613d0d5781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555b5050565b613d1b8282612109565b613d5d5760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b60448201526064016109b9565b6001600160a01b0381166000908152600180840160205260408220548454909291613d8791615037565b9050808214613e2f576000846000018281548110613db557634e487b7160e01b600052603260045260246000fd5b60009182526020909120015485546001600160a01b0390911691508190869085908110613df257634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080613e4e57634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b6000613ee9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613f669092919063ffffffff16565b805190915015610f115780806020019051810190613f07919061458a565b610f115760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109b9565b6060610ab9848460008585843b613fbf5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109b9565b600080866001600160a01b03168587604051613fdb9190614aa0565b60006040518083038185875af1925050503d8060008114614018576040519150601f19603f3d011682016040523d82523d6000602084013e61401d565b606091505b509150915061402d828286614038565b979650505050505050565b60608315614047575081610abc565b8251156140575782518084602001fd5b8160405162461bcd60e51b81526004016109b99190614cbb565b60405180608001604052806004906020820280368337509192915050565b8280548282559060005260206000209081019282156140ca579160200282015b828111156140ca5782358255916020019190600101906140af565b506140d69291506140da565b5090565b5b808211156140d657600081556001016140db565b60006141026140fd84614f92565b614f62565b9050808382526020808301915083868660051b8601111561412257600080fd5b60005b868110156141b65781356001600160401b038082111561414457600080fd5b8188019150601f8a8184011261415957600080fd5b82358281111561416b5761416b61515f565b61417c818301601f19168801614f62565b92508083528b8782860101111561419257600080fd5b80878501888501376000908301870152508552509282019290820190600101614125565b505050509392505050565b60008083601f8401126141d2578182fd5b5081356001600160401b038111156141e8578182fd5b6020830191508360208260051b850101111561420357600080fd5b9250929050565b60006080828403121561421b578081fd5b604051608081018181106001600160401b038211171561423d5761423d61515f565b806040525080915082518060070b811461425657600080fd5b8152602083015161426681615198565b60208201526040830151600381900b811461428057600080fd5b6040820152606092830151920191909152919050565b6000602082840312156142a7578081fd5b8135610abc81615175565b6000602082840312156142c3578081fd5b8151610abc81615175565b6000806000604084860312156142e2578182fd5b83356142ed81615175565b925060208401356001600160401b03811115614307578283fd5b614313868287016141c1565b9497909650939450505050565b600080600080600060808688031215614337578283fd5b853561434281615175565b945060208601356001600160401b0381111561435c578384fd5b614368888289016141c1565b909550935050604086013561437c81615175565b9150606086013561438c8161518a565b809150509295509295909350565b6000806000604084860312156143ae578081fd5b83356143b981615175565b925060208401356001600160401b03811115614307578182fd5b600080604083850312156143e5578182fd5b82356143f081615175565b9150602083013561440081615175565b809150509250929050565b6000806040838503121561441d578182fd5b823561442881615175565b946020939093013593505050565b6000806000806040858703121561444b578182fd5b84356001600160401b0380821115614461578384fd5b61446d888389016141c1565b90965094506020870135915080821115614485578384fd5b50614492878288016141c1565b95989497509550505050565b600060208083850312156144b0578182fd5b82516001600160401b038111156144c5578283fd5b8301601f810185136144d5578283fd5b80516144e36140fd82614f92565b81815283810190838501610120808502860187018a1015614502578788fd5b8795505b848610156145605780828b03121561451c578788fd5b614524614f3a565b825181526145348b89850161420a565b888201526145458b60a0850161420a565b60408201528452600195909501949286019290810190614506565b509098975050505050505050565b60006020828403121561457f578081fd5b8135610abc8161518a565b60006020828403121561459b578081fd5b8151610abc8161518a565b6000602082840312156145b7578081fd5b5051919050565b6000806000806000806000806000806101008b8d0312156145dd578788fd5b8a35995060208b01356145ef81615198565b985060408b01356001600160401b038082111561460a57898afd5b6146168e838f016141c1565b909a50985060608d013591508082111561462e578687fd5b5061463b8d828e016141c1565b90975095505060808b013561464f81615175565b935060a08b0135925060c08b01356146668161518a565b915060e08b013561467681615175565b809150509295989b9194979a5092959850565b60008060008060008060008060c0898b0312156146a4578182fd5b8835975060208901356146b681615198565b965060408901356001600160401b03808211156146d1578384fd5b6146dd8c838d016141c1565b909850965060608b0135955060808b01359150808211156146fc578384fd5b506147098b828c016141c1565b90945092505060a089013561471d81615175565b809150509295985092959890939650565b600060c0828403121561473f578081fd5b60405160c081018181106001600160401b03821117156147615761476161515f565b604052825161476f81615175565b8152602083015161477f81615175565b6020820152604083015161479281615175565b604082015260608301516147a581615175565b606082015260808301516147b881615175565b608082015260a08301516147cb81615175565b60a08201529392505050565b6000608082840312156147e8578081fd5b604051608081018181106001600160401b038211171561480a5761480a61515f565b60405282516148188161518a565b808252506020830151602082015260408301516040820152606083015161483e81615198565b60608201529392505050565b60006080828403121561485b578081fd5b610abc838361420a565b600060208284031215614876578081fd5b5035919050565b6000806040838503121561488f578182fd5b50508035926020909101359150565b6000806000606084860312156148b2578081fd5b833592506020840135915060408401356148cb81615175565b809150509250925092565b6000602082840312156148e7578081fd5b8151610abc81615198565b6000806000806000806000806000806101208b8d031215614911578384fd5b8a3561491c81615198565b995060208b013561492c81615198565b985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b0135935060e08b013592506101008b01356001600160401b03811115614971578283fd5b61497d8d828e016141c1565b915080935050809150509295989b9194979a5092959850565b6000602082840312156149a7578081fd5b815160ff81168114610abc578182fd5b6000600282106149d557634e487b7160e01b81526021600452602481fd5b50815260200190565b600082825180855260208086019550808260051b840101818601855b84811015614a2857601f19868403018952614a16838351614a74565b988401989250908301906001016149fa565b5090979650505050505050565b6000815180845260208085019450808401835b83811015614a6957614a5b8783516149b7565b965090820190600101614a48565b509495945050505050565b60008151808452614a8c8160208601602086016150e2565b601f01601f19169290920160200192915050565b60008251614ab28184602087016150e2565b9190910192915050565b6001600160a01b038c811682528b166020820152604081018a90526001600160401b03898116606083015288166080820152600787900b60a082015261014060c0820181905281018590526000866101608301825b88811015614b4357823560028110614b27578485fd5b614b3183826149b7565b60209490940193925050600101614b11565b5060e084019690965250506101008101929092526101209091015298975050505050505050565b6020808252825182820181905260009190848201906040850190845b81811015614bab5783516001600160a01b031683529284019291840191600101614b86565b50909695505050505050565b602081526000610abc60208301846149de565b608081526000614bdd60808301876149de565b828103602084810191909152865180835287820192820190845b81811015614c1357845183529383019391830191600101614bf7565b50506001600160401b039687166040860152949095166060909301929092525090949350505050565b604080825283519082018190526000906020906060840190828701845b82811015614c7857815160070b84529284019290840190600101614c59565b50505093151592019190915250919050565b60808101818360005b6004811015614cb2578151835260209283019290910190600101614c93565b50505092915050565b602081526000610abc6020830184614a74565b6020808252600f908201526e43616e206e6f74207265736f6c766560881b604082015260600190565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208152614da56020820183516001600160a01b03169052565b60006020830151614dc160408401826001600160a01b03169052565b50604083015160608301526060830151614de660808401826001600160401b03169052565b5060808301516001600160401b03811660a08401525060a08301516001600160401b03811660c08401525060c0830151614e2560e084018260070b9052565b5060e08301516101606101008181860152614e44610180860184614a35565b908601516101208681019190915286015161014080870191909152909501519301929092525090919050565b60006101206001600160401b03808e168452808d166020850152508a60408401528960608401528860808401528760a08401528660c08401528560e08401528061010084015283818401525061014060018060fb1b03841115614ed1578182fd5b8360051b808683860137929092019091019081529a9950505050505050505050565b6000808335601e19843603018112614f09578283fd5b8301803591506001600160401b03821115614f22578283fd5b6020019150600581901b360382131561420357600080fd5b604051606081016001600160401b0381118282101715614f5c57614f5c61515f565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614f8a57614f8a61515f565b604052919050565b60006001600160401b03821115614fab57614fab61515f565b5060051b60200190565b60008219821115614fc857614fc8615149565b500190565b60006001600160401b03808316818516808303821115614fef57614fef615149565b01949350505050565b60008261501357634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561503257615032615149565b500290565b60008282101561504957615049615149565b500390565b600061505c6140fd84614f92565b808482526020808301925084368760051b87011115615079578485fd5b845b878110156150c95781356001600160401b03811115615098578687fd5b870136601f8201126150a8578687fd5b6150b63682358684016140ef565b865250938201939082019060010161507b565b50919695505050505050565b6000610abc3684846140ef565b60005b838110156150fd5781810151838201526020016150e5565b838111156116b05750506000910152565b600060001982141561512257615122615149565b5060010190565b600060ff821660ff81141561514057615140615149565b60010192915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610dd157600080fd5b8015158114610dd157600080fd5b6001600160401b0381168114610dd157600080fdfea2646970667358221220bb13557568426e21dea53ec6120422ee17f4677a6fd44d57dc02a706d847be3664736f6c63430008040033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading