Contract 0xaeded2b52830f2433e9f8c9cb162890d921bd2c9

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

Contract Overview

Balance:
Txn Hash Method
Block
From
To
Value
0x12c2b22e73651aa6ff90f0274f046d74a5dec8668385e908197f03213d0d29220x60806040192128612023-12-29 12:43:10146 days 16 hrs ago0xd866b2332d4383c1bf719732177e2d9109c99dbc IN  Create: SpeedMarketsAMM0 ETH0.0000000525590.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:
SpeedMarketsAMM

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 25 : SpeedMarketsAMM.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/IAddressManager.sol";
import "../interfaces/ISpeedMarketsAMM.sol";

import "./SpeedMarket.sol";
import "./SpeedMarketsAMMUtils.sol";

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

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

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

    IERC20Upgradeable public sUSD;

    address public speedMarketMastercopy;

    uint public safeBoxImpact;
    uint public lpFee;

    address private safeBox; // unused, moved to AddressManager

    mapping(bytes32 => bool) public supportedAsset;

    uint public minimalTimeToMaturity;
    uint public maximalTimeToMaturity;

    uint public minBuyinAmount;
    uint public maxBuyinAmount;

    mapping(bytes32 => uint) public maxRiskPerAsset;
    mapping(bytes32 => uint) public currentRiskPerAsset;

    mapping(bytes32 => bytes32) public assetToPythId;

    IPyth private pyth; // unused, moved to AddressManager

    uint64 public maximumPriceDelay;

    IStakingThales private stakingThales; // unused, moved to AddressManager

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

    mapping(address => bool) public whitelistedAddresses;
    IMultiCollateralOnOffRamp private multiCollateralOnOffRamp; // unused, moved to AddressManager
    bool public multicollateralEnabled;

    mapping(bytes32 => mapping(SpeedMarket.Direction => uint)) public maxRiskPerAssetAndDirection;
    mapping(bytes32 => mapping(SpeedMarket.Direction => uint)) public currentRiskPerAssetAndDirection;

    uint64 public maximumPriceDelayForResolving;

    mapping(address => bool) public marketHasCreatedAtAttribute;

    address private referrals; // unused, moved to AddressManager

    uint[] public timeThresholdsForFees;
    uint[] public lpFees;

    SpeedMarketsAMMUtils private speedMarketsAMMUtils;

    mapping(address => bool) public marketHasFeeAttribute;

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

    uint public maxSkewImpact;
    uint private constant SKEW_SLIPPAGE = 1e16;

    // using this to solve stack too deep
    struct TempData {
        uint lpFeeWithSkew;
        PythStructs.Price pythPrice;
    }

    receive() external payable {}

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

    /// @notice create new market for given strike time, in case it is zero delta time is used
    function createNewMarket(
        bytes32 asset,
        uint64 strikeTime,
        uint64 delta,
        SpeedMarket.Direction direction,
        uint buyinAmount,
        bytes[] calldata priceUpdateData,
        address referrer,
        uint skewImpact
    ) external payable nonReentrant notPaused {
        IAddressManager.Addresses memory contractsAddresses = addressManager.getAddresses();
        _createNewMarket(
            asset,
            strikeTime == 0 ? uint64(block.timestamp + delta) : strikeTime,
            direction,
            buyinAmount,
            priceUpdateData,
            true,
            referrer,
            skewImpact,
            contractsAddresses
        );
    }

    /// @notice create new market with different collateral (not sUSD) for a given strike time, in case it is zero delta time is used
    function createNewMarketWithDifferentCollateral(
        bytes32 asset,
        uint64 strikeTime,
        uint64 delta,
        SpeedMarket.Direction direction,
        bytes[] calldata priceUpdateData,
        address collateral,
        uint collateralAmount,
        bool isEth,
        address referrer,
        uint skewImpact
    ) external payable nonReentrant notPaused {
        _createNewMarketWithDifferentCollateral(
            asset,
            strikeTime == 0 ? uint64(block.timestamp + delta) : strikeTime,
            direction,
            priceUpdateData,
            collateral,
            collateralAmount,
            isEth,
            referrer,
            skewImpact
        );
    }

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

        IMultiCollateralOnOffRamp iMultiCollateralOnOffRamp = IMultiCollateralOnOffRamp(
            contractsAddresses.multiCollateralOnOffRamp
        );

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

        uint lpFeeForDeltaTime = speedMarketsAMMUtils.getFeeByTimeThreshold(
            uint64(strikeTime - block.timestamp),
            timeThresholdsForFees,
            lpFees,
            lpFee
        );

        buyinAmount = (convertedAmount * ONE) / (ONE + safeBoxImpact + lpFeeForDeltaTime);

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

    function _createNewMarketWithDifferentCollateral(
        bytes32 asset,
        uint64 strikeTime,
        SpeedMarket.Direction direction,
        bytes[] calldata priceUpdateData,
        address collateral,
        uint collateralAmount,
        bool isEth,
        address referrer,
        uint skewImpact
    ) internal {
        IAddressManager.Addresses memory contractsAddresses = addressManager.getAddresses();
        uint buyinAmount = _getBuyinWithConversion(collateral, collateralAmount, isEth, strikeTime, contractsAddresses);
        _createNewMarket(
            asset,
            strikeTime,
            direction,
            buyinAmount,
            priceUpdateData,
            false,
            referrer,
            skewImpact,
            contractsAddresses
        );
    }

    function _getSkewByAssetAndDirection(bytes32 _asset, SpeedMarket.Direction _direction) internal view returns (uint) {
        return
            (((currentRiskPerAssetAndDirection[_asset][_direction] * ONE) /
                maxRiskPerAssetAndDirection[_asset][_direction]) * maxSkewImpact) / ONE;
    }

    function _handleRiskAndGetFee(
        bytes32 asset,
        SpeedMarket.Direction direction,
        uint buyinAmount,
        uint64 strikeTime,
        uint skewImpact
    ) internal returns (uint lpFeeWithSkew) {
        uint skew = _getSkewByAssetAndDirection(asset, direction);
        require(skew <= skewImpact + SKEW_SLIPPAGE, "Skew slippage exceeded");

        SpeedMarket.Direction oppositeDirection = direction == SpeedMarket.Direction.Up
            ? SpeedMarket.Direction.Down
            : SpeedMarket.Direction.Up;

        // calculate discount as half of skew for opposite direction
        uint discount = skew == 0 ? _getSkewByAssetAndDirection(asset, oppositeDirection) / 2 : 0;

        // decrease risk for opposite directionif there is, otherwise increase risk for current direction
        if (currentRiskPerAssetAndDirection[asset][oppositeDirection] > buyinAmount) {
            currentRiskPerAssetAndDirection[asset][oppositeDirection] -= buyinAmount;
        } else {
            currentRiskPerAssetAndDirection[asset][direction] +=
                buyinAmount -
                currentRiskPerAssetAndDirection[asset][oppositeDirection];
            currentRiskPerAssetAndDirection[asset][oppositeDirection] = 0;
            require(
                currentRiskPerAssetAndDirection[asset][direction] <= maxRiskPerAssetAndDirection[asset][direction],
                "Risk per direction exceeded"
            );
        }

        // LP fee by delta time + skew impact based on risk per direction and asset - discount as half of opposite skew
        lpFeeWithSkew =
            speedMarketsAMMUtils.getFeeByTimeThreshold(
                uint64(strikeTime - block.timestamp),
                timeThresholdsForFees,
                lpFees,
                lpFee
            ) +
            skew -
            discount;

        currentRiskPerAsset[asset] += (buyinAmount * 2 - (buyinAmount * (ONE + lpFeeWithSkew)) / ONE);
        require(currentRiskPerAsset[asset] <= maxRiskPerAsset[asset], "Risk per asset exceeded");
    }

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

            if (newOrExistingReferrer != address(0)) {
                uint referrerFeeByTier = iReferrals.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 strikeTime,
        SpeedMarket.Direction direction,
        uint buyinAmount,
        bytes[] memory priceUpdateData,
        bool transferSusd,
        address referrer,
        uint skewImpact,
        IAddressManager.Addresses memory contractsAddresses
    ) internal {
        require(supportedAsset[asset], "Asset is not supported");
        require(buyinAmount >= minBuyinAmount && buyinAmount <= maxBuyinAmount, "Wrong buy in amount");
        require(strikeTime >= (block.timestamp + minimalTimeToMaturity), "Strike time not alloowed");
        require(strikeTime <= block.timestamp + maximalTimeToMaturity, "Time too far into the future");

        TempData memory tempData;
        tempData.lpFeeWithSkew = _handleRiskAndGetFee(asset, direction, buyinAmount, strikeTime, skewImpact);

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

        tempData.pythPrice = iPyth.getPriceUnsafe(assetToPythId[asset]);

        require(
            (tempData.pythPrice.publishTime + maximumPriceDelay) > block.timestamp && tempData.pythPrice.price > 0,
            "Stale price"
        );

        if (transferSusd) {
            uint totalAmountToTransfer = (buyinAmount * (ONE + safeBoxImpact + tempData.lpFeeWithSkew)) / ONE;
            sUSD.safeTransferFrom(msg.sender, address(this), totalAmountToTransfer);
        }
        SpeedMarket srm = SpeedMarket(Clones.clone(speedMarketMastercopy));
        srm.initialize(
            SpeedMarket.InitParams(
                address(this),
                msg.sender,
                asset,
                strikeTime,
                tempData.pythPrice.price,
                direction,
                buyinAmount,
                safeBoxImpact,
                tempData.lpFeeWithSkew
            )
        );

        sUSD.safeTransfer(address(srm), buyinAmount * 2);

        _handleReferrerAndSafeBox(referrer, buyinAmount, contractsAddresses);

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

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

        marketHasCreatedAtAttribute[address(srm)] = true;
        marketHasFeeAttribute[address(srm)] = true;
        emit MarketCreated(address(srm), msg.sender, asset, strikeTime, tempData.pythPrice.price, direction, buyinAmount);
        emit MarketCreatedWithFees(
            address(srm),
            msg.sender,
            asset,
            strikeTime,
            tempData.pythPrice.price,
            direction,
            buyinAmount,
            safeBoxImpact,
            tempData.lpFeeWithSkew
        );
    }

    /// @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 resolveMarket 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 {
        require(multicollateralEnabled, "Multicollateral offramp not enabled");
        address user = SpeedMarket(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 iMultiCollateralOnOffRamp = IMultiCollateralOnOffRamp(
                addressManager.multiCollateralOnOffRamp()
            );
            if (toEth) {
                uint offramped = iMultiCollateralOnOffRamp.offrampIntoEth(amountDiff);
                address payable _to = payable(user);
                bool sent = _to.send(offramped);
                require(sent, "Failed to send Ether");
            } else {
                uint offramped = iMultiCollateralOnOffRamp.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])) {
                bytes[] memory subarray = new bytes[](1);
                subarray[0] = priceUpdateData[i];
                _resolveMarket(markets[i], subarray);
            }
        }
    }

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

        IPyth iPyth = IPyth(addressManager.pyth());
        bytes32[] memory priceIds = new bytes32[](1);
        priceIds[0] = assetToPythId[SpeedMarket(market).asset()];
        PythStructs.PriceFeed[] memory prices = iPyth.parsePriceFeedUpdates{value: iPyth.getUpdateFee(priceUpdateData)}(
            priceUpdateData,
            priceIds,
            SpeedMarket(market).strikeTime(),
            SpeedMarket(market).strikeTime() + maximumPriceDelayForResolving
        );

        PythStructs.Price memory price = prices[0].price;

        require(price.price > 0, "Invalid price");

        _resolveMarketWithPrice(market, price.price);
    }

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

    /// @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]);
            }
        }
    }

    /// @notice owner can resolve market for a given market address with finalPrice
    function resolveMarketAsOwner(address _market, int64 _finalPrice) external onlyOwner {
        require(canResolveMarket(_market), "Can not resolve");
        _resolveMarketWithPrice(_market, _finalPrice);
    }

    function _resolveMarketManually(address _market, int64 _finalPrice) internal {
        SpeedMarket.Direction direction = SpeedMarket(_market).direction();
        int64 strikePrice = SpeedMarket(_market).strikePrice();
        bool isUserWinner = (_finalPrice < strikePrice && direction == SpeedMarket.Direction.Down) ||
            (_finalPrice > strikePrice && direction == SpeedMarket.Direction.Up);
        require(canResolveMarket(_market) && !isUserWinner, "Can not resolve manually");
        _resolveMarketWithPrice(_market, _finalPrice);
    }

    function _resolveMarketWithPrice(address market, int64 _finalPrice) internal {
        SpeedMarket(market).resolve(_finalPrice);
        _activeMarkets.remove(market);
        _maturedMarkets.add(market);
        address user = SpeedMarket(market).user();

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

        bytes32 asset = SpeedMarket(market).asset();
        uint buyinAmount = SpeedMarket(market).buyinAmount();
        SpeedMarket.Direction direction = SpeedMarket(market).direction();

        if (currentRiskPerAssetAndDirection[asset][direction] > buyinAmount) {
            currentRiskPerAssetAndDirection[asset][direction] -= buyinAmount;
        } else {
            currentRiskPerAssetAndDirection[asset][direction] = 0;
        }

        if (!SpeedMarket(market).isUserWinner()) {
            if (currentRiskPerAsset[asset] > 2 * buyinAmount) {
                currentRiskPerAsset[asset] -= (2 * buyinAmount);
            } else {
                currentRiskPerAsset[asset] = 0;
            }
        }

        emit MarketResolved(market, SpeedMarket(market).result(), SpeedMarket(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) &&
            (SpeedMarket(market).strikeTime() < block.timestamp) &&
            !SpeedMarket(market).resolved();
    }

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

    /// @notice get parmas for create market
    function getParams(bytes32 asset) external view returns (ISpeedMarketsAMM.Params memory) {
        ISpeedMarketsAMM.Params memory params;
        params.supportedAsset = supportedAsset[asset];
        params.pythId = assetToPythId[asset];
        params.safeBoxImpact = safeBoxImpact;
        params.maximumPriceDelay = maximumPriceDelay;
        return params;
    }

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

    /// @notice Set addresses used in AMM
    /// @param _mastercopy to use to create markets
    /// @param _speedMarketsAMMUtils address of speed markets AMM utils
    /// @param _addressManager address manager contract
    function setAMMAddresses(
        address _mastercopy,
        SpeedMarketsAMMUtils _speedMarketsAMMUtils,
        address _addressManager
    ) external onlyOwner {
        speedMarketMastercopy = _mastercopy;
        speedMarketsAMMUtils = _speedMarketsAMMUtils;
        addressManager = IAddressManager(_addressManager);
        emit AMMAddressesChanged(_mastercopy, _speedMarketsAMMUtils, _addressManager);
    }

    /// @notice Set parameters for limits
    function setLimitParams(
        uint _minBuyinAmount,
        uint _maxBuyinAmount,
        uint _minimalTimeToMaturity,
        uint _maximalTimeToMaturity,
        uint64 _maximumPriceDelay,
        uint64 _maximumPriceDelayForResolving
    ) external onlyOwner {
        minBuyinAmount = _minBuyinAmount;
        maxBuyinAmount = _maxBuyinAmount;
        minimalTimeToMaturity = _minimalTimeToMaturity;
        maximalTimeToMaturity = _maximalTimeToMaturity;
        maximumPriceDelay = _maximumPriceDelay;
        maximumPriceDelayForResolving = _maximumPriceDelayForResolving;
        emit LimitParamsChanged(
            _minBuyinAmount,
            _maxBuyinAmount,
            _minimalTimeToMaturity,
            _maximalTimeToMaturity,
            _maximumPriceDelay,
            _maximumPriceDelayForResolving
        );
    }

    /// @notice maximum risk per asset and per asset and direction
    function setMaxRisks(
        bytes32 asset,
        uint _maxRiskPerAsset,
        uint _maxRiskPerAssetAndDirection
    ) external onlyOwner {
        maxRiskPerAsset[asset] = _maxRiskPerAsset;
        currentRiskPerAsset[asset] = 0; // TODO: this can be removed with next upgrade
        maxRiskPerAssetAndDirection[asset][SpeedMarket.Direction.Up] = _maxRiskPerAssetAndDirection;
        maxRiskPerAssetAndDirection[asset][SpeedMarket.Direction.Down] = _maxRiskPerAssetAndDirection;
        emit SetMaxRisks(asset, _maxRiskPerAsset, _maxRiskPerAssetAndDirection);
    }

    /// @notice set SafeBox and max skew impact
    /// @param _safeBoxImpact skew impact
    /// @param _maxSkewImpact skew impact
    function setSafeBoxAndMaxSkewImpact(uint _safeBoxImpact, uint _maxSkewImpact) external onlyOwner {
        safeBoxImpact = _safeBoxImpact;
        maxSkewImpact = _maxSkewImpact;
        emit SafeBoxAndMaxSkewImpactChanged(_safeBoxImpact, _maxSkewImpact);
    }

    /// @notice set LP fee params
    /// @param _timeThresholds array of time thresholds (minutes) for different fees in ascending order
    /// @param _lpFees array of fees applied to each time frame defined in _timeThresholds
    /// @param _lpFee default LP fee when there are no dynamic fees
    function setLPFeeParams(
        uint[] calldata _timeThresholds,
        uint[] calldata _lpFees,
        uint _lpFee
    ) external onlyOwner {
        require(_timeThresholds.length == _lpFees.length, "Times and fees must have the same length");
        delete timeThresholdsForFees;
        delete lpFees;
        for (uint i = 0; i < _timeThresholds.length; i++) {
            timeThresholdsForFees.push(_timeThresholds[i]);
            lpFees.push(_lpFees[i]);
        }
        lpFee = _lpFee;
        emit SetLPFeeParams(_timeThresholds, _lpFees, _lpFee);
    }

    /// @notice set whether an asset is supported
    function setSupportedAsset(bytes32 asset, bool _supported) external onlyOwner {
        supportedAsset[asset] = _supported;
        emit SetSupportedAsset(asset, _supported);
    }

    /// @notice map asset to PythID, e.g. "ETH" as bytes 32 to an equivalent ID from pyth docs
    function setAssetToPythID(bytes32 asset, bytes32 pythId) external onlyOwner {
        assetToPythId[asset] = pythId;
        emit SetAssetToPythID(asset, pythId);
    }

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

    /// @notice adding/removing whitelist address depending on a flag
    /// @param _whitelistAddress address that needed to be whitelisted/ ore removed from WL
    /// @param _flag adding or removing from whitelist (true: add, false: remove)
    function addToWhitelist(address _whitelistAddress, bool _flag) external onlyOwner {
        require(_whitelistAddress != address(0));
        whitelistedAddresses[_whitelistAddress] = _flag;
        emit AddedIntoWhitelist(_whitelistAddress, _flag);
    }

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

    modifier isAddressWhitelisted() {
        require(whitelistedAddresses[msg.sender], "Resolver not whitelisted");
        _;
    }

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

    event MarketCreated(
        address _market,
        address _user,
        bytes32 _asset,
        uint _strikeTime,
        int64 _strikePrice,
        SpeedMarket.Direction _direction,
        uint _buyinAmount
    );
    event MarketCreatedWithFees(
        address _market,
        address _user,
        bytes32 _asset,
        uint _strikeTime,
        int64 _strikePrice,
        SpeedMarket.Direction _direction,
        uint _buyinAmount,
        uint _safeBoxImpact,
        uint _lpFee
    );

    event MarketResolved(address _market, SpeedMarket.Direction _result, bool _userIsWinner);

    event AMMAddressesChanged(address _mastercopy, SpeedMarketsAMMUtils _speedMarketsAMMUtils, address _addressManager);
    event LimitParamsChanged(
        uint _minBuyinAmount,
        uint _maxBuyinAmount,
        uint _minimalTimeToMaturity,
        uint _maximalTimeToMaturity,
        uint _maximumPriceDelay,
        uint _maximumPriceDelayForResolving
    );
    event SetMaxRisks(bytes32 asset, uint _maxRiskPerAsset, uint _maxRiskPerAssetAndDirection);
    event SafeBoxAndMaxSkewImpactChanged(uint _safeBoxImpact, uint _maxSkewImpact);
    event SetLPFeeParams(uint[] _timeThresholds, uint[] _lpFees, uint _lpFee);
    event SetSupportedAsset(bytes32 asset, bool _supported);
    event SetAssetToPythID(bytes32 asset, bytes32 pythId);
    event AddedIntoWhitelist(address _whitelistAddress, bool _flag);
    event MultiCollateralOnOffRampEnabled(bool _enabled);
    event ReferrerPaid(address refferer, address trader, uint amount, uint volume);
    event AmountTransfered(address _destination, uint _amount);
}

File 2 of 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 20 of 25 : 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 21 of 25 : 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 25 : SpeedMarketsAMMUtils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title An AMM utils for Thales speed markets
contract SpeedMarketsAMMUtils {
    uint private constant SECONDS_PER_MINUTE = 60;

    /// @notice get dynamic fee based on defined time thresholds for a given delta time
    /// @param _deltaTimeSec to search for appropriate time range (in seconds)
    /// @param _timeThresholds array of time thresholds for each fee (in minutes)
    /// @param _fees array of fees for every time range
    /// @param _defaultFee if _deltaTime doesn't have appropriate time range return this value
    /// @return fee defined for specific time range to which _deltaTime belongs to
    function getFeeByTimeThreshold(
        uint64 _deltaTimeSec,
        uint[] calldata _timeThresholds,
        uint[] calldata _fees,
        uint _defaultFee
    ) external pure returns (uint fee) {
        fee = _defaultFee;
        uint _deltaTime = _deltaTimeSec / SECONDS_PER_MINUTE;
        for (uint i = _timeThresholds.length; i > 0; i--) {
            if (_deltaTime >= _timeThresholds[i - 1]) {
                fee = _fees[i - 1];
                break;
            }
        }
    }
}

File 23 of 25 : 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 25 : 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 25 : 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);
}

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":"_mastercopy","type":"address"},{"indexed":false,"internalType":"contract SpeedMarketsAMMUtils","name":"_speedMarketsAMMUtils","type":"address"},{"indexed":false,"internalType":"address","name":"_addressManager","type":"address"}],"name":"AMMAddressesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_whitelistAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"_flag","type":"bool"}],"name":"AddedIntoWhitelist","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":"uint256","name":"_minBuyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxBuyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minimalTimeToMaturity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maximalTimeToMaturity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maximumPriceDelay","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maximumPriceDelayForResolving","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":"uint256","name":"_strikeTime","type":"uint256"},{"indexed":false,"internalType":"int64","name":"_strikePrice","type":"int64"},{"indexed":false,"internalType":"enum SpeedMarket.Direction","name":"_direction","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"_buyinAmount","type":"uint256"}],"name":"MarketCreated","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":"uint256","name":"_strikeTime","type":"uint256"},{"indexed":false,"internalType":"int64","name":"_strikePrice","type":"int64"},{"indexed":false,"internalType":"enum SpeedMarket.Direction","name":"_direction","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"_buyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lpFee","type":"uint256"}],"name":"MarketCreatedWithFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_market","type":"address"},{"indexed":false,"internalType":"enum SpeedMarket.Direction","name":"_result","type":"uint8"},{"indexed":false,"internalType":"bool","name":"_userIsWinner","type":"bool"}],"name":"MarketResolved","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxSkewImpact","type":"uint256"}],"name":"SafeBoxAndMaxSkewImpactChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"pythId","type":"bytes32"}],"name":"SetAssetToPythID","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"_timeThresholds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"_lpFees","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"_lpFee","type":"uint256"}],"name":"SetLPFeeParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_maxRiskPerAsset","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxRiskPerAssetAndDirection","type":"uint256"}],"name":"SetMaxRisks","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"_supported","type":"bool"}],"name":"SetSupportedAsset","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":[{"internalType":"address","name":"_whitelistAddress","type":"address"},{"internalType":"bool","name":"_flag","type":"bool"}],"name":"addToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addressManager","outputs":[{"internalType":"contract IAddressManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"assetToPythId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"canResolveMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"strikeTime","type":"uint64"},{"internalType":"uint64","name":"delta","type":"uint64"},{"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"internalType":"uint256","name":"buyinAmount","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint256","name":"skewImpact","type":"uint256"}],"name":"createNewMarket","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"strikeTime","type":"uint64"},{"internalType":"uint64","name":"delta","type":"uint64"},{"internalType":"enum SpeedMarket.Direction","name":"direction","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"},{"internalType":"uint256","name":"skewImpact","type":"uint256"}],"name":"createNewMarketWithDifferentCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"currentRiskPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"enum SpeedMarket.Direction","name":"","type":"uint8"}],"name":"currentRiskPerAssetAndDirection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getLengths","outputs":[{"internalType":"uint256[5]","name":"","type":"uint256[5]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"}],"name":"getParams","outputs":[{"components":[{"internalType":"bool","name":"supportedAsset","type":"bool"},{"internalType":"bytes32","name":"pythId","type":"bytes32"},{"internalType":"uint256","name":"safeBoxImpact","type":"uint256"},{"internalType":"uint64","name":"maximumPriceDelay","type":"uint64"}],"internalType":"struct ISpeedMarketsAMM.Params","name":"","type":"tuple"}],"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":[],"name":"lpFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lpFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"marketHasCreatedAtAttribute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"marketHasFeeAttribute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"maxRiskPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"enum SpeedMarket.Direction","name":"","type":"uint8"}],"name":"maxRiskPerAssetAndDirection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSkewImpact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximalTimeToMaturity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumPriceDelay","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumPriceDelayForResolving","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":"minimalTimeToMaturity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"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":"_finalPrice","type":"int64"}],"name":"resolveMarketAsOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"int64","name":"_finalPrice","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":[],"name":"safeBoxImpact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_mastercopy","type":"address"},{"internalType":"contract SpeedMarketsAMMUtils","name":"_speedMarketsAMMUtils","type":"address"},{"internalType":"address","name":"_addressManager","type":"address"}],"name":"setAMMAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"bytes32","name":"pythId","type":"bytes32"}],"name":"setAssetToPythID","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_timeThresholds","type":"uint256[]"},{"internalType":"uint256[]","name":"_lpFees","type":"uint256[]"},{"internalType":"uint256","name":"_lpFee","type":"uint256"}],"name":"setLPFeeParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minBuyinAmount","type":"uint256"},{"internalType":"uint256","name":"_maxBuyinAmount","type":"uint256"},{"internalType":"uint256","name":"_minimalTimeToMaturity","type":"uint256"},{"internalType":"uint256","name":"_maximalTimeToMaturity","type":"uint256"},{"internalType":"uint64","name":"_maximumPriceDelay","type":"uint64"},{"internalType":"uint64","name":"_maximumPriceDelayForResolving","type":"uint64"}],"name":"setLimitParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint256","name":"_maxRiskPerAsset","type":"uint256"},{"internalType":"uint256","name":"_maxRiskPerAssetAndDirection","type":"uint256"}],"name":"setMaxRisks","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":"uint256","name":"_safeBoxImpact","type":"uint256"},{"internalType":"uint256","name":"_maxSkewImpact","type":"uint256"}],"name":"setSafeBoxAndMaxSkewImpact","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"bool","name":"_supported","type":"bool"}],"name":"setSupportedAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"speedMarketMastercopy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"supportedAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"timeThresholdsForFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b50615e1980620000216000396000f3fe60806040526004361061039b5760003560e01c806389c6318d116101dc578063caab6cb711610102578063e396ed26116100a0578063ebc797721161006f578063ebc7977214610bc2578063ef469ba214610bd7578063f8335cde14610bf7578063fd6e9b9714610c1757600080fd5b8063e396ed2614610b2f578063e60a4d2514610b5f578063e73efc9b14610b8c578063e915586614610bac57600080fd5b8063d69fb668116100dc578063d69fb66814610aae578063d7081e0314610ac4578063da6b532f14610ae4578063e11f951d14610af757600080fd5b8063caab6cb714610a5b578063ce87e2ee14610a6e578063cf898ca914610a8e57600080fd5b8063a3a2adf01161017a578063bc93233f11610149578063bc93233f146109c1578063bd47a9b8146109e1578063c3b83f5f14610a0e578063c453180214610a2e57600080fd5b8063a3a2adf01461095b578063a87730c31461096e578063a8da1a1714610981578063b711d407146109a157600080fd5b80639324cac7116101b65780639324cac7146108bb57806399c18e7e146108db5780639fc42703146108fc578063a201b3071461091c57600080fd5b806389c6318d1461085f5780638da5cb5b1461087f57806391b4ded9146108a557600080fd5b80633ab76e9f116102c15780635403f80f1161025f5780636bfffb121161022e5780636bfffb12146107f4578063704ce43e1461081457806379ba50971461082a5780637de926d11461083f57600080fd5b80635403f80f146107845780635631bf8a1461079a5780635c975abb146107ba57806368b9f66b146107d457600080fd5b8063485cc9551161029b578063485cc955146107045780634d6e8c6e146107245780634eb7c43b1461074457806353a47bb71461076457600080fd5b80633ab76e9f146106965780633b46bfc9146106ce5780633e7ad1de146106ee57600080fd5b806313af40351161033957806317b94eac1161030857806317b94eac146105695780632b03da3c1461057c5780632c43dc831461065657806330a1ea011461067657600080fd5b806313af4035146104e757806314527f3a146105095780631627540c1461052957806316c38b3c1461054957600080fd5b806306c933d81161037557806306c933d81461045e57806307b53bb41461048e57806312039b6d146104a457806312aa3833146104d157600080fd5b806301bea636146103a7578063023fb259146103eb57806305bfdfd41461041857600080fd5b366103a257005b600080fd5b3480156103b357600080fd5b506103d66103c2366004614e2f565b602080526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156103f757600080fd5b5061040b610406366004614e2f565b610c47565b6040516103e29190615906565b34801561042457600080fd5b50610450610433366004615294565b601e60209081526000928352604080842090915290825290205481565b6040519081526020016103e2565b34801561046a57600080fd5b506103d6610479366004614e2f565b601b6020526000908152604090205460ff1681565b34801561049a57600080fd5b5061045060135481565b3480156104b057600080fd5b506104c46104bf366004615571565b610ca2565b6040516103e29190615834565b3480156104dd57600080fd5b5061045060125481565b3480156104f357600080fd5b50610507610502366004614e2f565b610cd2565b005b34801561051557600080fd5b506103d6610524366004614e2f565b610e12565b34801561053557600080fd5b50610507610544366004614e2f565b610f23565b34801561055557600080fd5b506105076105643660046151e7565b610f79565b610507610577366004614e67565b610fef565b34801561058857600080fd5b5061061861059736600461521f565b604080516080808201835260008083526020808401829052838501829052606093840182905284519283018552818352828101828152838601838152948401838152878452600f83528684205460ff1615158552968352601690915293902054909252600c549052601754600160a01b90046001600160401b031690915290565b6040516103e2919081511515815260208083015190820152604080830151908201526060918201516001600160401b03169181019190915260800190565b34801561066257600080fd5b5061050761067136600461503a565b611067565b34801561068257600080fd5b50610507610691366004614fe2565b611194565b3480156106a257600080fd5b506026546106b6906001600160a01b031681565b6040516001600160a01b0390911681526020016103e2565b3480156106da57600080fd5b506105076106e936600461559e565b6111f1565b3480156106fa57600080fd5b5061045060105481565b34801561071057600080fd5b5061050761071f366004614f6b565b6112ae565b34801561073057600080fd5b5061050761073f366004615273565b611395565b34801561075057600080fd5b5061045061075f36600461521f565b6113e5565b34801561077057600080fd5b506001546106b6906001600160a01b031681565b34801561079057600080fd5b5061045060115481565b3480156107a657600080fd5b506104506107b536600461521f565b611406565b3480156107c657600080fd5b506003546103d69060ff1681565b3480156107e057600080fd5b506105076107ef3660046151e7565b611416565b34801561080057600080fd5b5061050761080f366004614f98565b61159b565b34801561082057600080fd5b50610450600d5481565b34801561083657600080fd5b50610507611628565b34801561084b57600080fd5b5061050761085a36600461524f565b611725565b34801561086b57600080fd5b506104c461087a366004615273565b61177f565b34801561088b57600080fd5b506000546106b6906201000090046001600160a01b031681565b3480156108b157600080fd5b5061045060025481565b3480156108c757600080fd5b50600a546106b6906001600160a01b031681565b3480156108e757600080fd5b50601c546103d690600160a01b900460ff1681565b34801561090857600080fd5b506104c4610917366004615571565b61178d565b34801561092857600080fd5b5060175461094390600160a01b90046001600160401b031681565b6040516001600160401b0390911681526020016103e2565b61050761096936600461503a565b6117b3565b61050761097c3660046152e3565b611959565b34801561098d57600080fd5b5061050761099c366004614fe2565b6119ff565b3480156109ad57600080fd5b506105076109bc366004615177565b611a63565b3480156109cd57600080fd5b506105076109dc366004614f33565b611bd5565b3480156109ed57600080fd5b506104506109fc36600461521f565b60166020526000908152604090205481565b348015610a1a57600080fd5b50610507610a29366004614e2f565b611c4c565b348015610a3a57600080fd5b50610450610a4936600461521f565b60146020526000908152604090205481565b610507610a693660046153b0565b611d65565b348015610a7a57600080fd5b50600b546106b6906001600160a01b031681565b348015610a9a57600080fd5b50601f54610943906001600160401b031681565b348015610aba57600080fd5b50610450600c5481565b348015610ad057600080fd5b50610507610adf36600461500f565b611e92565b610507610af2366004614eb9565b611ef0565b348015610b0357600080fd5b50610450610b12366004615294565b601d60209081526000928352604080842090915290825290205481565b348015610b3b57600080fd5b506103d6610b4a36600461521f565b600f6020526000908152604090205460ff1681565b348015610b6b57600080fd5b50610450610b7a36600461521f565b60156020526000908152604090205481565b348015610b9857600080fd5b506104c4610ba7366004615273565b6123e2565b348015610bb857600080fd5b5061045060275481565b348015610bce57600080fd5b506105076123f0565b348015610be357600080fd5b50610507610bf23660046152b8565b61244e565b348015610c0357600080fd5b50610507610c12366004615273565b6124cc565b348015610c2357600080fd5b506103d6610c32366004614e2f565b60256020526000908152604090205460ff1681565b610c4f614caf565b506040805160a08101825260065481526008546020808301919091526001600160a01b039093166000818152601985528381205483850152908152601a9093529120546060820152602354608082015290565b6001600160a01b0381166000908152601960205260409020606090610cc890858561251c565b90505b9392505050565b6001600160a01b038116610d2d5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610d995760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610d24565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b6000610e1f600683612660565b8015610ea3575042826001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e6057600080fd5b505afa158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9891906155fb565b6001600160401b0316105b8015610f1d5750816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015610ee357600080fd5b505afa158015610ef7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1b9190615203565b155b92915050565b610f2b6126e2565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610e07565b610f816126e2565b60035460ff1615158115151415610f955750565b6003805460ff191682151590811790915560ff1615610fb357426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610e07565b50565b6001600460008282546110029190615bbe565b909155505060045460035460ff161561102d5760405162461bcd60e51b8152600401610d2490615984565b6110408461103b8486615c57565b61275c565b60045481146110615760405162461bcd60e51b8152600401610d24906159e1565b50505050565b336000908152601b602052604090205460ff166110c15760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610d24565b60005b8381101561118d576111048585838181106110ef57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906105249190614e2f565b1561117b5761117b85858381811061112c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111419190614e2f565b84848481811061116157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111769190615475565b612b7e565b8061118581615d48565b9150506110c4565b5050505050565b61119c6126e2565b6111a582610e12565b6111e35760405162461bcd60e51b815260206004820152600f60248201526e43616e206e6f74207265736f6c766560881b6044820152606401610d24565b6111ed8282612d3f565b5050565b6111f96126e2565b60128690556013859055601084905560118390556017805467ffffffffffffffff60a01b1916600160a01b6001600160401b0385811691820292909217909255601f805467ffffffffffffffff19169184169182179055604080518981526020810189905290810187905260608101869052608081019290925260a08201527fcb4727945d0c9bf77ea3b48c6c630e5b0e5016c1fe67c9508feafe8fc265cdba9060c0015b60405180910390a1505050505050565b600054610100900460ff166112c95760005460ff16156112cd565b303b155b6113305760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610d24565b600054610100900460ff16158015611352576000805461ffff19166101011790555b61135b83610cd2565b6113636123f0565b600a80546001600160a01b0319166001600160a01b0384161790558015611390576000805461ff00191690555b505050565b61139d6126e2565b600c829055602781905560408051838152602081018390527f8804a85a7ad3ea6e27f776005d85bfafeb449428ffd674719eccfdd9a1b0631791015b60405180910390a15050565b602381815481106113f557600080fd5b600091825260209091200154905081565b602281815481106113f557600080fd5b61141e6126e2565b60265460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f916004808301926020929190829003018186803b15801561146357600080fd5b505afa158015611477573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061149b9190614e4b565b90506001600160a01b0381161561154e57600a546001600160a01b031663095ea7b382846114ca5760006114ce565b6000195b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561151457600080fd5b505af1158015611528573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154c9190615203565b505b601c8054831515600160a01b0260ff60a01b199091161790556040517fb76eab56cfa3088dda43a9a4b3ea4bb7685b8007428d4a65248fdaa763d339f8906113d990841515815260200190565b6115a36126e2565b600b80546001600160a01b038581166001600160a01b0319928316811790935560248054868316908416811790915560268054928616929093168217909255604080519384526020840192909252908201527fbf934b81354c7e34eda71aa08a74419a5682a0737282cc3f448b353a1893c41f906060015b60405180910390a1505050565b6001546001600160a01b031633146116a05760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610d24565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b61172d6126e2565b6000828152600f6020908152604091829020805460ff19168415159081179091558251858152918201527f6af8d0ea20290a2d8dcbb43a77926d5993cd89bac2c6a72cd7813c4eacc2124b91016113d9565b6060610ccb6008848461251c565b6001600160a01b0381166000908152601a60205260409020606090610cc890858561251c565b6001600460008282546117c69190615bbe565b909155505060045460035460ff16156117f15760405162461bcd60e51b8152600401610d2490615984565b60005b848110156119375761181f8686838181106110ef57634e487b7160e01b600052603260045260246000fd5b1561192557604080516001808252818301909252600091816020015b606081526020019060019003908161183b57905050905084848381811061187257634e487b7160e01b600052603260045260246000fd5b90506020028101906118849190615aff565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052508551869450909250151590506118da57634e487b7160e01b600052603260045260246000fd5b602002602001018190525061192387878481811061190857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061191d9190614e2f565b8261275c565b505b8061192f81615d48565b9150506117f4565b50600454811461118d5760405162461bcd60e51b8152600401610d24906159e1565b60016004600082825461196c9190615bbe565b909155505060045460035460ff16156119975760405162461bcd60e51b8152600401610d2490615984565b6119d08c6001600160401b038d16156119b0578c6119c3565b6119c36001600160401b038d1642615bbe565b8b8b8b8b8b8b8b8b613324565b60045481146119f15760405162461bcd60e51b8152600401610d24906159e1565b505050505050505050505050565b336000908152601b602052604090205460ff16611a595760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610d24565b6111ed8282612b7e565b611a6b6126e2565b838214611acb5760405162461bcd60e51b815260206004820152602860248201527f54696d657320616e642066656573206d7573742068617665207468652073616d6044820152670ca40d8cadccee8d60c31b6064820152608401610d24565b611ad760226000614ccd565b611ae360236000614ccd565b60005b84811015611b88576022868683818110611b1057634e487b7160e01b600052603260045260246000fd5b835460018101855560009485526020948590209190940292909201359190920155506023848483818110611b5457634e487b7160e01b600052603260045260246000fd5b8354600181018555600094855260209485902091909402929092013591909201555080611b8081615d48565b915050611ae6565b50600d8190556040517f97b8e3f33b113d945b11628418dc7b155d05943a8a517a937a9d88f4eda67a6b90611bc69087908790879087908790615937565b60405180910390a15050505050565b611bdd6126e2565b6001600160a01b038216611bf057600080fd5b6001600160a01b0382166000818152601b6020908152604091829020805460ff19168515159081179091558251938452908301527f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd91016113d9565b611c546126e2565b6001600160a01b038116611c9c5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610d24565b600154600160a81b900460ff1615611cec5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610d24565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610e07565b600160046000828254611d789190615bbe565b909155505060045460035460ff1615611da35760405162461bcd60e51b8152600401610d2490615984565b602654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b158015611de857600080fd5b505afa158015611dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2091906154ad565b9050611e648b6001600160401b038c1615611e3b578b611e4e565b611e4e6001600160401b038c1642615bbe565b8a8a611e5a8a8c615c57565b60018a8a896133cb565b506004548114611e865760405162461bcd60e51b8152600401610d24906159e1565b50505050505050505050565b611e9a6126e2565b600a54611eb1906001600160a01b03168383613a90565b604080516001600160a01b0384168152602081018390527fc3ce4eeef579533b0a2d7ae2e50eb68dccae3b183dc8cce60267f3c9fa4935c091016113d9565b600160046000828254611f039190615bbe565b909155505060045460035460ff1615611f2e5760405162461bcd60e51b8152600401610d2490615984565b601c54600160a01b900460ff16611f935760405162461bcd60e51b815260206004820152602360248201527f4d756c7469636f6c6c61746572616c206f666672616d70206e6f7420656e61626044820152621b195960ea1b6064820152608401610d24565b6000866001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b158015611fce57600080fd5b505afa158015611fe2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120069190614e4b565b9050336001600160a01b038216146120605760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c7920616c6c6f7765642066726f6d206d61726b6574206f776e657200006044820152606401610d24565b600a546040516370a0823160e01b81526001600160a01b03838116600483015260009216906370a082319060240160206040518083038186803b1580156120a657600080fd5b505afa1580156120ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120de9190615237565b90506120ee8861103b888a615c57565b600a546040516370a0823160e01b81526001600160a01b03848116600483015260009284929116906370a082319060240160206040518083038186803b15801561213757600080fd5b505afa15801561214b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216f9190615237565b6121799190615c40565b600a54909150612194906001600160a01b0316843084613af3565b80156123b65760265460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f916004808301926020929190829003018186803b1580156121df57600080fd5b505afa1580156121f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122179190614e4b565b905085156123165760405163b45e98d960e01b8152600481018390526000906001600160a01b0383169063b45e98d990602401602060405180830381600087803b15801561226457600080fd5b505af1158015612278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229c9190615237565b60405190915085906000906001600160a01b0383169084156108fc0290859084818181858888f1935050505090508061230e5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610d24565b5050506123b4565b604051630992646d60e31b81526001600160a01b0388811660048301526024820184905260009190831690634c93236890604401602060405180830381600087803b15801561236457600080fd5b505af1158015612378573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239c9190615237565b90506123b26001600160a01b0389168683613a90565b505b505b50505060045481146123da5760405162461bcd60e51b8152600401610d24906159e1565b505050505050565b6060610ccb6006848461251c565b60055460ff16156124395760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610d24565b6005805460ff19166001908117909155600455565b6124566126e2565b600083815260146020908152604080832085905560158252808320839055601d82528083208380528252808320849055600183529182902083905581518581529081018490529081018290527facbec488a49aaa9d1b3799159ede0349850bc1a73c0e90913ff03dd4354a34a89060600161161b565b6124d46126e2565b60008281526016602090815260409182902083905581518481529081018390527fbe9b5564f6075c4b92cab3a707053c7e8828f045a5d233c3157bc3407cb0096391016113d9565b6060600061252a8385615bbe565b855490915081111561253a575083545b838111612557575050604080516000815260208101909152610ccb565b60006125638583615c40565b90506000816001600160401b0381111561258d57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156125b6578160200160208202803683370190505b50905060005b8281101561265557876125cf8883615bbe565b815481106125ed57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682828151811061262b57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101528061264d81615d48565b9150506125bc565b509695505050505050565b815460009061267157506000610f1d565b6001600160a01b0382166000908152600184016020526040902054801515806126da5750826001600160a01b0316846000016000815481106126c357634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b949350505050565b6000546201000090046001600160a01b0316331461275a5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610d24565b565b61276582610e12565b6127a35760405162461bcd60e51b815260206004820152600f60248201526e43616e206e6f74207265736f6c766560881b6044820152606401610d24565b60265460408051630f98d06f60e41b815290516000926001600160a01b03169163f98d06f0916004808301926020929190829003018186803b1580156127e857600080fd5b505afa1580156127fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128209190614e4b565b604080516001808252818301909252919250600091906020808301908036833701905050905060166000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561288357600080fd5b505afa158015612897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128bb9190615237565b815260200190815260200160002054816000815181106128eb57634e487b7160e01b600052603260045260246000fd5b602090810291909101015260405163d47eed4560e01b81526000906001600160a01b03841690634716e9c590829063d47eed459061292d908990600401615881565b60206040518083038186803b15801561294557600080fd5b505afa158015612959573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297d9190615237565b8685896001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156129b857600080fd5b505afa1580156129cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129f091906155fb565b601f60009054906101000a90046001600160401b03168b6001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b158015612a3f57600080fd5b505afa158015612a53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7791906155fb565b612a819190615bd6565b6040518663ffffffff1660e01b8152600401612aa09493929190615894565b6000604051808303818588803b158015612ab957600080fd5b505af1158015612acd573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052612af691908101906150a2565b9050600081600081518110612b1b57634e487b7160e01b600052603260045260246000fd5b60200260200101516020015190506000816000015160070b13612b705760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606401610d24565b6123da868260000151612d3f565b6000826001600160a01b031663645539ed6040518163ffffffff1660e01b815260040160206040518083038186803b158015612bb957600080fd5b505afa158015612bcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bf19190615459565b90506000836001600160a01b031663c52987cf6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c2e57600080fd5b505afa158015612c42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c669190615491565b905060008160070b8460070b128015612c9e57506001836001811115612c9c57634e487b7160e01b600052602160045260246000fd5b145b80612cd857508160070b8460070b138015612cd857506000836001811115612cd657634e487b7160e01b600052602160045260246000fd5b145b9050612ce385610e12565b8015612ced575080155b612d395760405162461bcd60e51b815260206004820152601860248201527f43616e206e6f74207265736f6c7665206d616e75616c6c7900000000000000006044820152606401610d24565b61118d85855b604051631f67c49160e01b8152600782900b60048201526001600160a01b03831690631f67c49190602401600060405180830381600087803b158015612d8457600080fd5b505af1158015612d98573d6000803e3d6000fd5b50505050612db0826006613b2b90919063ffffffff16565b612dbb600883613cae565b6000826001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b158015612df657600080fd5b505afa158015612e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e2e9190614e4b565b6001600160a01b0381166000908152601960205260409020909150612e539084612660565b15612e7a576001600160a01b0381166000908152601960205260409020612e7a9084613b2b565b6001600160a01b0381166000908152601a60205260409020612e9c9084613cae565b6000836001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b158015612ed757600080fd5b505afa158015612eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f0f9190615237565b90506000846001600160a01b0316631fcc8bb26040518163ffffffff1660e01b815260040160206040518083038186803b158015612f4c57600080fd5b505afa158015612f60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f849190615237565b90506000856001600160a01b031663645539ed6040518163ffffffff1660e01b815260040160206040518083038186803b158015612fc157600080fd5b505afa158015612fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ff99190615459565b6000848152601e6020526040812091925083919083600181111561302d57634e487b7160e01b600052602160045260246000fd5b600181111561304c57634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000205411156130d8576000838152601e60205260408120839183600181111561309157634e487b7160e01b600052602160045260246000fd5b60018111156130b057634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060008282546130cd9190615c40565b909155506131389050565b6000838152601e602052604081208183600181111561310757634e487b7160e01b600052602160045260246000fd5b600181111561312657634e487b7160e01b600052602160045260246000fd5b81526020810191909152604001600020555b856001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b15801561317157600080fd5b505afa158015613185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131a99190615203565b613211576131b8826002615c21565b6000848152601560205260409020541115613201576131d8826002615c21565b600084815260156020526040812080549091906131f6908490615c40565b909155506132119050565b6000838152601560205260408120555b7f738ac9ca76b7fd50246d5acdc827b2852e656ed2c287d6538e57b046f0ecf64b86876001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b15801561326c57600080fd5b505afa158015613280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132a49190615459565b886001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b1580156132dd57600080fd5b505afa1580156132f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133159190615203565b60405161129e93929190615807565b602654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b15801561336957600080fd5b505afa15801561337d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a191906154ad565b905060006133b28787878e86613d00565b90506119f18c8c8c846133c58d8f615c57565b60008a8a8a5b6000898152600f602052604090205460ff166134225760405162461bcd60e51b8152602060048201526016602482015275105cdcd95d081a5cc81b9bdd081cdd5c1c1bdc9d195960521b6044820152606401610d24565b601254861015801561343657506013548611155b6134785760405162461bcd60e51b815260206004820152601360248201527215dc9bdb99c8189d5e481a5b88185b5bdd5b9d606a1b6044820152606401610d24565b6010546134859042615bbe565b886001600160401b031610156134dd5760405162461bcd60e51b815260206004820152601860248201527f537472696b652074696d65206e6f7420616c6c6f6f77656400000000000000006044820152606401610d24565b6011546134ea9042615bbe565b886001600160401b031611156135425760405162461bcd60e51b815260206004820152601c60248201527f54696d6520746f6f2066617220696e746f2074686520667574757265000000006044820152606401610d24565b61354a614ceb565b6135578a89898c8761415a565b8152608082015160405163d47eed4560e01b81526001600160a01b0382169063ef9e5e2890829063d47eed4590613592908c90600401615881565b60206040518083038186803b1580156135aa57600080fd5b505afa1580156135be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135e29190615237565b896040518363ffffffff1660e01b81526004016135ff9190615881565b6000604051808303818588803b15801561361857600080fd5b505af115801561362c573d6000803e3d6000fd5b50505060008d815260166020526040908190205490516396834ad360e01b815260048101919091526001600160a01b03841692506396834ad3915060240160806040518083038186803b15801561368257600080fd5b505afa158015613696573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ba9190615556565b6020830181905260175460609091015142916136e791600160a01b9091046001600160401b031690615bbe565b1180156136ff5750600082602001516000015160070b135b6137395760405162461bcd60e51b815260206004820152600b60248201526a5374616c6520707269636560a81b6044820152606401610d24565b8515613796578151600c54600091670de0b6b3a76400009161375b9083615bbe565b6137659190615bbe565b61376f908b615c21565b6137799190615c01565b600a54909150613794906001600160a01b0316333084613af3565b505b600b546000906137ae906001600160a01b03166146ce565b9050806001600160a01b03166358d9d182604051806101200160405280306001600160a01b03168152602001336001600160a01b031681526020018f81526020018e6001600160401b0316815260200186602001516000015160070b81526020018d600181111561382f57634e487b7160e01b600052602160045260246000fd5b81526020018c8152602001600c54815260200186600001518152506040518263ffffffff1660e01b81526004016138669190615a18565b600060405180830381600087803b15801561388057600080fd5b505af1158015613894573d6000803e3d6000fd5b505050506138bc818a60026138a99190615c21565b600a546001600160a01b03169190613a90565b6138c7868a8661476b565b506138d3600682613cae565b3360009081526019602052604090206138ec9082613cae565b60408401516001600160a01b0316156139665760408085015190516302c7739b60e01b8152336004820152602481018b90526001600160a01b03909116906302c7739b90604401600060405180830381600087803b15801561394d57600080fd5b505af1158015613961573d6000803e3d6000fd5b505050505b600160206000836001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600160256000836001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f4fb5dd0be05638074eabb1b37a9bdf9ab8cbad8d83c7bce9298aca16de5b79c381338e8e8760200151600001518f8f604051613a259796959493929190615749565b60405180910390a17f51f385a862a654703b4b7a2e647518a58930354129b8364d5dbe945752df364681338e8e8760200151600001518f8f600c548b60000151604051613a7a999897969594939291906157a0565b60405180910390a1505050505050505050505050565b6040516001600160a01b03831660248201526044810182905261139090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526149d2565b6040516001600160a01b03808516602483015283166044820152606481018290526110619085906323b872dd60e01b90608401613abc565b613b358282612660565b613b775760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b6044820152606401610d24565b6001600160a01b0381166000908152600180840160205260408220548454909291613ba191615c40565b9050808214613c49576000846000018281548110613bcf57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015485546001600160a01b0390911691508190869085908110613c0c57634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080613c6857634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b613cb88282612660565b6111ed5781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b601c54600090600160a01b900460ff16613d675760405162461bcd60e51b815260206004820152602260248201527f4d756c7469636f6c6c61746572616c206f6e72616d70206e6f7420656e61626c604482015261195960f21b6064820152608401610d24565b600a546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015613dab57600080fd5b505afa158015613dbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613de39190615237565b606084015190915060008615613e7657604051631321b85d60e01b8152600481018990526001600160a01b03831690631321b85d908a906024016020604051808303818588803b158015613e3657600080fd5b505af1158015613e4a573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613e6f9190615237565b9050613f93565b613e8b6001600160a01b038a1633308b613af3565b60405163095ea7b360e01b81526001600160a01b038381166004830152602482018a90528a169063095ea7b390604401602060405180830381600087803b158015613ed557600080fd5b505af1158015613ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f0d9190615203565b506040516322ceb11360e21b81526001600160a01b038a81166004830152602482018a9052831690638b3ac44c90604401602060405180830381600087803b158015613f5857600080fd5b505af1158015613f6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f909190615237565b90505b6024546000906001600160a01b031663336ef50d613fba426001600160401b038b16615c40565b60226023600d546040518563ffffffff1660e01b8152600401613fe09493929190615ab9565b60206040518083038186803b158015613ff857600080fd5b505afa15801561400c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140309190615237565b905080600c54670de0b6b3a76400006140499190615bbe565b6140539190615bbe565b614065670de0b6b3a764000084615c21565b61406f9190615c01565b600a546040516370a0823160e01b815230600482015291965060009186916001600160a01b0316906370a082319060240160206040518083038186803b1580156140b857600080fd5b505afa1580156140cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140f09190615237565b6140fa9190615c40565b90508581101561414c5760405162461bcd60e51b815260206004820152601e60248201527f6e6f7420656e6f75676820726563656976656420766961206f6e72616d7000006044820152606401610d24565b505050505095945050505050565b6000806141678787614aa4565b905061417a662386f26fc1000084615bbe565b8111156141c25760405162461bcd60e51b815260206004820152601660248201527514dad95dc81cdb1a5c1c1859d948195e18d95959195960521b6044820152606401610d24565b6000808760018111156141e557634e487b7160e01b600052602160045260246000fd5b146141f15760006141f4565b60015b90506000821561420557600061421b565b60026142118a84614aa4565b61421b9190615c01565b60008a8152601e6020526040812091925088919084600181111561424f57634e487b7160e01b600052602160045260246000fd5b600181111561426e57634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000205411156142fa576000898152601e6020526040812088918460018111156142b357634e487b7160e01b600052602160045260246000fd5b60018111156142d257634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060008282546142ef9190615c40565b909155506145469050565b6000898152601e602052604081209083600181111561432957634e487b7160e01b600052602160045260246000fd5b600181111561434857634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054876143629190615c40565b60008a8152601e60205260408120908a600181111561439157634e487b7160e01b600052602160045260246000fd5b60018111156143b057634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060008282546143cd9190615bbe565b90915550506000898152601e602052604081208184600181111561440157634e487b7160e01b600052602160045260246000fd5b600181111561442057634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002081905550601d60008a8152602001908152602001600020600089600181111561446757634e487b7160e01b600052602160045260246000fd5b600181111561448657634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054601e60008b815260200190815260200160002060008a60018111156144ca57634e487b7160e01b600052602160045260246000fd5b60018111156144e957634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000205411156145465760405162461bcd60e51b815260206004820152601b60248201527f5269736b2070657220646972656374696f6e20657863656564656400000000006044820152606401610d24565b602454819084906001600160a01b031663336ef50d61456e426001600160401b038c16615c40565b60226023600d546040518563ffffffff1660e01b81526004016145949493929190615ab9565b60206040518083038186803b1580156145ac57600080fd5b505afa1580156145c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145e49190615237565b6145ee9190615bbe565b6145f89190615c40565b9350670de0b6b3a764000061460d8582615bbe565b6146179089615c21565b6146219190615c01565b61462c886002615c21565b6146369190615c40565b60008a81526015602052604081208054909190614654908490615bbe565b909155505060008981526014602090815260408083205460159092529091205411156146c25760405162461bcd60e51b815260206004820152601760248201527f5269736b207065722061737365742065786365656465640000000000000000006044820152606401610d24565b50505095945050505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b0381166147665760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610d24565b919050565b60208101516000906001600160a01b038116156149965760006001600160a01b038616156147fc5760405163bbddaca360e01b81526001600160a01b03878116600483015233602483015283169063bbddaca390604401600060405180830381600087803b1580156147dc57600080fd5b505af11580156147f0573d6000803e3d6000fd5b50505050859050614876565b604051639ca423b360e01b81523360048201526001600160a01b03831690639ca423b39060240160206040518083038186803b15801561483b57600080fd5b505afa15801561484f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148739190614e4b565b90505b6001600160a01b038116156149945760405163c7d1f5f160e01b81526001600160a01b0382811660048301526000919084169063c7d1f5f19060240160206040518083038186803b1580156148ca57600080fd5b505afa1580156148de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149029190615237565b9050801561499257670de0b6b3a764000061491d8288615c21565b6149279190615c01565b600a54909450614941906001600160a01b03168386613a90565b604080516001600160a01b0384168152336020820152908101859052606081018790527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b505b6149ca836000015183670de0b6b3a7640000600c54886149b69190615c21565b6149c09190615c01565b6138a99190615c40565b509392505050565b6000614a27826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ba49092919063ffffffff16565b8051909150156113905780806020019051810190614a459190615203565b6113905760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610d24565b6027546000838152601d602052604081209091670de0b6b3a76400009183856001811115614ae257634e487b7160e01b600052602160045260246000fd5b6001811115614b0157634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054670de0b6b3a7640000601e60008881526020019081526020016000206000876001811115614b4e57634e487b7160e01b600052602160045260246000fd5b6001811115614b6d57634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054614b869190615c21565b614b909190615c01565b614b9a9190615c21565b610ccb9190615c01565b6060610cc8848460008585843b614bfd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610d24565b600080866001600160a01b03168587604051614c19919061572d565b60006040518083038185875af1925050503d8060008114614c56576040519150601f19603f3d011682016040523d82523d6000602084013e614c5b565b606091505b5091509150614c6b828286614c76565b979650505050505050565b60608315614c85575081610ccb565b825115614c955782518084602001fd5b8160405162461bcd60e51b8152600401610d249190615971565b6040518060a001604052806005906020820280368337509192915050565b5080546000825590600052602060002090810190610fec9190614d3c565b604051806040016040528060008152602001614d376040518060800160405280600060070b815260200160006001600160401b03168152602001600060030b8152602001600081525090565b905290565b5b80821115614d515760008155600101614d3d565b5090565b803561476681615d8f565b60008083601f840112614d71578182fd5b5081356001600160401b03811115614d87578182fd5b6020830191508360208260051b8501011115614da257600080fd5b9250929050565b600060808284031215614dba578081fd5b604051608081018181106001600160401b0382111715614ddc57614ddc615d79565b80604052508091508251614def81615dbf565b81526020830151614dff81615dce565b60208201526040830151600381900b8114614e1957600080fd5b6040820152606092830151920191909152919050565b600060208284031215614e40578081fd5b8135610ccb81615d8f565b600060208284031215614e5c578081fd5b8151610ccb81615d8f565b600080600060408486031215614e7b578182fd5b8335614e8681615d8f565b925060208401356001600160401b03811115614ea0578283fd5b614eac86828701614d60565b9497909650939450505050565b600080600080600060808688031215614ed0578283fd5b8535614edb81615d8f565b945060208601356001600160401b03811115614ef5578384fd5b614f0188828901614d60565b9095509350506040860135614f1581615d8f565b91506060860135614f2581615da4565b809150509295509295909350565b60008060408385031215614f45578182fd5b8235614f5081615d8f565b91506020830135614f6081615da4565b809150509250929050565b60008060408385031215614f7d578182fd5b8235614f8881615d8f565b91506020830135614f6081615d8f565b600080600060608486031215614fac578081fd5b8335614fb781615d8f565b92506020840135614fc781615d8f565b91506040840135614fd781615d8f565b809150509250925092565b60008060408385031215614ff4578182fd5b8235614fff81615d8f565b91506020830135614f6081615dbf565b60008060408385031215615021578182fd5b823561502c81615d8f565b946020939093013593505050565b6000806000806040858703121561504f578182fd5b84356001600160401b0380821115615065578384fd5b61507188838901614d60565b90965094506020870135915080821115615089578384fd5b5061509687828801614d60565b95989497509550505050565b600060208083850312156150b4578182fd5b82516001600160401b038111156150c9578283fd5b8301601f810185136150d9578283fd5b80516150ec6150e782615b9b565b615b6b565b81815283810190838501610120808502860187018a101561510b578788fd5b8795505b848610156151695780828b031215615125578788fd5b61512d615b43565b8251815261513d8b898501614da9565b8882015261514e8b60a08501614da9565b6040820152845260019590950194928601929081019061510f565b509098975050505050505050565b60008060008060006060868803121561518e578283fd5b85356001600160401b03808211156151a4578485fd5b6151b089838a01614d60565b909750955060208801359150808211156151c8578485fd5b506151d588828901614d60565b96999598509660400135949350505050565b6000602082840312156151f8578081fd5b8135610ccb81615da4565b600060208284031215615214578081fd5b8151610ccb81615da4565b600060208284031215615230578081fd5b5035919050565b600060208284031215615248578081fd5b5051919050565b60008060408385031215615261578182fd5b823591506020830135614f6081615da4565b60008060408385031215615285578182fd5b50508035926020909101359150565b600080604083850312156152a6578182fd5b823591506020830135614f6081615db2565b6000806000606084860312156152cc578081fd5b505081359360208301359350604090920135919050565b60008060008060008060008060008060006101408c8e031215615304578889fd5b8b359a5060208c013561531681615dce565b995060408c013561532681615dce565b985060608c013561533681615db2565b975060808c01356001600160401b03811115615350578687fd5b61535c8e828f01614d60565b90985096505060a08c013561537081615d8f565b945060c08c0135935060e08c013561538781615da4565b92506153966101008d01614d55565b91506101208c013590509295989b509295989b9093969950565b60008060008060008060008060006101008a8c0312156153ce578283fd5b8935985060208a01356153e081615dce565b975060408a01356153f081615dce565b965060608a013561540081615db2565b955060808a0135945060a08a01356001600160401b03811115615421578384fd5b61542d8c828d01614d60565b90955093505060c08a013561544181615d8f565b8092505060e08a013590509295985092959850929598565b60006020828403121561546a578081fd5b8151610ccb81615db2565b600060208284031215615486578081fd5b8135610ccb81615dbf565b6000602082840312156154a2578081fd5b8151610ccb81615dbf565b600060c082840312156154be578081fd5b60405160c081018181106001600160401b03821117156154e0576154e0615d79565b60405282516154ee81615d8f565b815260208301516154fe81615d8f565b6020820152604083015161551181615d8f565b6040820152606083015161552481615d8f565b6060820152608083015161553781615d8f565b608082015260a083015161554a81615d8f565b60a08201529392505050565b600060808284031215615567578081fd5b610ccb8383614da9565b600080600060608486031215615585578081fd5b83359250602084013591506040840135614fd781615d8f565b60008060008060008060c087890312156155b6578384fd5b8635955060208701359450604087013593506060870135925060808701356155dd81615dce565b915060a08701356155ed81615dce565b809150509295509295509295565b60006020828403121561560c578081fd5b8151610ccb81615dce565b600082825180855260208086019550808260051b840101818601855b8481101561566157601f1986840301895261564f8383516156df565b98840198925090830190600101615633565b5090979650505050505050565b81835260006001600160fb1b03831115615686578081fd5b8260051b80836020870137939093016020019283525090919050565b6000815480845260208085019450838352808320835b838110156156d4578154875295820195600191820191016156b8565b509495945050505050565b600081518084526156f7816020860160208601615d1c565b601f01601f19169290920160200192915050565b6002811061572957634e487b7160e01b600052602160045260246000fd5b9052565b6000825161573f818460208701615d1c565b9190910192915050565b6001600160a01b03888116825287166020820152604081018690526001600160401b0385166060820152600784900b608082015260e0810161578e60a083018561570b565b8260c083015298975050505050505050565b6001600160a01b038a8116825289166020820152604081018890526001600160401b0387166060820152600786900b608082015261012081016157e660a083018761570b565b8460c08301528360e0830152826101008301529a9950505050505050505050565b6001600160a01b038416815260608101615824602083018561570b565b8215156040830152949350505050565b6020808252825182820181905260009190848201906040850190845b818110156158755783516001600160a01b031683529284019291840191600101615850565b50909695505050505050565b602081526000610ccb6020830184615617565b6080815260006158a76080830187615617565b828103602084810191909152865180835287820192820190845b818110156158dd578451835293830193918301916001016158c1565b50506001600160401b039687166040860152949095166060909301929092525090949350505050565b60a08101818360005b600581101561592e57815183526020928301929091019060010161590f565b50505092915050565b60608152600061594b60608301878961566e565b828103602084015261595e81868861566e565b9150508260408301529695505050505050565b602081526000610ccb60208301846156df565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b81516001600160a01b03168152602080830151610120830191615a45908401826001600160a01b03169052565b50604083015160408301526060830151615a6a60608401826001600160401b03169052565b506080830151615a7f608084018260070b9052565b5060a0830151615a9260a084018261570b565b5060c083015160c083015260e083015160e083015261010080840151818401525092915050565b6001600160401b0385168152608060208201526000615adb60808301866156a2565b8281036040840152615aed81866156a2565b91505082606083015295945050505050565b6000808335601e19843603018112615b15578283fd5b8301803591506001600160401b03821115615b2e578283fd5b602001915036819003821315614da257600080fd5b604051606081016001600160401b0381118282101715615b6557615b65615d79565b60405290565b604051601f8201601f191681016001600160401b0381118282101715615b9357615b93615d79565b604052919050565b60006001600160401b03821115615bb457615bb4615d79565b5060051b60200190565b60008219821115615bd157615bd1615d63565b500190565b60006001600160401b03808316818516808303821115615bf857615bf8615d63565b01949350505050565b600082615c1c57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615c3b57615c3b615d63565b500290565b600082821015615c5257615c52615d63565b500390565b6000615c656150e784615b9b565b808482526020808301925084368760051b87011115615c82578485fd5b845b87811015615d105781356001600160401b0380821115615ca2578788fd5b90880190601f3681840112615cb5578889fd5b823582811115615cc757615cc7615d79565b615cd8818301601f19168801615b6b565b92508083523687828601011115615ced57898afd5b808785018885013782018601899052508652509382019390820190600101615c84565b50919695505050505050565b60005b83811015615d37578181015183820152602001615d1f565b838111156110615750506000910152565b6000600019821415615d5c57615d5c615d63565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610fec57600080fd5b8015158114610fec57600080fd5b60028110610fec57600080fd5b8060070b8114610fec57600080fd5b6001600160401b0381168114610fec57600080fdfea2646970667358221220d9015aee7abca54ac30120273d2668cc9c496ef2e581bf44c6863dcc028b445064736f6c63430008040033

Deployed Bytecode

0x60806040526004361061039b5760003560e01c806389c6318d116101dc578063caab6cb711610102578063e396ed26116100a0578063ebc797721161006f578063ebc7977214610bc2578063ef469ba214610bd7578063f8335cde14610bf7578063fd6e9b9714610c1757600080fd5b8063e396ed2614610b2f578063e60a4d2514610b5f578063e73efc9b14610b8c578063e915586614610bac57600080fd5b8063d69fb668116100dc578063d69fb66814610aae578063d7081e0314610ac4578063da6b532f14610ae4578063e11f951d14610af757600080fd5b8063caab6cb714610a5b578063ce87e2ee14610a6e578063cf898ca914610a8e57600080fd5b8063a3a2adf01161017a578063bc93233f11610149578063bc93233f146109c1578063bd47a9b8146109e1578063c3b83f5f14610a0e578063c453180214610a2e57600080fd5b8063a3a2adf01461095b578063a87730c31461096e578063a8da1a1714610981578063b711d407146109a157600080fd5b80639324cac7116101b65780639324cac7146108bb57806399c18e7e146108db5780639fc42703146108fc578063a201b3071461091c57600080fd5b806389c6318d1461085f5780638da5cb5b1461087f57806391b4ded9146108a557600080fd5b80633ab76e9f116102c15780635403f80f1161025f5780636bfffb121161022e5780636bfffb12146107f4578063704ce43e1461081457806379ba50971461082a5780637de926d11461083f57600080fd5b80635403f80f146107845780635631bf8a1461079a5780635c975abb146107ba57806368b9f66b146107d457600080fd5b8063485cc9551161029b578063485cc955146107045780634d6e8c6e146107245780634eb7c43b1461074457806353a47bb71461076457600080fd5b80633ab76e9f146106965780633b46bfc9146106ce5780633e7ad1de146106ee57600080fd5b806313af40351161033957806317b94eac1161030857806317b94eac146105695780632b03da3c1461057c5780632c43dc831461065657806330a1ea011461067657600080fd5b806313af4035146104e757806314527f3a146105095780631627540c1461052957806316c38b3c1461054957600080fd5b806306c933d81161037557806306c933d81461045e57806307b53bb41461048e57806312039b6d146104a457806312aa3833146104d157600080fd5b806301bea636146103a7578063023fb259146103eb57806305bfdfd41461041857600080fd5b366103a257005b600080fd5b3480156103b357600080fd5b506103d66103c2366004614e2f565b602080526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156103f757600080fd5b5061040b610406366004614e2f565b610c47565b6040516103e29190615906565b34801561042457600080fd5b50610450610433366004615294565b601e60209081526000928352604080842090915290825290205481565b6040519081526020016103e2565b34801561046a57600080fd5b506103d6610479366004614e2f565b601b6020526000908152604090205460ff1681565b34801561049a57600080fd5b5061045060135481565b3480156104b057600080fd5b506104c46104bf366004615571565b610ca2565b6040516103e29190615834565b3480156104dd57600080fd5b5061045060125481565b3480156104f357600080fd5b50610507610502366004614e2f565b610cd2565b005b34801561051557600080fd5b506103d6610524366004614e2f565b610e12565b34801561053557600080fd5b50610507610544366004614e2f565b610f23565b34801561055557600080fd5b506105076105643660046151e7565b610f79565b610507610577366004614e67565b610fef565b34801561058857600080fd5b5061061861059736600461521f565b604080516080808201835260008083526020808401829052838501829052606093840182905284519283018552818352828101828152838601838152948401838152878452600f83528684205460ff1615158552968352601690915293902054909252600c549052601754600160a01b90046001600160401b031690915290565b6040516103e2919081511515815260208083015190820152604080830151908201526060918201516001600160401b03169181019190915260800190565b34801561066257600080fd5b5061050761067136600461503a565b611067565b34801561068257600080fd5b50610507610691366004614fe2565b611194565b3480156106a257600080fd5b506026546106b6906001600160a01b031681565b6040516001600160a01b0390911681526020016103e2565b3480156106da57600080fd5b506105076106e936600461559e565b6111f1565b3480156106fa57600080fd5b5061045060105481565b34801561071057600080fd5b5061050761071f366004614f6b565b6112ae565b34801561073057600080fd5b5061050761073f366004615273565b611395565b34801561075057600080fd5b5061045061075f36600461521f565b6113e5565b34801561077057600080fd5b506001546106b6906001600160a01b031681565b34801561079057600080fd5b5061045060115481565b3480156107a657600080fd5b506104506107b536600461521f565b611406565b3480156107c657600080fd5b506003546103d69060ff1681565b3480156107e057600080fd5b506105076107ef3660046151e7565b611416565b34801561080057600080fd5b5061050761080f366004614f98565b61159b565b34801561082057600080fd5b50610450600d5481565b34801561083657600080fd5b50610507611628565b34801561084b57600080fd5b5061050761085a36600461524f565b611725565b34801561086b57600080fd5b506104c461087a366004615273565b61177f565b34801561088b57600080fd5b506000546106b6906201000090046001600160a01b031681565b3480156108b157600080fd5b5061045060025481565b3480156108c757600080fd5b50600a546106b6906001600160a01b031681565b3480156108e757600080fd5b50601c546103d690600160a01b900460ff1681565b34801561090857600080fd5b506104c4610917366004615571565b61178d565b34801561092857600080fd5b5060175461094390600160a01b90046001600160401b031681565b6040516001600160401b0390911681526020016103e2565b61050761096936600461503a565b6117b3565b61050761097c3660046152e3565b611959565b34801561098d57600080fd5b5061050761099c366004614fe2565b6119ff565b3480156109ad57600080fd5b506105076109bc366004615177565b611a63565b3480156109cd57600080fd5b506105076109dc366004614f33565b611bd5565b3480156109ed57600080fd5b506104506109fc36600461521f565b60166020526000908152604090205481565b348015610a1a57600080fd5b50610507610a29366004614e2f565b611c4c565b348015610a3a57600080fd5b50610450610a4936600461521f565b60146020526000908152604090205481565b610507610a693660046153b0565b611d65565b348015610a7a57600080fd5b50600b546106b6906001600160a01b031681565b348015610a9a57600080fd5b50601f54610943906001600160401b031681565b348015610aba57600080fd5b50610450600c5481565b348015610ad057600080fd5b50610507610adf36600461500f565b611e92565b610507610af2366004614eb9565b611ef0565b348015610b0357600080fd5b50610450610b12366004615294565b601d60209081526000928352604080842090915290825290205481565b348015610b3b57600080fd5b506103d6610b4a36600461521f565b600f6020526000908152604090205460ff1681565b348015610b6b57600080fd5b50610450610b7a36600461521f565b60156020526000908152604090205481565b348015610b9857600080fd5b506104c4610ba7366004615273565b6123e2565b348015610bb857600080fd5b5061045060275481565b348015610bce57600080fd5b506105076123f0565b348015610be357600080fd5b50610507610bf23660046152b8565b61244e565b348015610c0357600080fd5b50610507610c12366004615273565b6124cc565b348015610c2357600080fd5b506103d6610c32366004614e2f565b60256020526000908152604090205460ff1681565b610c4f614caf565b506040805160a08101825260065481526008546020808301919091526001600160a01b039093166000818152601985528381205483850152908152601a9093529120546060820152602354608082015290565b6001600160a01b0381166000908152601960205260409020606090610cc890858561251c565b90505b9392505050565b6001600160a01b038116610d2d5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610d995760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610d24565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b6000610e1f600683612660565b8015610ea3575042826001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e6057600080fd5b505afa158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9891906155fb565b6001600160401b0316105b8015610f1d5750816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015610ee357600080fd5b505afa158015610ef7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1b9190615203565b155b92915050565b610f2b6126e2565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610e07565b610f816126e2565b60035460ff1615158115151415610f955750565b6003805460ff191682151590811790915560ff1615610fb357426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610e07565b50565b6001600460008282546110029190615bbe565b909155505060045460035460ff161561102d5760405162461bcd60e51b8152600401610d2490615984565b6110408461103b8486615c57565b61275c565b60045481146110615760405162461bcd60e51b8152600401610d24906159e1565b50505050565b336000908152601b602052604090205460ff166110c15760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610d24565b60005b8381101561118d576111048585838181106110ef57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906105249190614e2f565b1561117b5761117b85858381811061112c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111419190614e2f565b84848481811061116157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111769190615475565b612b7e565b8061118581615d48565b9150506110c4565b5050505050565b61119c6126e2565b6111a582610e12565b6111e35760405162461bcd60e51b815260206004820152600f60248201526e43616e206e6f74207265736f6c766560881b6044820152606401610d24565b6111ed8282612d3f565b5050565b6111f96126e2565b60128690556013859055601084905560118390556017805467ffffffffffffffff60a01b1916600160a01b6001600160401b0385811691820292909217909255601f805467ffffffffffffffff19169184169182179055604080518981526020810189905290810187905260608101869052608081019290925260a08201527fcb4727945d0c9bf77ea3b48c6c630e5b0e5016c1fe67c9508feafe8fc265cdba9060c0015b60405180910390a1505050505050565b600054610100900460ff166112c95760005460ff16156112cd565b303b155b6113305760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610d24565b600054610100900460ff16158015611352576000805461ffff19166101011790555b61135b83610cd2565b6113636123f0565b600a80546001600160a01b0319166001600160a01b0384161790558015611390576000805461ff00191690555b505050565b61139d6126e2565b600c829055602781905560408051838152602081018390527f8804a85a7ad3ea6e27f776005d85bfafeb449428ffd674719eccfdd9a1b0631791015b60405180910390a15050565b602381815481106113f557600080fd5b600091825260209091200154905081565b602281815481106113f557600080fd5b61141e6126e2565b60265460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f916004808301926020929190829003018186803b15801561146357600080fd5b505afa158015611477573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061149b9190614e4b565b90506001600160a01b0381161561154e57600a546001600160a01b031663095ea7b382846114ca5760006114ce565b6000195b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561151457600080fd5b505af1158015611528573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154c9190615203565b505b601c8054831515600160a01b0260ff60a01b199091161790556040517fb76eab56cfa3088dda43a9a4b3ea4bb7685b8007428d4a65248fdaa763d339f8906113d990841515815260200190565b6115a36126e2565b600b80546001600160a01b038581166001600160a01b0319928316811790935560248054868316908416811790915560268054928616929093168217909255604080519384526020840192909252908201527fbf934b81354c7e34eda71aa08a74419a5682a0737282cc3f448b353a1893c41f906060015b60405180910390a1505050565b6001546001600160a01b031633146116a05760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610d24565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b61172d6126e2565b6000828152600f6020908152604091829020805460ff19168415159081179091558251858152918201527f6af8d0ea20290a2d8dcbb43a77926d5993cd89bac2c6a72cd7813c4eacc2124b91016113d9565b6060610ccb6008848461251c565b6001600160a01b0381166000908152601a60205260409020606090610cc890858561251c565b6001600460008282546117c69190615bbe565b909155505060045460035460ff16156117f15760405162461bcd60e51b8152600401610d2490615984565b60005b848110156119375761181f8686838181106110ef57634e487b7160e01b600052603260045260246000fd5b1561192557604080516001808252818301909252600091816020015b606081526020019060019003908161183b57905050905084848381811061187257634e487b7160e01b600052603260045260246000fd5b90506020028101906118849190615aff565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052508551869450909250151590506118da57634e487b7160e01b600052603260045260246000fd5b602002602001018190525061192387878481811061190857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061191d9190614e2f565b8261275c565b505b8061192f81615d48565b9150506117f4565b50600454811461118d5760405162461bcd60e51b8152600401610d24906159e1565b60016004600082825461196c9190615bbe565b909155505060045460035460ff16156119975760405162461bcd60e51b8152600401610d2490615984565b6119d08c6001600160401b038d16156119b0578c6119c3565b6119c36001600160401b038d1642615bbe565b8b8b8b8b8b8b8b8b613324565b60045481146119f15760405162461bcd60e51b8152600401610d24906159e1565b505050505050505050505050565b336000908152601b602052604090205460ff16611a595760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610d24565b6111ed8282612b7e565b611a6b6126e2565b838214611acb5760405162461bcd60e51b815260206004820152602860248201527f54696d657320616e642066656573206d7573742068617665207468652073616d6044820152670ca40d8cadccee8d60c31b6064820152608401610d24565b611ad760226000614ccd565b611ae360236000614ccd565b60005b84811015611b88576022868683818110611b1057634e487b7160e01b600052603260045260246000fd5b835460018101855560009485526020948590209190940292909201359190920155506023848483818110611b5457634e487b7160e01b600052603260045260246000fd5b8354600181018555600094855260209485902091909402929092013591909201555080611b8081615d48565b915050611ae6565b50600d8190556040517f97b8e3f33b113d945b11628418dc7b155d05943a8a517a937a9d88f4eda67a6b90611bc69087908790879087908790615937565b60405180910390a15050505050565b611bdd6126e2565b6001600160a01b038216611bf057600080fd5b6001600160a01b0382166000818152601b6020908152604091829020805460ff19168515159081179091558251938452908301527f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd91016113d9565b611c546126e2565b6001600160a01b038116611c9c5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610d24565b600154600160a81b900460ff1615611cec5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610d24565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610e07565b600160046000828254611d789190615bbe565b909155505060045460035460ff1615611da35760405162461bcd60e51b8152600401610d2490615984565b602654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b158015611de857600080fd5b505afa158015611dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2091906154ad565b9050611e648b6001600160401b038c1615611e3b578b611e4e565b611e4e6001600160401b038c1642615bbe565b8a8a611e5a8a8c615c57565b60018a8a896133cb565b506004548114611e865760405162461bcd60e51b8152600401610d24906159e1565b50505050505050505050565b611e9a6126e2565b600a54611eb1906001600160a01b03168383613a90565b604080516001600160a01b0384168152602081018390527fc3ce4eeef579533b0a2d7ae2e50eb68dccae3b183dc8cce60267f3c9fa4935c091016113d9565b600160046000828254611f039190615bbe565b909155505060045460035460ff1615611f2e5760405162461bcd60e51b8152600401610d2490615984565b601c54600160a01b900460ff16611f935760405162461bcd60e51b815260206004820152602360248201527f4d756c7469636f6c6c61746572616c206f666672616d70206e6f7420656e61626044820152621b195960ea1b6064820152608401610d24565b6000866001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b158015611fce57600080fd5b505afa158015611fe2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120069190614e4b565b9050336001600160a01b038216146120605760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c7920616c6c6f7765642066726f6d206d61726b6574206f776e657200006044820152606401610d24565b600a546040516370a0823160e01b81526001600160a01b03838116600483015260009216906370a082319060240160206040518083038186803b1580156120a657600080fd5b505afa1580156120ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120de9190615237565b90506120ee8861103b888a615c57565b600a546040516370a0823160e01b81526001600160a01b03848116600483015260009284929116906370a082319060240160206040518083038186803b15801561213757600080fd5b505afa15801561214b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216f9190615237565b6121799190615c40565b600a54909150612194906001600160a01b0316843084613af3565b80156123b65760265460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f916004808301926020929190829003018186803b1580156121df57600080fd5b505afa1580156121f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122179190614e4b565b905085156123165760405163b45e98d960e01b8152600481018390526000906001600160a01b0383169063b45e98d990602401602060405180830381600087803b15801561226457600080fd5b505af1158015612278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229c9190615237565b60405190915085906000906001600160a01b0383169084156108fc0290859084818181858888f1935050505090508061230e5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610d24565b5050506123b4565b604051630992646d60e31b81526001600160a01b0388811660048301526024820184905260009190831690634c93236890604401602060405180830381600087803b15801561236457600080fd5b505af1158015612378573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239c9190615237565b90506123b26001600160a01b0389168683613a90565b505b505b50505060045481146123da5760405162461bcd60e51b8152600401610d24906159e1565b505050505050565b6060610ccb6006848461251c565b60055460ff16156124395760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610d24565b6005805460ff19166001908117909155600455565b6124566126e2565b600083815260146020908152604080832085905560158252808320839055601d82528083208380528252808320849055600183529182902083905581518581529081018490529081018290527facbec488a49aaa9d1b3799159ede0349850bc1a73c0e90913ff03dd4354a34a89060600161161b565b6124d46126e2565b60008281526016602090815260409182902083905581518481529081018390527fbe9b5564f6075c4b92cab3a707053c7e8828f045a5d233c3157bc3407cb0096391016113d9565b6060600061252a8385615bbe565b855490915081111561253a575083545b838111612557575050604080516000815260208101909152610ccb565b60006125638583615c40565b90506000816001600160401b0381111561258d57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156125b6578160200160208202803683370190505b50905060005b8281101561265557876125cf8883615bbe565b815481106125ed57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682828151811061262b57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101528061264d81615d48565b9150506125bc565b509695505050505050565b815460009061267157506000610f1d565b6001600160a01b0382166000908152600184016020526040902054801515806126da5750826001600160a01b0316846000016000815481106126c357634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b949350505050565b6000546201000090046001600160a01b0316331461275a5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610d24565b565b61276582610e12565b6127a35760405162461bcd60e51b815260206004820152600f60248201526e43616e206e6f74207265736f6c766560881b6044820152606401610d24565b60265460408051630f98d06f60e41b815290516000926001600160a01b03169163f98d06f0916004808301926020929190829003018186803b1580156127e857600080fd5b505afa1580156127fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128209190614e4b565b604080516001808252818301909252919250600091906020808301908036833701905050905060166000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561288357600080fd5b505afa158015612897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128bb9190615237565b815260200190815260200160002054816000815181106128eb57634e487b7160e01b600052603260045260246000fd5b602090810291909101015260405163d47eed4560e01b81526000906001600160a01b03841690634716e9c590829063d47eed459061292d908990600401615881565b60206040518083038186803b15801561294557600080fd5b505afa158015612959573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297d9190615237565b8685896001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156129b857600080fd5b505afa1580156129cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129f091906155fb565b601f60009054906101000a90046001600160401b03168b6001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b158015612a3f57600080fd5b505afa158015612a53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7791906155fb565b612a819190615bd6565b6040518663ffffffff1660e01b8152600401612aa09493929190615894565b6000604051808303818588803b158015612ab957600080fd5b505af1158015612acd573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052612af691908101906150a2565b9050600081600081518110612b1b57634e487b7160e01b600052603260045260246000fd5b60200260200101516020015190506000816000015160070b13612b705760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606401610d24565b6123da868260000151612d3f565b6000826001600160a01b031663645539ed6040518163ffffffff1660e01b815260040160206040518083038186803b158015612bb957600080fd5b505afa158015612bcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bf19190615459565b90506000836001600160a01b031663c52987cf6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c2e57600080fd5b505afa158015612c42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c669190615491565b905060008160070b8460070b128015612c9e57506001836001811115612c9c57634e487b7160e01b600052602160045260246000fd5b145b80612cd857508160070b8460070b138015612cd857506000836001811115612cd657634e487b7160e01b600052602160045260246000fd5b145b9050612ce385610e12565b8015612ced575080155b612d395760405162461bcd60e51b815260206004820152601860248201527f43616e206e6f74207265736f6c7665206d616e75616c6c7900000000000000006044820152606401610d24565b61118d85855b604051631f67c49160e01b8152600782900b60048201526001600160a01b03831690631f67c49190602401600060405180830381600087803b158015612d8457600080fd5b505af1158015612d98573d6000803e3d6000fd5b50505050612db0826006613b2b90919063ffffffff16565b612dbb600883613cae565b6000826001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b158015612df657600080fd5b505afa158015612e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e2e9190614e4b565b6001600160a01b0381166000908152601960205260409020909150612e539084612660565b15612e7a576001600160a01b0381166000908152601960205260409020612e7a9084613b2b565b6001600160a01b0381166000908152601a60205260409020612e9c9084613cae565b6000836001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b158015612ed757600080fd5b505afa158015612eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f0f9190615237565b90506000846001600160a01b0316631fcc8bb26040518163ffffffff1660e01b815260040160206040518083038186803b158015612f4c57600080fd5b505afa158015612f60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f849190615237565b90506000856001600160a01b031663645539ed6040518163ffffffff1660e01b815260040160206040518083038186803b158015612fc157600080fd5b505afa158015612fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ff99190615459565b6000848152601e6020526040812091925083919083600181111561302d57634e487b7160e01b600052602160045260246000fd5b600181111561304c57634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000205411156130d8576000838152601e60205260408120839183600181111561309157634e487b7160e01b600052602160045260246000fd5b60018111156130b057634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060008282546130cd9190615c40565b909155506131389050565b6000838152601e602052604081208183600181111561310757634e487b7160e01b600052602160045260246000fd5b600181111561312657634e487b7160e01b600052602160045260246000fd5b81526020810191909152604001600020555b856001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b15801561317157600080fd5b505afa158015613185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131a99190615203565b613211576131b8826002615c21565b6000848152601560205260409020541115613201576131d8826002615c21565b600084815260156020526040812080549091906131f6908490615c40565b909155506132119050565b6000838152601560205260408120555b7f738ac9ca76b7fd50246d5acdc827b2852e656ed2c287d6538e57b046f0ecf64b86876001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b15801561326c57600080fd5b505afa158015613280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132a49190615459565b886001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b1580156132dd57600080fd5b505afa1580156132f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133159190615203565b60405161129e93929190615807565b602654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c0929190829003018186803b15801561336957600080fd5b505afa15801561337d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a191906154ad565b905060006133b28787878e86613d00565b90506119f18c8c8c846133c58d8f615c57565b60008a8a8a5b6000898152600f602052604090205460ff166134225760405162461bcd60e51b8152602060048201526016602482015275105cdcd95d081a5cc81b9bdd081cdd5c1c1bdc9d195960521b6044820152606401610d24565b601254861015801561343657506013548611155b6134785760405162461bcd60e51b815260206004820152601360248201527215dc9bdb99c8189d5e481a5b88185b5bdd5b9d606a1b6044820152606401610d24565b6010546134859042615bbe565b886001600160401b031610156134dd5760405162461bcd60e51b815260206004820152601860248201527f537472696b652074696d65206e6f7420616c6c6f6f77656400000000000000006044820152606401610d24565b6011546134ea9042615bbe565b886001600160401b031611156135425760405162461bcd60e51b815260206004820152601c60248201527f54696d6520746f6f2066617220696e746f2074686520667574757265000000006044820152606401610d24565b61354a614ceb565b6135578a89898c8761415a565b8152608082015160405163d47eed4560e01b81526001600160a01b0382169063ef9e5e2890829063d47eed4590613592908c90600401615881565b60206040518083038186803b1580156135aa57600080fd5b505afa1580156135be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135e29190615237565b896040518363ffffffff1660e01b81526004016135ff9190615881565b6000604051808303818588803b15801561361857600080fd5b505af115801561362c573d6000803e3d6000fd5b50505060008d815260166020526040908190205490516396834ad360e01b815260048101919091526001600160a01b03841692506396834ad3915060240160806040518083038186803b15801561368257600080fd5b505afa158015613696573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ba9190615556565b6020830181905260175460609091015142916136e791600160a01b9091046001600160401b031690615bbe565b1180156136ff5750600082602001516000015160070b135b6137395760405162461bcd60e51b815260206004820152600b60248201526a5374616c6520707269636560a81b6044820152606401610d24565b8515613796578151600c54600091670de0b6b3a76400009161375b9083615bbe565b6137659190615bbe565b61376f908b615c21565b6137799190615c01565b600a54909150613794906001600160a01b0316333084613af3565b505b600b546000906137ae906001600160a01b03166146ce565b9050806001600160a01b03166358d9d182604051806101200160405280306001600160a01b03168152602001336001600160a01b031681526020018f81526020018e6001600160401b0316815260200186602001516000015160070b81526020018d600181111561382f57634e487b7160e01b600052602160045260246000fd5b81526020018c8152602001600c54815260200186600001518152506040518263ffffffff1660e01b81526004016138669190615a18565b600060405180830381600087803b15801561388057600080fd5b505af1158015613894573d6000803e3d6000fd5b505050506138bc818a60026138a99190615c21565b600a546001600160a01b03169190613a90565b6138c7868a8661476b565b506138d3600682613cae565b3360009081526019602052604090206138ec9082613cae565b60408401516001600160a01b0316156139665760408085015190516302c7739b60e01b8152336004820152602481018b90526001600160a01b03909116906302c7739b90604401600060405180830381600087803b15801561394d57600080fd5b505af1158015613961573d6000803e3d6000fd5b505050505b600160206000836001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600160256000836001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f4fb5dd0be05638074eabb1b37a9bdf9ab8cbad8d83c7bce9298aca16de5b79c381338e8e8760200151600001518f8f604051613a259796959493929190615749565b60405180910390a17f51f385a862a654703b4b7a2e647518a58930354129b8364d5dbe945752df364681338e8e8760200151600001518f8f600c548b60000151604051613a7a999897969594939291906157a0565b60405180910390a1505050505050505050505050565b6040516001600160a01b03831660248201526044810182905261139090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526149d2565b6040516001600160a01b03808516602483015283166044820152606481018290526110619085906323b872dd60e01b90608401613abc565b613b358282612660565b613b775760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b6044820152606401610d24565b6001600160a01b0381166000908152600180840160205260408220548454909291613ba191615c40565b9050808214613c49576000846000018281548110613bcf57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015485546001600160a01b0390911691508190869085908110613c0c57634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080613c6857634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b613cb88282612660565b6111ed5781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b601c54600090600160a01b900460ff16613d675760405162461bcd60e51b815260206004820152602260248201527f4d756c7469636f6c6c61746572616c206f6e72616d70206e6f7420656e61626c604482015261195960f21b6064820152608401610d24565b600a546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015613dab57600080fd5b505afa158015613dbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613de39190615237565b606084015190915060008615613e7657604051631321b85d60e01b8152600481018990526001600160a01b03831690631321b85d908a906024016020604051808303818588803b158015613e3657600080fd5b505af1158015613e4a573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613e6f9190615237565b9050613f93565b613e8b6001600160a01b038a1633308b613af3565b60405163095ea7b360e01b81526001600160a01b038381166004830152602482018a90528a169063095ea7b390604401602060405180830381600087803b158015613ed557600080fd5b505af1158015613ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f0d9190615203565b506040516322ceb11360e21b81526001600160a01b038a81166004830152602482018a9052831690638b3ac44c90604401602060405180830381600087803b158015613f5857600080fd5b505af1158015613f6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f909190615237565b90505b6024546000906001600160a01b031663336ef50d613fba426001600160401b038b16615c40565b60226023600d546040518563ffffffff1660e01b8152600401613fe09493929190615ab9565b60206040518083038186803b158015613ff857600080fd5b505afa15801561400c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140309190615237565b905080600c54670de0b6b3a76400006140499190615bbe565b6140539190615bbe565b614065670de0b6b3a764000084615c21565b61406f9190615c01565b600a546040516370a0823160e01b815230600482015291965060009186916001600160a01b0316906370a082319060240160206040518083038186803b1580156140b857600080fd5b505afa1580156140cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140f09190615237565b6140fa9190615c40565b90508581101561414c5760405162461bcd60e51b815260206004820152601e60248201527f6e6f7420656e6f75676820726563656976656420766961206f6e72616d7000006044820152606401610d24565b505050505095945050505050565b6000806141678787614aa4565b905061417a662386f26fc1000084615bbe565b8111156141c25760405162461bcd60e51b815260206004820152601660248201527514dad95dc81cdb1a5c1c1859d948195e18d95959195960521b6044820152606401610d24565b6000808760018111156141e557634e487b7160e01b600052602160045260246000fd5b146141f15760006141f4565b60015b90506000821561420557600061421b565b60026142118a84614aa4565b61421b9190615c01565b60008a8152601e6020526040812091925088919084600181111561424f57634e487b7160e01b600052602160045260246000fd5b600181111561426e57634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000205411156142fa576000898152601e6020526040812088918460018111156142b357634e487b7160e01b600052602160045260246000fd5b60018111156142d257634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060008282546142ef9190615c40565b909155506145469050565b6000898152601e602052604081209083600181111561432957634e487b7160e01b600052602160045260246000fd5b600181111561434857634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054876143629190615c40565b60008a8152601e60205260408120908a600181111561439157634e487b7160e01b600052602160045260246000fd5b60018111156143b057634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060008282546143cd9190615bbe565b90915550506000898152601e602052604081208184600181111561440157634e487b7160e01b600052602160045260246000fd5b600181111561442057634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002081905550601d60008a8152602001908152602001600020600089600181111561446757634e487b7160e01b600052602160045260246000fd5b600181111561448657634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054601e60008b815260200190815260200160002060008a60018111156144ca57634e487b7160e01b600052602160045260246000fd5b60018111156144e957634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000205411156145465760405162461bcd60e51b815260206004820152601b60248201527f5269736b2070657220646972656374696f6e20657863656564656400000000006044820152606401610d24565b602454819084906001600160a01b031663336ef50d61456e426001600160401b038c16615c40565b60226023600d546040518563ffffffff1660e01b81526004016145949493929190615ab9565b60206040518083038186803b1580156145ac57600080fd5b505afa1580156145c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145e49190615237565b6145ee9190615bbe565b6145f89190615c40565b9350670de0b6b3a764000061460d8582615bbe565b6146179089615c21565b6146219190615c01565b61462c886002615c21565b6146369190615c40565b60008a81526015602052604081208054909190614654908490615bbe565b909155505060008981526014602090815260408083205460159092529091205411156146c25760405162461bcd60e51b815260206004820152601760248201527f5269736b207065722061737365742065786365656465640000000000000000006044820152606401610d24565b50505095945050505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b0381166147665760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610d24565b919050565b60208101516000906001600160a01b038116156149965760006001600160a01b038616156147fc5760405163bbddaca360e01b81526001600160a01b03878116600483015233602483015283169063bbddaca390604401600060405180830381600087803b1580156147dc57600080fd5b505af11580156147f0573d6000803e3d6000fd5b50505050859050614876565b604051639ca423b360e01b81523360048201526001600160a01b03831690639ca423b39060240160206040518083038186803b15801561483b57600080fd5b505afa15801561484f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148739190614e4b565b90505b6001600160a01b038116156149945760405163c7d1f5f160e01b81526001600160a01b0382811660048301526000919084169063c7d1f5f19060240160206040518083038186803b1580156148ca57600080fd5b505afa1580156148de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149029190615237565b9050801561499257670de0b6b3a764000061491d8288615c21565b6149279190615c01565b600a54909450614941906001600160a01b03168386613a90565b604080516001600160a01b0384168152336020820152908101859052606081018790527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b505b6149ca836000015183670de0b6b3a7640000600c54886149b69190615c21565b6149c09190615c01565b6138a99190615c40565b509392505050565b6000614a27826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ba49092919063ffffffff16565b8051909150156113905780806020019051810190614a459190615203565b6113905760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610d24565b6027546000838152601d602052604081209091670de0b6b3a76400009183856001811115614ae257634e487b7160e01b600052602160045260246000fd5b6001811115614b0157634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054670de0b6b3a7640000601e60008881526020019081526020016000206000876001811115614b4e57634e487b7160e01b600052602160045260246000fd5b6001811115614b6d57634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054614b869190615c21565b614b909190615c01565b614b9a9190615c21565b610ccb9190615c01565b6060610cc8848460008585843b614bfd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610d24565b600080866001600160a01b03168587604051614c19919061572d565b60006040518083038185875af1925050503d8060008114614c56576040519150601f19603f3d011682016040523d82523d6000602084013e614c5b565b606091505b5091509150614c6b828286614c76565b979650505050505050565b60608315614c85575081610ccb565b825115614c955782518084602001fd5b8160405162461bcd60e51b8152600401610d249190615971565b6040518060a001604052806005906020820280368337509192915050565b5080546000825590600052602060002090810190610fec9190614d3c565b604051806040016040528060008152602001614d376040518060800160405280600060070b815260200160006001600160401b03168152602001600060030b8152602001600081525090565b905290565b5b80821115614d515760008155600101614d3d565b5090565b803561476681615d8f565b60008083601f840112614d71578182fd5b5081356001600160401b03811115614d87578182fd5b6020830191508360208260051b8501011115614da257600080fd5b9250929050565b600060808284031215614dba578081fd5b604051608081018181106001600160401b0382111715614ddc57614ddc615d79565b80604052508091508251614def81615dbf565b81526020830151614dff81615dce565b60208201526040830151600381900b8114614e1957600080fd5b6040820152606092830151920191909152919050565b600060208284031215614e40578081fd5b8135610ccb81615d8f565b600060208284031215614e5c578081fd5b8151610ccb81615d8f565b600080600060408486031215614e7b578182fd5b8335614e8681615d8f565b925060208401356001600160401b03811115614ea0578283fd5b614eac86828701614d60565b9497909650939450505050565b600080600080600060808688031215614ed0578283fd5b8535614edb81615d8f565b945060208601356001600160401b03811115614ef5578384fd5b614f0188828901614d60565b9095509350506040860135614f1581615d8f565b91506060860135614f2581615da4565b809150509295509295909350565b60008060408385031215614f45578182fd5b8235614f5081615d8f565b91506020830135614f6081615da4565b809150509250929050565b60008060408385031215614f7d578182fd5b8235614f8881615d8f565b91506020830135614f6081615d8f565b600080600060608486031215614fac578081fd5b8335614fb781615d8f565b92506020840135614fc781615d8f565b91506040840135614fd781615d8f565b809150509250925092565b60008060408385031215614ff4578182fd5b8235614fff81615d8f565b91506020830135614f6081615dbf565b60008060408385031215615021578182fd5b823561502c81615d8f565b946020939093013593505050565b6000806000806040858703121561504f578182fd5b84356001600160401b0380821115615065578384fd5b61507188838901614d60565b90965094506020870135915080821115615089578384fd5b5061509687828801614d60565b95989497509550505050565b600060208083850312156150b4578182fd5b82516001600160401b038111156150c9578283fd5b8301601f810185136150d9578283fd5b80516150ec6150e782615b9b565b615b6b565b81815283810190838501610120808502860187018a101561510b578788fd5b8795505b848610156151695780828b031215615125578788fd5b61512d615b43565b8251815261513d8b898501614da9565b8882015261514e8b60a08501614da9565b6040820152845260019590950194928601929081019061510f565b509098975050505050505050565b60008060008060006060868803121561518e578283fd5b85356001600160401b03808211156151a4578485fd5b6151b089838a01614d60565b909750955060208801359150808211156151c8578485fd5b506151d588828901614d60565b96999598509660400135949350505050565b6000602082840312156151f8578081fd5b8135610ccb81615da4565b600060208284031215615214578081fd5b8151610ccb81615da4565b600060208284031215615230578081fd5b5035919050565b600060208284031215615248578081fd5b5051919050565b60008060408385031215615261578182fd5b823591506020830135614f6081615da4565b60008060408385031215615285578182fd5b50508035926020909101359150565b600080604083850312156152a6578182fd5b823591506020830135614f6081615db2565b6000806000606084860312156152cc578081fd5b505081359360208301359350604090920135919050565b60008060008060008060008060008060006101408c8e031215615304578889fd5b8b359a5060208c013561531681615dce565b995060408c013561532681615dce565b985060608c013561533681615db2565b975060808c01356001600160401b03811115615350578687fd5b61535c8e828f01614d60565b90985096505060a08c013561537081615d8f565b945060c08c0135935060e08c013561538781615da4565b92506153966101008d01614d55565b91506101208c013590509295989b509295989b9093969950565b60008060008060008060008060006101008a8c0312156153ce578283fd5b8935985060208a01356153e081615dce565b975060408a01356153f081615dce565b965060608a013561540081615db2565b955060808a0135945060a08a01356001600160401b03811115615421578384fd5b61542d8c828d01614d60565b90955093505060c08a013561544181615d8f565b8092505060e08a013590509295985092959850929598565b60006020828403121561546a578081fd5b8151610ccb81615db2565b600060208284031215615486578081fd5b8135610ccb81615dbf565b6000602082840312156154a2578081fd5b8151610ccb81615dbf565b600060c082840312156154be578081fd5b60405160c081018181106001600160401b03821117156154e0576154e0615d79565b60405282516154ee81615d8f565b815260208301516154fe81615d8f565b6020820152604083015161551181615d8f565b6040820152606083015161552481615d8f565b6060820152608083015161553781615d8f565b608082015260a083015161554a81615d8f565b60a08201529392505050565b600060808284031215615567578081fd5b610ccb8383614da9565b600080600060608486031215615585578081fd5b83359250602084013591506040840135614fd781615d8f565b60008060008060008060c087890312156155b6578384fd5b8635955060208701359450604087013593506060870135925060808701356155dd81615dce565b915060a08701356155ed81615dce565b809150509295509295509295565b60006020828403121561560c578081fd5b8151610ccb81615dce565b600082825180855260208086019550808260051b840101818601855b8481101561566157601f1986840301895261564f8383516156df565b98840198925090830190600101615633565b5090979650505050505050565b81835260006001600160fb1b03831115615686578081fd5b8260051b80836020870137939093016020019283525090919050565b6000815480845260208085019450838352808320835b838110156156d4578154875295820195600191820191016156b8565b509495945050505050565b600081518084526156f7816020860160208601615d1c565b601f01601f19169290920160200192915050565b6002811061572957634e487b7160e01b600052602160045260246000fd5b9052565b6000825161573f818460208701615d1c565b9190910192915050565b6001600160a01b03888116825287166020820152604081018690526001600160401b0385166060820152600784900b608082015260e0810161578e60a083018561570b565b8260c083015298975050505050505050565b6001600160a01b038a8116825289166020820152604081018890526001600160401b0387166060820152600786900b608082015261012081016157e660a083018761570b565b8460c08301528360e0830152826101008301529a9950505050505050505050565b6001600160a01b038416815260608101615824602083018561570b565b8215156040830152949350505050565b6020808252825182820181905260009190848201906040850190845b818110156158755783516001600160a01b031683529284019291840191600101615850565b50909695505050505050565b602081526000610ccb6020830184615617565b6080815260006158a76080830187615617565b828103602084810191909152865180835287820192820190845b818110156158dd578451835293830193918301916001016158c1565b50506001600160401b039687166040860152949095166060909301929092525090949350505050565b60a08101818360005b600581101561592e57815183526020928301929091019060010161590f565b50505092915050565b60608152600061594b60608301878961566e565b828103602084015261595e81868861566e565b9150508260408301529695505050505050565b602081526000610ccb60208301846156df565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b81516001600160a01b03168152602080830151610120830191615a45908401826001600160a01b03169052565b50604083015160408301526060830151615a6a60608401826001600160401b03169052565b506080830151615a7f608084018260070b9052565b5060a0830151615a9260a084018261570b565b5060c083015160c083015260e083015160e083015261010080840151818401525092915050565b6001600160401b0385168152608060208201526000615adb60808301866156a2565b8281036040840152615aed81866156a2565b91505082606083015295945050505050565b6000808335601e19843603018112615b15578283fd5b8301803591506001600160401b03821115615b2e578283fd5b602001915036819003821315614da257600080fd5b604051606081016001600160401b0381118282101715615b6557615b65615d79565b60405290565b604051601f8201601f191681016001600160401b0381118282101715615b9357615b93615d79565b604052919050565b60006001600160401b03821115615bb457615bb4615d79565b5060051b60200190565b60008219821115615bd157615bd1615d63565b500190565b60006001600160401b03808316818516808303821115615bf857615bf8615d63565b01949350505050565b600082615c1c57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615c3b57615c3b615d63565b500290565b600082821015615c5257615c52615d63565b500390565b6000615c656150e784615b9b565b808482526020808301925084368760051b87011115615c82578485fd5b845b87811015615d105781356001600160401b0380821115615ca2578788fd5b90880190601f3681840112615cb5578889fd5b823582811115615cc757615cc7615d79565b615cd8818301601f19168801615b6b565b92508083523687828601011115615ced57898afd5b808785018885013782018601899052508652509382019390820190600101615c84565b50919695505050505050565b60005b83811015615d37578181015183820152602001615d1f565b838111156110615750506000910152565b6000600019821415615d5c57615d5c615d63565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610fec57600080fd5b8015158114610fec57600080fd5b60028110610fec57600080fd5b8060070b8114610fec57600080fd5b6001600160401b0381168114610fec57600080fdfea2646970667358221220d9015aee7abca54ac30120273d2668cc9c496ef2e581bf44c6863dcc028b445064736f6c63430008040033

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